| 123456789101112131415161718192021222324252627282930 |
- from __future__ import annotations
- from src.trader_mcp.strategy_sdk import Strategy
- class Strategy(Strategy):
- LABEL = "Hello World"
- TICK_MINUTES = 0.2
- CONFIG_SCHEMA = {
- "label": {"type": "string", "default": "hello world"},
- }
- STATE_SCHEMA = {
- "counter": {"type": "int", "default": 0},
- }
- def init(self):
- # Tiny demo state, useful for persistence smoke tests.
- return {"counter": 0}
- def on_tick(self, tick):
- self.state["counter"] += 1
- return self.state["counter"]
- def render(self):
- return {
- "widgets": [
- {"type": "text", "label": "message", "value": self.config.get("label", "hello world")},
- {"type": "metric", "label": "ticks", "value": self.state["counter"]},
- ]
- }
|