Closed yangmeishu closed 2 months ago
这是成功的代码:
from okx.app.market import MarketSPOT
from okx.app.utils import eprint
if __name__ == '__main__':
proxy_host = None
marketSPOT = MarketSPOT(proxy_host=proxy_host)
history_candle = marketSPOT.get_history_candle(
instId='BTC-USDT',
start='2024-01-01 00:00:00',
end='2024-01-01 22:00:00',
bar='2H',
)
eprint(history_candle)
输出结果:
{'code': '0', 'data': array([[1.70403840e+12, 4.24576000e+04, 4.27007000e+04, 4.24301000e+04, 4.26104000e+04, 3.78315832e+02, 1.61084931e+07, 1.61084931e+07, 1.00000000e+00], [1.70404560e+12, 4.26105000e+04, 4.27200000e+04, 4.25333000e+04, 4.26121000e+04, 3.48587937e+02, 1.48615666e+07, 1.48615666e+07, 1.00000000e+00], [1.70405280e+12, 4.26158000e+04, 4.26808000e+04, 4.25058000e+04, 4.25144000e+04, 3.62747155e+02, 1.54495793e+07, 1.54495793e+07, 1.00000000e+00], [1.70406000e+12, 4.25145000e+04, 4.25911000e+04, 4.20660000e+04, 4.22830000e+04, 8.69770762e+02, 3.67719985e+07, 3.67719985e+07, 1.00000000e+00], [1.70406720e+12, 4.22840000e+04, 4.27777000e+04, 4.22597000e+04, 4.26139000e+04, 5.88295584e+02, 2.50402635e+07, 2.50402635e+07, 1.00000000e+00], [1.70407440e+12, 4.26139000e+04, 4.26438000e+04, 4.22090000e+04, 4.23357000e+04, 5.61299281e+02, 2.38199641e+07, 2.38199641e+07, 1.00000000e+00], [1.70408160e+12, 4.23357000e+04, 4.24023000e+04, 4.21820000e+04, 4.22410000e+04, 5.28343756e+02, 2.23519674e+07, 2.23519674e+07, 1.00000000e+00], [1.70408880e+12, 4.22396000e+04, 4.25047000e+04, 4.22064000e+04, 4.24952000e+04, 5.04646095e+02, 2.14063019e+07, 2.14063019e+07, 1.00000000e+00], [1.70409600e+12, 4.24953000e+04, 4.26950000e+04, 4.24541000e+04, 4.26550000e+04, 4.98716704e+02, 2.12273604e+07, 2.12273604e+07, 1.00000000e+00], [1.70410320e+12, 4.26535000e+04, 4.27602000e+04, 4.26020000e+04, 4.26895000e+04, 4.48015722e+02, 1.91258758e+07, 1.91258758e+07, 1.00000000e+00], [1.70411040e+12, 4.26895000e+04, 4.27740000e+04, 4.26102000e+04, 4.27181000e+04, 3.68393192e+02, 1.57314187e+07, 1.57314187e+07, 1.00000000e+00], [1.70411760e+12, 4.27182000e+04, 4.28480000e+04, 4.25743000e+04, 4.27828000e+04, 7.57382673e+02, 3.23363389e+07, 3.23363389e+07, 1.00000000e+00]]), 'msg': ''}
可能需要注意的:
感谢作者的耐心回复。我使用的是 https://github.com/pyted/okx/blob/master/examples/2.4%20APP%20%E7%8E%B0%E8%B4%A7%E8%A1%8C%E6%83%85-%E5%8E%86%E5%8F%B2K%E7%BA%BF.ipynb 这个链接的例子 2H 是因为示例1m太多数据
我示例里,第一次是能够得到okx返回的数据,在包处理组合时候,出现的错误情况。 我的具体代码
另外作者你推荐的用 proxy_host okx_resender 能docker就好啦
更新一下底层:
pip3 install candlelite --upgrade pip3 install paux --upgrade pip3 install pandas --upgrade pip3 install numpy --upgrade
Pandas版本过低,有BUG
作者帮忙给个正常运行的 pip list 看看版本 谢谢 这个是我的
paux 1.0.13 candlelite 1.0.17 pandas 2.0.3 numpy 1.24.4 okx 2.1.1 binance_interface 2.0.5 urllib3 1.26.12 requests 2.31.0
注意urllib3的版本不要过高,Pandas不要低于2
感谢,不过后面按照操作了也没成功。只能换了ccxt和官方包了
` history_candle = self.market.get_history_candle( instId='BTC-USDT', start='2024-01-01 00:00:00', end='2024-01-01 23:59:00', bar='2H', )
返回的是
{'code': 'CANDLE_START_ERROR', 'data': array([], shape=(0, 9), dtype=float64), 'msg': 'BTC-USDT[candle empty]'} candle.shape= (0, 9)