Beginner here, using Python. I want to trade EURUSD from an hour after markets open (6PM sunday EST) to closing out my positions an hour before they close (4PM friday EST). What is the best way to do this?
Also, is there some documentation of available methods I can search through? For example, I don't know how to find more about "self.ClosePositions". Or search for relevant time methods.
Thank you!
Jared Vetto
Nevermind the second part - I have found that you can search the API tree in the Algorithm Lab environment (under debug).
Rahul Chowdhury
Hi Jared Vetto,
self.ClosePositions represents a scheduled event and it is defined in the algorithm. In other words, it is not a QuantConnect/Lean method.
Scheduled events execute code at specific times of the day. We can define a scheduled event using the self.Schedule.On method. Here's an example:
# In Initialize self.Schedule.On(self.DateRules.Every(DayOfWeek.Friday), self.TimeRules.At(16, 0), self.ClosePositions) # In main class def ClosePositions(self): # code to close positions pass
Learn more about scheduled events in the documentation and in the boot camps, specifically check out the opening range breakout bootcamp.
If you have any other questions, please don't hesitate to reach out!
Best
Rahul
Jared Vetto
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!