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

Help with sample code



  • I am testing the sample code in doc>quick start with hourly OHLC data instead of daily data feeds. I find any order created will only be executed at next day open rather than next bar open. Is there any parameters I shall adjust in the code please?



  • add the output:
    Starting Portfolio Value: 100000.00
    2019-01-03, Close, 3843.86
    2019-01-03, BUY CREATE, 3843.86
    2019-01-03, Close, 3830.78
    2019-01-03, Close, 3826.99
    2019-01-03, Close, 3835.96
    2019-01-03, Close, 3838.95
    2019-01-03, Close, 3833.47
    2019-01-03, Close, 3842.83
    2019-01-03, Close, 3841.83
    2019-01-03, Close, 3849.04
    2019-01-03, Close, 3834.59
    2019-01-03, Close, 3820.00
    2019-01-03, Close, 3824.38
    2019-01-03, Close, 3823.14
    2019-01-03, Close, 3820.53
    2019-01-03, Close, 3825.02
    2019-01-03, Close, 3828.88
    2019-01-03, Close, 3826.98
    2019-01-03, Close, 3805.00
    2019-01-03, Close, 3806.17
    2019-01-03, Close, 3805.81
    2019-01-03, Close, 3812.69
    2019-01-03, Close, 3811.52
    2019-01-03, Close, 3802.01
    2019-01-03, Close, 3804.00
    2019-01-03, Close, 3800.07
    2019-01-03, Close, 3818.02
    2019-01-03, Close, 3813.94
    2019-01-03, Close, 3817.36
    2019-01-03, Close, 3808.52
    2019-01-03, Close, 3796.70
    2019-01-03, Close, 3804.98
    2019-01-03, Close, 3806.70
    2019-01-03, Close, 3748.73
    2019-01-03, Close, 3738.00
    2019-01-03, Close, 3755.03
    2019-01-03, Close, 3748.46
    2019-01-03, Close, 3748.06
    2019-01-03, Close, 3757.89
    2019-01-03, Close, 3751.55
    2019-01-03, Close, 3756.00
    2019-01-03, Close, 3772.82
    2019-01-03, Close, 3780.03
    2019-01-03, Close, 3775.07
    2019-01-03, Close, 3771.26
    2019-01-03, Close, 3760.44
    2019-01-03, Close, 3773.79
    2019-01-03, Close, 3764.44
    2019-01-03, Close, 3766.78
    2019-01-04, BUY EXECUTED, 3767.20
    2019-01-04, Close, 3746.79
    2019-01-04, Close, 3750.30
    2019-01-04, Close, 3762.93
    2019-01-04, Close, 3766.23
    2019-01-04, Close, 3761.68
    2019-01-04, Close, 3758.65
    2019-01-04, SELL CREATE, 3758.65
    2019-01-04, Close, 3760.13
    2019-01-04, Close, 3780.04
    2019-01-04, Close, 3773.00
    2019-01-04, Close, 3775.33
    2019-01-04, Close, 3768.86
    2019-01-04, Close, 3779.90
    2019-01-04, Close, 3788.87
    2019-01-04, Close, 3783.02
    2019-01-04, Close, 3786.19
    2019-01-04, Close, 3783.28
    2019-01-04, Close, 3786.03
    2019-01-04, Close, 3771.34
    2019-01-04, Close, 3767.14
    2019-01-04, Close, 3764.35
    2019-01-04, Close, 3766.04
    2019-01-04, Close, 3775.48
    2019-01-04, Close, 3772.97
    2019-01-04, Close, 3757.55
    2019-01-04, Close, 3755.55
    2019-01-04, Close, 3755.52
    2019-01-04, Close, 3747.13
    2019-01-04, Close, 3744.00
    2019-01-04, Close, 3744.92
    2019-01-04, Close, 3717.14
    2019-01-04, Close, 3719.21
    2019-01-04, Close, 3725.28
    2019-01-04, Close, 3736.98
    2019-01-04, Close, 3747.50
    2019-01-04, Close, 3741.79
    2019-01-04, Close, 3745.22
    2019-01-04, Close, 3734.98
    2019-01-04, Close, 3730.00
    2019-01-04, Close, 3738.76
    2019-01-04, Close, 3739.53
    2019-01-04, Close, 3738.26
    2019-01-04, Close, 3764.24
    2019-01-04, Close, 3780.22
    2019-01-04, Close, 3802.36
    2019-01-04, Close, 3791.24
    2019-01-04, Close, 3790.98
    2019-01-04, Close, 3794.33
    2019-01-04, Close, 3792.01
    2019-01-05, SELL EXECUTED, 3790.09
    2019-01-05, Close, 3810.44
    2019-01-05, Close, 3811.76
    2019-01-05, Close, 3798.07
    2019-01-05, Close, 3803.58
    2019-01-05, Close, 3817.21
    2019-01-05, Close, 3811.88
    2019-01-05, Close, 3807.89
    2019-01-05, BUY CREATE, 3807.89
    2019-01-05, Close, 3815.00
    2019-01-05, Close, 3820.50
    2019-01-05, Close, 3815.72
    2019-01-05, Close, 3828.81
    2019-01-05, Close, 3834.01
    2019-01-05, Close, 3811.10
    2019-01-05, Close, 3799.45
    2019-01-05, Close, 3800.55
    2019-01-05, Close, 3785.15
    2019-01-05, Close, 3791.61
    2019-01-05, Close, 3793.56
    2019-01-05, Close, 3793.00
    2019-01-05, Close, 3790.36
    2019-01-05, Close, 3785.72
    2019-01-05, Close, 3787.94
    2019-01-05, Close, 3796.74
    2019-01-05, Close, 3801.26
    2019-01-05, Close, 3808.24
    2019-01-05, Close, 3802.47
    2019-01-05, Close, 3790.68
    2019-01-05, Close, 3793.84
    2019-01-05, Close, 3787.78
    2019-01-05, Close, 3787.45
    2019-01-05, Close, 3807.61
    2019-01-05, Close, 3785.58
    2019-01-05, Close, 3804.28
    2019-01-05, Close, 3797.19
    2019-01-05, Close, 3797.48
    2019-01-05, Close, 3801.36
    2019-01-05, Close, 3806.08
    2019-01-05, Close, 3809.02
    2019-01-05, Close, 3812.66
    2019-01-05, Close, 3810.98
    2019-01-05, Close, 3803.24
    2019-01-05, Close, 3803.68
    2019-01-05, Close, 3805.40
    2019-01-05, Close, 3806.57
    2019-01-05, Close, 3776.40
    2019-01-05, Close, 3786.62
    2019-01-05, Close, 3780.07
    2019-01-05, Close, 3770.96
    2019-01-06, BUY EXECUTED, 3771.12
    2019-01-06, Close, 3775.74
    2019-01-06, Close, 3786.76
    2019-01-06, Close, 3784.40
    2019-01-06, Close, 3765.65
    2019-01-06, Close, 3767.69
    2019-01-06, Close, 3771.82
    2019-01-06, SELL CREATE, 3771.82
    2019-01-06, Close, 3766.74
    2019-01-06, Close, 3771.15
    2019-01-06, Close, 3765.19
    2019-01-06, Close, 3767.90
    2019-01-06, Close, 3782.03
    2019-01-06, Close, 3777.75
    2019-01-06, Close, 3776.79
    2019-01-06, Close, 3772.22
    2019-01-06, Close, 3761.55
    2019-01-06, Close, 3767.94
    2019-01-06, Close, 3766.73
    2019-01-06, Close, 3772.88
    2019-01-06, Close, 3773.02
    2019-01-06, Close, 3771.30
    2019-01-06, Close, 3772.33
    2019-01-06, Close, 3796.99
    2019-01-06, Close, 3802.92
    2019-01-06, Close, 3814.24
    2019-01-06, Close, 3803.07
    2019-01-06, Close, 3790.81
    2019-01-06, Close, 3796.01
    2019-01-06, Close, 3798.61
    2019-01-06, Close, 3797.39
    2019-01-06, Close, 3801.35
    2019-01-06, Close, 3815.05
    2019-01-06, Close, 3806.82
    2019-01-06, Close, 3810.23
    2019-01-06, Close, 3813.39
    2019-01-06, Close, 3993.09
    2019-01-06, Close, 4007.11
    2019-01-06, Close, 4001.99
    2019-01-06, Close, 3989.09
    2019-01-06, Close, 4001.85
    2019-01-06, Close, 4002.46
    2019-01-06, Close, 4001.87
    2019-01-06, Close, 3977.16
    2019-01-06, Close, 3959.57
    2019-01-06, Close, 3967.49
    2019-01-06, Close, 3984.91
    2019-01-06, Close, 3970.36
    2019-01-06, Close, 3999.43
    2019-01-06, Close, 3987.60
    Final Portfolio Value: 100239.37



  • Try using compression and set it to 60, default value is 1. So assuming you are a newbie on this platform, you can set this parameter when you import your data or in the cerebro call. Check the docs all the info is there in abundant detail.



  • @robin-dhillon tks for your answer. I insert timeframe=bt.TimeFrame.Minutes when feeding the data. It's solved!


Log in to reply
 

});