Ethereum: How to Adjust Open Position Size via Binance API Without Closing Position (Using Python)?
Februari 7, 2025 | by Gusri Efendi

Adjusting Open Position Size via Binance API without Closing Position
As a Python developer working with Binance API, you’re likely familiar with the concept of managing open positions in your trading bots. In this article, we’ll explore how to adjust the size of an open position using the Binance API without closing the position.
Understanding Position Sizes
Before diving into adjusting position sizes, let’s understand how they work:
- A
Position Size refers to the amount of cryptocurrency (e.g., Ether or Bitcoin) you’re willing to risk on a trade.
- The
Trade Size is the actual amount of cryptocurrency being exchanged in the trade.
- The
Position Size per Trade Size Ratio determines the proportion of the trade size that goes towards the position size.
For example, if your initial position size is 100 ETH and the trade size ratio is 1:10, you’ll risk 10 ETH on each trade, with a total trade size of 100 ETH.
Adjusting Open Position Size via Binance API
To adjust the open position size without closing it, we can use the positions.update()
method to modify the existing position. Here’s an example Python code snippet that demonstrates how to do this:
import binance

Initialize the Binance API client
api = binance.client.create_api()
Replace with your API credentials and secret key
client_id = "YOUR_CLIENT_ID"
client_secret = "YOUR_CLIENT_SECRET"
Set the position size as a float between 0 and 100
position_size = 20.0
Get the current open positions
open_positions = api.get_open_positions()
Iterate through each open position
for position in open_positions:
Check if the position is active (i.e., not closed)
if position.status == "ACTIVE":
Update the position size using the Binance API
client_id = "YOUR_CLIENT_ID"
client_secret = "YOUR_CLIENT_SECRET"
apipositions.update(position.id, {"position_size": round(position_size * 100)})
Print a success message to confirm the updated positions
print("Open Positions Updated Successfully!")
In this code snippet:
- We initialize the Binance API client using your credentials and secret key.
- We set the initial position size as a float between 0 and 100.
- We get the current open positions using the
get_open_positions()
method.
- We iterate through each open position, checking if it’s active (i.e., not closed).
- If an active position is found, we update its position size by calling the
update()
method with a new value of the specifiedposition_size
parameter.
Tips and Variations
- To avoid closing positions without updating their sizes, make sure to check for active positions before making changes.
- You can also use the
positions.update()
method with additional parameters, such aslimit_price
,stop_loss_price
, ortake_profit_price
, depending on your trading strategy.
- Keep in mind that you should only update an open position if it’s still active and not closed. If a position is closed, there will be no effect from updating its size.
By following this article and adapting the code snippet to your specific requirements, you’ll be able to efficiently adjust open position sizes via Binance API without closing positions. Happy trading!
RELATED POSTS
View all