Hello,
My understanding of the current implementation of the method before_trading_start() is that it is rather limited since it can only be used to update the instruments universe.
In actual trading, it is common to update portfolio metrics and send orders to a broker overnight (i.e., between 4 pm EST and 9:30 am EST the next day).
Basically, what I'd like to see implemented is:
- The ability to run the methods after_trading_end() and before_trading_start() at a specific time between the end of the current day's session and the beginning of the next day's trading session. For example, if I get custom data outside of Quantopian at 2 am EST I could run after_trading_end() at 2:30 am EST:
def after_trading_end(run_at=datetime.time(2, 30)):
# Get my custom data into Quantopian at 2:30 am EST
fetch_csv(url=my_url)
# do some other stuff
Access to the same data as during the trading day (i.e., pricing data, fundamentals, account, orders, etc.). For example, I would need to get the open orders in order to calculate the distance to stops and see where I stand for each position or strategy and my total portfolio risk. These methods should be similar to a data event. The only difference is that the trader chooses when these events are triggered.
The possibility to send orders to IB in after_trading_end() and before_trading_start() exactly like what I'm doing in real life. It is not doable in Quantopian at the moment and this is very unfortunate. One reason is to be found in a related topic where Alisa Deychman wrote (see discussion here):
Why do orders get cancelled at the end of the trading day, automatically?
This was built as a precautionary measure to protect live traders against wild price swings overnight.
I don't understand this choice. I know that Quantopian is a social platform, but socialist? If some traders don't know what they're doing, please let them learn it the hard way and do not limit those who've done their homework.
In IB, traders can specify the time in force and whether to allow the order to be filled outside of regular trading hours, or during the pre-open session. Is this a feature Quantopian is going to implement?
I know that we - the traders - are very picky when it comes to our trading tools. You folks at Quantopian get many requests and need to prioritize, I totally understand that. Adding support for futures, stats-arb and expanding the research platform is really cool. But closing the gap between what Quantopian can do and what we can do in real trading is IMHO the top priority. Quantopian's limitations are:
- can't trade on the first minute bar
- can't send market-on-open (MOO) and market-on-close (MOC) orders
- need to cancel all open orders at 4 pm EST/can't specify time-in-force (e.g., DAY, GTC, pre-open/after-trading-hours)
- can't run overnight events
That said, I do find Quantopian amazing for many more reasons not cited here. :)
I'd love to have your thoughts on this.
Cheers!