Skip to content

Instantly share code, notes, and snippets.

@ugik
Last active August 26, 2021 01:08
Show Gist options
  • Save ugik/a1dfe2130e93c4d4df905d2878cd1be6 to your computer and use it in GitHub Desktop.
Save ugik/a1dfe2130e93c4d4df905d2878cd1be6 to your computer and use it in GitHub Desktop.
def getBuyingDataETH(side, usd=None, eth=None):
book = CMclient.get_full_book('ETHUSD')
topBid = float(list(book['book']['bid'].items())[0][0])
topAsk = float(list(book['book']['ask'].items())[0][0])
spread = topAsk-topBid
print('bid', topBid, 'ask', topAsk, 'spread', spread, '%', spread/topAsk*100)
if side=='SELL':
sellingQty = eth
buyingQty = eth*topAsk
print('buyingQty (USD)', buyingQty, 'sellingQty (ETH)', sellingQty)
else:
buyingQty = usd/topBid
sellingQty = usd
print('buyingQty (ETH)', buyingQty, 'sellingQty (USD)', sellingQty)
return buyingQty, sellingQty
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment