Initial commit
This commit is contained in:
86
backend/test/probe_results.json
Normal file
86
backend/test/probe_results.json
Normal file
@ -0,0 +1,86 @@
|
||||
[
|
||||
{
|
||||
"name": "institutions",
|
||||
"url": "https://api.wmcloud.com/data/v1/api/moneyflow/getMoneyFlow.json",
|
||||
"params": {
|
||||
"tradeDate": "2026-03-19",
|
||||
"field": "tradeDate,secID,instNetFlow,retailNetFlow,instBuyCash,instSellCash"
|
||||
},
|
||||
"status_code": 200,
|
||||
"headers": {
|
||||
"Server": "nginx",
|
||||
"Date": "Thu, 19 Mar 2026 14:21:57 GMT",
|
||||
"Content-Type": "application/json;charset=utf8",
|
||||
"Content-Length": "40",
|
||||
"Connection": "keep-alive",
|
||||
"Set-Cookie": "cloud-anonymous-token=1a422c2c29a9465a9469a75c7e092970;Path=/;Domain=.datayes.com;Expires=Wed, 17-Jun-2026 14:21:57 GMT",
|
||||
"Expires": "Thu, 01 Jan 1970 00:00:00 GMT",
|
||||
"DYes-Rsp-count": "0",
|
||||
"Access-Control-Allow-Credentials": "true",
|
||||
"Access-Control-Allow-Methods": "GET,POST,HEAD,PUT,OPTIONS,DELETE,TRACE,CONNECT,MOVE,PROXY",
|
||||
"Access-Control-Allow-Headers": "authorization,Access-Control-Allow-Origin,Content-Type,Cookie,Cache-Control,Connection,Accept-Language,Accept-Encoding,Accept,Pragma,Referer,User-Agent,DNT,Host,Accept-Charset,AccessToken,Pms-Mac-Addr,X-Requested-With",
|
||||
"Strict-Transport-Security": "max-age=31536000"
|
||||
},
|
||||
"body": {
|
||||
"retCode": -12,
|
||||
"retMsg": "API Not Found"
|
||||
},
|
||||
"description": "Main/Institution vs retail capital flow summary."
|
||||
},
|
||||
{
|
||||
"name": "blocks",
|
||||
"url": "https://api.wmcloud.com/data/v1/api/moneyflow/getBlockMoneyFlow.json",
|
||||
"params": {
|
||||
"tradeDate": "2026-03-19",
|
||||
"field": "tradeDate,industryName,blockNetFlow,blockBuyCash,blockSellCash"
|
||||
},
|
||||
"status_code": 200,
|
||||
"headers": {
|
||||
"Server": "nginx",
|
||||
"Date": "Thu, 19 Mar 2026 14:21:58 GMT",
|
||||
"Content-Type": "application/json;charset=utf8",
|
||||
"Content-Length": "40",
|
||||
"Connection": "keep-alive",
|
||||
"Set-Cookie": "cloud-anonymous-token=7491f7e8d13644cbbe311aa8f2ce9b4d;Path=/;Domain=.datayes.com;Expires=Wed, 17-Jun-2026 14:21:58 GMT",
|
||||
"Expires": "Thu, 01 Jan 1970 00:00:00 GMT",
|
||||
"DYes-Rsp-count": "0",
|
||||
"Access-Control-Allow-Credentials": "true",
|
||||
"Access-Control-Allow-Methods": "GET,POST,HEAD,PUT,OPTIONS,DELETE,TRACE,CONNECT,MOVE,PROXY",
|
||||
"Access-Control-Allow-Headers": "authorization,Access-Control-Allow-Origin,Content-Type,Cookie,Cache-Control,Connection,Accept-Language,Accept-Encoding,Accept,Pragma,Referer,User-Agent,DNT,Host,Accept-Charset,AccessToken,Pms-Mac-Addr,X-Requested-With",
|
||||
"Strict-Transport-Security": "max-age=31536000"
|
||||
},
|
||||
"body": {
|
||||
"retCode": -12,
|
||||
"retMsg": "API Not Found"
|
||||
},
|
||||
"description": "Block/sector capital inflows and outflows."
|
||||
},
|
||||
{
|
||||
"name": "indices",
|
||||
"url": "https://api.wmcloud.com/data/v1/api/moneyflow/getIndexMoneyFlow.json",
|
||||
"params": {
|
||||
"tradeDate": "2026-03-19",
|
||||
"field": "tradeDate,indexName,indexNetFlow,indexBuyCash,indexSellCash"
|
||||
},
|
||||
"status_code": 200,
|
||||
"headers": {
|
||||
"Server": "nginx",
|
||||
"Date": "Thu, 19 Mar 2026 14:21:58 GMT",
|
||||
"Content-Type": "application/json;charset=utf8",
|
||||
"Content-Length": "40",
|
||||
"Connection": "keep-alive",
|
||||
"Set-Cookie": "cloud-anonymous-token=83e9f966c3594f2a87dd9bfcfaa9b45c;Path=/;Domain=.datayes.com;Expires=Wed, 17-Jun-2026 14:21:58 GMT",
|
||||
"Expires": "Thu, 01 Jan 1970 00:00:00 GMT",
|
||||
"DYes-Rsp-count": "0",
|
||||
"Access-Control-Allow-Credentials": "true",
|
||||
"Access-Control-Allow-Methods": "GET,POST,HEAD,PUT,OPTIONS,DELETE,TRACE,CONNECT,MOVE,PROXY",
|
||||
"Access-Control-Allow-Headers": "authorization,Access-Control-Allow-Origin,Content-Type,Cookie,Cache-Control,Connection,Accept-Language,Accept-Encoding,Accept,Pragma,Referer,User-Agent,DNT,Host,Accept-Charset,AccessToken,Pms-Mac-Addr,X-Requested-With",
|
||||
"Strict-Transport-Security": "max-age=31536000"
|
||||
},
|
||||
"body": {
|
||||
"retCode": -12,
|
||||
"retMsg": "API Not Found"
|
||||
},
|
||||
"description": "Broad index capital flow overview."
|
||||
}
|
||||
]
|
||||
1
backend/test/requirements.txt
Normal file
1
backend/test/requirements.txt
Normal file
@ -0,0 +1 @@
|
||||
requests>=2.31
|
||||
95
backend/test/wind_data_probe.py
Normal file
95
backend/test/wind_data_probe.py
Normal file
@ -0,0 +1,95 @@
|
||||
import argparse
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
import requests
|
||||
|
||||
|
||||
API_ENDPOINTS = [
|
||||
{
|
||||
"name": "institutions",
|
||||
"description": "Main/Institution vs retail capital flow summary.",
|
||||
"path": "/data/v1/api/moneyflow/getMoneyFlow.json",
|
||||
"params": {
|
||||
"tradeDate": None,
|
||||
"field": "tradeDate,secID,instNetFlow,retailNetFlow,instBuyCash,instSellCash",
|
||||
},
|
||||
},
|
||||
{
|
||||
"name": "blocks",
|
||||
"description": "Block/sector capital inflows and outflows.",
|
||||
"path": "/data/v1/api/moneyflow/getBlockMoneyFlow.json",
|
||||
"params": {
|
||||
"tradeDate": None,
|
||||
"field": "tradeDate,industryName,blockNetFlow,blockBuyCash,blockSellCash",
|
||||
},
|
||||
},
|
||||
{
|
||||
"name": "indices",
|
||||
"description": "Broad index capital flow overview.",
|
||||
"path": "/data/v1/api/moneyflow/getIndexMoneyFlow.json",
|
||||
"params": {
|
||||
"tradeDate": None,
|
||||
"field": "tradeDate,indexName,indexNetFlow,indexBuyCash,indexSellCash",
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
def probe_endpoint(
|
||||
base_url: str, token: str | None, endpoint: dict[str, Any], default_trade_date: str
|
||||
) -> dict[str, Any]:
|
||||
params = {**endpoint["params"]}
|
||||
params["tradeDate"] = params["tradeDate"] or default_trade_date
|
||||
url = f"{base_url}{endpoint['path']}"
|
||||
headers = {}
|
||||
if token:
|
||||
headers["Authorization"] = f"Bearer {token}"
|
||||
response = requests.get(url, headers=headers, params=params, timeout=20)
|
||||
try:
|
||||
body = response.json()
|
||||
except ValueError:
|
||||
body = response.text
|
||||
|
||||
return {
|
||||
"name": endpoint["name"],
|
||||
"url": url,
|
||||
"params": params,
|
||||
"status_code": response.status_code,
|
||||
"headers": dict(response.headers),
|
||||
"body": body,
|
||||
"description": endpoint["description"],
|
||||
}
|
||||
|
||||
|
||||
def main() -> None:
|
||||
parser = argparse.ArgumentParser(description="Probe Wind/WMCloud capital flow endpoints.")
|
||||
parser.add_argument("--trade-date", default="2026-03-19")
|
||||
parser.add_argument("--out", default="probe_results.json")
|
||||
parser.add_argument("--base-url", default="https://api.wmcloud.com")
|
||||
args = parser.parse_args()
|
||||
|
||||
token = os.environ.get("WIND_API_TOKEN")
|
||||
results: list[dict[str, Any]] = []
|
||||
|
||||
for endpoint in API_ENDPOINTS:
|
||||
try:
|
||||
result = probe_endpoint(args.base_url, token, endpoint, args.trade_date)
|
||||
except requests.RequestException as exc:
|
||||
result = {
|
||||
"name": endpoint["name"],
|
||||
"description": endpoint["description"],
|
||||
"error": str(exc),
|
||||
"url": f"{args.base_url}{endpoint['path']}",
|
||||
}
|
||||
results.append(result)
|
||||
|
||||
out_path = Path(__file__).resolve().parent / args.out
|
||||
out_path.write_text(json.dumps(results, ensure_ascii=False, indent=2), encoding="utf-8")
|
||||
print(out_path)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user