fix bug
This commit is contained in:
@@ -44,8 +44,6 @@ def collector_push(account_id: str, assets: Any, positions: Any) -> None:
|
||||
"positions": positions,
|
||||
}
|
||||
)
|
||||
pretty_json = json.dumps(payload, indent=4, ensure_ascii=False)
|
||||
print(pretty_json)
|
||||
httpx.post(COLLECTOR_URL, json=payload, timeout=3.0)
|
||||
except BaseException:
|
||||
# Collection must never interrupt or affect the trading workflow.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from datetime import datetime
|
||||
import json
|
||||
|
||||
from sdk import Client
|
||||
from libs.collector import collector_push
|
||||
from sdk import Assets, Client, PositionItem
|
||||
|
||||
|
||||
BASE_URL = "http://127.0.0.1:10086"
|
||||
@@ -9,17 +9,15 @@ TOKEN = "QMTbyYanweidong"
|
||||
STOCK_CODE = "000021.SZ"
|
||||
VOLUME = 100
|
||||
|
||||
|
||||
def main() -> None:
|
||||
"""只读查询四类原始数据,输出 JSON 便于核对字段。"""
|
||||
with Client(BASE_URL, TOKEN) as client:
|
||||
for datatype in ("account", "order", "deal", "position"):
|
||||
print(f"\n=== {datatype} ===")
|
||||
try:
|
||||
result = client.org(datatype)
|
||||
print(f"记录数:{len(result)}")
|
||||
print(json.dumps(result, ensure_ascii=False, indent=2, default=str))
|
||||
except Exception as exc:
|
||||
print(f"查询失败:{exc}")
|
||||
portfolio = client.portfolio()
|
||||
assets = portfolio.assets
|
||||
positions = list(portfolio.positions.values())
|
||||
collector_push("86037237", assets, positions)
|
||||
|
||||
|
||||
|
||||
def main1() -> None:
|
||||
|
||||
Reference in New Issue
Block a user