Further typing ...
This commit is contained in:
@@ -1,19 +1,22 @@
|
||||
from datetime import datetime
|
||||
from typing import Optional, TypedDict, Union
|
||||
from typing import List, Literal, Optional, TypedDict, Union
|
||||
|
||||
from freqtrade.enums import RPCMessageType
|
||||
|
||||
|
||||
class RPCSendMsgBase(TypedDict):
|
||||
type: RPCMessageType
|
||||
pass
|
||||
# ty1pe: Literal[RPCMessageType]
|
||||
|
||||
|
||||
class RPCStatusMsg(RPCSendMsgBase):
|
||||
"""Used for Status, Startup and Warning messages"""
|
||||
type: Literal[RPCMessageType.STATUS]
|
||||
status: str
|
||||
|
||||
|
||||
class RPCProtectionMsg(RPCSendMsgBase):
|
||||
type: Literal[RPCMessageType.PROTECTION_TRIGGER, RPCMessageType.PROTECTION_TRIGGER_GLOBAL]
|
||||
id: int
|
||||
pair: str
|
||||
base_currency: Optional[str]
|
||||
@@ -26,7 +29,13 @@ class RPCProtectionMsg(RPCSendMsgBase):
|
||||
active: bool
|
||||
|
||||
|
||||
class RPCWhitelistMsg(RPCSendMsgBase):
|
||||
type: Literal[RPCMessageType.WHITELIST]
|
||||
data: List[str]
|
||||
|
||||
|
||||
class RPCBuyMsg(RPCSendMsgBase):
|
||||
type: Literal[RPCMessageType.ENTRY, RPCMessageType.ENTRY_FILL]
|
||||
trade_id: int
|
||||
buy_tag: Optional[str]
|
||||
enter_tag: Optional[str]
|
||||
@@ -47,10 +56,12 @@ class RPCBuyMsg(RPCSendMsgBase):
|
||||
|
||||
|
||||
class RPCCancelMsg(RPCBuyMsg):
|
||||
type: Literal[RPCMessageType.ENTRY_CANCEL]
|
||||
reason: str
|
||||
|
||||
|
||||
class RPCSellMsg(RPCBuyMsg):
|
||||
type: Literal[RPCMessageType.EXIT, RPCMessageType.EXIT_FILL]
|
||||
cumulative_profit: float
|
||||
gain: str # Literal["profit", "loss"]
|
||||
close_rate: float
|
||||
@@ -64,6 +75,7 @@ class RPCSellMsg(RPCBuyMsg):
|
||||
|
||||
|
||||
class RPCSellCancelMsg(RPCBuyMsg):
|
||||
type: Literal[RPCMessageType.EXIT_CANCEL]
|
||||
reason: str
|
||||
gain: str # Literal["profit", "loss"]
|
||||
profit_amount: float
|
||||
@@ -76,6 +88,7 @@ class RPCSellCancelMsg(RPCBuyMsg):
|
||||
RPCSendMsg = Union[
|
||||
RPCStatusMsg,
|
||||
RPCProtectionMsg,
|
||||
RPCWhitelistMsg,
|
||||
RPCBuyMsg,
|
||||
RPCCancelMsg,
|
||||
RPCSellMsg,
|
||||
|
Reference in New Issue
Block a user