-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
111 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from abc import abstractmethod | ||
|
||
from core.abstract_event_manager import AbstractEventManager | ||
from core.events.ohlcv import OHLCV | ||
|
||
|
||
class AbsctractActor(AbstractEventManager): | ||
@property | ||
@abstractmethod | ||
def id(self) -> str: | ||
pass | ||
|
||
@abstractmethod | ||
def start(self): | ||
pass | ||
|
||
@abstractmethod | ||
def stop(self): | ||
pass | ||
|
||
@abstractmethod | ||
def next(self, data: OHLCV): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from abc import abstractmethod | ||
|
||
from .abstract_actor import AbsctractActor | ||
|
||
|
||
class AbsctractStrategyActorFactory: | ||
@abstractmethod | ||
def create_actor(self, wasm_path: str, strategy: str, paremeters: tuple[int]) -> AbsctractActor: | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from wasmtime import Store, Linker, WasiConfig, Module | ||
|
||
from .abstract_strategy_factory import AbsctractStrategyActorFactory | ||
from .strategy_actor import StrategyActor | ||
|
||
|
||
class StrategyActorFactory(AbsctractStrategyActorFactory): | ||
def __init__(self): | ||
self.store = Store() | ||
self.linker = Linker(self.store.engine) | ||
wasi_config = WasiConfig() | ||
wasi_config.wasm_multi_value = True | ||
self.store.set_wasi(wasi_config) | ||
self.linker.define_wasi() | ||
|
||
def create_actor(self, wasm_path, strategy, parameters): | ||
module = Module.from_file(self.store.engine, wasm_path) | ||
|
||
return StrategyActor(strategy, parameters, self.linker, self.store, module) |