# Question about Position Sizing, Leverage and Risk Managment

Hi everyone,

I am backtesting strategies and interested in algorithmic trading. In my strategies, I mostly use 1:2 Risk Ratio. Risk; %2 of my capital. So, if I have 1000\$, that means every winning trade will be 40\$ (4%) and every losing trade will be 20\$ (2%). But, imagine that an entry position comes with a stop loss of -0.23% and take profit at +0.46%. If I want a flat -%2+%4, I need leverage. I can calculate how much leverage I need with this standard formula;

40\$ (%2 Risk) / ,23 (Stoploss) : 1.739 (the leverage level that should be taken)
1.739 x 1000 \$: 1739 \$ (the size I should enter to this position in order to reach my target)

I wanted to ask; is there any possibility of adapting the leverage in every trade individually with a script? I imagine something that always calculates the last capital and calculates my -%2+%4 target for the new entry position. And of course, since I want my trades to be automated, is it possible to execute trades with my wishing formula?

Hi.
Though some of the points in this strategy are not clear for me, let me assume that the stop loss/ take profit orders you are referring to are both market orders (stop loss market order and take profit market order). That is, in this example, if the price turns to 0.23% lower than the entry price, a stop loss order is placed into the order book and gets filled with market price. So the final gain/ loss may be slightly different from the expectation.

It is possible to utilise the API service to adjust the leverage level; however, there are some challenges when applying to the aforementioned strategy. First, the leverage is set up per symbol instead of trade. Second, the leverage level is restricted to be integer value.
Ref. `POST /fapi/v1/leverage` https://binance-docs.github.io/apidocs/futures/en/#change-initial-leverage-trade

`Symbol` is one of the mandatory parameter in the request payload. It represent which kind of the trading pair to apply the leverage level. In addition, this endpoint cannot specify which order or trade to have what leverage level. This means if there are multiple open orders under the same symbol, for instance, BTCUSDT. It’s not allowed to have 1 order with leverage level = 10 and another one with leverage level = 20.