I migrated from Quantopian and I really enjoy the QC here. One thing I want to ask is, in Quantopian they provide default slippage model like this:
"If you do not specify a slippage method, slippage defaults to VolumeShareSlippage(volume_limit=0.025, price_impact=0.1)
(you can take up to 2.5% of a minute's trade volume)."
I was wondering in QC, how can I set up something like above - as far as I could understand, all partially filled orders in QC are set to immediately filled. After some research, it seems that I should use
// Set the fill models in initialize:
Securities["IBM"].FillModel = new PartialFillModel();
// Custom fill model implementation stub
public class PartialFillModel : ImmediateFillModel {
public override OrderEvent MarketFill(Security asset, MarketOrder order) {
//Override order event handler and return partial order fills,
}
}
However, I am stuck at this point:
1. My algo is not using individual Securities function to add stocks, it is using custom universe, so I was wondering if I could use something like, Universe.FillModel to set every stock in the universe.
2. What code should go in the the PartialFillModel to let it perform similar function as the slippage model in Quantopian?
Thanks so much!
Michael Handschuh
In order to set models for securities coming out of universe selection I recommend using the `ISecurityInitializer`. We'll invoke that after the security is created (either via universe selection or via `AddSecurity` methods). Check out this partial fill model:
Yours will need to be different. Instead of accepting a `numberOfFills` it should just accept the `percentage` directly. The rest of the logic there *should* work. If this ends up working well, we can look at putting it into the core LEAN.
QQQ VVV
Michael Handschuh
Thanks for the answer. If I understand correctly, the "numberOfFills" indicates the number of "smaller" orders to make the original complete order. So if 100 shares are wanted, the numberOfFills = 4, then 25 shares is filled immediately each time.
If my understanding above is correct, then I think there is still some difference between the Slippage model stated in the original post above and the github link you provided. The Slippage model stated in the original post is constrained by the *volume* of the *market*, which means if the volume of the market at this moment = 100 shares, the order can only be filled to up to a set percentage of it (say, 5%, then the order could only be filled for 5 shares at this moment)...
Please let me know if I made it more confusing... and thanks a lot for your help!!!
QQQ VVV
bump for answers... thanks!
Jared Broad
You can make the reality models do anything you like. There is no model as you've described though. It will be a few lines of code to implement it.
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.
QQQ VVV
Jared Broad
If I use "Securities["SPY"].FillModel = new PartialMarketFillModel(Transactions, 2);" as Michael Handschuh mentioned, I am not quite sure how I can use all the stocks in my universe to the same FillModel as I tried "UniverseSettings.FillModel = new PartialMarketFillModel(Transactions, 2);" which returns errors. Thanks...
Jared Broad
Thats a cool idea -- "UniverseSettings.FillModel = new PartialMarketFillModel()" !
The "right" way to do this is with a SecurityInitializer class:
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.
QQQ VVV
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!