2
0
forked from kodorvan/stcs

Fixed the budget calculation function

This commit is contained in:
algizn97
2025-10-10 14:14:46 +05:00
parent 42c4660fe3
commit fc8ab19ae9
4 changed files with 11 additions and 29 deletions

View File

@@ -158,7 +158,7 @@ async def get_liquidation_price(
async def calculate_total_budget(
quantity, martingale_factor, max_steps, commission_fee_percent
quantity, martingale_factor, max_steps
) -> float:
"""
Calculate the total budget for a series of trading steps.
@@ -167,7 +167,6 @@ async def calculate_total_budget(
quantity (float): The initial quantity of the asset.
martingale_factor (float): The factor by which the quantity is multiplied for each step.
max_steps (int): The maximum number of trading steps.
commission_fee_percent (float): The commission fee percentage.
Returns:
float: The total budget for the series of trading steps.
@@ -175,12 +174,8 @@ async def calculate_total_budget(
total = 0
for step in range(max_steps):
set_quantity = quantity * (martingale_factor**step)
if commission_fee_percent == 0:
# Commission fee is not added to the position size
r_quantity = set_quantity
else:
# Commission fee is added to the position size
r_quantity = set_quantity * (1 + 2 * commission_fee_percent)
r_quantity = set_quantity
total += r_quantity
return total