I am trying to develop a bot using the IBAPI. I was trying to figure out how to write python code to get VWAP value, but I want to be able to define from what time VWAP restarts calculating.
Using the TA phython package, its VWAP function resets at a set time and I could not change it.
I want my VWAP to reset at 2am EST every day.
I was able to get the VWAP value I wanted on TradingView using the following Pine Script:
`//@version=5
indicator('VWAP Midnight', overlay=true)
var float vwapsum = na
var float volumesum = na
//------------------------------------------------
Midnight = hour == 23 and minute == 0
newSession = Midnight and not Midnight[1]
//------------------------------------------------
vwapsum := newSession ? hl2 * volume : hl2 * volume + vwapsum[1]
volumesum := newSession ? volume : volume + volumesum[1]
myvwap = vwapsum / volumesum`
Just need help translating the math to python using IBAPI