siruku6/fx_alarm_py

View on GitHub

Showing 17 of 38 total issues

File real_trader.py has 298 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import dataclasses
from datetime import datetime, timedelta
from pprint import pprint
from typing import Any, Callable, Dict, List, Literal, Optional, Union

Severity: Minor
Found in src/real_trader.py - About 3 hrs to fix

    File history_visualizer.py has 292 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import datetime
    from datetime import timedelta
    from typing import List, Optional, Tuple, TypedDict
    
    from oanda_accessor_pyv20 import OandaInterface
    Severity: Minor
    Found in src/history_visualizer.py - About 3 hrs to fix

      Function __calc_parabolic has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

          def __calc_parabolic(self):
              candles = self.__base_candles
              # 初期値
              acceleration_factor = Analyzer.INITIAL_AF
              # INFO: 初期状態は上昇トレンドと仮定して計算
      Severity: Minor
      Found in src/analyzer.py - About 2 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Visualizer has 21 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class Visualizer:
          DRAWABLE_ROWS = 200
      
          def __init__(
              self,
      Severity: Minor
      Found in src/history_visualizer.py - About 2 hrs to fix

        File drawer.py has 253 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import datetime
        
        import matplotlib
        import matplotlib.pyplot as plt
        import mplfinance.original_flavor as mpf
        Severity: Minor
        Found in src/drawer.py - About 2 hrs to fix

          Function __append_performance_result_to_csv has 8 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def __append_performance_result_to_csv(
          Severity: Major
          Found in src/lib/statistics_module.py - About 1 hr to fix

            Function repulsion_exist has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

            def repulsion_exist(
                trend: str,
                previous_ema: float,
                two_before_high: float,
                previous_high: float,
            Severity: Minor
            Found in src/trade_rules/scalping.py - About 55 mins to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            Function __play_swing_trade has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def __play_swing_trade(
                    self,
                    candles: pd.DataFrame,
                    indicators: pd.DataFrame,
                ) -> None:
            Severity: Minor
            Found in src/real_trader.py - About 45 mins to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            Function __draw_one_chart has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def __draw_one_chart(
            Severity: Minor
            Found in src/result_processor.py - About 45 mins to fix

              Function repulsion_exist has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              def repulsion_exist(
              Severity: Minor
              Found in src/trade_rules/scalping.py - About 45 mins to fix

                Function step_trailing has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                def step_trailing(
                Severity: Minor
                Found in src/trade_rules/stoploss.py - About 35 mins to fix

                  Function detect_thrust has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  def detect_thrust(trend, previous_high, high, previous_low, low):
                  Severity: Minor
                  Found in src/trade_rules/base.py - About 35 mins to fix

                    Function thrusting_exist has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                    def thrusting_exist(trend, two_before_high, previous_high, two_before_low, previous_low):
                    Severity: Minor
                    Found in src/trade_rules/wait_close.py - About 35 mins to fix

                      Function ask_granularity has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                      def ask_granularity() -> str:
                          while True:
                              error_msg: str = "Invalid granularity !\n"
                      
                              print("取得スパンは?(ex: M5): ", end="")
                      Severity: Minor
                      Found in src/lib/interface.py - About 35 mins to fix

                      Cognitive Complexity

                      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                      A method's cognitive complexity is based on a few simple rules:

                      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                      • Code is considered more complex for each "break in the linear flow of the code"
                      • Code is considered more complex when "flow breaking structures are nested"

                      Further reading

                      Function draw_positions_df has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def draw_positions_df(self, positions_df, plot_type=PLOT_TYPE["long"], size=20, nolabel=None):
                              if plot_type == FigureDrawer.PLOT_TYPE["long"]:
                                  color = "white"
                                  edgecolors = "green"
                                  label = "long"
                      Severity: Minor
                      Found in src/drawer.py - About 25 mins to fix

                      Cognitive Complexity

                      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                      A method's cognitive complexity is based on a few simple rules:

                      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                      • Code is considered more complex for each "break in the linear flow of the code"
                      • Code is considered more complex when "flow breaking structures are nested"

                      Further reading

                      Function _create_position has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def _create_position(
                              self, previous_candle: pd.Series, direction: str, last_indicators: pd.Series = None
                          ) -> None:
                              """
                              Order Oanda to create position
                      Severity: Minor
                      Found in src/real_trader.py - About 25 mins to fix

                      Cognitive Complexity

                      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                      A method's cognitive complexity is based on a few simple rules:

                      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                      • Code is considered more complex for each "break in the linear flow of the code"
                      • Code is considered more complex when "flow breaking structures are nested"

                      Further reading

                      Function calc_indicators has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def calc_indicators(self, candles, long_span_candles=None, stoc_only=False):
                              if candles is None or candles.empty:
                                  print("[ERROR] Analyzer: 分析対象データがありません")
                                  exit()
                      
                      
                      Severity: Minor
                      Found in src/analyzer.py - About 25 mins to fix

                      Cognitive Complexity

                      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                      A method's cognitive complexity is based on a few simple rules:

                      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                      • Code is considered more complex for each "break in the linear flow of the code"
                      • Code is considered more complex when "flow breaking structures are nested"

                      Further reading

                      Severity
                      Category
                      Status
                      Source
                      Language