Hi,
I'm studying the forex grid trading strategy at the moment. I'm planning to place the limit order where they should be right after the market is open. However, I found out either limit order got triggered twice in the same minute bar. Can anyone help me figure out what is going on here?
2022-02-06 17:04:00 2022-02-06 17:04:00: Time: 02/06/2022 22:04:00 OrderID: 11 EventID: 2 Symbol: USDCHF Status: Filled Quantity: -54323 FillQuantity: -54323 FillPrice: 0.92491 CHF LimitPrice: 0.92042 (Short1)
2022-02-06 17:04:00 2022-02-06 17:04:00: Time: 02/06/2022 22:04:00 OrderID: 12 EventID: 2 Symbol: USDCHF Status: Filled Quantity: -54280 FillQuantity: -54280 FillPrice: 0.92491 CHF LimitPrice: 0.92114 (Short2)
2022-02-06 17:04:00 2022-02-06 17:04:00: Time: 02/06/2022 22:04:00 OrderID: 15 EventID: 2 Symbol: USDCHF Status: Filled Quantity: -54323 FillQuantity: -54323 FillPrice: 0.92491 CHF LimitPrice: 0.92042 (Short1)
2022-02-06 17:04:00 2022-02-06 17:04:00: Time: 02/06/2022 22:04:00 OrderID: 16 EventID: 2 Symbol: USDCHF Status: Filled Quantity: -54280 FillQuantity: -54280 FillPrice: 0.92491 CHF LimitPrice: 0.92114 (Short2)
2022-02-06 17:06:00 2022-02-06 17:06:00: Time: 02/06/2022 22:06:00 OrderID: 17 EventID: 2 Symbol: USDCHF Status: Filled Quantity: -54323 FillQuantity: -54323 FillPrice: 0.92491 CHF LimitPrice: 0.91969 (Short1-Liquidate)
2022-02-06 17:06:00 2022-02-06 17:06:00: Time: 02/06/2022 22:06:00 OrderID: 18 EventID: 2 Symbol: USDCHF Status: Filled Quantity: -54280 FillQuantity: -54280 FillPrice: 0.92491 CHF LimitPrice: 0.92042 (Short2-Liquidate)
2022-02-06 17:06:00 2022-02-06 17:06:00: Time: 02/06/2022 22:06:00 OrderID: 19 EventID: 2 Symbol: USDCHF Status: Filled Quantity: -54323 FillQuantity: -54323 FillPrice: 0.92491 CHF LimitPrice: 0.91969 (Short1-Liquidate)
2022-02-06 17:06:00 2022-02-06 17:06:00: Time: 02/06/2022 22:06:00 OrderID: 20 EventID: 2 Symbol: USDCHF Status: Filled Quantity: -54280 FillQuantity: -54280 FillPrice: 0.92491 CHF LimitPrice: 0.92042 (Short2-Liquidate)
Michael Hsia
Found the cause:
From the log, that I've found on `2022-02-06`, the below schedule event was triggered twice.
Is this the expected outcome when calling the Schedule.On AfterMarketOpen()?
Log attached below for reference:
Michael Hsia
Is there anyone still available to help answer this question? I'm just not sure whether it's just me or it's a systematic error. Would be great to know how it comes out.
Varad Kabade
Hi Michael Hsia,
The scheduled event did not trigger twice on the same day; if we look at the logs when it was triggered, we can confirm that:
2022-02-04 00:00:00 : 2022-02-04 00:00:00 Market start
2022-02-06 17:01:00 : 2022-02-06 17:00:00 Market start
Thus the algorithm has created 2 orders of each type(short1,short2) therefore, either order is executed as the limit condition has reached
Best,
Varad Kabade
Michael Hsia
Hi Varad,
Could you kindly let me know where did you find the log message of `2022-02-04 00:00:00 : 2022-02-04 00:00:00 Market start`? I couldn't find it anywhere in the backtest log.
Thanks
Varad Kabade
Hi Micheal,
I just commented off the first line in onMarket method:
Refer to the attached backtest.
Best,
Varad Kabade
Michael Hsia
Thanks Varad Kabade
I'm not sure what happened but seems what you have is what I expected. However, I did not manage to get that result but instead printed the `02-06 market start` two times last week.
Thanks again for your patience.
Michael Hsia
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!