LEAN is the open source
algorithmic trading engine powering QuantConnect. Founded in 2013 LEAN has been built by a
global community of 80+ engineers and powers more than a dozen hedge funds today.
Alpha League Competition: $1,000 Weekly Prize Pool
Qualifying Alpha Streams Reentered Weekly Learn
more
Let's say AAPL current price is $1,000. I open a new position on AAPL for $2,000 (2 shares) (we'll call this "aapl_1"). At some point later AAPL goes down to $900. I open a new position ("aapl_2") for $2,000 (2.22 shares). Sometime later AAPL goes back up to $1,000. How do I close position "aapl_2" to take a profit, while keeping position "aapl_1" untouched? I've looked everywhere and it seems there isn't a way to close specific positions, unless they have been opened with a take profit option. I can also use a market order to sell stock, but that will sell a generic number, regardless of the opening price. I can also liquidate AAPL, but that means also closing "aapl_1", which is not what I am after. What have I been missing?
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.
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.
Rahul Chowdhury
39.9k
,
Hey Mihai,
You can create a queue of OrderTickets, which contain the fill price and quantity of each new position you enter. Once the downtrend has reversed, the latest entry OrderTicket will be in profit first. As each entry order is in profit (i.e. the current market price is better than the fill price on the OrderTicket), you can create a corresponding exit market order with the same quantity which will close that position. You can do this for each order as it becomes profitable.
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...
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!