HuobiRDCenter / huobi_Python

Python SDK for Huobi Spot API
https://huobiapi.github.io/docs/spot/v1/en
Apache License 2.0
680 stars 332 forks source link

get_candlestick always return 1min data #56

Closed sorjor closed 3 years ago

sorjor commented 4 years ago

i m try to get 15min candlestick for test

symbol = "adausdt" list_obj = market_client.get_candlestick(symbol, '15min', 10)

for k in list_obj: print(k.close)

LogInfo.output("---- {interval} candlestick for {symbol} ----".format(interval=interval, symbol=symbol))

LogInfo.output_list(list_obj)

and its return 1min candlestick 0.121713 0.121914 0.12188 0.121763 0.121672 0.121669 0.121481 0.121516 0.1219 0.121662 Id : 1594347780 High : 0.121911 Low : 0.121675 Open : 0.121911 Close : 0.121713 Count : 54 Amount : 132281.06750672866 Volume : 16107.9599034442

Id : 1594347720 High : 0.12195 Low : 0.121883 Open : 0.121886 Close : 0.121914 Count : 28 Amount : 96753.15110478163 Volume : 11794.0036594614

Id : 1594347660 High : 0.121886 Low : 0.121746 Open : 0.121828 Close : 0.12188 Count : 29 Amount : 18519.715947675315 Volume : 2256.2868972041

Id : 1594347600 High : 0.121763 Low : 0.121628 Open : 0.121722 Close : 0.121763 Count : 52 Amount : 155829.0080548023 Volume : 18968.4866346081

Id : 1594347540 High : 0.121779 Low : 0.121608 Open : 0.121617 Close : 0.121672 Count : 59 Amount : 72723.23675317562 Volume : 8847.867451519

Id : 1594347480 High : 0.121674 Low : 0.121487 Open : 0.121564 Close : 0.121669 Count : 30 Amount : 40434.50929292199 Volume : 4917.1316266523

Id : 1594347420 High : 0.121617 Low : 0.121421 Open : 0.121508 Close : 0.121481 Count : 95 Amount : 190802.9073224408 Volume : 23181.7959195717

Id : 1594347360 High : 0.121939 Low : 0.121516 Open : 0.121887 Close : 0.121516 Count : 95 Amount : 138464.38278449216 Volume : 16846.1558703949

Id : 1594347300 High : 0.121978 Low : 0.121682 Open : 0.121696 Close : 0.1219 Count : 39 Amount : 28132.052194365635 Volume : 3426.204759435763

Id : 1594347240 High : 0.121729 Low : 0.121536 Open : 0.121617 Close : 0.121662 Count : 40 Amount : 32190.976746379936 Volume : 3916.712209975

sorjor commented 4 years ago

i m try debug response = session.get(request.host + request.url, headers=request.header)

and found url is right '

url = https://api.huobi.pro/market/history/kline?symbol=adausdt&interval=15min&size=10'

but response is not

b'{"ch":"market.adausdt.kline.1min","status":"ok","ts":1594348432249,"data":[{"id":1594348380,"open":0.120629,"close":0.121351,"low":0.120629,"high":0.121365,"amount":585014.393037782,"vol":70795.74992104543,"count":211},{"id":1594348320,"open":0.120487,"close":0.120573,"low":0.120305,"high":0.120717,"amount":404959.73244635935,"vol":48781.8771877041,"count":215},{"id":1594348260,"open":0.120855,"close":0.120596,"low":0.120489,"high":0.120855,"amount":427981.4237426004,"vol":51620.9516000573,"count":208},{"id":1594348200,"open":0.120749,"close":0.120892,"low":0.120749,"high":0.121003,"amount":134279.5404265479,"vol":16228.3295471856,"count":125},{"id":1594348140,"open":0.120734,"close":0.120685,"low":0.120666,"high":0.120815,"amount":79575.32009665997,"vol":9605.734810902,"count":67},{"id":1594348080,"open":0.120951,"close":0.120745,"low":0.120345,"high":0.120973,"amount":551476.7969611437,"vol":66516.26426800758,"count":264},{"id":1594348020,"open":0.120892,"close":0.120962,"low":0.120825,"high":0.121032,"amount":185056.40908422688,"vol":22376.5800937766,"count":179},{"id":1594347960,"open":0.121569,"close":0.12093,"low":0.12075,"high":0.121569,"amount":1112264.3609642822,"vol":134790.9393143321,"count":411},{"id":1594347900,"open":0.12162,"close":0.121519,"low":0.121512,"high":0.121643,"amount":317126.2293833718,"vol":38547.8576652787,"count":130},{"id":1594347840,"open":0.121732,"close":0.12162,"low":0.12156,"high":0.121781,"amount":88654.23637774932,"vol":10783.3815919052,"count":57}]}'

728443778 commented 4 years ago

websocket client is right,but http request is more convenient

728443778 commented 4 years ago

Modify huobi/client/market.py In line 36, change the interval to period

shuangbi commented 3 years ago

already fixed, close this issue