I'm trying to understand what's the logic to implement when selling only the profit or all the position of a given order.
I have already implemented the BUY operation. So, let's say the user wants to buy 100$ worth of BTC at the current BTC price, I do as the follow:
$params =
[
'symbol' => 'BTCUSDT',
'side' => 'BUY',
'type' => 'MARKET',
'quoteOrderQty' => 100,
'timestamp' => $timestamp
];
$binance->buy($params);
https://binance-docs.github.io/apidocs/spot/en/#new-order-trade
I save both OrderId & clientOrderId response from Binance. A week later I'd like to sell the order position and to have the following available options:
- Sell only the profit of this order & (maybe) close
- Sell all my position (no matter if with profit or not) of this order & (maybe) close
Question: How can I accomplish both situations?