Execute Buy immediatly after Sell completes
Author: QuinnHarris
Creation Date: 11/30/2010 4:03 PM
profile picture

QuinnHarris

#1
I have a strategy that needs to sell one issue and buy up another issue immediately after with the cash from the first sale. Is there any way in Wealthlab, especially using the Strategy monitor, to issue a sell for one issue that will be quickly (less than 1min) followed by a buy for another issue? It is essential the sell executes before the buy.
profile picture

Eugene

#2
Each of the SellAt* methods return a boolean value indicating if the sale happened on the current bar. In pseudocode:
CODE:
Please log in to see this code.

Of course you need to be careful not to fall victim of peeking e.g. buy at open after selling at stop, all at the same bar.
profile picture

QuinnHarris

#3
With back testing if I sell then buy on the same bar at the same point (open, close) the cash from the sale will not be available for the buy. So a SellAtMarket and BuyAtClose might work but the actual execution could be as far apart as the time period used. If actual execution behaves like back testing its not ideal.

I haven't used the strategy monitor much so I am uncertain to its exact behavior but this is how I understand how it works.

The strategy is run once for each of the selected issues. This produces a set of trades. The strategy monitor will then use that set of trades to do the actual execution after the strategy code has executed and generated all trades.

So does SellAtMarket actually wait for the order to be executed on the market before returning or does it return true when it expects the order can execute (if its on the current time bar)?

Can you provide an example of a strategy that sells one issue then buys another issue immediately after that will actually execute on the market (using strategy monitor I presume) using Fidelity in the prescribed order every time?

profile picture

Cone

#4
QUOTE:
If actual execution behaves like back testing its not ideal.
If you exit Position AtMarket, the proceeds from that transaction are available for other trades on the same day in a Portfolio Mode simulation.

Wealth-Lab will generate all Alerts for live trading, i.e., no Alerts are ever "rejected".
Call Fidelity (or your broker) to determine how buying power/available funds works for real trading.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).