How to do intraday trading in backtrader ?
-
Suppose I just want to do intraday trading then how can I do it using timers or filters.I can do it any way by handling the datetime object and check if current time falls within the intraday timing then only i will execute the buy or sell signals but I want some smart way or inbuilt functionality to do it.
And how to forcefully execute or close all the open orders if these signals(buy,sell) crossed the intraday time limit ? -
@ry-93 said in How to do intraday trading in backtrader ?:
Suppose I just want to do intraday trading then how can I do it using timers or filters
By using intraday data (i.e.: sub-day timeframe)
@ry-93 said in How to do intraday trading in backtrader ?:
I can do it any way by handling the datetime object and check if current time falls within the intraday timing then only i will execute the buy or sell signals but I want some smart way or inbuilt functionality to do it.
Each data feed carries a timestamp which can be converted to a
datetime.datetime
and/ordatetime.time
instance to let you know what the current time is in Python format. For examplecur_dt = self.data.datetime.datetime(0) # get current datetime cur_tm = self.data.datetime.time(0) # get current time
You may of course get the
time component from the
datetimeobject
if you prefer.@ry-93 said in How to do intraday trading in backtrader ?:
And how to forcefully execute or close all the open orders if these signals(buy,sell) crossed the intraday time limit ?
Keep a reference to the orders you have issued, check the time and when your deadline is met, issue a
cancel
on the orders which have not been executed yet (i.e.: not remove from your list, because they have been notified asCompleted
) -
Hello,
does backtrader have access to preMarket data too in smaller timeframes? -
@Onder-Oz said in How to do intraday trading in backtrader ?:
does backtrader have access to preMarket data too in smaller timeframes
Backtrader accepts any data, pre/post market included. Just be sure your data provider supplies such data.