added eventmetadata class

This commit is contained in:
Giulio De Pasquale 2020-12-15 16:15:44 +00:00
parent 2d7307a038
commit 672a55d229

View File

@ -16,6 +16,27 @@ def __add_to_dict_list__(dict: Dict[int, List], k, v):
dict[k].append(v)
class EventKind(Enum):
NEW_MINIMUM = 1,
NEW_MAXIMUM = 2,
REACHED_LOSS = 3,
REACHED_BREAK_EVEN = 4,
REACHED_MIN_PROFIT = 5,
REACHED_GOOD_PROFIT = 6,
REACHED_MAX_LOSS = 7,
CLOSE_POSITION = 8,
TRAILING_STOP_SET = 9,
TRAILING_STOP_MOVED = 10,
ORDER_SUBMITTED = 11,
NEW_TICK = 12
class EventMetadata:
def __init__(self, position_id: int = None, order_id: int = None):
self.position_id: int = position_id
self.order_id: int = order_id
class PositionState(Enum):
CRITICAL = -1,
LOSS = 0,
@ -32,21 +53,6 @@ class PositionState(Enum):
return "green"
class EventKind(Enum):
NEW_MINIMUM = 1,
NEW_MAXIMUM = 2,
REACHED_LOSS = 3,
REACHED_BREAK_EVEN = 4,
REACHED_MIN_PROFIT = 5,
REACHED_GOOD_PROFIT = 6,
REACHED_MAX_LOSS = 7,
CLOSE_POSITION = 8,
TRAILING_STOP_SET = 9,
TRAILING_STOP_MOVED = 10,
ORDER_SUBMITTED = 11,
NEW_TICK = 12
class Ticker:
def __init__(self, sec) -> None:
self.seconds: int = sec
@ -58,10 +64,10 @@ class Ticker:
class Event:
def __init__(self, kind: EventKind, tick: int, metadata: Dict = None) -> None:
def __init__(self, kind: EventKind, tick: int, metadata: EventMetadata = None) -> None:
self.kind: EventKind = kind
self.tick: int = tick
self.metadata = metadata
self.metadata: EventMetadata = metadata
def __repr__(self) -> str:
return f"{self.kind.name} @ Tick {self.tick}"