get_realtime_quotes主要有2个问题:
- _parse_stock_code代码里没有对5开头的基金和1开头的基金查询作判断
应该做的判断如下:
elif code.startswith('5'): return TDXParams.MARKET_SH, code # 上海市场 elif code.startswith('1'): return TDXParams.MARKET_SZ, code # 深圳市场
- 通达信行情数据本身对基金价格做了放大处理:部分基金(尤其是ETF)在通达信原始数据中,价格被放大了 10 倍,而 pytdx 默认未自动还原,导致返回的价格偏大,主要涉及的代码在_format_quote_data里,需要添加基金判断逻辑:
is_etf = True if code.startswith('5') or code.startswith('1') else False 并且在涉及到price 相关的时候,包含:last_close,price,high,open,low 及 买1到买5(bid1~bid5),卖1到卖5(ask1~ask5)的价格都要进行处理
get_realtime_quotes主要有2个问题:
应该做的判断如下:
elif code.startswith('5'): return TDXParams.MARKET_SH, code # 上海市场 elif code.startswith('1'): return TDXParams.MARKET_SZ, code # 深圳市场is_etf = True if code.startswith('5') or code.startswith('1') else False 并且在涉及到price 相关的时候,包含:last_close,price,high,open,low 及 买1到买5(bid1~bid5),卖1到卖5(ask1~ask5)的价格都要进行处理