Skip to content

Instantly share code, notes, and snippets.

@under0tech
Created May 6, 2023 08:24
Show Gist options
  • Save under0tech/68879f0ee01b9c1c70b08ca5beaac437 to your computer and use it in GitHub Desktop.
Save under0tech/68879f0ee01b9c1c70b08ca5beaac437 to your computer and use it in GitHub Desktop.
# TRADING
def trade(api, stock, operation, shares_to_trade, take_profit, stop_loss):
api.submit_order(symbol = stock, qty = shares_to_trade, side = operation, type = 'market',
order_class = 'bracket', time_in_force = 'day',
take_profit = {'limit_price': take_profit},
stop_loss = {'stop_price': stop_loss})
message = f'\n\t*{stock}*, qty _{shares_to_trade}_ \n\t\twere {operation}'
send_message(f'{TRADER_ID}: we entered the market with:' + message)
return True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment