binance: better bad account in order request error msg

basic_buy_bot
Tyler Goodlet 2023-06-26 13:30:56 -04:00
parent 2d291bd2c3
commit 249b091c2f
1 changed files with 12 additions and 4 deletions

View File

@ -198,8 +198,11 @@ async def handle_order_requests(
account = msg.get('account') account = msg.get('account')
if account not in {'binance.spot', 'binance.futes'}: if account not in {'binance.spot', 'binance.futes'}:
log.error( log.error(
'This is a binance account, \ 'Order request does not have a valid binance account name?\n'
only a `binance.spot/.futes` selection is valid' 'Only one of\n'
'- `binance.spot` or,\n'
'- `binance.usdtm`\n'
'is currently valid!'
) )
await ems_order_stream.send( await ems_order_stream.send(
BrokerdError( BrokerdError(
@ -277,7 +280,7 @@ async def open_trade_dialog(
# TODO: load other market wide data / statistics: # TODO: load other market wide data / statistics:
# - OI: https://binance-docs.github.io/apidocs/futures/en/#open-interest # - OI: https://binance-docs.github.io/apidocs/futures/en/#open-interest
# - OI stats: https://binance-docs.github.io/apidocs/futures/en/#open-interest-statistics # - OI stats: https://binance-docs.github.io/apidocs/futures/en/#open-interest-statistics
accounts: bidict[str, str] = bidict() accounts: bidict[str, str] = bidict({'binance.usdtm': None})
balances: dict[Asset, float] = {} balances: dict[Asset, float] = {}
positions: list[BrokerdPosition] = [] positions: list[BrokerdPosition] = []
@ -292,6 +295,8 @@ async def open_trade_dialog(
# 'canWithdraw': True, # 'canWithdraw': True,
# 'feeTier': 0} # 'feeTier': 0}
if 'account' in req: if 'account' in req:
# NOTE: fill in the hash-like key/alias binance
# provides for the account.
alias: str = resp['accountAlias'] alias: str = resp['accountAlias']
accounts['binance.usdtm'] = alias accounts['binance.usdtm'] = alias
@ -369,7 +374,10 @@ async def open_trade_dialog(
f'{pformat(entry)}\n' f'{pformat(entry)}\n'
) )
await ctx.started((positions, list(accounts))) await ctx.started((
positions,
list(accounts)
))
# TODO: package more state tracking into the dialogs API? # TODO: package more state tracking into the dialogs API?
# - hmm maybe we could include `OrderDialogs.dids: # - hmm maybe we could include `OrderDialogs.dids: