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:
parent
0e20c7c75c
commit
34fcea2cc5
@ -13,9 +13,9 @@ class DatabaseConfig:
|
|||||||
"""PostgreSQL configuration."""
|
"""PostgreSQL configuration."""
|
||||||
host: str = "localhost"
|
host: str = "localhost"
|
||||||
port: int = 5432
|
port: int = 5432
|
||||||
database: str = "orbiquant_trading"
|
database: str = "trading_platform"
|
||||||
user: str = "orbiquant_user"
|
user: str = "trading_user"
|
||||||
password: str = "orbiquant_dev_2025"
|
password: str = "trading_dev_2026"
|
||||||
min_connections: int = 5
|
min_connections: int = 5
|
||||||
max_connections: int = 20
|
max_connections: int = 20
|
||||||
|
|
||||||
@ -116,9 +116,9 @@ class Config:
|
|||||||
database=DatabaseConfig(
|
database=DatabaseConfig(
|
||||||
host=os.getenv("DB_HOST", "localhost"),
|
host=os.getenv("DB_HOST", "localhost"),
|
||||||
port=int(os.getenv("DB_PORT", "5432")),
|
port=int(os.getenv("DB_PORT", "5432")),
|
||||||
database=os.getenv("DB_NAME", "orbiquant_trading"),
|
database=os.getenv("DB_NAME", "trading_platform"),
|
||||||
user=os.getenv("DB_USER", "orbiquant_user"),
|
user=os.getenv("DB_USER", "trading_user"),
|
||||||
password=os.getenv("DB_PASSWORD", "orbiquant_dev_2025"),
|
password=os.getenv("DB_PASSWORD", "trading_dev_2026"),
|
||||||
),
|
),
|
||||||
polygon=PolygonConfig.from_env(),
|
polygon=PolygonConfig.from_env(),
|
||||||
metaapi=MetaAPIConfig.from_env(),
|
metaapi=MetaAPIConfig.from_env(),
|
||||||
|
|||||||
@ -41,12 +41,13 @@ class DataSyncService:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
# Supported timeframes with their table mappings
|
# Supported timeframes with their table mappings
|
||||||
|
# Table names match DDL: market_data.ohlcv_5m, market_data.ohlcv_15m
|
||||||
TIMEFRAME_TABLES = {
|
TIMEFRAME_TABLES = {
|
||||||
Timeframe.MINUTE_1: "ohlcv_1min",
|
Timeframe.MINUTE_1: "ohlcv_1m",
|
||||||
Timeframe.MINUTE_5: "ohlcv_5min",
|
Timeframe.MINUTE_5: "ohlcv_5m",
|
||||||
Timeframe.MINUTE_15: "ohlcv_15min",
|
Timeframe.MINUTE_15: "ohlcv_15m",
|
||||||
Timeframe.HOUR_1: "ohlcv_1hour",
|
Timeframe.HOUR_1: "ohlcv_1h",
|
||||||
Timeframe.HOUR_4: "ohlcv_4hour",
|
Timeframe.HOUR_4: "ohlcv_4h",
|
||||||
Timeframe.DAY_1: "ohlcv_daily",
|
Timeframe.DAY_1: "ohlcv_daily",
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -211,8 +212,7 @@ class DataSyncService:
|
|||||||
float(bar.close),
|
float(bar.close),
|
||||||
float(bar.volume) if bar.volume else 0.0,
|
float(bar.volume) if bar.volume else 0.0,
|
||||||
float(bar.vwap) if bar.vwap else None,
|
float(bar.vwap) if bar.vwap else None,
|
||||||
bar.transactions,
|
int(bar.timestamp.timestamp() * 1000)
|
||||||
int(bar.timestamp.timestamp())
|
|
||||||
))
|
))
|
||||||
|
|
||||||
# Insert in batches
|
# Insert in batches
|
||||||
@ -287,16 +287,15 @@ class DataSyncService:
|
|||||||
await conn.executemany(
|
await conn.executemany(
|
||||||
f"""
|
f"""
|
||||||
INSERT INTO market_data.{table_name}
|
INSERT INTO market_data.{table_name}
|
||||||
(ticker_id, timestamp, open, high, low, close, volume, vwap, trades, ts_epoch)
|
(ticker_id, timestamp, open, high, low, close, volume, vwap, ts_epoch)
|
||||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)
|
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)
|
||||||
ON CONFLICT (ticker_id, timestamp) DO UPDATE SET
|
ON CONFLICT (ticker_id, timestamp) DO UPDATE SET
|
||||||
open = EXCLUDED.open,
|
open = EXCLUDED.open,
|
||||||
high = EXCLUDED.high,
|
high = EXCLUDED.high,
|
||||||
low = EXCLUDED.low,
|
low = EXCLUDED.low,
|
||||||
close = EXCLUDED.close,
|
close = EXCLUDED.close,
|
||||||
volume = EXCLUDED.volume,
|
volume = EXCLUDED.volume,
|
||||||
vwap = EXCLUDED.vwap,
|
vwap = EXCLUDED.vwap
|
||||||
trades = EXCLUDED.trades
|
|
||||||
""",
|
""",
|
||||||
bars
|
bars
|
||||||
)
|
)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user