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

Problems with Analyzer and Pandas Datafeed



  • Hello,
    I'm new in the community so I hope this is the right place for this question:
    I've downloaded a few minutes bars of BTC/USD and I was testing the Sharpe Ratio with the SMA_CrossOver strategy included with BT but it keeps giving me:
    Sharpe Ratio: OrderedDict([('sharperatio', None)])

    The dataframe i'm feeding Cerebro has columns :
    ['Open', 'High', 'Low', 'Close', 'Volume', 'Datetime']
    the index also is called Datetime (is set equal to the last column)
    I'm on Windows but I'm using Notepad++ and launching scripts with a macro within Notepad++

    I've uploaded both my (simple) script and the data over Drive
    I'm worried it may be something basic or really stupid of my code but i can't find it.
    If someone can help me I'd really appreciate it.
    Thanks, Andrea.


  • administrators

    The most obvious thing: how you load the dataframe yields 0 data points and no operations is executed.

    Easy to see by simply checking the length of the data at stop and it will probably be 0



  • Ok, not that simple: I've add
    self.log('Data size: '+str(self.data.line.lencount), doprint = True)
    both in stop and in next and it shows the data is growing up to 300 bars.
    I'm also plotting the strategy and it is opening positions:
    0_1535902353195_It does something.png
    By the way I forgot saying i'm using the default
    bt.feeds.PandasData(dataname = df, timeframe=bt.TimeFrame.Minutes)
    to load the bars.

    Here is the slightly modded SMA_CrossOver strategy i'm using:

    #!/usr/bin/env python
    # -*- coding: utf-8; py-indent-offset:4 -*-
    ###############################################################################
    #
    # Copyright (C) 2015, 2016, 2017 Daniel Rodriguez
    #
    # This program is free software: you can redistribute it and/or modify
    # it under the terms of the GNU General Public License as published by
    # the Free Software Foundation, either version 3 of the License, or
    # (at your option) any later version.
    #
    # This program is distributed in the hope that it will be useful,
    # but WITHOUT ANY WARRANTY; without even the implied warranty of
    # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    # GNU General Public License for more details.
    #
    # You should have received a copy of the GNU General Public License
    # along with this program.  If not, see <http://www.gnu.org/licenses/>.
    #
    ###############################################################################
    from __future__ import (absolute_import, division, print_function,
                            unicode_literals)
    
    
    import backtrader as bt
    import backtrader.indicators as btind
    
    
    class MA_CrossOver(bt.Strategy):
        '''This is a long-only strategy which operates on a moving average cross
    
        Note:
          - Although the default
    
        Buy Logic:
          - No position is open on the data
    
          - The ``fast`` moving averagecrosses over the ``slow`` strategy to the
            upside.
    
        Sell Logic:
          - A position exists on the data
    
          - The ``fast`` moving average crosses over the ``slow`` strategy to the
            downside
    
        Order Execution Type:
          - Market
    
        '''
        alias = ('SMA_CrossOver',)
    
        params = (
            # period for the fast Moving Average
            ('fast', 10),
            # period for the slow moving average
            ('slow', 30),
    		('printlog', False),
            # moving average to use
            ('_movav', btind.MovAv.SMA)
        )
    
        def log(self, txt, dt=None, doprint=False):
            ''' Logging function fot this strategy'''
            if self.params.printlog or doprint:
                dt = dt or self.datas[0].datetime.date(0)
                print('%s, %s' % (dt.isoformat(), txt))
    			
        def __init__(self):
            sma_fast = self.p._movav(period=self.p.fast)
            sma_slow = self.p._movav(period=self.p.slow)
    
            self.buysig = btind.CrossOver(sma_fast, sma_slow)
    
        def next(self):
            if self.position.size:
                if self.buysig < 0:
                    self.sell()
    
            elif self.buysig > 0:
                self.buy()
            self.log('Data size: '+str(self.data.line.lencount), doprint = True)
    	
        def stop(self):
            self.log('(Fast MA Period %2d , Slow MA Period %2d) Ending Value %.2f' %
                     (self.params.fast, self.params.slow, self.broker.getvalue()), doprint=True)
            self.log('Data size: '+str(self.data.line.lencount), doprint = True)
    

    and here "my" script:

    import pandas as pd
    import backtrader as bt
    import backtrader.analyzers as btanalyzers
    import sma_crossover_logged as CO_logged
    
    cerebro = bt.Cerebro()
    
    # the dataframe
    df = pd.read_pickle('C:/Users/Kyouma Hououin/Documents/Python Scripts/Finale/2018-06-18T17-19_2018-06-28T17-19/preproc_gdax_BTC-USD_1m.pkl')
    # just renaming 'strDate' to 'Datetime'
    df.columns = ['Open', 'High', 'Low', 'Close', 'Volume', 'Datetime']
    
    df = df.set_index(df['Datetime'])
    
    #using only the first 5 hours of data
    df = df.iloc[0:300]
    
    data = bt.feeds.PandasData(dataname = df, timeframe=bt.TimeFrame.Minutes)
    
    #data.params.datetime = df.index
    cerebro.adddata(data)
    
    # strategy
    cerebro.addstrategy(CO_logged.SMA_CrossOver)
    
    # Analyzer
    cerebro.addanalyzer(btanalyzers.SharpeRatio, _name='mysharpe')
    
    #Setting up the environment
    cerebro.broker.setcash(10000.0)
    # Add a FixedSize sizer according to the stake
    cerebro.addsizer(bt.sizers.FixedSize, stake=1)
    # Set the commission
    cerebro.broker.setcommission(commission=0.0)
    
    thestrats = cerebro.run()
    cerebro.plot()	#just to show it's doing 'things'
    thestrat = thestrats[0]
    
    print('Sharpe Ratio:', thestrat.analyzers.mysharpe.get_analysis())
    
    
    

    The pikle file is over Drive but here is a vars(data) after cerebro's run:

    In [1]: vars(data)
    Out[1]:
    {'_barstack': deque([]),
     '_barstash': deque([]),
     '_calendar': None,
     '_colmapping': {'close': 3,
      'datetime': None,
      'high': 1,
      'low': 2,
      'open': 0,
      'openinterest': None,
      'volume': 4},
     '_compression': 1,
     '_dataname':                         Open     High      Low    Close     Volume  \
     Datetime
     2018-06-18 17:20:00  6451.21  6451.21  6448.49  6451.03   2.331300
     2018-06-18 17:21:00  6451.00  6451.00  6448.20  6449.09   1.589995
     2018-06-18 17:22:00  6449.08  6449.09  6447.09  6448.22   1.544545
     2018-06-18 17:23:00  6448.21  6448.21  6448.20  6448.21   1.087600
     2018-06-18 17:24:00  6448.21  6450.00  6448.20  6449.99   1.131800
     2018-06-18 17:25:00  6450.00  6450.00  6449.99  6449.99   1.781800
     2018-06-18 17:26:00  6449.99  6450.02  6449.99  6450.02   1.314507
     2018-06-18 17:27:00  6451.20  6454.28  6451.20  6454.27   1.723946
     2018-06-18 17:28:00  6454.27  6454.28  6454.27  6454.28   2.463945
     2018-06-18 17:29:00  6454.27  6454.28  6454.27  6454.28   2.260079
     2018-06-18 17:30:00  6454.28  6454.28  6454.27  6454.28   1.008700
     2018-06-18 17:31:00  6454.28  6455.00  6454.27  6454.99   1.610200
     2018-06-18 17:32:00  6455.00  6455.00  6454.99  6455.00   1.122360
     2018-06-18 17:33:00  6454.99  6455.00  6454.99  6454.99   2.474700
     2018-06-18 17:34:00  6454.99  6455.00  6454.99  6455.00   1.022600
     2018-06-18 17:35:00  6454.99  6455.00  6454.99  6455.00   1.753015
     2018-06-18 17:36:00  6454.99  6455.00  6454.99  6454.99   0.955800
     2018-06-18 17:37:00  6454.99  6455.00  6454.99  6455.00   1.372800
     2018-06-18 17:38:00  6454.99  6455.00  6454.99  6454.99   1.989300
     2018-06-18 17:39:00  6454.99  6454.99  6454.99  6454.99   0.685100
     2018-06-18 17:40:00  6454.99  6455.00  6454.99  6454.99   1.299995
     2018-06-18 17:41:00  6455.00  6455.00  6454.99  6454.99   2.608430
     2018-06-18 17:42:00  6455.00  6455.00  6454.99  6455.00   3.192259
     2018-06-18 17:43:00  6454.99  6455.00  6454.99  6455.00   5.147237
     2018-06-18 17:44:00  6454.99  6455.00  6454.99  6455.00   3.389700
     2018-06-18 17:45:00  6454.99  6455.00  6445.19  6450.33   6.670208
     2018-06-18 17:46:00  6450.33  6452.44  6450.33  6452.43   3.138790
     2018-06-18 17:47:00  6452.44  6452.44  6452.43  6452.43   2.164410
     2018-06-18 17:48:00  6452.43  6452.44  6452.43  6452.43   4.339065
     2018-06-18 17:49:00  6452.43  6452.44  6452.43  6452.44   3.972103
     ...                      ...      ...      ...      ...        ...
     2018-06-18 21:50:00  6690.88  6690.88  6690.00  6690.01   1.855200
     2018-06-18 21:51:00  6690.00  6690.00  6689.60  6690.00   3.343455
     2018-06-18 21:52:00  6690.00  6690.00  6689.99  6690.00   2.596800
     2018-06-18 21:53:00  6689.99  6690.00  6687.61  6690.00   9.388000
     2018-06-18 21:54:00  6689.99  6690.00  6689.99  6689.99   0.716400
     2018-06-18 21:55:00  6690.00  6690.00  6689.99  6689.99   1.095582
     2018-06-18 21:56:00  6690.00  6700.00  6690.00  6700.00   6.624785
     2018-06-18 21:57:00  6700.00  6700.00  6699.99  6700.00   1.599961
     2018-06-18 21:58:00  6700.00  6700.00  6699.99  6699.99   4.996700
     2018-06-18 21:59:00  6699.99  6700.00  6698.66  6698.66   3.222140
     2018-06-18 22:00:00  6697.33  6697.33  6696.91  6696.92   6.493750
     2018-06-18 22:01:00  6696.92  6712.19  6696.91  6712.19  23.056562
     2018-06-18 22:02:00  6712.19  6712.19  6712.18  6712.18   7.647897
     2018-06-18 22:03:00  6712.18  6712.19  6712.18  6712.18   1.431562
     2018-06-18 22:04:00  6712.19  6712.19  6712.18  6712.19   1.803460
     2018-06-18 22:05:00  6712.19  6712.19  6712.18  6712.19   1.248818
     2018-06-18 22:06:00  6712.18  6712.19  6708.95  6710.51  22.718036
     2018-06-18 22:07:00  6710.51  6710.98  6704.79  6707.16  57.105447
     2018-06-18 22:08:00  6707.16  6707.16  6705.19  6707.13  29.973388
     2018-06-18 22:09:00  6707.13  6707.14  6707.13  6707.14   5.188970
     2018-06-18 22:10:00  6707.13  6707.14  6707.13  6707.14   1.728400
     2018-06-18 22:11:00  6707.14  6707.14  6707.14  6707.14   1.507436
     2018-06-18 22:12:00  6707.14  6707.14  6707.13  6707.13   0.967055
     2018-06-18 22:13:00  6707.14  6707.14  6707.13  6707.13   4.475000
     2018-06-18 22:14:00  6707.13  6707.14  6707.13  6707.13   2.962290
     2018-06-18 22:15:00  6707.13  6707.13  6702.36  6702.36   1.616414
     2018-06-18 22:16:00  6701.65  6701.66  6695.13  6695.14  10.706247
     2018-06-18 22:17:00  6695.13  6702.50  6695.13  6702.49   5.333366
     2018-06-18 22:18:00  6702.49  6702.50  6695.55  6696.33  51.705592
     2018-06-18 22:19:00  6696.34  6696.34  6696.33  6696.34   1.216545
    
                                    Datetime
     Datetime
     2018-06-18 17:20:00 2018-06-18 17:20:00
     2018-06-18 17:21:00 2018-06-18 17:21:00
     2018-06-18 17:22:00 2018-06-18 17:22:00
     2018-06-18 17:23:00 2018-06-18 17:23:00
     2018-06-18 17:24:00 2018-06-18 17:24:00
     2018-06-18 17:25:00 2018-06-18 17:25:00
     2018-06-18 17:26:00 2018-06-18 17:26:00
     2018-06-18 17:27:00 2018-06-18 17:27:00
     2018-06-18 17:28:00 2018-06-18 17:28:00
     2018-06-18 17:29:00 2018-06-18 17:29:00
     2018-06-18 17:30:00 2018-06-18 17:30:00
     2018-06-18 17:31:00 2018-06-18 17:31:00
     2018-06-18 17:32:00 2018-06-18 17:32:00
     2018-06-18 17:33:00 2018-06-18 17:33:00
     2018-06-18 17:34:00 2018-06-18 17:34:00
     2018-06-18 17:35:00 2018-06-18 17:35:00
     2018-06-18 17:36:00 2018-06-18 17:36:00
     2018-06-18 17:37:00 2018-06-18 17:37:00
     2018-06-18 17:38:00 2018-06-18 17:38:00
     2018-06-18 17:39:00 2018-06-18 17:39:00
     2018-06-18 17:40:00 2018-06-18 17:40:00
     2018-06-18 17:41:00 2018-06-18 17:41:00
     2018-06-18 17:42:00 2018-06-18 17:42:00
     2018-06-18 17:43:00 2018-06-18 17:43:00
     2018-06-18 17:44:00 2018-06-18 17:44:00
     2018-06-18 17:45:00 2018-06-18 17:45:00
     2018-06-18 17:46:00 2018-06-18 17:46:00
     2018-06-18 17:47:00 2018-06-18 17:47:00
     2018-06-18 17:48:00 2018-06-18 17:48:00
     2018-06-18 17:49:00 2018-06-18 17:49:00
     ...                                 ...
     2018-06-18 21:50:00 2018-06-18 21:50:00
     2018-06-18 21:51:00 2018-06-18 21:51:00
     2018-06-18 21:52:00 2018-06-18 21:52:00
     2018-06-18 21:53:00 2018-06-18 21:53:00
     2018-06-18 21:54:00 2018-06-18 21:54:00
     2018-06-18 21:55:00 2018-06-18 21:55:00
     2018-06-18 21:56:00 2018-06-18 21:56:00
     2018-06-18 21:57:00 2018-06-18 21:57:00
     2018-06-18 21:58:00 2018-06-18 21:58:00
     2018-06-18 21:59:00 2018-06-18 21:59:00
     2018-06-18 22:00:00 2018-06-18 22:00:00
     2018-06-18 22:01:00 2018-06-18 22:01:00
     2018-06-18 22:02:00 2018-06-18 22:02:00
     2018-06-18 22:03:00 2018-06-18 22:03:00
     2018-06-18 22:04:00 2018-06-18 22:04:00
     2018-06-18 22:05:00 2018-06-18 22:05:00
     2018-06-18 22:06:00 2018-06-18 22:06:00
     2018-06-18 22:07:00 2018-06-18 22:07:00
     2018-06-18 22:08:00 2018-06-18 22:08:00
     2018-06-18 22:09:00 2018-06-18 22:09:00
     2018-06-18 22:10:00 2018-06-18 22:10:00
     2018-06-18 22:11:00 2018-06-18 22:11:00
     2018-06-18 22:12:00 2018-06-18 22:12:00
     2018-06-18 22:13:00 2018-06-18 22:13:00
     2018-06-18 22:14:00 2018-06-18 22:14:00
     2018-06-18 22:15:00 2018-06-18 22:15:00
     2018-06-18 22:16:00 2018-06-18 22:16:00
     2018-06-18 22:17:00 2018-06-18 22:17:00
     2018-06-18 22:18:00 2018-06-18 22:18:00
     2018-06-18 22:19:00 2018-06-18 22:19:00
    
     [300 rows x 6 columns],
     '_env': <backtrader.cerebro.Cerebro at 0x1e7620b4828>,
     '_feed': None,
     '_ffilters': [],
     '_filters': [],
     '_id': 1,
     '_idx': 300,
     '_laststatus': 0,
     '_name': '',
     '_opstage': 1,
     '_owner': None,
     '_started': True,
     '_timeframe': 4,
     '_tz': None,
     '_tzinput': None,
     'fromdate': -inf,
     'l': <backtrader.lineseries.Lines_LineSeries_DataSeries_OHLC_OHLCDateTime_AbstractDataBase_DataBase_PandasData at 0x1e76aaf77f0>,
     'line': <backtrader.linebuffer.LineBuffer at 0x1e76aaf7748>,
     'line0': <backtrader.linebuffer.LineBuffer at 0x1e76aaf7748>,
     'line1': <backtrader.linebuffer.LineBuffer at 0x1e76aaf7668>,
     'line2': <backtrader.linebuffer.LineBuffer at 0x1e76aaf76d8>,
     'line3': <backtrader.linebuffer.LineBuffer at 0x1e76aaf7908>,
     'line4': <backtrader.linebuffer.LineBuffer at 0x1e76aaf79b0>,
     'line5': <backtrader.linebuffer.LineBuffer at 0x1e76aaf7b38>,
     'line6': <backtrader.linebuffer.LineBuffer at 0x1e76aaf7be0>,
     'line_0': <backtrader.linebuffer.LineBuffer at 0x1e76aaf7748>,
     'line_1': <backtrader.linebuffer.LineBuffer at 0x1e76aaf7668>,
     'line_2': <backtrader.linebuffer.LineBuffer at 0x1e76aaf76d8>,
     'line_3': <backtrader.linebuffer.LineBuffer at 0x1e76aaf7908>,
     'line_4': <backtrader.linebuffer.LineBuffer at 0x1e76aaf79b0>,
     'line_5': <backtrader.linebuffer.LineBuffer at 0x1e76aaf7b38>,
     'line_6': <backtrader.linebuffer.LineBuffer at 0x1e76aaf7be0>,
     'lines': <backtrader.lineseries.Lines_LineSeries_DataSeries_OHLC_OHLCDateTime_AbstractDataBase_DataBase_PandasData at 0x1e76aaf77f0>,
     'notifs': deque([]),
     'p': <backtrader.metabase.AutoInfoClass_LineRoot_LineMultiple_LineSeries_DataSeries_OHLC_OHLCDateTime_AbstractDataBase_DataBase_PandasData at 0x1e76aaf7828>,
     'params': <backtrader.metabase.AutoInfoClass_LineRoot_LineMultiple_LineSeries_DataSeries_OHLC_OHLCDateTime_AbstractDataBase_DataBase_PandasData at 0x1e76aaf7828>,
     'plotinfo': <backtrader.metabase.AutoInfoClass_pi_LineSeries_pi_DataSeries_pi_OHLC_pi_OHLCDateTime_pi_AbstractDataBase_pi_DataBase_pi_PandasData at 0x1e76aacbd68>,
     'plotlines': <backtrader.metabase.AutoInfoClass_pl_LineSeries_pl_DataSeries_pl_OHLC_pl_OHLCDateTime_pl_AbstractDataBase_pl_DataBase_pl_PandasData at 0x1e76aaf77b8>,
     'sessionend': 0.9999999998842592,
     'sessionstart': 0.0,
     'tick_close': None,
     'tick_high': None,
     'tick_last': None,
     'tick_low': None,
     'tick_open': None,
     'tick_openinterest': None,
     'tick_volume': None,
     'todate': inf}
    

    and the same for the dataframe:

    In [2]: vars(df)
    Out[2]:
    {'_data': BlockManager
     Items: Index(['Open', 'High', 'Low', 'Close', 'Volume', 'Datetime'], dtype='object')
     Axis 1: DatetimeIndex(['2018-06-18 17:20:00', '2018-06-18 17:21:00',
                    '2018-06-18 17:22:00', '2018-06-18 17:23:00',
                    '2018-06-18 17:24:00', '2018-06-18 17:25:00',
                    '2018-06-18 17:26:00', '2018-06-18 17:27:00',
                    '2018-06-18 17:28:00', '2018-06-18 17:29:00',
                    ...
                    '2018-06-18 22:10:00', '2018-06-18 22:11:00',
                    '2018-06-18 22:12:00', '2018-06-18 22:13:00',
                    '2018-06-18 22:14:00', '2018-06-18 22:15:00',
                    '2018-06-18 22:16:00', '2018-06-18 22:17:00',
                    '2018-06-18 22:18:00', '2018-06-18 22:19:00'],
                   dtype='datetime64[ns]', name='Datetime', length=300, freq=None)
     FloatBlock: slice(0, 5, 1), 5 x 300, dtype: float64
     DatetimeBlock: slice(5, 6, 1), 1 x 300, dtype: datetime64[ns],
     '_iloc': <pandas.core.indexing._iLocIndexer at 0x1e76ab10240>,
     '_item_cache': {'Close': Datetime
      2018-06-18 17:20:00    6451.03
      2018-06-18 17:21:00    6449.09
      2018-06-18 17:22:00    6448.22
      2018-06-18 17:23:00    6448.21
      2018-06-18 17:24:00    6449.99
      2018-06-18 17:25:00    6449.99
      2018-06-18 17:26:00    6450.02
      2018-06-18 17:27:00    6454.27
      2018-06-18 17:28:00    6454.28
      2018-06-18 17:29:00    6454.28
      2018-06-18 17:30:00    6454.28
      2018-06-18 17:31:00    6454.99
      2018-06-18 17:32:00    6455.00
      2018-06-18 17:33:00    6454.99
      2018-06-18 17:34:00    6455.00
      2018-06-18 17:35:00    6455.00
      2018-06-18 17:36:00    6454.99
      2018-06-18 17:37:00    6455.00
      2018-06-18 17:38:00    6454.99
      2018-06-18 17:39:00    6454.99
      2018-06-18 17:40:00    6454.99
      2018-06-18 17:41:00    6454.99
      2018-06-18 17:42:00    6455.00
      2018-06-18 17:43:00    6455.00
      2018-06-18 17:44:00    6455.00
      2018-06-18 17:45:00    6450.33
      2018-06-18 17:46:00    6452.43
      2018-06-18 17:47:00    6452.43
      2018-06-18 17:48:00    6452.43
      2018-06-18 17:49:00    6452.44
                              ...
      2018-06-18 21:50:00    6690.01
      2018-06-18 21:51:00    6690.00
      2018-06-18 21:52:00    6690.00
      2018-06-18 21:53:00    6690.00
      2018-06-18 21:54:00    6689.99
      2018-06-18 21:55:00    6689.99
      2018-06-18 21:56:00    6700.00
      2018-06-18 21:57:00    6700.00
      2018-06-18 21:58:00    6699.99
      2018-06-18 21:59:00    6698.66
      2018-06-18 22:00:00    6696.92
      2018-06-18 22:01:00    6712.19
      2018-06-18 22:02:00    6712.18
      2018-06-18 22:03:00    6712.18
      2018-06-18 22:04:00    6712.19
      2018-06-18 22:05:00    6712.19
      2018-06-18 22:06:00    6710.51
      2018-06-18 22:07:00    6707.16
      2018-06-18 22:08:00    6707.13
      2018-06-18 22:09:00    6707.14
      2018-06-18 22:10:00    6707.14
      2018-06-18 22:11:00    6707.14
      2018-06-18 22:12:00    6707.13
      2018-06-18 22:13:00    6707.13
      2018-06-18 22:14:00    6707.13
      2018-06-18 22:15:00    6702.36
      2018-06-18 22:16:00    6695.14
      2018-06-18 22:17:00    6702.49
      2018-06-18 22:18:00    6696.33
      2018-06-18 22:19:00    6696.34
      Name: Close, Length: 300, dtype: float64, 'High': Datetime
      2018-06-18 17:20:00    6451.21
      2018-06-18 17:21:00    6451.00
      2018-06-18 17:22:00    6449.09
      2018-06-18 17:23:00    6448.21
      2018-06-18 17:24:00    6450.00
      2018-06-18 17:25:00    6450.00
      2018-06-18 17:26:00    6450.02
      2018-06-18 17:27:00    6454.28
      2018-06-18 17:28:00    6454.28
      2018-06-18 17:29:00    6454.28
      2018-06-18 17:30:00    6454.28
      2018-06-18 17:31:00    6455.00
      2018-06-18 17:32:00    6455.00
      2018-06-18 17:33:00    6455.00
      2018-06-18 17:34:00    6455.00
      2018-06-18 17:35:00    6455.00
      2018-06-18 17:36:00    6455.00
      2018-06-18 17:37:00    6455.00
      2018-06-18 17:38:00    6455.00
      2018-06-18 17:39:00    6454.99
      2018-06-18 17:40:00    6455.00
      2018-06-18 17:41:00    6455.00
      2018-06-18 17:42:00    6455.00
      2018-06-18 17:43:00    6455.00
      2018-06-18 17:44:00    6455.00
      2018-06-18 17:45:00    6455.00
      2018-06-18 17:46:00    6452.44
      2018-06-18 17:47:00    6452.44
      2018-06-18 17:48:00    6452.44
      2018-06-18 17:49:00    6452.44
                              ...
      2018-06-18 21:50:00    6690.88
      2018-06-18 21:51:00    6690.00
      2018-06-18 21:52:00    6690.00
      2018-06-18 21:53:00    6690.00
      2018-06-18 21:54:00    6690.00
      2018-06-18 21:55:00    6690.00
      2018-06-18 21:56:00    6700.00
      2018-06-18 21:57:00    6700.00
      2018-06-18 21:58:00    6700.00
      2018-06-18 21:59:00    6700.00
      2018-06-18 22:00:00    6697.33
      2018-06-18 22:01:00    6712.19
      2018-06-18 22:02:00    6712.19
      2018-06-18 22:03:00    6712.19
      2018-06-18 22:04:00    6712.19
      2018-06-18 22:05:00    6712.19
      2018-06-18 22:06:00    6712.19
      2018-06-18 22:07:00    6710.98
      2018-06-18 22:08:00    6707.16
      2018-06-18 22:09:00    6707.14
      2018-06-18 22:10:00    6707.14
      2018-06-18 22:11:00    6707.14
      2018-06-18 22:12:00    6707.14
      2018-06-18 22:13:00    6707.14
      2018-06-18 22:14:00    6707.14
      2018-06-18 22:15:00    6707.13
      2018-06-18 22:16:00    6701.66
      2018-06-18 22:17:00    6702.50
      2018-06-18 22:18:00    6702.50
      2018-06-18 22:19:00    6696.34
      Name: High, Length: 300, dtype: float64, 'Low': Datetime
      2018-06-18 17:20:00    6448.49
      2018-06-18 17:21:00    6448.20
      2018-06-18 17:22:00    6447.09
      2018-06-18 17:23:00    6448.20
      2018-06-18 17:24:00    6448.20
      2018-06-18 17:25:00    6449.99
      2018-06-18 17:26:00    6449.99
      2018-06-18 17:27:00    6451.20
      2018-06-18 17:28:00    6454.27
      2018-06-18 17:29:00    6454.27
      2018-06-18 17:30:00    6454.27
      2018-06-18 17:31:00    6454.27
      2018-06-18 17:32:00    6454.99
      2018-06-18 17:33:00    6454.99
      2018-06-18 17:34:00    6454.99
      2018-06-18 17:35:00    6454.99
      2018-06-18 17:36:00    6454.99
      2018-06-18 17:37:00    6454.99
      2018-06-18 17:38:00    6454.99
      2018-06-18 17:39:00    6454.99
      2018-06-18 17:40:00    6454.99
      2018-06-18 17:41:00    6454.99
      2018-06-18 17:42:00    6454.99
      2018-06-18 17:43:00    6454.99
      2018-06-18 17:44:00    6454.99
      2018-06-18 17:45:00    6445.19
      2018-06-18 17:46:00    6450.33
      2018-06-18 17:47:00    6452.43
      2018-06-18 17:48:00    6452.43
      2018-06-18 17:49:00    6452.43
                              ...
      2018-06-18 21:50:00    6690.00
      2018-06-18 21:51:00    6689.60
      2018-06-18 21:52:00    6689.99
      2018-06-18 21:53:00    6687.61
      2018-06-18 21:54:00    6689.99
      2018-06-18 21:55:00    6689.99
      2018-06-18 21:56:00    6690.00
      2018-06-18 21:57:00    6699.99
      2018-06-18 21:58:00    6699.99
      2018-06-18 21:59:00    6698.66
      2018-06-18 22:00:00    6696.91
      2018-06-18 22:01:00    6696.91
      2018-06-18 22:02:00    6712.18
      2018-06-18 22:03:00    6712.18
      2018-06-18 22:04:00    6712.18
      2018-06-18 22:05:00    6712.18
      2018-06-18 22:06:00    6708.95
      2018-06-18 22:07:00    6704.79
      2018-06-18 22:08:00    6705.19
      2018-06-18 22:09:00    6707.13
      2018-06-18 22:10:00    6707.13
      2018-06-18 22:11:00    6707.14
      2018-06-18 22:12:00    6707.13
      2018-06-18 22:13:00    6707.13
      2018-06-18 22:14:00    6707.13
      2018-06-18 22:15:00    6702.36
      2018-06-18 22:16:00    6695.13
      2018-06-18 22:17:00    6695.13
      2018-06-18 22:18:00    6695.55
      2018-06-18 22:19:00    6696.33
      Name: Low, Length: 300, dtype: float64, 'Open': Datetime
      2018-06-18 17:20:00    6451.21
      2018-06-18 17:21:00    6451.00
      2018-06-18 17:22:00    6449.08
      2018-06-18 17:23:00    6448.21
      2018-06-18 17:24:00    6448.21
      2018-06-18 17:25:00    6450.00
      2018-06-18 17:26:00    6449.99
      2018-06-18 17:27:00    6451.20
      2018-06-18 17:28:00    6454.27
      2018-06-18 17:29:00    6454.27
      2018-06-18 17:30:00    6454.28
      2018-06-18 17:31:00    6454.28
      2018-06-18 17:32:00    6455.00
      2018-06-18 17:33:00    6454.99
      2018-06-18 17:34:00    6454.99
      2018-06-18 17:35:00    6454.99
      2018-06-18 17:36:00    6454.99
      2018-06-18 17:37:00    6454.99
      2018-06-18 17:38:00    6454.99
      2018-06-18 17:39:00    6454.99
      2018-06-18 17:40:00    6454.99
      2018-06-18 17:41:00    6455.00
      2018-06-18 17:42:00    6455.00
      2018-06-18 17:43:00    6454.99
      2018-06-18 17:44:00    6454.99
      2018-06-18 17:45:00    6454.99
      2018-06-18 17:46:00    6450.33
      2018-06-18 17:47:00    6452.44
      2018-06-18 17:48:00    6452.43
      2018-06-18 17:49:00    6452.43
                              ...
      2018-06-18 21:50:00    6690.88
      2018-06-18 21:51:00    6690.00
      2018-06-18 21:52:00    6690.00
      2018-06-18 21:53:00    6689.99
      2018-06-18 21:54:00    6689.99
      2018-06-18 21:55:00    6690.00
      2018-06-18 21:56:00    6690.00
      2018-06-18 21:57:00    6700.00
      2018-06-18 21:58:00    6700.00
      2018-06-18 21:59:00    6699.99
      2018-06-18 22:00:00    6697.33
      2018-06-18 22:01:00    6696.92
      2018-06-18 22:02:00    6712.19
      2018-06-18 22:03:00    6712.18
      2018-06-18 22:04:00    6712.19
      2018-06-18 22:05:00    6712.19
      2018-06-18 22:06:00    6712.18
      2018-06-18 22:07:00    6710.51
      2018-06-18 22:08:00    6707.16
      2018-06-18 22:09:00    6707.13
      2018-06-18 22:10:00    6707.13
      2018-06-18 22:11:00    6707.14
      2018-06-18 22:12:00    6707.14
      2018-06-18 22:13:00    6707.14
      2018-06-18 22:14:00    6707.13
      2018-06-18 22:15:00    6707.13
      2018-06-18 22:16:00    6701.65
      2018-06-18 22:17:00    6695.13
      2018-06-18 22:18:00    6702.49
      2018-06-18 22:19:00    6696.34
      Name: Open, Length: 300, dtype: float64, 'Volume': Datetime
      2018-06-18 17:20:00     2.331300
      2018-06-18 17:21:00     1.589995
      2018-06-18 17:22:00     1.544545
      2018-06-18 17:23:00     1.087600
      2018-06-18 17:24:00     1.131800
      2018-06-18 17:25:00     1.781800
      2018-06-18 17:26:00     1.314507
      2018-06-18 17:27:00     1.723946
      2018-06-18 17:28:00     2.463945
      2018-06-18 17:29:00     2.260079
      2018-06-18 17:30:00     1.008700
      2018-06-18 17:31:00     1.610200
      2018-06-18 17:32:00     1.122360
      2018-06-18 17:33:00     2.474700
      2018-06-18 17:34:00     1.022600
      2018-06-18 17:35:00     1.753015
      2018-06-18 17:36:00     0.955800
      2018-06-18 17:37:00     1.372800
      2018-06-18 17:38:00     1.989300
      2018-06-18 17:39:00     0.685100
      2018-06-18 17:40:00     1.299995
      2018-06-18 17:41:00     2.608430
      2018-06-18 17:42:00     3.192259
      2018-06-18 17:43:00     5.147237
      2018-06-18 17:44:00     3.389700
      2018-06-18 17:45:00     6.670208
      2018-06-18 17:46:00     3.138790
      2018-06-18 17:47:00     2.164410
      2018-06-18 17:48:00     4.339065
      2018-06-18 17:49:00     3.972103
                               ...
      2018-06-18 21:50:00     1.855200
      2018-06-18 21:51:00     3.343455
      2018-06-18 21:52:00     2.596800
      2018-06-18 21:53:00     9.388000
      2018-06-18 21:54:00     0.716400
      2018-06-18 21:55:00     1.095582
      2018-06-18 21:56:00     6.624785
      2018-06-18 21:57:00     1.599961
      2018-06-18 21:58:00     4.996700
      2018-06-18 21:59:00     3.222140
      2018-06-18 22:00:00     6.493750
      2018-06-18 22:01:00    23.056562
      2018-06-18 22:02:00     7.647897
      2018-06-18 22:03:00     1.431562
      2018-06-18 22:04:00     1.803460
      2018-06-18 22:05:00     1.248818
      2018-06-18 22:06:00    22.718036
      2018-06-18 22:07:00    57.105447
      2018-06-18 22:08:00    29.973388
      2018-06-18 22:09:00     5.188970
      2018-06-18 22:10:00     1.728400
      2018-06-18 22:11:00     1.507436
      2018-06-18 22:12:00     0.967055
      2018-06-18 22:13:00     4.475000
      2018-06-18 22:14:00     2.962290
      2018-06-18 22:15:00     1.616414
      2018-06-18 22:16:00    10.706247
      2018-06-18 22:17:00     5.333366
      2018-06-18 22:18:00    51.705592
      2018-06-18 22:19:00     1.216545
      Name: Volume, Length: 300, dtype: float64},
     'is_copy': <weakref at 0x000001E76AAF3F48; dead>}
    

    Hope it helps....


  • administrators

    @kyouma-hououin said in Problems with Analyzer and Pandas Datafeed:

    bt.feeds.PandasData(dataname = df, timeframe=bt.TimeFrame.Minutes)

    The SharpeRatio defaults to analyzing yearly returns (which is what the industry does) and cannot find any with your Minutes input. See: Docs - Analyzers Reference

    You can configure it to use timeframe=bt.TimeFrame.Minutes, but imho ... that's not something you would really want to do.