-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTalibApp.py
More file actions
30 lines (22 loc) · 744 Bytes
/
Copy pathTalibApp.py
File metadata and controls
30 lines (22 loc) · 744 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from talib import abstract
import numpy as np
import pandas as pd
import f_Ut_GetStockHist as GSH
def WhichBBInterval(HistClose, price):
# 0 -> lower -> 1 -> middle -> 2 -> upper -> 3
bbd = abstract.Function('BBANDS')
real_data = [float(x) for x in HistClose]
np_real_data = np.array(real_data)
upper, middle, lower = bbd( np_real_data,timeperiod=20, nbdevup=2.0, nbdevdn=2.0,matype=2)
if price <= lower[-1]:
return 0
if price <= middle[-1]:
return 1
if price <= upper[-1]:
return 2
else:
return 3
#df1 = GSH.GetStockHist('20200501', '2330')
#df2 = GSH.GetStockHist('20200601', '2330')
#result = pd.concat([df1, df2])
#print(WhichBBInterval(result['Close'].values, 280 ))