예제 #1
0
    def __init__(
        self,
        name: str,
        type: StrategyType,
        batch_id: str,
        schedule: List[Dict],
        ref_run_id: int = None,
        data_loader: DataLoader = None,
    ):
        """Strategy default initialization, should be called by all Strategy objects.

        Keyword arguments:
        name: Strategy name, used in the `tradeplan.toml` file,
        type: Strategy type (= day-trade / swing),
        batch_id: generated by the platform, used to group executions,
        schedule: execution time, a defined in the .toml file, note it's mandatory to include,
                  may have more than one execution window. Execution winodows are not enforced
                  by the platform.
        ref_run_id : Used for back-testing,
        data_loader: Passed by the framework, used like a DataFrame to access symbol data.
        """

        self.name = name
        self.batch_id = batch_id
        self.type = type
        self.ref_run_id = ref_run_id
        self.algo_run = AlgoRun(strategy_name=self.name, batch_id=batch_id)
        self.schedule = schedule
        self.data_loader = data_loader
        self.global_var: Dict = {}
예제 #2
0
 def __init__(
     self,
     name: str,
     type: StrategyType,
     batch_id: str,
     schedule: List[Dict],
     ref_run_id: int = None,
 ):
     self.name = name
     self.type = type
     self.ref_run_id = ref_run_id
     self.algo_run = AlgoRun(strategy_name=self.name, batch_id=batch_id)
     self.schedule = schedule
예제 #3
0
 async def create_session(self, algo_name: str) -> AlgoRun:
     new_batch_id = str(uuid.uuid4())
     algo_run = AlgoRun(algo_name, new_batch_id)
     await algo_run.save()
     return algo_run