I am getting runetime tuple index error.
I want to check the change in obv over last few days but unable to get obv in first place.
Thanks in advance.
import talib
import numpy as np
def initialize(context):
context.security = symbol('AAPL')
#set_benchmark(symbol('SPY'))
pass
# Will be called on every trade event for the securities you specify.
def handle_data(context, data):
p_history = history(bar_count=200, frequency="1d", field="close_price").dropna(axis=1)
closes = p_history[context.security]
v_history = history(bar_count=200, frequency="1d", field="volume").dropna(axis=1)
volumes = v_history[context.security]
''' - referred Technical Framework posted on community
closeDeck = history(200, "1d", "close_price").dropna(axis=1)
closeDeck = closeDeck[[sid for sid in closeDeck if sid in data]]
volumeDeck = history(200, "1d", "volume").dropna(axis=1)
volumeDeck = volumeDeck[[sid for sid in volumeDeck if sid in data]]
for stock in closeDeck:
context.S[stock].OBV = talib.OBV(closeDeck[stock], volumeDeck[stock])[-1]'''
obv_n = talib.OBV(closes, volumes)[-1]
log.info(obv_n=obv_n)