use FtPrecise to convert to contracts and back

This commit is contained in:
Matthias 2022-09-24 14:55:58 +02:00
parent 00b192b4df
commit 4efe2e9bc4

View File

@ -2891,7 +2891,7 @@ def amount_to_contracts(amount: float, contract_size: Optional[float]) -> float:
:return: num-contracts :return: num-contracts
""" """
if contract_size and contract_size != 1: if contract_size and contract_size != 1:
return amount / contract_size return float(FtPrecise(amount) / FtPrecise(contract_size))
else: else:
return amount return amount
@ -2905,7 +2905,7 @@ def contracts_to_amount(num_contracts: float, contract_size: Optional[float]) ->
""" """
if contract_size and contract_size != 1: if contract_size and contract_size != 1:
return num_contracts * contract_size return float(FtPrecise(num_contracts) * FtPrecise(contract_size))
else: else:
return num_contracts return num_contracts