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

btrun how to set dtformat=('%Y-%m-%d %H:%M:%S') and tmformat =('%H:%M:%S')



  • Hi,
    I am using btrun to execute backtesting.
    I am trying to feed 15 mins data for backtesting my strategies using btrun.
    I would like to set dtformat and tmformat when feeding the data.
    Following is the command to execute btrun -
    btrun --csvformat btcsv --data /home/dev/backTest/btDev/data/EOD/Long/Data_Q117_asianpaint.csv --strategy /home/dev/backTest/btDev/data/tbadu99/strategyA --cash 100000 --commission 0.006 --fromdate 2017-01-01 --todate 2017-03-31 --analyzer :Returns --analyzer :DrawDown --analyzer :SharpeRatio --analyzer :Transactions --observer :Value --nostdstats --write csv=True --slip_open --slip_perc 0.01 > /home/dev/backTest/btDev/data/tbadu99/result.csv

    When using jupyter notebook backtrader correctly consumes 15 min data since we have option to specify the data format using dtformat and tmformat.

    But when going throught the btrun documentation https://www.backtrader.com/docu/automated-bt-run/automated-bt-run.html. It doesn;t have it listed anywhere.



  • Need help if someone was able to use btrun and correctly consume 15 min data



  • Because I guess it's not possible (the available command line arguments don't suggest you can pass parameters to a data feed using btrun) ...

    Wouldn't it be better if you reformat the csv (Data_Q117_asianpaint.csv) files you are processing? If they are real CSV it should be fairly straightforward to rewrite them in the expected format so that you can load your 15-minutes bars.



  • three records in the file(Data_Q117_asianpaint.csv) looks like -
    date,high,low,open,close,volume,openinterest
    2017-03-01 09:15:00,1033.1,1026.4,1028.95,1029.45,150520,0
    2017-03-01 09:30:00,1033.5,1028,1029,1031.4,83338,0
    2017-03-01 09:45:00,1035.9,1031.4,1031.4,1034,68902,0

    But output that i see in result.csv file is -
    Id,Data_Q117_asianpaint,len,datetime,open,high,low,close,volume,openinterest,Strategy,len,datetime,Value,len,value
    1,Data_Q117_asianpaint,1,2017-03-01 23:59:59.999989,1033.1,1026.4,1028.95,1029.45,150520.0,0.0,Strategy,1,736389.9999999999,Value,1,100000.0
    2,Data_Q117_asianpaint,2,2017-03-01 23:59:59.999989,1033.5,1028.0,1029.0,1031.4,83338.0,0.0,Strategy,2,736389.9999999999,Value,2,100000.0
    3,Data_Q117_asianpaint,3,2017-03-01 23:59:59.999989,1035.9,1031.4,1031.4,1034.0,68902.0,0.0,Strategy,3,736389.9999999999,Value,3,100000.0



  • @Tausif said in btrun how to set dtformat=('%Y-%m-%d %H:%M:%S') and tmformat =('%H:%M:%S'):

    btrun --csvformat btcsv --data /home/dev/backTest/btDev/data/EOD/Long/Data_Q117_asianpaint.csv --strategy /home/dev/backTest/btDev/data/tbadu99/strategyA --cash 100000 --commission 0.006 --fromdate 2017-01-01 --todate 2017-03-31 --analyzer :Returns --analyzer :DrawDown --analyzer :SharpeRatio --analyzer :Transactions --observer :Value --nostdstats --write csv=True --slip_open --slip_perc 0.01 > /home/dev/backTest/btDev/data/tbadu99/result.csv
    

    That may be because not --timeframe and no --compression are being specified



  • So for 15 mins timeframe should be minutes and compression 1 right?



  • Compression 15


Log in to reply
 

Looks like your connection to Backtrader Community was lost, please wait while we try to reconnect.