shrimpy-python icon indicating copy to clipboard operation
shrimpy-python copied to clipboard

Buy side output does not make sense

Open KobaKhit opened this issue 4 years ago • 0 comments

Hello. So I set my code up to execute orders on Binance US and whenever I submit an order to buy ETH for USDT the trade_status response does not make sense to me.

smart_order_response = api_client.create_trade(
            user_id,    # user_id
            account_id, # account_id
           'USDT',            # from_symbol
           'ETH',           # to_symbol
           150.27,         # amount of from_symbol
            True              # enable smart_routing
        )

I would assume that usdValue in 'fills' should sum up close to 150.27. I don not understand why it would not. And when I check my balance after the trade completed the actual amount transfered is 142.87 and I dont see that number in the trade_status response and even nativeValue is wayoff from what I expected.

{'trade': {'amount': '150.2700000000000000',
  'errorCode': 0,
  'errorMessage': '',
  'fromSymbol': 'USDT',
  'id': 'd8e18bd7-60df-49a9-94f7-6d3b7eac457b',
  'status': 'started',
  'success': False,
  'toSymbol': 'ETH',
  'exchangeApiErrors': [],
  'maxSpreadPercent': '10',
  'maxSlippagePercent': '10',
  'smartRouting': True,
  'triggeredMaxSlippage': False,
  'triggeredMaxSpread': False},
 'changes': [{'symbol': 'ETH',
   'nativeValue': '0.01719',
   'btcValue': 0.0006986328338995042,
   'usdValue': 23.8248243},
  {'symbol': 'USDT',
   'nativeValue': '-23.8212144',
   'btcValue': -0.0006986328338995042,
   'usdValue': -23.8248243}],
 'fills': [{'side': 'BUY',
   'baseSymbol': 'ETH',
   'quoteSymbol': 'USDT',
   'baseAmount': '0.0086',
   'quoteAmount': '11.917536',
   'price': '1386.61',
   'usdValue': 11.919342,
   'btcValue': 0.00034951962603465593},
  {'side': 'BUY',
   'baseSymbol': 'ETH',
   'quoteSymbol': 'USDT',
   'baseAmount': '0.00859',
   'quoteAmount': '11.9036784',
   'price': '1386.61',
   'usdValue': 11.905482300000001,
   'btcValue': 0.00034911320786484823}]}

I would like to avoid hitting the balance endpoint after every trade to see what was the actual amount transfered from coin to coin. I am sure there is detail I missing. Looking forward to any help.

KobaKhit avatar Jan 29 '21 23:01 KobaKhit