cyberhybridhub/server/lib/trading/market_history_config.dart
2026-05-31 13:11:09 -05:00

35 lines
1.4 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/// Defaults for RTH session-half market history ([MarketHistorySessionSlot]).
/// Env overrides via [MarketHistoryEnv] in [ServerEnv.load].
abstract final class MarketHistoryConfig {
/// Rolling window length in US trading days (MonFri; holidays skipped).
static const int windowDays = 5;
/// Stored bar timeframe (two aggregates per US trading day).
static const String barTimeframe = 'sessionHalf';
/// Alpaca fetch granularity for backfill (aggregated into [barTimeframe]).
static const String alpacaFetchTimeframe = '1Min';
/// Symbols per Alpaca `GET /v2/stocks/bars` request (max ~100).
static const int historySyncBatchSize = 100;
/// Hard cap on symbols synced per run (Alpaca Basic rate-limit safety).
static const int historySyncMaxSymbols = 2000;
/// Minimum session-half bars required before a symbol is eligible for the
/// guess-the-move question rule.
static const int minBarsForGuess = 5;
/// Hours before the same symbol can fire another guess question.
static const int guessCooldownHours = 24;
/// Rows deleted per cleanup loop iteration (Postgres batched DELETE).
static const int retentionBatchSize = 5000;
/// Max Alpaca HTTP calls per rolling minute during history backfill.
static const int apiRequestsPerMinute = 200;
/// Wait after HTTP 429 before retrying the same bars request.
static const Duration rateLimitCooldown = Duration(minutes: 1);
}