1
$\begingroup$

This is a very simple perhaps naive question. Let's say I have a stock price prediction model trained on daily closing prices of that stock. So when I use this model for live trading, I'll have trading signals only at market close. How'd I put in an order and trade?

I see a lot of strategy research articles on the internet, and quite a few of them backtested their strategy on daily data, but I never understood how such strategies are implemented live.

$\endgroup$
2
$\begingroup$

If your signals only become available at market close, you obviously can't execute them in that day's trading session. You have a few options -

  1. Try to execute your trades out of market hours with a willing broker (probably a bad idea, you almost certainly won't get good prices)
  2. Trade in the opening auction the next day.
  3. Trade in the next day's continuous trading session.
  4. Trade in the closing auction the next day.

Options 2. and 4. are the easiest to simulate using daily stock price data, since you typically have both opening and closing prices. However, you should remember that the fact that you are trading in the opening/closing auction will move the auction price, so you should simulate market impact.

Option 3 can be simulated if you have access to intraday stock price data, or if you can find a source of VWAP or TWAP prices. You should still simulate market impact though.

| improve this answer | |
$\endgroup$
  • $\begingroup$ Thanks Chris. That’s very helpful. I have a stats PhD so the strategy component is fun but execution is really giving me a headache. As far as I know when I place an open on market it only gets sent to primary exchanges. But I think my daily closing prices aren’t just from the exchanges. I need to work on my data feed more. Thanks again! $\endgroup$ – dynamic89 Nov 16 '19 at 16:00
0
$\begingroup$

You need an API to interface with a broker (which interfaces to exchanges).

You will have your strategy running, using data from the API, and ultimately the part of your code involved in signal generation will send an API request (in the form of, e.g., “buy 100 shares of AAPL”).

The IB API is quite popular, I would suggest looking through the documentation (irrespective of whether you plan on using them; it will be useful for understanding how this works at a high level).

| improve this answer | |
$\endgroup$
  • $\begingroup$ Sure but if the model is trained using daily closing prices of the stock and I only get a signal by the end of the day (that's when a new data point comes in). Then when I put in an order the market is already closed. I see a lot of papers using daily closing prices instead of opening prices, is there a reason? $\endgroup$ – dynamic89 Nov 15 '19 at 4:28
  • $\begingroup$ In various parts of the world, a stock is available to trade on multiple exchanges. The "open" therefore has multiple meanings. On a consolidated tape basis, the open represents the first reported trade. On the primary listing exchange, is often done via an opening auction or driven by a market maker, and they may open the market seconds or minutes later than the opening bell. A similar auction takes place on the closing bell, but this time the primary listing exchange close is the arbiter of the close price (if there's enough liquidity for an auction). $\endgroup$ – Norgate Data Nov 15 '19 at 4:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.