Skip to content

Commit 6dc4e76

Browse files
committed
Initial commit for OrderingState
1 parent 6d0a7fc commit 6dc4e76

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
from typing import List
2+
3+
from investing_bot_framework.core.states import BotState
4+
from investing_bot_framework.core.exceptions import OperationalException
5+
from investing_bot_framework.core.order_executors import OrderExecutor
6+
7+
8+
class OrderingState(BotState):
9+
10+
from investing_bot_framework.core.states.templates.data_providing_state import DataProvidingState
11+
transition_state_class = DataProvidingState
12+
13+
order_executors: List[OrderExecutor] = None
14+
15+
def __init__(self, context) -> None:
16+
super(OrderingState, self).__init__(context)
17+
18+
if self.order_executors is None or len(self.order_executors) < 1:
19+
raise OperationalException("OrderingState state has not any order executors configured")
20+
21+
def run(self) -> None:
22+
23+
for order_executor in OrderingState.order_executors:
24+
order_executor.execute_orders()
25+
26+
@staticmethod
27+
def register_order_executors(order_executors: List[OrderExecutor]) -> None:
28+
OrderingState.order_executors = order_executors
29+
30+

0 commit comments

Comments
 (0)