1% ABOVE PURCHASE PRICE: self.Log("SELL >> {0}".format(self.Securities["TWTR"].Price)) self.Liquidate("TWTR")I'm ..."> 1% ABOVE PURCHASE PRICE: self.Log("SELL >> {0}".format(self.Securities["TWTR"].Price)) self.Liquidate("TWTR")I'm ..."> How do I sell for some percent higher than my purchase price? by Brian Graichen - QuantConnect.com
Back

How do I sell for some percent higher than my purchase price?

if holdings > 0 and self.Securities["TWTR"].Price > 1% ABOVE PURCHASE PRICE:
self.Log("SELL >> {0}".format(self.Securities["TWTR"].Price))
self.Liquidate("TWTR")

I'm not very good at coding, so simple is better :)

I'll normally have a Moving Average after my last > Greater Than sign. How do I sell for a higher percentage price? Thanks!

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.


Hi Brian,

If you plan on only having one holding for each ticker (i.e. you're not going to add several buys for the same ticker), then you can use self.Portfolio["TWTR"].AveragePrice. Bear in mind, though, that you should only assume this is a numeric, sensible price if you know you already have holdings in this security.

If you have multiple holdings in the security, you'll have to decide which one you want to get 1% of and look at the fill price of the specific order.

1

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