From 672a55d22997bb2af42ad3458cac6fdf77027065 Mon Sep 17 00:00:00 2001 From: Giulio De Pasquale Date: Tue, 15 Dec 2020 16:15:44 +0000 Subject: [PATCH] added eventmetadata class --- bfxbot/models.py | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/bfxbot/models.py b/bfxbot/models.py index c74d410..5ee0e12 100644 --- a/bfxbot/models.py +++ b/bfxbot/models.py @@ -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}"