# calculate_sizes_for_leverage#

API documentation for tradeexecutor.state.loan.calculate_sizes_for_leverage Python function.

calculate_sizes_for_leverage(starting_reserve, leverage)[source]#

Calculate the collateral and borrow loan size to hit the target leverage with a starting capital.

• When calculating the loan size using this function, the loan net asset value will be the same as starting capital

• Because loan net asset value is same is deposited reserve, portfolio total NAV stays intact

Notes:

```col / (col - borrow) = leverage
col = (col - borrow) * leverage
col = col * leverage - borrow * leverage
col - col * leverage = - borrow * levereage
col(1 - leverage) = - borrow * leverage
col = -(borrow * leverage) / (1 - leverage)

# Calculate leverage for 4x and 1000 USD collateral
col - borrow = 1000
col = 1000
leverage = 3

col / (col - borrow) = 3
3(col - borrow) = col
3borrow = 3col - col
borrow = col - col/3

col / (col - (col - borrow)) = leverage
col / borrow = leverage
borrow = leverage * 1000
```
Parameters:
• starting_reserve (float) – Initial deposit in lending protocol

• leverage (float) –

Returns:

Tuple (borrow value, collateral value) in dollars

Return type: