Skip to content

Instantly share code, notes, and snippets.

@andrewkim316
Last active September 4, 2019 22:12
Show Gist options
  • Save andrewkim316/6636c9bde8ce6642c8fa931e5f360219 to your computer and use it in GitHub Desktop.
Save andrewkim316/6636c9bde8ce6642c8fa931e5f360219 to your computer and use it in GitHub Desktop.
# 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