huobi icon indicating copy to clipboard operation
huobi copied to clipboard

Store account id when init client

Open Jay54520 opened this issue 6 years ago • 6 comments

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

Jay54520 avatar May 28 '18 00:05 Jay54520

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

ericls avatar May 28 '18 02:05 ericls

Does this library only provide functions that huobi provides?

Jay54520 avatar May 28 '18 07:05 Jay54520

@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.

ericls avatar May 31 '18 02:05 ericls

Add an option is not a bad idea.

Put this codes under HuobiRestClient.__init__?

Jay54520 avatar Jun 01 '18 01:06 Jay54520

I can see it working under HuobiRestClient.__init__

Would be happy to see a PR :)

ericls avatar Jun 01 '18 02:06 ericls

Ok, let me do it.

Jay54520 avatar Jun 01 '18 09:06 Jay54520