For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

BackTrader Example Stratagy Problems



  • GOOOOOOOOD afternoon Gentlemen.

    I started using Backtrader yesterday, and have been learning the syntax any getting used to everything.
    I'm running into an issue with my test file though.

    I'm using this video as reference: Part Time Larry video (Youtube)
    This is the data file that is being pushed through: Backtrader Test File GIT raw

    Below are the two files I'm using. I have issues with the strategy, specifically getting the sell to run. While it's supposed to buy one, wait 5 bars, sell one, it just buys one and sits for the rest of the simulation.

    Running in Atom IDE with script, had no problems till now, so what am I missing?

    Posted below: Head file, strategy file, then output.

    Head:

    import backtrader
    import matplotlib
    from strategies import TestStrategy
    import datetime
    
    cerebro = backtrader.Cerebro()
    
    cerebro.broker.set_cash(1000000)
    
    data = backtrader.feeds.YahooFinanceCSVData(
        dataname='oracle.csv',
        # Do not pass values before this date
        fromdate=datetime.datetime(2000, 1, 1),
        # Do not pass values after this date
        todate=datetime.datetime(2000, 12, 31),
        reverse=False)
    
    cerebro.adddata(data)
    
    cerebro.addstrategy(TestStrategy)
    
    print('starting Portfolio Value: %.2f' % cerebro.broker.getvalue())
    cerebro.run()
    print('Final Portfolio Value: %2f' % cerebro.broker.getvalue())
    

    Strategy:

    import backtrader
    import datetime
    
    class TestStrategy(backtrader.Strategy):
    
        def log(self, txt, dt=None):
            ''' Logging function for this strategy'''
            dt = dt or self.datas[0].datetime.date(0)
            print('%s, %s' % (dt.isoformat(), txt))
    
        def __init__(self):
            # Keep a reference to the "close" line in the data[0] dataseries
            self.dataclose = self.datas[0].close
            self.order = None
    
        def notify_orders(self, order):
            if order.status in [order.submitted, order.accepted]:
                return
    
            if order.status in [order.completed]:
                if order.isbuy():
                    self.log('Buy Excecuted {}'.format(order.excecuted.price))
                elif order.issell():
                    self.log('Sell Excecuted {}'.format(order.excecuted.price))
                self.bar_executed = len(self)
    
            self.order = None
    
        def next(self):
            # Simply log the closing price of the series from the reference
            self.log('Close, %.2f' % self.dataclose[0])
    
            if self.order:
                return
    
            if not self.position:
                if self.dataclose[0] < self.dataclose[-1]:
                    # current close less than previous close
    
                    if self.dataclose[-1] < self.dataclose[-2]:
                        # previous close less than the previous close
    
                        # BUY, BUY, BUY!!! (with all possible default parameters)
                        self.log('BUY CREATED, %.2f' % self.dataclose[0])
                        self.order = self.buy()
    
            else:
                print('Activated')
                if len(self) >= (self.bar_executed + 5):
                    self.log('SELL CREATED {}'.format(self.dataclose[0]))
                    self.order = self.sell()
    

    Output:

    starting Portfolio Value: 1000000.00
    2000-01-03, Close, 26.27
    2000-01-04, Close, 23.95
    2000-01-05, Close, 22.68
    2000-01-05, BUY CREATED, 22.68
    Bought
    2000-01-06, Close, 21.35
    2000-01-07, Close, 22.99
    2000-01-10, Close, 25.74
    2000-01-11, Close, 24.99
    2000-01-12, Close, 23.49
    2000-01-13, Close, 23.36
    2000-01-14, Close, 23.75
    2000-01-18, Close, 24.74
    2000-01-19, Close, 25.41
    2000-01-20, Close, 26.35
    2000-01-21, Close, 26.55
    2000-01-24, Close, 24.10
    2000-01-25, Close, 25.10
    2000-01-26, Close, 24.49
    2000-01-27, Close, 23.04
    2000-01-28, Close, 21.07
    2000-01-31, Close, 22.22
    2000-02-01, Close, 24.02
    2000-02-02, Close, 24.16
    2000-02-03, Close, 25.21
    2000-02-04, Close, 25.71
    2000-02-07, Close, 26.66
    2000-02-08, Close, 26.49
    2000-02-09, Close, 26.66
    2000-02-10, Close, 27.71
    2000-02-11, Close, 26.55
    2000-02-14, Close, 27.66
    2000-02-15, Close, 27.30
    2000-02-16, Close, 27.24
    2000-02-17, Close, 27.41
    2000-02-18, Close, 26.05
    2000-02-22, Close, 26.38
    2000-02-23, Close, 28.05
    2000-02-24, Close, 27.55
    2000-02-25, Close, 31.41
    2000-02-28, Close, 30.52
    2000-02-29, Close, 33.02
    2000-03-01, Close, 31.80
    2000-03-02, Close, 30.47
    2000-03-03, Close, 33.36
    2000-03-06, Close, 33.69
    2000-03-07, Close, 33.33
    2000-03-08, Close, 36.97
    2000-03-09, Close, 37.36
    2000-03-10, Close, 36.30
    2000-03-13, Close, 35.02
    2000-03-14, Close, 34.25
    2000-03-15, Close, 34.97
    2000-03-16, Close, 36.44
    2000-03-17, Close, 35.50
    2000-03-20, Close, 34.75
    2000-03-21, Close, 35.89
    2000-03-22, Close, 37.39
    2000-03-23, Close, 38.64
    2000-03-24, Close, 38.69
    2000-03-27, Close, 39.33
    2000-03-28, Close, 38.50
    2000-03-29, Close, 36.69
    2000-03-30, Close, 34.88
    2000-03-31, Close, 34.72
    2000-04-03, Close, 34.19
    2000-04-04, Close, 33.77
    2000-04-05, Close, 34.80
    2000-04-06, Close, 36.55
    2000-04-07, Close, 38.75
    2000-04-10, Close, 36.69
    2000-04-11, Close, 34.41
    2000-04-12, Close, 32.52
    2000-04-13, Close, 31.99
    2000-04-14, Close, 27.80
    2000-04-17, Close, 33.27
    2000-04-18, Close, 35.11
    2000-04-19, Close, 33.16
    2000-04-20, Close, 31.49
    2000-04-24, Close, 32.22
    2000-04-25, Close, 33.61
    2000-04-26, Close, 32.11
    2000-04-27, Close, 34.38
    2000-04-28, Close, 35.55
    2000-05-01, Close, 35.44
    2000-05-02, Close, 34.61
    2000-05-03, Close, 33.72
    2000-05-04, Close, 33.02
    2000-05-05, Close, 34.16
    2000-05-08, Close, 32.16
    2000-05-09, Close, 32.02
    2000-05-10, Close, 30.08
    2000-05-11, Close, 32.19
    2000-05-12, Close, 32.99
    2000-05-15, Close, 34.25
    2000-05-16, Close, 35.22
    2000-05-17, Close, 34.77
    2000-05-18, Close, 32.49
    2000-05-19, Close, 31.16
    2000-05-22, Close, 30.16
    2000-05-23, Close, 27.85
    2000-05-24, Close, 28.57
    2000-05-25, Close, 29.55
    2000-05-26, Close, 29.80
    2000-05-30, Close, 32.99
    2000-05-31, Close, 31.97
    2000-06-01, Close, 34.63
    2000-06-02, Close, 35.66
    2000-06-05, Close, 36.00
    2000-06-06, Close, 34.27
    2000-06-07, Close, 35.58
    2000-06-08, Close, 36.64
    2000-06-09, Close, 36.77
    2000-06-12, Close, 35.83
    2000-06-13, Close, 36.33
    2000-06-14, Close, 35.13
    2000-06-15, Close, 36.69
    2000-06-16, Close, 36.41
    2000-06-19, Close, 38.25
    2000-06-20, Close, 38.27
    2000-06-21, Close, 38.33
    2000-06-22, Close, 36.25
    2000-06-23, Close, 35.36
    2000-06-26, Close, 36.77
    2000-06-27, Close, 36.58
    2000-06-28, Close, 36.89
    2000-06-29, Close, 35.97
    2000-06-30, Close, 37.39
    2000-07-03, Close, 35.66
    2000-07-05, Close, 32.16
    2000-07-06, Close, 33.63
    2000-07-07, Close, 33.75
    2000-07-10, Close, 32.97
    2000-07-11, Close, 32.16
    2000-07-12, Close, 33.22
    2000-07-13, Close, 33.69
    2000-07-14, Close, 33.86
    2000-07-17, Close, 33.86
    2000-07-18, Close, 32.99
    2000-07-19, Close, 32.80
    2000-07-20, Close, 34.75
    2000-07-21, Close, 33.55
    2000-07-24, Close, 33.36
    2000-07-25, Close, 33.80
    2000-07-26, Close, 34.13
    2000-07-27, Close, 33.38
    2000-07-28, Close, 32.19
    2000-07-31, Close, 33.44
    2000-08-01, Close, 32.52
    2000-08-02, Close, 32.52
    2000-08-03, Close, 34.44
    2000-08-04, Close, 36.27
    2000-08-07, Close, 36.41
    2000-08-08, Close, 36.91
    2000-08-09, Close, 36.19
    2000-08-10, Close, 35.61
    2000-08-11, Close, 36.08
    2000-08-14, Close, 36.64
    2000-08-15, Close, 36.14
    2000-08-16, Close, 36.11
    2000-08-17, Close, 37.33
    2000-08-18, Close, 36.16
    2000-08-21, Close, 37.00
    2000-08-22, Close, 37.16
    2000-08-23, Close, 36.86
    2000-08-24, Close, 37.66
    2000-08-25, Close, 37.64
    2000-08-28, Close, 38.58
    2000-08-29, Close, 39.03
    2000-08-30, Close, 39.25
    2000-08-31, Close, 40.44
    2000-09-01, Close, 41.19
    2000-09-05, Close, 40.50
    2000-09-06, Close, 39.69
    2000-09-07, Close, 40.56
    2000-09-08, Close, 38.50
    2000-09-11, Close, 37.11
    2000-09-12, Close, 35.30
    2000-09-13, Close, 36.39
    2000-09-14, Close, 37.78
    2000-09-15, Close, 34.83
    2000-09-18, Close, 34.01
    2000-09-19, Close, 35.27
    2000-09-20, Close, 35.55
    2000-09-21, Close, 35.11
    2000-09-22, Close, 35.91
    2000-09-25, Close, 35.02
    2000-09-26, Close, 35.33
    2000-09-27, Close, 35.52
    2000-09-28, Close, 36.24
    2000-09-29, Close, 35.02
    2000-10-02, Close, 35.02
    2000-10-03, Close, 30.91
    2000-10-04, Close, 30.30
    2000-10-05, Close, 30.38
    2000-10-06, Close, 30.08
    2000-10-09, Close, 29.69
    2000-10-10, Close, 28.74
    2000-10-11, Close, 27.69
    2000-10-12, Close, 28.02
    2000-10-13, Close, 31.69
    2000-10-16, Close, 30.74
    2000-10-17, Close, 29.96
    2000-10-18, Close, 29.85
    2000-10-19, Close, 32.36
    2000-10-20, Close, 31.35
    2000-10-23, Close, 30.30
    2000-10-24, Close, 31.85
    2000-10-25, Close, 30.58
    2000-10-26, Close, 30.30
    2000-10-27, Close, 30.41
    2000-10-30, Close, 28.13
    2000-10-31, Close, 29.35
    2000-11-01, Close, 27.91
    2000-11-02, Close, 26.30
    2000-11-03, Close, 26.96
    2000-11-06, Close, 24.85
    2000-11-07, Close, 23.63
    2000-11-08, Close, 22.07
    2000-11-09, Close, 24.18
    2000-11-10, Close, 22.63
    2000-11-13, Close, 22.01
    2000-11-14, Close, 25.24
    2000-11-15, Close, 25.68
    2000-11-16, Close, 24.35
    2000-11-17, Close, 25.63
    2000-11-20, Close, 22.01
    2000-11-21, Close, 21.24
    2000-11-22, Close, 19.85
    2000-11-24, Close, 21.46
    2000-11-27, Close, 20.57
    2000-11-28, Close, 20.15
    2000-11-29, Close, 20.35
    2000-11-30, Close, 23.57
    2000-12-01, Close, 23.52
    2000-12-04, Close, 25.07
    2000-12-05, Close, 28.02
    2000-12-06, Close, 26.85
    2000-12-07, Close, 25.18
    2000-12-08, Close, 26.74
    2000-12-11, Close, 28.41
    2000-12-12, Close, 27.35
    2000-12-13, Close, 25.24
    2000-12-14, Close, 24.46
    2000-12-15, Close, 25.41
    2000-12-18, Close, 28.46
    2000-12-19, Close, 27.24
    2000-12-20, Close, 25.35
    2000-12-21, Close, 26.24
    2000-12-22, Close, 28.35
    2000-12-26, Close, 27.52
    2000-12-27, Close, 27.30
    2000-12-28, Close, 27.63
    2000-12-29, Close, 25.85
    Final Portfolio Value: 1000003.580000
    [Finished in 0.581s]
    


  • Output shown is from the different script. Script above doesn't print Bought shown in the output. On the other side every time the order is executed the script should print Buy/Sell Excecuted, show this line int the output.



  • @ab_trader You are correct, my bad. I was using 'BOUGHT' to track when it was activated and took it out at the last moment.
    While there are probably no functional differences, I miss things. Below are is the strategy and the output, re run.

    Strat:

    import backtrader
    import datetime
    
    class TestStrategy(backtrader.Strategy):
    
        def log(self, txt, dt=None):
            ''' Logging function for this strategy'''
            dt = dt or self.datas[0].datetime.date(0)
            print('%s, %s' % (dt.isoformat(), txt))
    
        def __init__(self):
            # Keep a reference to the "close" line in the data[0] dataseries
            self.dataclose = self.datas[0].close
            self.order = None
    
        def notify_orders(self, order):
            if order.status in [order.submitted, order.accepted]:
                return
    
            if order.status in [order.completed]:
                if order.isbuy():
                    self.log('Buy Excecuted {}'.format(order.excecuted.price))
                elif order.issell():
                    self.log('Sell Excecuted {}'.format(order.excecuted.price))
                self.bar_executed = len(self)
    
            self.order = None
    
        def next(self):
            # Simply log the closing price of the series from the reference
            self.log('Close, %.2f' % self.dataclose[0])
    
            if self.order:
                return
    
            if not self.position:
                if self.dataclose[0] < self.dataclose[-1]:
                    # current close less than previous close
    
                    if self.dataclose[-1] < self.dataclose[-2]:
                        # previous close less than the previous close
    
                        # BUY, BUY, BUY!!! (with all possible default parameters)
                        self.log('BUY CREATED, %.2f' % self.dataclose[0])
                        self.order = self.buy()
    
            else:
                print('Activated')
                if len(self) >= (self.bar_executed + 5):
                    self.log('SELL CREATED {}'.format(self.dataclose[0]))
                    self.order = self.sell()
    

    Output:

    starting Portfolio Value: 1000000.00
    2000-01-03, Close, 26.27
    2000-01-04, Close, 23.95
    2000-01-05, Close, 22.68
    2000-01-05, BUY CREATED, 22.68
    2000-01-06, Close, 21.35
    2000-01-07, Close, 22.99
    2000-01-10, Close, 25.74
    2000-01-11, Close, 24.99
    2000-01-12, Close, 23.49
    2000-01-13, Close, 23.36
    2000-01-14, Close, 23.75
    2000-01-18, Close, 24.74
    2000-01-19, Close, 25.41
    2000-01-20, Close, 26.35
    2000-01-21, Close, 26.55
    2000-01-24, Close, 24.10
    2000-01-25, Close, 25.10
    2000-01-26, Close, 24.49
    2000-01-27, Close, 23.04
    2000-01-28, Close, 21.07
    2000-01-31, Close, 22.22
    2000-02-01, Close, 24.02
    2000-02-02, Close, 24.16
    2000-02-03, Close, 25.21
    2000-02-04, Close, 25.71
    2000-02-07, Close, 26.66
    2000-02-08, Close, 26.49
    2000-02-09, Close, 26.66
    2000-02-10, Close, 27.71
    2000-02-11, Close, 26.55
    2000-02-14, Close, 27.66
    2000-02-15, Close, 27.30
    2000-02-16, Close, 27.24
    2000-02-17, Close, 27.41
    2000-02-18, Close, 26.05
    2000-02-22, Close, 26.38
    2000-02-23, Close, 28.05
    2000-02-24, Close, 27.55
    2000-02-25, Close, 31.41
    2000-02-28, Close, 30.52
    2000-02-29, Close, 33.02
    2000-03-01, Close, 31.80
    2000-03-02, Close, 30.47
    2000-03-03, Close, 33.36
    2000-03-06, Close, 33.69
    2000-03-07, Close, 33.33
    2000-03-08, Close, 36.97
    2000-03-09, Close, 37.36
    2000-03-10, Close, 36.30
    2000-03-13, Close, 35.02
    2000-03-14, Close, 34.25
    2000-03-15, Close, 34.97
    2000-03-16, Close, 36.44
    2000-03-17, Close, 35.50
    2000-03-20, Close, 34.75
    2000-03-21, Close, 35.89
    2000-03-22, Close, 37.39
    2000-03-23, Close, 38.64
    2000-03-24, Close, 38.69
    2000-03-27, Close, 39.33
    2000-03-28, Close, 38.50
    2000-03-29, Close, 36.69
    2000-03-30, Close, 34.88
    2000-03-31, Close, 34.72
    2000-04-03, Close, 34.19
    2000-04-04, Close, 33.77
    2000-04-05, Close, 34.80
    2000-04-06, Close, 36.55
    2000-04-07, Close, 38.75
    2000-04-10, Close, 36.69
    2000-04-11, Close, 34.41
    2000-04-12, Close, 32.52
    2000-04-13, Close, 31.99
    2000-04-14, Close, 27.80
    2000-04-17, Close, 33.27
    2000-04-18, Close, 35.11
    2000-04-19, Close, 33.16
    2000-04-20, Close, 31.49
    2000-04-24, Close, 32.22
    2000-04-25, Close, 33.61
    2000-04-26, Close, 32.11
    2000-04-27, Close, 34.38
    2000-04-28, Close, 35.55
    2000-05-01, Close, 35.44
    2000-05-02, Close, 34.61
    2000-05-03, Close, 33.72
    2000-05-04, Close, 33.02
    2000-05-05, Close, 34.16
    2000-05-08, Close, 32.16
    2000-05-09, Close, 32.02
    2000-05-10, Close, 30.08
    2000-05-11, Close, 32.19
    2000-05-12, Close, 32.99
    2000-05-15, Close, 34.25
    2000-05-16, Close, 35.22
    2000-05-17, Close, 34.77
    2000-05-18, Close, 32.49
    2000-05-19, Close, 31.16
    2000-05-22, Close, 30.16
    2000-05-23, Close, 27.85
    2000-05-24, Close, 28.57
    2000-05-25, Close, 29.55
    2000-05-26, Close, 29.80
    2000-05-30, Close, 32.99
    2000-05-31, Close, 31.97
    2000-06-01, Close, 34.63
    2000-06-02, Close, 35.66
    2000-06-05, Close, 36.00
    2000-06-06, Close, 34.27
    2000-06-07, Close, 35.58
    2000-06-08, Close, 36.64
    2000-06-09, Close, 36.77
    2000-06-12, Close, 35.83
    2000-06-13, Close, 36.33
    2000-06-14, Close, 35.13
    2000-06-15, Close, 36.69
    2000-06-16, Close, 36.41
    2000-06-19, Close, 38.25
    2000-06-20, Close, 38.27
    2000-06-21, Close, 38.33
    2000-06-22, Close, 36.25
    2000-06-23, Close, 35.36
    2000-06-26, Close, 36.77
    2000-06-27, Close, 36.58
    2000-06-28, Close, 36.89
    2000-06-29, Close, 35.97
    2000-06-30, Close, 37.39
    2000-07-03, Close, 35.66
    2000-07-05, Close, 32.16
    2000-07-06, Close, 33.63
    2000-07-07, Close, 33.75
    2000-07-10, Close, 32.97
    2000-07-11, Close, 32.16
    2000-07-12, Close, 33.22
    2000-07-13, Close, 33.69
    2000-07-14, Close, 33.86
    2000-07-17, Close, 33.86
    2000-07-18, Close, 32.99
    2000-07-19, Close, 32.80
    2000-07-20, Close, 34.75
    2000-07-21, Close, 33.55
    2000-07-24, Close, 33.36
    2000-07-25, Close, 33.80
    2000-07-26, Close, 34.13
    2000-07-27, Close, 33.38
    2000-07-28, Close, 32.19
    2000-07-31, Close, 33.44
    2000-08-01, Close, 32.52
    2000-08-02, Close, 32.52
    2000-08-03, Close, 34.44
    2000-08-04, Close, 36.27
    2000-08-07, Close, 36.41
    2000-08-08, Close, 36.91
    2000-08-09, Close, 36.19
    2000-08-10, Close, 35.61
    2000-08-11, Close, 36.08
    2000-08-14, Close, 36.64
    2000-08-15, Close, 36.14
    2000-08-16, Close, 36.11
    2000-08-17, Close, 37.33
    2000-08-18, Close, 36.16
    2000-08-21, Close, 37.00
    2000-08-22, Close, 37.16
    2000-08-23, Close, 36.86
    2000-08-24, Close, 37.66
    2000-08-25, Close, 37.64
    2000-08-28, Close, 38.58
    2000-08-29, Close, 39.03
    2000-08-30, Close, 39.25
    2000-08-31, Close, 40.44
    2000-09-01, Close, 41.19
    2000-09-05, Close, 40.50
    2000-09-06, Close, 39.69
    2000-09-07, Close, 40.56
    2000-09-08, Close, 38.50
    2000-09-11, Close, 37.11
    2000-09-12, Close, 35.30
    2000-09-13, Close, 36.39
    2000-09-14, Close, 37.78
    2000-09-15, Close, 34.83
    2000-09-18, Close, 34.01
    2000-09-19, Close, 35.27
    2000-09-20, Close, 35.55
    2000-09-21, Close, 35.11
    2000-09-22, Close, 35.91
    2000-09-25, Close, 35.02
    2000-09-26, Close, 35.33
    2000-09-27, Close, 35.52
    2000-09-28, Close, 36.24
    2000-09-29, Close, 35.02
    2000-10-02, Close, 35.02
    2000-10-03, Close, 30.91
    2000-10-04, Close, 30.30
    2000-10-05, Close, 30.38
    2000-10-06, Close, 30.08
    2000-10-09, Close, 29.69
    2000-10-10, Close, 28.74
    2000-10-11, Close, 27.69
    2000-10-12, Close, 28.02
    2000-10-13, Close, 31.69
    2000-10-16, Close, 30.74
    2000-10-17, Close, 29.96
    2000-10-18, Close, 29.85
    2000-10-19, Close, 32.36
    2000-10-20, Close, 31.35
    2000-10-23, Close, 30.30
    2000-10-24, Close, 31.85
    2000-10-25, Close, 30.58
    2000-10-26, Close, 30.30
    2000-10-27, Close, 30.41
    2000-10-30, Close, 28.13
    2000-10-31, Close, 29.35
    2000-11-01, Close, 27.91
    2000-11-02, Close, 26.30
    2000-11-03, Close, 26.96
    2000-11-06, Close, 24.85
    2000-11-07, Close, 23.63
    2000-11-08, Close, 22.07
    2000-11-09, Close, 24.18
    2000-11-10, Close, 22.63
    2000-11-13, Close, 22.01
    2000-11-14, Close, 25.24
    2000-11-15, Close, 25.68
    2000-11-16, Close, 24.35
    2000-11-17, Close, 25.63
    2000-11-20, Close, 22.01
    2000-11-21, Close, 21.24
    2000-11-22, Close, 19.85
    2000-11-24, Close, 21.46
    2000-11-27, Close, 20.57
    2000-11-28, Close, 20.15
    2000-11-29, Close, 20.35
    2000-11-30, Close, 23.57
    2000-12-01, Close, 23.52
    2000-12-04, Close, 25.07
    2000-12-05, Close, 28.02
    2000-12-06, Close, 26.85
    2000-12-07, Close, 25.18
    2000-12-08, Close, 26.74
    2000-12-11, Close, 28.41
    2000-12-12, Close, 27.35
    2000-12-13, Close, 25.24
    2000-12-14, Close, 24.46
    2000-12-15, Close, 25.41
    2000-12-18, Close, 28.46
    2000-12-19, Close, 27.24
    2000-12-20, Close, 25.35
    2000-12-21, Close, 26.24
    2000-12-22, Close, 28.35
    2000-12-26, Close, 27.52
    2000-12-27, Close, 27.30
    2000-12-28, Close, 27.63
    2000-12-29, Close, 25.85
    Final Portfolio Value: 1000003.580000
    [Finished in 0.595s]
    


  • @Evan-Ledwith said in BackTrader Example Stratagy Problems:

    [order.submitted, order.accepted]

    Those are Order class' methods and not status codes. The order status should be checked against the status codes like Order.Completed,Order.Canceled, ...



  • @vladisld Could you give me a quick example of this?



  • @Evan-Ledwith said in BackTrader Example Stratagy Problems:

    Could you give me a quick example of this?

    Look in the full code here.


Log in to reply
 

});