Last active
September 4, 2019 22:12
-
-
Save andrewkim316/6636c9bde8ce6642c8fa931e5f360219 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
# Stream listeners | |
@conn.on(r'trade_updates') | |
async def trade_updates_handler(conn, chan, data): | |
if data.event == "new": | |
return "" | |
elif data.event == "fill" or data.event == "partial_fill": | |
text = f'*Event*: {data.event}, {data.order["type"]} order of | {data.order["side"]} {data.order["qty"]} {data.order["symbol"]} {data.order["time_in_force"]} | {data.event} at {data.price}' | |
else: | |
text = f'*Event*: {data.event}, {data.order["type"]} order of | {data.order["side"]} {data.order["qty"]} {data.order["symbol"]} {data.order["time_in_force"]} {data.event}' | |
response = requests.post(url="https://slack.com/api/chat.postMessage", data={ | |
"token": config["slack_token"], | |
"channel": config["channel"], | |
"text": text | |
}) | |
return "" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment