Skip to content

Commit 2220b1b

Browse files
committed
get_price_oi function added
1 parent 397d18b commit 2220b1b

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

oi_graph/futures_oi.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,22 @@ def get_open_interest(data, symbol):
3636
pct_pivot = pivot.pct_change()*100
3737
return (list(pivot.columns), pivot.reset_index())
3838

39+
def get_price_oi(data, symbol):
40+
"""
41+
Get the price and combined open_interest for the symbol
42+
data
43+
dataframe with all data
44+
symbol
45+
symbol to extract data
46+
"""
47+
temp = data[data.symbol == symbol]
48+
grouped = temp.groupby('timestamp')
49+
agg = grouped.agg({'open_int': sum, 'close': 'mean'}).reset_index()
50+
agg['date'] = agg.timestamp.dt.date.astype(str)
51+
agg['index'] = range(len(agg))
52+
return agg
53+
54+
3955
output_file('futures_oi.html')
4056
df = load_data()
4157
symbols = list(df.symbol.unique())

0 commit comments

Comments
 (0)