How do I calculate volume/time weighted avg price? Any pointers will help.
-
I read blogs on position.price and cost basis but those discussions werent conclusive.
-
Not really clear what are you looking for. Do you want to create VWAP indicator? Or calculate trade entry/exit VWAP? Latter is done by bt by default I think.
-
@ab_trader yes, I want to calculate entry/exit vwap. could you let me know if position.price is size-weighted average price VWAP? and how do I calculateTWAP?
-
could you let me know if position.price is size-weighted average price VWAP?
I think so, I believe I've seen this discussion somewhere on the forum. Test it to be totally sure that it is what you are looking for.
and how do I calculate TWAP?
As an idea - get prices from
notify_order
for each executed order within single trade and then do all necessary calculations. At least I would start from there. -
thank you, surely a start to code a strategy