Files
2026-08-07 16:08:34 +08:00

21 lines
565 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""策略抽象基类。策略只产生买卖意图(向 broker 下单),不负责撮合/费用。"""
from __future__ import annotations
from abc import ABC, abstractmethod
import pandas as pd
from ..broker import PaperBroker
class Strategy(ABC):
"""compute 预算指标on_bar 逐 bar 决策并向 broker 下单。"""
@abstractmethod
def compute(self, close: pd.Series, high: pd.Series, low: pd.Series) -> pd.DataFrame:
...
@abstractmethod
def on_bar(self, i: int, row: pd.Series, broker: PaperBroker) -> None:
...