passed mypy
This commit is contained in:
parent
8f5150e831
commit
e1fca320e6
@ -12,6 +12,7 @@ class InterestMode(Enum):
|
|||||||
|
|
||||||
HOURSPERDAY = "HOURSPERDAY"
|
HOURSPERDAY = "HOURSPERDAY"
|
||||||
HOURSPER4 = "HOURSPER4" # Hours per 4 hour segment
|
HOURSPER4 = "HOURSPER4" # Hours per 4 hour segment
|
||||||
|
NONE = "NONE"
|
||||||
|
|
||||||
def __call__(self, *args, **kwargs):
|
def __call__(self, *args, **kwargs):
|
||||||
|
|
||||||
|
@ -269,7 +269,7 @@ class LocalTrade():
|
|||||||
liquidation_price: Optional[float] = None
|
liquidation_price: Optional[float] = None
|
||||||
is_short: bool = False
|
is_short: bool = False
|
||||||
leverage: float = 1.0
|
leverage: float = 1.0
|
||||||
interest_mode: Optional[InterestMode] = None
|
interest_mode: InterestMode = InterestMode.NONE
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def has_no_leverage(self) -> bool:
|
def has_no_leverage(self) -> bool:
|
||||||
@ -301,7 +301,8 @@ class LocalTrade():
|
|||||||
def set_stop_loss_helper(self, stop_loss: Optional[float], liquidation_price: Optional[float]):
|
def set_stop_loss_helper(self, stop_loss: Optional[float], liquidation_price: Optional[float]):
|
||||||
# Stoploss would be better as a computed variable,
|
# Stoploss would be better as a computed variable,
|
||||||
# but that messes up the database so it might not be possible
|
# but that messes up the database so it might not be possible
|
||||||
# TODO-mg: What should be done about initial_stop_loss
|
|
||||||
|
assert stop_loss or liquidation_price # programming error check
|
||||||
if liquidation_price is not None:
|
if liquidation_price is not None:
|
||||||
if stop_loss is not None:
|
if stop_loss is not None:
|
||||||
if self.is_short:
|
if self.is_short:
|
||||||
@ -313,9 +314,10 @@ class LocalTrade():
|
|||||||
self.initial_stop_loss = liquidation_price
|
self.initial_stop_loss = liquidation_price
|
||||||
self.liquidation_price = liquidation_price
|
self.liquidation_price = liquidation_price
|
||||||
else:
|
else:
|
||||||
if not self.stop_loss:
|
if stop_loss: # Will always be true, here for mypy
|
||||||
self.initial_stop_loss = stop_loss
|
if not self.stop_loss:
|
||||||
self.stop_loss = stop_loss
|
self.initial_stop_loss = stop_loss
|
||||||
|
self.stop_loss = stop_loss
|
||||||
|
|
||||||
def set_stop_loss(self, stop_loss: float):
|
def set_stop_loss(self, stop_loss: float):
|
||||||
self.set_stop_loss_helper(stop_loss=stop_loss, liquidation_price=self.liquidation_price)
|
self.set_stop_loss_helper(stop_loss=stop_loss, liquidation_price=self.liquidation_price)
|
||||||
@ -711,7 +713,7 @@ class LocalTrade():
|
|||||||
return 0.0
|
return 0.0
|
||||||
else:
|
else:
|
||||||
if self.has_no_leverage:
|
if self.has_no_leverage:
|
||||||
# TODO: Use one profit_ratio calculation
|
# TODO-mg: Use one profit_ratio calculation
|
||||||
profit_ratio = (close_trade_value/self.open_trade_value) - 1
|
profit_ratio = (close_trade_value/self.open_trade_value) - 1
|
||||||
else:
|
else:
|
||||||
if self.is_short:
|
if self.is_short:
|
||||||
|
Loading…
Reference in New Issue
Block a user