wrap api method calls with uri and nonce value
parent
0c537a67a8
commit
3ac48656a9
|
@ -197,7 +197,7 @@ class Client:
|
||||||
self,
|
self,
|
||||||
method: str,
|
method: str,
|
||||||
data: dict,
|
data: dict,
|
||||||
uri_path: str,
|
uri_path: str
|
||||||
) -> Dict[str, Any]:
|
) -> Dict[str, Any]:
|
||||||
headers = {
|
headers = {
|
||||||
'Content-Type':
|
'Content-Type':
|
||||||
|
@ -215,17 +215,17 @@ class Client:
|
||||||
)
|
)
|
||||||
return resproc(resp, log)
|
return resproc(resp, log)
|
||||||
|
|
||||||
async def get_balances(
|
async def get_user_data(
|
||||||
self,
|
self,
|
||||||
) -> Dict[str, str]:
|
method: str,
|
||||||
data = {
|
data: Dict[str, Any]
|
||||||
'nonce' : str(int(1000*time.time()))
|
) -> Dict[str, Any]:
|
||||||
}
|
uri_path = f'/0/private/{method}'
|
||||||
resp = await self._private('Balance', data, '/0/private/Balance')
|
data['nonce'] = str(int(1000*time.time()))
|
||||||
|
resp = await self._private(method, data, uri_path)
|
||||||
err = resp['error']
|
err = resp['error']
|
||||||
if err:
|
if err:
|
||||||
print(err)
|
print(err)
|
||||||
|
|
||||||
return resp['result']
|
return resp['result']
|
||||||
|
|
||||||
async def symbol_info(
|
async def symbol_info(
|
||||||
|
@ -345,8 +345,12 @@ async def get_client() -> Client:
|
||||||
section = conf.get('kraken')
|
section = conf.get('kraken')
|
||||||
client._api_key = section['api_key']
|
client._api_key = section['api_key']
|
||||||
client._secret = section['secret']
|
client._secret = section['secret']
|
||||||
|
data = {
|
||||||
|
# add non nonce vars
|
||||||
|
}
|
||||||
|
|
||||||
balances = await client.get_balances()
|
balances = await client.get_user_data('Balance', data)
|
||||||
|
ledgers = await client.get_user_data('Ledgers', data)
|
||||||
|
|
||||||
await tractor.breakpoint()
|
await tractor.breakpoint()
|
||||||
|
|
||||||
|
@ -356,6 +360,29 @@ async def get_client() -> Client:
|
||||||
yield client
|
yield client
|
||||||
|
|
||||||
|
|
||||||
|
# @tractor.context
|
||||||
|
# async def trades_dialogue(
|
||||||
|
# ctx: tractor.Context,
|
||||||
|
# loglevel: str = None,
|
||||||
|
# ) -> AsyncIterator[Dict[str, Any]]:
|
||||||
|
#
|
||||||
|
# # XXX: required to propagate ``tractor`` loglevel to piker logging
|
||||||
|
# get_console_log(loglevel or tractor.current_actor().loglevel)
|
||||||
|
#
|
||||||
|
# # deliver positions to subscriber before anything else
|
||||||
|
# positions = await _trio_run_client_method(method='positions')
|
||||||
|
#
|
||||||
|
# all_positions = {}
|
||||||
|
#
|
||||||
|
# for pos in positions:
|
||||||
|
# msg = pack_position(pos)
|
||||||
|
# all_positions[msg.symbol] = msg.dict()
|
||||||
|
#
|
||||||
|
# await ctx.started(all_positions)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
async def stream_messages(ws):
|
async def stream_messages(ws):
|
||||||
|
|
||||||
too_slow_count = last_hb = 0
|
too_slow_count = last_hb = 0
|
||||||
|
|
Loading…
Reference in New Issue