Hourly bars?
-
Hi,
I copy pasted the quickstart code under "The broker says: Show me the money!" and adjusted filename and following feed params:data = data = btfeeds.GenericCSVData( dataname='test_ForBacktraderHourly.csv', fromdate=datetime.datetime(2017, 1, 1), todate=datetime.datetime(2017, 1, 5), nullvalue=0.0, dtformat=('%Y-%m-%d %H'), # it is hourly data headers = True, datetime=0, high=1, low=2, open=3, close=4, volume=5, openinterest=-1 )
The csv contains datal like this:
Date, High, Low, Open, Close, Volume
2011-09-13 15, 6.000000000000, 5.800000000000, 5.800000000000, 6.000000000000, 25.000000000000
2011-09-13 16 , 5.950000000000, 5.760000000000, 5.950000000000, 5.760000000000, 22.353982380000So that should be hourly bars.
But when executing the self.buy() the buy is not executed at next bar, but at next day.
How to change from Daily to Hourly?
I tried to addtimeframe = bt.TimeFrame.Hours
but 1) this is only used for Resampling (dont know yet what it is) and 2) does Hours not exist.
edit:
So question is not only about "hourly" it is about customized bars, so even 2 hourly or 0.5hourly and so on. -
@Serp said in Hourly bars?:
timeframe = bt.TimeFrame.Hours
but 1) this is only used for Resampling (dont know yet what it is) and 2) does Hours not exist.
No, ``timeframe` is not only for resampling. It is a standard parameter for all data feeds. It is especially important when resampling because a target is needed.
Which means that if your input is really not
Days
(the default value), you have to tell the platform what it is.- does Hours not exist.
You can still use
Minutes
and60
which is 1 hour. -
thank you very much. English is not my native language and I thought the sentence:
"Informative unless Data Resampling/Replaying is used" would mean, that it is just for my personal informative use (like I could print that it is "daily", but it has no other purpose).Thanks, so to sum it up (for other people reading here) the solution was:
timeframe = bt.TimeFrame.Minutes, compression = 60,
-
You read it right and has been corrected. The platform was tightened around that area due to how users were actually addressing the multiple possible corners.