refactored positionwrapper. added on_new_tick for strategy. refactored names in symbolstatus
This commit is contained in:
parent
672a55d229
commit
15cad71afc
@ -79,18 +79,11 @@ class Event:
|
||||
class PositionWrapper:
|
||||
def __init__(self, position: Position):
|
||||
self.position: Position = position
|
||||
self.stop_percentage: float = None
|
||||
self.state: PositionState = PositionState.LOSS
|
||||
|
||||
def get_stop_percentage(self) -> float:
|
||||
return self.stop_percentage
|
||||
|
||||
def get_state(self) -> PositionState:
|
||||
return self.state
|
||||
|
||||
def set_stop_percentage(self, perc: float):
|
||||
self.stop_percentage = perc
|
||||
|
||||
def set_state(self, state: PositionState):
|
||||
if not isinstance(state, PositionState):
|
||||
return
|
||||
@ -128,13 +121,13 @@ class SymbolStatus:
|
||||
def all_ticks(self) -> List[int]:
|
||||
return [x for x in range(1, self.current_tick + 1)]
|
||||
|
||||
def last_events(self, n) -> List[Event]:
|
||||
return self.events[-n:]
|
||||
|
||||
def last_positions(self) -> List[PositionWrapper]:
|
||||
def current_positions(self) -> List[PositionWrapper]:
|
||||
return self.positions[self.current_tick]
|
||||
|
||||
def previous_position_w(self, pid: int) -> PositionWrapper:
|
||||
def current_price(self):
|
||||
return self.prices[self.current_tick]
|
||||
|
||||
def previous_pw(self, pid: int) -> PositionWrapper:
|
||||
if self.current_tick == 1:
|
||||
return None
|
||||
|
||||
@ -167,6 +160,13 @@ class SymbolStatus:
|
||||
|
||||
|
||||
class Strategy:
|
||||
"""
|
||||
Defines a list of events on a new tick
|
||||
"""
|
||||
|
||||
def on_new_tick(self, ss: SymbolStatus) -> List[Event]:
|
||||
pass
|
||||
|
||||
"""
|
||||
Defines new position state and events after tick.
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user