fix(data-service): Fix DB credentials and sync_service table mappings

- Update config.py: trading_platform/trading_user/trading_dev_2026
- Fix sync_service.py: ohlcv_5m/ohlcv_15m table names (was ohlcv_5min)
- Fix sync_service.py: Remove non-existent 'trades' column from INSERT

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Adrian Flores Cortes 2026-01-27 04:39:32 -06:00
parent 0e20c7c75c
commit 34fcea2cc5
2 changed files with 16 additions and 17 deletions

View File

@ -13,9 +13,9 @@ class DatabaseConfig:
"""PostgreSQL configuration."""
host: str = "localhost"
port: int = 5432
database: str = "orbiquant_trading"
user: str = "orbiquant_user"
password: str = "orbiquant_dev_2025"
database: str = "trading_platform"
user: str = "trading_user"
password: str = "trading_dev_2026"
min_connections: int = 5
max_connections: int = 20
@ -116,9 +116,9 @@ class Config:
database=DatabaseConfig(
host=os.getenv("DB_HOST", "localhost"),
port=int(os.getenv("DB_PORT", "5432")),
database=os.getenv("DB_NAME", "orbiquant_trading"),
user=os.getenv("DB_USER", "orbiquant_user"),
password=os.getenv("DB_PASSWORD", "orbiquant_dev_2025"),
database=os.getenv("DB_NAME", "trading_platform"),
user=os.getenv("DB_USER", "trading_user"),
password=os.getenv("DB_PASSWORD", "trading_dev_2026"),
),
polygon=PolygonConfig.from_env(),
metaapi=MetaAPIConfig.from_env(),

View File

@ -41,12 +41,13 @@ class DataSyncService:
"""
# Supported timeframes with their table mappings
# Table names match DDL: market_data.ohlcv_5m, market_data.ohlcv_15m
TIMEFRAME_TABLES = {
Timeframe.MINUTE_1: "ohlcv_1min",
Timeframe.MINUTE_5: "ohlcv_5min",
Timeframe.MINUTE_15: "ohlcv_15min",
Timeframe.HOUR_1: "ohlcv_1hour",
Timeframe.HOUR_4: "ohlcv_4hour",
Timeframe.MINUTE_1: "ohlcv_1m",
Timeframe.MINUTE_5: "ohlcv_5m",
Timeframe.MINUTE_15: "ohlcv_15m",
Timeframe.HOUR_1: "ohlcv_1h",
Timeframe.HOUR_4: "ohlcv_4h",
Timeframe.DAY_1: "ohlcv_daily",
}
@ -211,8 +212,7 @@ class DataSyncService:
float(bar.close),
float(bar.volume) if bar.volume else 0.0,
float(bar.vwap) if bar.vwap else None,
bar.transactions,
int(bar.timestamp.timestamp())
int(bar.timestamp.timestamp() * 1000)
))
# Insert in batches
@ -287,16 +287,15 @@ class DataSyncService:
await conn.executemany(
f"""
INSERT INTO market_data.{table_name}
(ticker_id, timestamp, open, high, low, close, volume, vwap, trades, ts_epoch)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)
(ticker_id, timestamp, open, high, low, close, volume, vwap, ts_epoch)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)
ON CONFLICT (ticker_id, timestamp) DO UPDATE SET
open = EXCLUDED.open,
high = EXCLUDED.high,
low = EXCLUDED.low,
close = EXCLUDED.close,
volume = EXCLUDED.volume,
vwap = EXCLUDED.vwap,
trades = EXCLUDED.trades
vwap = EXCLUDED.vwap
""",
bars
)