binance_interface
binance_interface copied to clipboard
K线指标
请问那些K线的指标能不能也一并开发了?
一起同时多线程获取N个产品的K线吗?
一起同时多线程获取N个产品的K线吗?
是SMA、BOLL这些指标,他们没有这个开放吗
没有注意到官方有这个指标,还是建议离线自己计算。
# Candle BOLL 布林带
def boll(
candle: np.array,
n: int
) -> np.ndarray:
'''
:param candle:历史K线数据
:param n:间隔
:return:
array([
[ts,mb,up,dn],
[ts,mb,up,dn],
[ts,mb,up,dn],
])
(mb:均线 up:上轨 dn:下轨)
'''
# list
boll_datas = []
for index in range(candle.shape[0]):
if index <= n - 1:
mb = np.nan
up = np.nan
dn = np.nan
else:
mb = candle[index - n:index, 4].mean() # 收盘价均值
sd = (candle[index - n:index, 4] - mb).std() # 收盘价标准差
up = mb + 2 * sd # 上轨
dn = mb - 2 * sd # 下轨
boll_datas.append(
[candle[index, 0], mb, up, dn]
)
# array
candle_boll = np.array(boll_datas)
return candle_boll