This InfluxDB 3 plugin is specifically designed to generate OHLCV (Open, High, Low, Close, Volume) candles from InfluxProchainDataPoint data structures. It automatically processes all supported timeframes (30s, 60s, 120s, 300s, 600s, 900s) in a single trigger, eliminating the need for multiple plugin instances. It can be used for both scheduled batch processing and on-demand HTTP requests.
influxdb3/candle_generator/
├── candle_generator.py # Main plugin implementation
├── candle_config_scheduler.toml # TOML configuration template
├── README.md # Comprehensive documentation
├── setup_example.sh # Setup script with examples
├── test_plugin.py # Test script for validation
└── PLUGIN_SUMMARY.md # This overview file
The plugin reads from measurements containing data with this structure:
pub struct InfluxProchainDataPoint {
pub time: DateTime<Utc>,
pub price: f64,
pub quote_volume: f64,
pub base_volume: f64,
pub key: String, // tag
pub object_type: String, // tag
pub mint: String, // tag
pub is_buy: bool, // tag
pub payer: String, // tag
pub trx: String, // tag
pub platform: String, // tag
}- Data Source: Reads from the specified source measurement/table (default:
raw_trades) - Automatic Window Calculation: Uses a 1-hour data window (automatically calculated based on 30-second trigger interval)
- Multi-Timeframe Processing: Automatically processes all supported timeframes in a single execution
- Data Aggregation: Groups data points by each timeframe (30s, 60s, 120s, 300s, 600s, 900s) from the source table
- OHLCV Calculation:
- Open: First price in the timeframe
- High: Highest price in the timeframe
- Low: Lowest price in the timeframe
- Close: Last price in the timeframe
- Volume: Sum of quote_volume in the timeframe
- Essential Tag Preservation: Preserves only essential tags (mint, platform, timeframe)
- Single Measurement: All candles are written to a single measurement with timeframe as a tag
- Output: Writes candles to a single measurement with timeframe differentiation via tags
Each candle contains:
- Fields:
open,high,low,close,volume - Tags: Essential tags only (
mint,platform,timeframe) - Measurement: All candles are saved to a single measurement (e.g.,
candles) with timeframe as a tag
- 30s: 30-second candles
- 60s: 1-minute candles
- 120s: 2-minute candles
- 300s: 5-minute candles
- 600s: 10-minute candles
- 900s: 15-minute candles
Automatically generates candles for all timeframes on configurable intervals:
# Generate all timeframes (30s, 60s, 120s, 300s, 600s, 900s) every 30 seconds
influxdb3 create trigger \
--database prochain_db \
--plugin-filename candle_generator.py \
--trigger-spec "every:30s" \
--trigger-arguments 'target_measurement=candles,target_database=candles_db,source_measurement=raw_trades' \
prochain_candles_all_timeframesOn-demand candle generation via HTTP API (supports single or all timeframes):
# Create HTTP trigger for all timeframes
influxdb3 create trigger \
--database prochain_db \
--plugin-filename candle_generator.py \
--trigger-spec "http" \
--trigger-arguments 'target_measurement=candles,target_database=candles_db,source_measurement=raw_trades' \
prochain_candles_http
# Or specify a single timeframe for HTTP requests
influxdb3 create trigger \
--database prochain_db \
--plugin-filename candle_generator.py \
--trigger-spec "http" \
--trigger-arguments 'target_measurement=candles,timeframe=30s,target_database=candles_db,source_measurement=raw_trades' \
prochain_candles_http_single- Single Trigger, All Timeframes: One plugin instance processes all 6 timeframes (30s, 60s, 120s, 300s, 600s, 900s)
- Efficient Resource Usage: Eliminates the need for 6 separate plugin instances
- Consistent Data: All timeframes are processed from the same data window, ensuring consistency
- Flexible HTTP Mode: HTTP requests can target all timeframes or specify a single timeframe
- Smart Window Sizing: Automatically uses a 1-hour data window based on the 30-second trigger interval
- Simplified Configuration: No need to specify window size - it's automatically optimized
- Optimal Coverage: 1-hour window ensures sufficient data for all timeframes (up to 15-minute candles)
- Consistent Processing: Every execution processes the same amount of historical data
- Unified Storage: All candles are stored in a single measurement regardless of timeframe
- Timeframe Tagging: Each candle includes a
timeframetag (30s, 60s, 120s, 300s, 600s, 900s) - Simplified Queries: Easy to query all timeframes or filter by specific timeframe
- Efficient Storage: Reduces measurement proliferation and simplifies data management
- TOML configuration file support
- Command-line argument support
- Environment variable support
- Configurable retry logic
- Detailed logging with task IDs
- Graceful error recovery
- Efficient SQL queries for aggregation using time_bucket functions
- Batch processing capabilities
- Memory-conscious data handling
- Mint address filtering
- Time range filtering
- Tag-based filtering
Raw InfluxProchainDataPoint Data:
┌─────────────────┬─────────┬─────────────┬─────────┬─────────┬─────────┐
│ time │ price │ quote_vol │ mint │ is_buy │ platform│
├─────────────────┼─────────┼─────────────┼─────────┼─────────┼─────────┤
│ 12:00:00 │ 100.0 │ 1000.0 │ TOKEN1 │ true │ pumpfun │
│ 12:00:15 │ 101.0 │ 1500.0 │ TOKEN1 │ false │ pumpfun │
│ 12:00:25 │ 99.5 │ 800.0 │ TOKEN1 │ true │ pumpfun │
│ 12:00:45 │ 102.0 │ 2000.0 │ TOKEN1 │ true │ pumpfun │
└─────────────────┴─────────┴─────────────┴─────────┴─────────┴─────────┘
Generated 30s Candle (saved to `candles` measurement with timeframe tag):
┌─────────────────┬──────┬──────┬──────┬───────┬─────────┬─────────┬───────────┐
│ time │ open │ high │ low │ close │ volume │ mint │ timeframe │
├─────────────────┼──────┼──────┼──────┼───────┼─────────┼─────────┼───────────┤
│ 12:00:00 │ 100.0│ 101.0│ 99.5 │ 99.5 │ 3300.0 │ TOKEN1 │ 30s │
└─────────────────┴──────┴──────┴──────┴───────┴─────────┴─────────┴───────────┘
- InfluxDB 3 with Processing Engine enabled
- Python 3.8+ (for plugin execution)
influxdb_client_3package
- Copy plugin files to your plugin directory
- Start InfluxDB 3 with
--plugin-dirflag - Create database and measurements
- Set up triggers using provided scripts
- Monitor candle generation
- Check plugin logs for execution status
- Query generated candles for validation
- Monitor performance metrics
The plugin can be customized for different data structures by modifying:
build_candle_query()function for different field nameswrite_candle_data()function for different output formatsparse_timeframe()function for additional timeframes
Common issues and solutions:
- No candles generated: Check source data exists and timeframes match
- Memory issues: Reduce window size or increase processing intervals
- Permission errors: Verify database and measurement permissions
- Invalid timeframes: Ensure timeframe is one of supported values
- Window Size: Balance between data coverage and memory usage
- Timeframe: Shorter timeframes = more candles = more processing
- Filtering: Use mint filters to reduce data volume
- Scheduling: Adjust trigger frequencies based on data volume
This plugin provides a complete solution for generating trading candles from Prochain data, enabling real-time and historical analysis of market movements.