Hey all, excuse me if this is a silly question but are we expecting to see slippage on backtested data? On a minute resolution EURUSD buy/sell?
I was playing around with Forex and EURUSD and attached is an simple algo that trades at a specified minute and sells the next minute after every day. The backtest shows a 95% loss rate (sad face), but my log would say otherwise... I log the moment before buying and the moment before selling and compare the two to see if they would profit or not. End of algorithm displays my expeced win rate of ~67%
Please let me know what I am missing
Thanks!
Ivan Baev
Hi. I think the answer to your question is:
2020-01-02 18:01:00 : PROFIT: 6.499999999998174e-05 2020-01-05 18:01:00 : PROFIT: 5.0000000000105516e-05
2020-01-02 18:00:00 EURUSD Buy Market $1.11732 USD 842,935 Filled 2020-01-02 18:01:00 EURUSD Sell Market $1.11717 USD -842,935 Filled Liquidated 2020-01-05 18:00:00 EURUSD Buy Market $1.11609 USD 843,743 Filled 2020-01-05 18:01:00 EURUSD Sell Market $1.1159 USD -843,743 Filled Liquidated
You've got your calculation wrong. Or execution. Your market order is not getting executed at the Security Price level. It's something else here. Your execution price is highest ask price. You can partially avoid this problem by using limit orders with desired price level.
Pcnpj
Hey Ivan BaevÂ
Thanks for taking the time to look at this. I was under the impression that due to EURUSD extremely high volume, I would be able to buy/sell at the current price pretty easily with market orders, is that not true?
Adn what do you mean that my execution price is highest ask price? Is SetHoldings set to always to the highest ask?
Again, thanks!
Jared Broad
Hi @Pcnpj - where possible we use spread to give you accurate fills. FX brokerages maintain a bid-ask spread; with market orders (like SetHoldings) you buy at the asking price, and sell at the best bid. Going back and forth between them will be expensive. There is no way to buy and sell at the "midpoint".Â
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.
Ivan Baev
Please have a look at my little not finished example. It gives a some sort of a look at what I mean exactly.
You can sell easily with market orders but they take the price that gets you losses, because of the market spreads.
Your BUY execution is at the lowest ask. your SELL execution in at the highest bid. And there is a big difference in these numbers.
I've plotted ASK and BID prices for you with the EMA values on the example below. You can see a difference in between your sell and buy values. It really matters in forex and any other market, to be honest...
Â
Please bear in mind that this example has some mistakes. Like order execution and order size calculation.
Pcnpj
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!