Is there anyway i could get the vwap indicator added to the TA lib? Its seems to be greatly used by retail traders right now and could be a good way to gauge the herd.plus price does seem to respect that level quite often.


  • ptunneyptunney Posts: 246
    edited May 2019

    TALIB is an external Python Library so we do not control that (http://ta-lib.org/)
    Most TALIB calculations are based on passing a series of bars (OHLCV Open High Low Close Volume) either daily or minute or groups of minutes and it returns a set of values.
    VWAP is a Volume Weighted Average Price. It is calculated on a trade by trade basis.
    As such TALIB would not be able to calculate it.
    We do calculate VWAP in our backtesting system but there are some glitches with the way it is calculated (we hope to get these resolved soon).

    Try the following script to see the VWAP updating... You will need ELITE for the on_trade callback to be called.

    from cloudquant.interfaces import Strategy
    class _VWAP(Strategy):
        def is_symbol_qualified(cls, symbol, md, service, account):
            return symbol=="AAPL"
        def on_start(self, md, order, service, account): #
            mydbar = md.bar.daily(start=-1)
            print service.time_to_string(md.L1.timestamp),"on_start  yest   bar  vwap  {:8.2f}".format(mydbar.vwap[0])
        def on_minute_bar(self, event, md, order, service, account, bar):
            mybar = md.bar.minute(start=-1,include_extended=True)
            print service.time_to_string(event.timestamp),"on_minute minute bar  vwap  {:8.2f}".format(mybar.vwap[0])
            print service.time_to_string(event.timestamp),"on_minute md.L1.daily_vwap  {:8.2f}".format(md.L1.daily_vwap) 
        def on_trade(self, event, md, order, service, account):
            print service.time_to_string(event.timestamp),"on_trade  md.L1.minute_vwap {:8.2f}  Last Trade {:8.2f}  Last Size {:8.0f}".format(md.L1.minute_vwap, md.L1.last,md.L1.last_size)
  • nj634677nj634677 Posts: 2

    Thank you very much! ill go through that

Sign In or Register to comment.