Test checking maximum risk with market data
This commit is contained in:
@@ -23,10 +23,13 @@ def get_balance_hook(user_id, user_name, account_id, account_name, balance):
|
||||
def tp_price_to_percent(tp_price, current_price, current_units, unrealised_pl):
|
||||
# Is this right?
|
||||
pl_per_unit = D(unrealised_pl) / D(current_units)
|
||||
print("pl_per_unit: ", pl_per_unit)
|
||||
initial_price = D(current_price) - pl_per_unit
|
||||
print("initial_price: ", initial_price)
|
||||
|
||||
# Get the percent change of the TP price from the initial price.
|
||||
change_percent = ((D(tp_price) - initial_price) / initial_price) * 100
|
||||
print("change_percent: ", change_percent)
|
||||
|
||||
# Doesn't check direction
|
||||
return abs(round(change_percent, 5))
|
||||
@@ -35,10 +38,13 @@ def tp_price_to_percent(tp_price, current_price, current_units, unrealised_pl):
|
||||
def sl_price_to_percent(sl_price, current_price, current_units, unrealised_pl):
|
||||
# Is this right?
|
||||
pl_per_unit = D(unrealised_pl) / D(current_units)
|
||||
print("pl_per_unit: ", pl_per_unit)
|
||||
initial_price = D(current_price) - pl_per_unit
|
||||
print("initial_price: ", initial_price)
|
||||
|
||||
# Get the percent change of the SL price from the initial price.
|
||||
change_percent = ((D(sl_price) - initial_price) / initial_price) * 100
|
||||
print("change_percent: ", change_percent)
|
||||
|
||||
# Doesn't check direction
|
||||
return abs(round(change_percent, 5))
|
||||
|
||||
Reference in New Issue
Block a user