base_add_calculation
This commit is contained in:
parent
68ac600361
commit
1a7de2f5a0
23
trader.py
23
trader.py
|
|
@ -308,6 +308,7 @@ class trader:
|
|||
|
||||
return 0
|
||||
|
||||
|
||||
def dca_cost_calculator(self, order_size: float, amount_of_so: int, scalar: float) -> float:
|
||||
'''
|
||||
Returns the maximum amount of currency that can be used by a trader, given the initial order size
|
||||
|
|
@ -323,6 +324,28 @@ class trader:
|
|||
return total
|
||||
|
||||
|
||||
def base_add_calculation(self, base_currency_amount: float, max_so: int = 100):
|
||||
'''
|
||||
Calculates how many safety orders you can add to the trader with a given amount of base currency.
|
||||
|
||||
:param base_currency_amount: float
|
||||
:return: int
|
||||
'''
|
||||
|
||||
if not self.config.get_is_short(): # Only works for short traders.
|
||||
return 0
|
||||
|
||||
safety_price_table = self.calculate_safety_prices(self.status.get_start_price(),max_so,self.config.get_safety_order_deviance())
|
||||
amount_accumulated = 0
|
||||
so_count = 0
|
||||
for i in range(self.status.get_so_amount()+1,max_so+1):
|
||||
amount_accumulated+= self.gib_so_size(self.status.get_start_price(),i,self.config.get_safety_order_scale())/safety_price_table[i]
|
||||
if amount_accumulated >= base_currency_amount:
|
||||
return so_count
|
||||
so_count+=1
|
||||
return so_count
|
||||
|
||||
|
||||
def return_optimal_order_size(self, amount: float, min_size: float, amount_of_safety_orders: int, scalar: float) -> float:
|
||||
'''
|
||||
Calculates the optimal order size for a short trader, according to the amount passed as a parameter.
|
||||
|
|
|
|||
Loading…
Reference in New Issue