Back

Algorithm is trading too often

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?

Update Backtest








*1/2 shares per day

0

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 

https://github.com/QuantConnect/Lean/blob/master/Algorithm.Python/MACDTrendAlgorithm.py
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.


Perfect, thanks!

0

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