Refactor code for improved readability and consistency
- Cleaned up whitespace and formatting in various files including http.py, language.py, logger.py, safe_exec.py, and SQL migration scripts. - Consolidated import statements and removed unnecessary blank lines. - Updated logging configuration for better clarity. - Enhanced the safe execution code with improved error handling and logging. - Removed commented-out code and unnecessary variables in backfill_zero_trades.py and other scripts. - Added a pyproject.toml for Ruff and Vulture configuration. - Introduced requirements-dev.txt for development dependencies. - Removed commented-out stock entries in init.sql for cleaner migration scripts.
This commit is contained in:
@@ -4,28 +4,28 @@ Symbol Mapping and Conversion
|
||||
Converts QuantDinger system symbols to IB contract format.
|
||||
"""
|
||||
|
||||
from typing import Tuple, Optional
|
||||
from typing import Optional, Tuple
|
||||
|
||||
|
||||
def normalize_symbol(symbol: str, market_type: str) -> Tuple[str, str, str]:
|
||||
"""
|
||||
Convert system symbol to IB contract parameters.
|
||||
|
||||
|
||||
Args:
|
||||
symbol: Symbol code in the system
|
||||
market_type: Market type (USStock)
|
||||
|
||||
|
||||
Returns:
|
||||
(ib_symbol, exchange, currency)
|
||||
"""
|
||||
symbol = (symbol or "").strip().upper()
|
||||
market_type = (market_type or "").strip()
|
||||
|
||||
|
||||
if market_type == "USStock":
|
||||
# US stocks: AAPL, TSLA, GOOGL
|
||||
# Use SMART routing for best execution
|
||||
return symbol, "SMART", "USD"
|
||||
|
||||
|
||||
else:
|
||||
# Default to US stock
|
||||
return symbol, "SMART", "USD"
|
||||
@@ -34,15 +34,15 @@ def normalize_symbol(symbol: str, market_type: str) -> Tuple[str, str, str]:
|
||||
def parse_symbol(symbol: str) -> Tuple[str, Optional[str]]:
|
||||
"""
|
||||
Parse symbol and auto-detect market type.
|
||||
|
||||
|
||||
Args:
|
||||
symbol: Symbol code
|
||||
|
||||
|
||||
Returns:
|
||||
(clean_symbol, market_type)
|
||||
"""
|
||||
symbol = (symbol or "").strip().upper()
|
||||
|
||||
|
||||
# Default to US stock
|
||||
return symbol, "USStock"
|
||||
|
||||
@@ -50,11 +50,11 @@ def parse_symbol(symbol: str) -> Tuple[str, Optional[str]]:
|
||||
def format_display_symbol(ib_symbol: str, exchange: str) -> str:
|
||||
"""
|
||||
Convert IB contract format back to display format.
|
||||
|
||||
|
||||
Args:
|
||||
ib_symbol: IB symbol
|
||||
exchange: Exchange code
|
||||
|
||||
|
||||
Returns:
|
||||
Display symbol
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user