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

why "buy/sell" marker is not in the right position?



  • Hi Guys,
    My data feed is hour bar, 6 bars per day. But it seems buy/sell marker is not in the right position sometimes.
    Some of the marker is in the right position, but some of them not. I've no clue about it.

    Like the picture below,
    2020-05-21T23:00:00, BUY CREATE, 3375.00.
    Buy order should be placed on the hand drawn red arrow (2020-05-21T23:00:00), But it was moved behind couple K lines.

    data
    3376.0,3386.0,3373.0,3384.0,269762,14987,0.0,2020,5,20,10,0,2020-05-20 10:00,3.780170763331913e-40
    3384.0,3388.0,3379.0,3386.0,268820,8959,0.0,2020,5,20,11,15,2020-05-20 11:15,3.766970531797973e-40
    3385.0,3387.0,3375.0,3381.0,266271,13117,0.0,2020,5,20,14,15,2020-05-20 14:15,3.731251433942334e-40
    3381.0,3384.0,3376.0,3376.0,268181,10815,0.0,2020,5,20,15,0,2020-05-20 15:00,3.758016234610938e-40
    3370.0,3386.0,3370.0,3379.0,266282,13071,0.0,2020,5,21,22,0,2020-05-21 22:00,3.731405576773409e-40
    3380.0,3382.0,3375.0,3375.0,266156,6290,0.0,2020,5,21,23,0,2020-05-21 23:00,3.72963994070836e-40
    3376.0,3394.0,3376.0,3384.0,262578,14631,0.0,2020,5,21,10,0,2020-05-21 10:00,3.679501481654818e-40
    3384.0,3392.0,3381.0,3390.0,261784,9748,0.0,2020,5,21,11,15,2020-05-21 11:15,3.668375171848079e-40
    3390.0,3407.0,3382.0,3405.0,257708,23010,0.0,2020,5,21,14,15,2020-05-21 14:15,3.6112582464421996e-40
    3405.0,3406.0,3394.0,3403.0,255225,19957,0.0,2020,5,21,15,0,2020-05-21 15:00,3.5764640055730144e-40
    3405.0,3423.0,3403.0,3420.0,250612,23267,0.0,2020,5,22,22,0,2020-05-22 22:00,3.5118221074137106e-40
    
    class data_feed_future(btfeed.GenericCSVData):
        params = (
            ('dtformat', '%Y-%m-%d %H:%M'),
            ('datetime', 12),
            ('open', 0),
            ('high', 1),
            ('low', 2),
            ('close', 3),
            ('volume', 5),
            ('openinterest', -1) 
        )
    
    
    if __name__ == '__main__':
    
        cerebro = bt.Cerebro()
    
    
        data = data_feed_future(dataname=data_file_dir + '\\' + ticker + '.csv',compression=60 ,timeframe=bt.TimeFrame.Minutes)
        cerebro.adddata(data)
        cerebro.addstrategy(strategy_under_test)
    
        # Set our desired cash start
        cerebro.broker.setcash(startcash)
        # Set the commission - 0.1% ... divide by 100 to remove the %
        cerebro.broker.setcommission(commission=0.002)
        # Add a FixedSize sizer according to the stake
        cerebro.addsizer(bt.sizers.FixedSize, stake=1)
        results = cerebro.run()  # run it all
        cerebro.plot(style='candlestick') 
    

    ![alt text](85c9b744-bb34-4f48-9fa5-d8b78e30d0b8-image.png image url)


Log in to reply
 

});