-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathplugin.py
More file actions
31 lines (26 loc) · 1.03 KB
/
Copy pathplugin.py
File metadata and controls
31 lines (26 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from __future__ import annotations
from dataclasses import dataclass
from zero_engine import MarketDataAdapter, Side, StrategyPluginMetadata, StrategySignal
from zero_engine.strategy import candle_move_pct
@dataclass(frozen=True)
class CloseStrengthPlugin:
metadata: StrategyPluginMetadata = StrategyPluginMetadata(
name="close-strength",
version="0.1.0",
description="Paper-only example plugin that buys when the latest candle closes strongly.",
)
min_move_pct: float = 0.01
quantity: float = 0.01
confidence: float = 0.8
def propose(self, market: MarketDataAdapter, symbol: str) -> StrategySignal | None:
latest = market.latest(symbol)
move_pct = candle_move_pct(latest)
if move_pct < self.min_move_pct:
return None
return StrategySignal(
symbol=latest.symbol,
side=Side.BUY,
confidence=self.confidence,
quantity=self.quantity,
reason=f"{self.metadata.name}: close moved {move_pct:.2%}",
)