Skip to content

Instantly share code, notes, and snippets.

@dkav6
Last active November 6, 2021 10:55
Show Gist options
  • Save dkav6/0ebd2a0af4ba0f2d9d810d1be4be469a to your computer and use it in GitHub Desktop.
Save dkav6/0ebd2a0af4ba0f2d9d810d1be4be469a to your computer and use it in GitHub Desktop.
def run(request):
alert = request.get_json()
# # If alert request is a buy, we buy
symbol = alert['ticker']
pair = symbol + "-USD"
side = alert['side']
usd_price = client.fetch_ticker(pair)['last']
position = client.fetch_balance()[symbol]['free']
size = usd_price * position
if side == 'buy' and size < 1:
buy_max(pair)
elif side == 'sell' and size > 1:
sell_max(pair)
else:
return f"alert {alert} was received but no orders were made"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment