Created
September 26, 2022 18:12
-
-
Save under0tech/731b2eb6ca1c246605874b65818c3d6d 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
# Trade with STOP_LOSS and TAKE_PROFIT | |
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_BOT_NAME}: 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