Last active
November 6, 2021 10:55
-
-
Save dkav6/0ebd2a0af4ba0f2d9d810d1be4be469a to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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