I would like my algo to buy a certain percentage of my portfolio, (say 30%) when it breaches its moving average. The problem is that a few times a day it will trade 1/2. This is completely unnecessary and will run up my brokerage fees. Does anyone have any potential solution for this issue?
James Parrish
*1/2 shares per day
Jing Wu
Hi James,
It is based on your trading logic and how you place orders. You requested the minute data for assets in Initialize(). Then each minute new data point will be pumped into OnData(). If the trading condition is satisfied, new orders will be placed.
There are many ways to reduce the trading frequency. For example, you can add this statement
if not self.Portfolio.Invested:
Then new buy order will be placed only when you don't have assets invested in your portfolio. If you want to trade only once per day, you could use self.Time.date() to control the OnData(). For your reference, this is a simple example
James Parrish
Perfect, thanks!
James Parrish
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!