-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
34 lines (26 loc) · 1.09 KB
/
utils.py
File metadata and controls
34 lines (26 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from config import TRADING_SYMBOLS
def get_api_symbol(symbol: str) -> str:
"""Convert a symbol to its API format.
Args:
symbol (str): The symbol from config (e.g., 'LTC/USD')
Returns:
str: The symbol in API format (e.g., 'LTCUSD' for crypto)
"""
if symbol not in TRADING_SYMBOLS:
return symbol
return symbol.replace('/', '') if TRADING_SYMBOLS[symbol]['market'] == 'CRYPTO' else symbol
def get_display_symbol(api_symbol: str) -> str:
"""Convert an API symbol back to display format.
Args:
api_symbol (str): The symbol in API format (e.g., 'LTCUSD')
Returns:
str: The symbol in display format (e.g., 'LTC/USD' for crypto)
"""
# First try direct match
if api_symbol in TRADING_SYMBOLS:
return api_symbol
# Try to find corresponding crypto symbol
for symbol in TRADING_SYMBOLS:
if TRADING_SYMBOLS[symbol]['market'] == 'CRYPTO' and symbol.replace('/', '') == api_symbol:
return symbol
return api_symbol # Return as-is if no match found