1. Architecture and Data Model
In Whaleer, saveable strategies are written as classes that inherit from Strategy. The usual flow is to prepare parameters inside initialize() and run trading logic inside on_candle(candle, df).
The current strategy model commonly uses:
• self.input.* for editable settings
• self.buy(...), self.sell(...), and self.close_position(...) for order logic
• self.get_position(), self.get_state(), and self.set_state() for tracking state
• self.plot(...) and self.mark(...) for visual output
Notes:
• df is still useful for reading candle history and calculating indicators.
• self.mark(...) places a single marker on the active candle, while self.plot(...) is used for visualizing a value series or line.
• These visual calls are mainly meaningful during backtests and chart review; in live execution they may quietly do nothing visible.
• Current EMA, grid, and mean reversion examples use event-driven order calls.
• The default editor template and the files under examples/ follow the same up-to-date structure.
Decimal → float Conversion
Example for converting numeric columns to float64:
for col in ['open', 'high', 'low', 'close', 'volume']:
if col in df.columns:
df[col] = df[col].astype(float)
Core Building Blocks
Base class: Strategy.
Main methods: initialize() and on_candle(candle, df).
Common calls: self.buy, self.sell, self.close_position, self.get_position, self.get_state, self.set_state, self.plot, self.mark.
