Hi,
I am trying to understand symbol data subscriptions and universes. My intent would be to run some scheduled universe event at anytime past midnight, select the stocks to be traded (more than 50 stocks daily) by sending a MarketOrder or a LimitOrder on that same day. For instance, if the universe selection is run on 2020-01-01 at 0:15AM, I would expect the LimitOrder to be active and submitted by 2020-01-01 at 9:30AM (if that was a real trading day). Then, if the order has not filled during the day, I would like to remove the data subscription to that ticker, and remove it from the universe, to free up some space in the subscription manager.
In live trading however, I end up with > 100 active subscriptions very fast because the Symbols stay in the ActiveSecurities object (IB caps you at 100 active data lines).
As a demo, when I run the attached backtest, I expect SPY to be removed from the universe at each even timestep, and added back at each odd timestep. This works until 2013-10-09, at which point it is never removed from the universe and appears in both ActiveSecurities and the OnData slice. Why is that?
Varad Kabade
Hi Marc Demers,
Active security is a security that is currently selected by the universe or has holdings or open orders. If the quantity of active securities is increasing, it means that there are open positions and orders. For the open limit order, we can cancel them one minute before the market closes Thus we can cap our subscription at any time to 100.
Best,
Varad Kabade
Marc Demers
Hi Varad,
For your second point, I understand that this works for Live Trading, but: say I add a security right before market open (for instance 2021-02-01 at 9:29) with a limit order for the day, and my security's resolution is Daily.
If I do a cancel order right before market close (at 2021-02-01 15:59), in the backtest the fill event will register as canceled because OnOrderEvent is called once a day at midnight (at 2021-02-02 00:00 AM).
In that case, the orders are never filled. Is there a solution to this?
Varad Kabade
Hi Marc Demers,
We recommend using intraday data if the algorithm is making intraday trading decisions.
Best,
Varad Kabade
Marc Demers
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!