Backtrader Community

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    1. Home
    2. Dim Trader
    For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
    D
    • Profile
    • Following 0
    • Followers 0
    • Topics 0
    • Posts 2
    • Best 2
    • Controversial 0
    • Groups 0

    Dim Trader

    @Dim Trader

    4
    Reputation
    1
    Profile views
    2
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    Dim Trader Unfollow Follow

    Best posts made by Dim Trader

    • RE: Genetic Optimization

      @d416 Thank you for point to the Gradient-Free-Optimizers. They are amazing and do optimization super fast!
      In my tests they are faster 40x times than build-in brute force optimization algo.

      I have prepared optimization statistics for different optimizers from Gradient-Free-Optimizers.
      I did my tests on the following simple strategy (just for proof):

      class SmaCross(bt.SignalStrategy):
          params = (
              ('fast', 10),
              ('slow', 30),
          )
          def __init__(self):
              sma1, sma2 = bt.ind.SMA(period=self.p.fast), bt.ind.SMA(period=self.p.slow)
              crossover = bt.ind.CrossOver(sma1, sma2)
              self.signal_add(bt.SIGNAL_LONG, crossover)
      

      And the test parameters were:

      "fast": np.arange(5, 150, 2),
      "slow": np.arange(50, 150, 2)
      

      The most interesting is the results for optimization times and scores:

      Build-in brute force: score:10035.94200515747, time:207.48 s, para: {"fast":57, "slow":56}
      
      HillClimbingOptimizer: score:10023.95000076294, time:7.72 s, para:{'fast': 129, 'slow': 54}
      RepulsingHillClimbingOptimizer: score:10023.95000076294, time:15.99 s, para:{'fast': 119, 'slow': 60}
      SimulatedAnnealingOptimizer: score:10023.95000076294, time:7.24 s, para:{'fast': 131, 'slow': 52}
      RandomSearchOptimizer: score:10026.352001190186, time:20.60 s, para:{'fast': 61, 'slow': 56}
      RandomRestartHillClimbingOptimizer: score:10023.95000076294, time:10.14 s, para:{'fast': 127, 'slow': 52}
      RandomAnnealingOptimizer: score:10023.95000076294, time:8.63 s, para:{'fast': 125, 'slow': 56}
      ParallelTemperingOptimizer: score:10021.9880027771, time:15.08 s, para:{'fast': 147, 'slow': 50}
      ParticleSwarmOptimizer: score:10030.186000823975, time:15.71 s, para:{'fast': 61, 'slow': 54}
      EvolutionStrategyOptimizer: score:10023.95000076294, time:14.98 s, para:{'fast': 131, 'slow': 52}
      DecisionTreeOptimizer: score:10035.94200515747, time:5.05 s, para:{'fast': 57, 'slow': 56}
      

      To summarize:

      • Build-in brute force: score:10035.94200515747, time:207.48 s
      • DecisionTreeOptimizer: score:10035.94200515747, time:5.05 s

      DecisionTreeOptimizer was 40x times faster!

      You could check my calculations on github.

      posted in General Discussion
      D
      Dim Trader
    • RE: Help With YahooFinance Data

      @rishabmah5 Please use yfinance to download data from yahoo finance.

      pip install yfinance
      

      And use this code

      import yfinance as yf
      import backtrader as bt
      
      data = bt.feeds.PandasData(dataname=yf.download('TSLA', '2018-01-01', '2019-01-01'))
      
      cerebro = bt.Cerebro()
      cerebro.adddata(data)
      
      posted in General Code/Help
      D
      Dim Trader

    Latest posts made by Dim Trader

    • RE: Help With YahooFinance Data

      @rishabmah5 Please use yfinance to download data from yahoo finance.

      pip install yfinance
      

      And use this code

      import yfinance as yf
      import backtrader as bt
      
      data = bt.feeds.PandasData(dataname=yf.download('TSLA', '2018-01-01', '2019-01-01'))
      
      cerebro = bt.Cerebro()
      cerebro.adddata(data)
      
      posted in General Code/Help
      D
      Dim Trader
    • RE: Genetic Optimization

      @d416 Thank you for point to the Gradient-Free-Optimizers. They are amazing and do optimization super fast!
      In my tests they are faster 40x times than build-in brute force optimization algo.

      I have prepared optimization statistics for different optimizers from Gradient-Free-Optimizers.
      I did my tests on the following simple strategy (just for proof):

      class SmaCross(bt.SignalStrategy):
          params = (
              ('fast', 10),
              ('slow', 30),
          )
          def __init__(self):
              sma1, sma2 = bt.ind.SMA(period=self.p.fast), bt.ind.SMA(period=self.p.slow)
              crossover = bt.ind.CrossOver(sma1, sma2)
              self.signal_add(bt.SIGNAL_LONG, crossover)
      

      And the test parameters were:

      "fast": np.arange(5, 150, 2),
      "slow": np.arange(50, 150, 2)
      

      The most interesting is the results for optimization times and scores:

      Build-in brute force: score:10035.94200515747, time:207.48 s, para: {"fast":57, "slow":56}
      
      HillClimbingOptimizer: score:10023.95000076294, time:7.72 s, para:{'fast': 129, 'slow': 54}
      RepulsingHillClimbingOptimizer: score:10023.95000076294, time:15.99 s, para:{'fast': 119, 'slow': 60}
      SimulatedAnnealingOptimizer: score:10023.95000076294, time:7.24 s, para:{'fast': 131, 'slow': 52}
      RandomSearchOptimizer: score:10026.352001190186, time:20.60 s, para:{'fast': 61, 'slow': 56}
      RandomRestartHillClimbingOptimizer: score:10023.95000076294, time:10.14 s, para:{'fast': 127, 'slow': 52}
      RandomAnnealingOptimizer: score:10023.95000076294, time:8.63 s, para:{'fast': 125, 'slow': 56}
      ParallelTemperingOptimizer: score:10021.9880027771, time:15.08 s, para:{'fast': 147, 'slow': 50}
      ParticleSwarmOptimizer: score:10030.186000823975, time:15.71 s, para:{'fast': 61, 'slow': 54}
      EvolutionStrategyOptimizer: score:10023.95000076294, time:14.98 s, para:{'fast': 131, 'slow': 52}
      DecisionTreeOptimizer: score:10035.94200515747, time:5.05 s, para:{'fast': 57, 'slow': 56}
      

      To summarize:

      • Build-in brute force: score:10035.94200515747, time:207.48 s
      • DecisionTreeOptimizer: score:10035.94200515747, time:5.05 s

      DecisionTreeOptimizer was 40x times faster!

      You could check my calculations on github.

      posted in General Discussion
      D
      Dim Trader