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:
|
class PositionWrapper:
|
||||||
def __init__(self, position: Position):
|
def __init__(self, position: Position):
|
||||||
self.position: Position = position
|
self.position: Position = position
|
||||||
self.stop_percentage: float = None
|
|
||||||
self.state: PositionState = PositionState.LOSS
|
self.state: PositionState = PositionState.LOSS
|
||||||
|
|
||||||
def get_stop_percentage(self) -> float:
|
|
||||||
return self.stop_percentage
|
|
||||||
|
|
||||||
def get_state(self) -> PositionState:
|
def get_state(self) -> PositionState:
|
||||||
return self.state
|
return self.state
|
||||||
|
|
||||||
def set_stop_percentage(self, perc: float):
|
|
||||||
self.stop_percentage = perc
|
|
||||||
|
|
||||||
def set_state(self, state: PositionState):
|
def set_state(self, state: PositionState):
|
||||||
if not isinstance(state, PositionState):
|
if not isinstance(state, PositionState):
|
||||||
return
|
return
|
||||||
@ -128,13 +121,13 @@ class SymbolStatus:
|
|||||||
def all_ticks(self) -> List[int]:
|
def all_ticks(self) -> List[int]:
|
||||||
return [x for x in range(1, self.current_tick + 1)]
|
return [x for x in range(1, self.current_tick + 1)]
|
||||||
|
|
||||||
def last_events(self, n) -> List[Event]:
|
def current_positions(self) -> List[PositionWrapper]:
|
||||||
return self.events[-n:]
|
|
||||||
|
|
||||||
def last_positions(self) -> List[PositionWrapper]:
|
|
||||||
return self.positions[self.current_tick]
|
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:
|
if self.current_tick == 1:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@ -167,6 +160,13 @@ class SymbolStatus:
|
|||||||
|
|
||||||
|
|
||||||
class Strategy:
|
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.
|
Defines new position state and events after tick.
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user