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