dev 2
This commit is contained in:
@@ -279,11 +279,10 @@ class MarketDataExHandler(BaseHandler):
|
||||
class FullTickHandler(BaseHandler):
|
||||
def post(self):
|
||||
data = json.loads(self.request.body)
|
||||
stocks = data.get('stocks', '')
|
||||
stocks = data.get('stocks', [])
|
||||
if not stocks:
|
||||
raise HTTPError(400, "need args stocks")
|
||||
code_list = [s.strip() for s in stocks.split(',')]
|
||||
ret = safe_call(self.ctx().get_full_tick, code_list)
|
||||
ret = safe_call(self.ctx().get_full_tick, stocks)
|
||||
if not ret:
|
||||
raise HTTPError(500, "获取分笔行情失败")
|
||||
self.write(json.dumps(ret, ensure_ascii=False, default=str))
|
||||
@@ -1447,12 +1446,25 @@ def make_app():
|
||||
|
||||
# ============= Callback 注册 =============
|
||||
def json_serializer(obj):
|
||||
"""自定义 JSON 序列化器"""
|
||||
if isinstance(obj, datetime.datetime):
|
||||
return obj.strftime("%Y-%m-%d %H:%M:%S")
|
||||
if isinstance(obj, datetime.date):
|
||||
return obj.strftime("%Y-%m-%d")
|
||||
raise TypeError(f"Type {type(obj)} not serializable")
|
||||
if hasattr(obj, 'to_dict'):
|
||||
return obj.to_dict()
|
||||
attrs = {}
|
||||
for name in dir(obj):
|
||||
if name.startswith('_'):
|
||||
continue
|
||||
try:
|
||||
val = getattr(obj, name)
|
||||
except Exception:
|
||||
continue
|
||||
if not callable(val):
|
||||
attrs[name] = val
|
||||
if attrs:
|
||||
return attrs
|
||||
return str(obj)
|
||||
|
||||
def write_json(file_key, data,order_id:str=''):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user