Back

How to set the spread

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,

Update Backtest








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
}
}

 

0

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.


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

0

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.

0

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.


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 ?

 

0

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.

0

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.


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.

0

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.
 

0

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.


Update Backtest





0

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.


Loading...

This discussion is closed