Hi,
I would like to know how to set the spread for a Forex.
I tried using a custom transaction model, overriding slippage and fees but i don't think this is the right way to go.
Regards,
QUANTCONNECT COMMUNITY
Hi,
I would like to know how to set the spread for a Forex.
I tried using a custom transaction model, overriding slippage and fees but i don't think this is the right way to go.
Regards,
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.
Alexandre Catarino
In order to implement a custom slippage model, we need to set it to the security:
// In Initialize Securities["EURUSD"].SlippageModel = new CustomSlippageModel();
And create the class with the model:
public class CustomSlippageModel : ISlippageModel { public decimal GetSlippageApproximation( Security asset, Order order) { /* Implement your model here. E.g.: */ return 0m; // No slippage } }
David Mabs
Thanks for your answer,
I'm a bit new to this but does the slippage equal to the spread between sell and buy spot prices.
So we have Spot_Sell - Spot_Buy = Slippage ?
Regards
Alexandre Catarino
Not quite. Slippage refers to the difference between the expected price of a trade and the price at which the trade is actually executed (source).
At minimum, it is the bid-ask spread:
public class CustomSlippageModel : ISlippageModel { public decimal GetSlippageApproximation( Security asset, Order order) { // Bid-ask slippage return asset.AskPrice - asset.BidPrice; } }
and can get bigger depending on the asset liquidity and volatility.
David Mabs
Oh okey, I think I understand better now.
So when you do a SetHolding with a positive number you buy at askPrice + slippage and with a negative number bidPrice + slippage.
Is that right ?
Alexandre Catarino
Theorically, that is right.
However, we only support bid and ask information for tick data at the moment. We are working on expanding this to tradebars.
David Mabs
Hum OK.
So to sum it up, at the moment when I do a setHolding there is no spread implemented between bid and ask prices.
To simulate it you have to set a slippage to will be equal to your spread so that when you use setHolding to take a long you take TradeBar.Price - slippage and when you take a short it's TradeBar.price + slippage.
Am I right ?
When you take a long it should be - slippage so you are losing money when you take the position.
Thanks for taking the time to answer.
Alexandre Catarino
Yes, that is correct.
While we do not have bid and ask on our tradebars, we can make a study of the impact of spread/slippage on our strategy. Setting it to a constant (one, two, ..., ten) pip and verify when it is still profitable.
David Mabs
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!