hello_world.py 825 B

123456789101112131415161718192021222324252627282930
  1. from __future__ import annotations
  2. from src.trader_mcp.strategy_sdk import Strategy
  3. class Strategy(Strategy):
  4. LABEL = "Hello World"
  5. TICK_MINUTES = 0.2
  6. CONFIG_SCHEMA = {
  7. "label": {"type": "string", "default": "hello world"},
  8. }
  9. STATE_SCHEMA = {
  10. "counter": {"type": "int", "default": 0},
  11. }
  12. def init(self):
  13. # Tiny demo state, useful for persistence smoke tests.
  14. return {"counter": 0}
  15. def on_tick(self, tick):
  16. self.state["counter"] += 1
  17. return self.state["counter"]
  18. def render(self):
  19. return {
  20. "widgets": [
  21. {"type": "text", "label": "message", "value": self.config.get("label", "hello world")},
  22. {"type": "metric", "label": "ticks", "value": self.state["counter"]},
  23. ]
  24. }