Files

57 lines
1.6 KiB
Python
Raw Permalink Normal View History

2026-09-03 11:33:43 +08:00
from datetime import datetime
2026-09-06 11:34:23 +08:00
import json
2026-09-03 11:33:43 +08:00
from sdk import Client
2026-08-28 18:52:27 +08:00
BASE_URL = "http://127.0.0.1:10086"
TOKEN = "QMTbyYanweidong"
2026-09-03 11:33:43 +08:00
STOCK_CODE = "000021.SZ"
VOLUME = 100
def main() -> None:
2026-09-06 11:34:23 +08:00
"""只读查询四类原始数据,输出 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}")
def main1() -> None:
2026-09-03 11:33:43 +08:00
order = {
"opType": 23,
"orderType": 1101,
"stockCode": STOCK_CODE,
"prType": 5,
"price": -1,
"volume": VOLUME,
"quickTrade": 2,
"strategyName": "manual-test",
"orderId": f"test-{datetime.now():%H%M%S}",
}
2026-08-28 18:52:27 +08:00
2026-09-03 11:33:43 +08:00
with Client(BASE_URL, TOKEN) as client:
#client._post_json("/api/sys/shutdown")
print("真实委托:", order)
result = client.passorder(
order["opType"],
order["stockCode"],
order["volume"],
order_type=order["orderType"],
pr_type=order["prType"],
price=order["price"],
quick_trade=order["quickTrade"],
strategy_name=order["strategyName"],
order_id=order["orderId"],
)
print("下单结果:", result)
2026-08-28 18:52:27 +08:00
2026-09-03 00:54:57 +08:00
if __name__ == "__main__":
main()