Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
VWAP Slap

Hi guys I’m hoping someone could get me started, I do have a bit of programming experience but not Python but I should pick up enough once I get started.

The very basics that I would need to get started is as follows, intraday trading only:

  1. Wait ‘N’ minutes after market open before a trade is placed.
  2. I want to place the trade (short) when the price action comes up to the VWAP and touches or within '$0.05' .
  3. I want to close the trade if the price continues over the VWAP by ‘$0.10’.

I have lots more to add but just want to get started.

3 responses

Wait ‘N’ minutes after market open before a trade is placed.

See https://www.quantopian.com/help#api-schedulefunction .

I want to place the trade (short) when the price action comes up to the VWAP and touches or within '$0.05' .
I want to close the trade if the price continues over the VWAP by ‘$0.10’.

I would consider how you want to define VWAP. Quantopian provides minute bars (OHLCV), so you have to write a little code to compute the VWAP (starting at the market open?) across your securities. Also, you might consider if you want to use the minutely closing price to make your trading decisions relative to VWAP, or if you want any averaging/smoothing.

Thanks Grant that link would help with the portion of the delayed start.

The part that has got me in knots is this section:

I want to place the trade (short) when the price action comes up to the VWAP and touches or within '$0.05' .
I want to close the trade if the price continues over the VWAP by ‘$0.10’.

Mark -

You might try expressing your definitions and conditions in some flavor of pseudocode; once you get everything laid out, translating to Python and the Quantopian API will be straightforward.

Some considerations:

place the trade - Submit an order?
price action vs. price - The same, or different?
VWAP - Of what? A single stock? Or are you looking to scan over multiple stocks? How would you like to calculate VWAP?
comes up to the VWAP and touches or within '$0.05' - What does this mean? It implies that first, the 'price action' needs to be below the VWAP, but it need to be increasing? And first it has to 'touch' (equal?) the VWAP value? But then maybe not, since you say 'or within '$0.05''?
close the trade - This presumably means submit an order to go to cash. Would you be scanning across multiple stocks, or a single one?
if the price continues over the VWAP by ‘$0.10’ - Will you continue to calculate VWAP? Or is this the VWAP computed when you decided to 'place the trade'? Also, when you say 'price continues' is the condition simply that the price exceeds the VWAP by $0.10? Or are you wanting to use slope/trend information ('continues' language)?