ericls / huobi

Huobi python sdk
MIT License
19 stars 10 forks source link

Store account id when init client #5

Open Jay54520 opened 6 years ago

Jay54520 commented 6 years ago

Some APIs such as place order need account id, but it's not appropriate to request account id before every placing order request.

The accounts response is like this:

{'status': 'ok', 'data': [{'id': 100000, 'type': 'spot', 'subtype': '', 'state': 'working'}, {'id': 300000, 'type': 'margin', 'subtype': 'btcusdt', 'state': 'working'}, {'id': 1050000, 'type': 'otc', 'subtype': '', 'state': 'working'}]}

I guess that one API_KEY will only have one working account id for each type, so we may store all working apis like this when init client:

client.spot_account_id = spot_account_id
client.margin_account_id = margin_account_id
client.otc_account_id = otc_account_id
ericls commented 6 years ago

I think this is beyond the scope of this library as it stands now

Jay54520 commented 6 years ago

Does this library only provide functions that huobi provides?

ericls commented 6 years ago

@Jay54520 at least we should not automagically store account IDs, the only way I see this working is to add an option for users to explicitly say that they want account IDs to be store for future requests.

Jay54520 commented 6 years ago

Add an option is not a bad idea.

Put this codes under HuobiRestClient.__init__?

ericls commented 6 years ago

I can see it working under HuobiRestClient.__init__

Would be happy to see a PR :)

Jay54520 commented 6 years ago

Ok, let me do it.