Refactor and translate comments and docstrings in utility modules to English for better clarity and maintainability. Update Gunicorn and application startup messages for consistency in language. Enhance documentation with English translations for better accessibility.

This commit is contained in:
dienakdz
2026-04-06 16:47:36 +07:00
parent 3ca291a346
commit 11e2e5aaa6
64 changed files with 2323 additions and 2336 deletions
+22 -22
View File
@@ -1,6 +1,6 @@
"""
数据源工厂
根据市场类型返回对应的数据源
data source factory
Return the corresponding data source according to the market type
"""
from typing import Dict, List, Any, Optional
@@ -11,20 +11,20 @@ logger = get_logger(__name__)
class DataSourceFactory:
"""数据源工厂"""
"""data source factory"""
_sources: Dict[str, BaseDataSource] = {}
@classmethod
def get_source(cls, market: str) -> BaseDataSource:
"""
获取指定市场的数据源
Get the data source for the specified market
Args:
market: 市场类型 (Crypto, USStock, Forex, Futures)
market: market type (Crypto, USStock, Forex, Futures)
Returns:
数据源实例
Data source instance
"""
if market not in cls._sources:
cls._sources[market] = cls._create_source(market)
@@ -48,7 +48,7 @@ class DataSourceFactory:
@classmethod
def _create_source(cls, market: str) -> BaseDataSource:
"""创建数据源实例"""
"""Create data source instance"""
if market == 'Crypto':
from app.data_sources.crypto import CryptoDataSource
return CryptoDataSource()
@@ -74,23 +74,23 @@ class DataSourceFactory:
before_time: Optional[int] = None
) -> List[Dict[str, Any]]:
"""
获取K线数据的便捷方法
A convenient way to obtain K-line data
Args:
market: 市场类型
symbol: 交易对/股票代码
timeframe: 时间周期
limit: 数据条数
before_time: 获取此时间之前的数据
market: market type
symbol: trading pair/stock code
timeframe: time period
limit: number of data items
before_time: Get data before this time
Returns:
K线数据列表
K-line data list
"""
try:
source = cls.get_source(market)
klines = source.get_kline(symbol, timeframe, limit, before_time)
# 确保数据按时间排序
# Make sure the data is sorted by time
klines.sort(key=lambda x: x['time'])
return klines
@@ -101,17 +101,17 @@ class DataSourceFactory:
@classmethod
def get_ticker(cls, market: str, symbol: str) -> Dict[str, Any]:
"""
获取实时报价的便捷方法
The convenient way to get realtime quotes
Args:
market: 市场类型
symbol: 交易对/股票代码
market: market type
symbol: trading pair/stock code
Returns:
实时报价数据: {
'last': 最新价,
'change': 涨跌额,
'changePercent': 涨跌幅,
Real-time quotation data: {
'last': latest price,
'change': change amount,
'changePercent': increase or decrease,
...
}
"""