Let's assume that I have buy_price, given I want to buy x quantity of that coin.
If the buy order is executed I want to execute a OCO order which would ensure to take profit on a certain price that would be greater than buy_price lets assume that as take_profit_price and sell if price drops below a stop loss price let's say that is stop_loss_price.
I am able to find OCO order that solve a part of the problem but I can't find any other order type that fits this scenario?
How can I accomplish this order in an automated way?
Assuming you use binance api and have your api key and client secret...
Basically,
place_buy_orderis creating the order for some cryptocurency which symbol is insymbolvariable, quantity is inquantityand price is inbuy_price. Then we calculate target price ad stop loss price. Then we also do an oco order and returing valuesbuy_orderandoco_order.And then comes the example with
BTCUSDTfor 40000 with 5% take profit and 3% loss price. After buying we print out orders and we are done.