Last active
August 26, 2021 01:08
-
-
Save ugik/a1dfe2130e93c4d4df905d2878cd1be6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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