更新 API使用指南.md
This commit is contained in:
+11
-11
@@ -97,7 +97,7 @@ def get_tick(symbol):
|
||||
data = api(f"/symbols/{symbol}/tick")["data"][0]
|
||||
return data["bid"], data["ask"]
|
||||
|
||||
bid, ask = get_tick("XAUUSDc")
|
||||
bid, ask = get_tick("XAUUSD")
|
||||
print(f"XAUUSD Bid: {bid} Ask: {ask} Spread: {ask - bid}")
|
||||
```
|
||||
|
||||
@@ -160,7 +160,7 @@ def get_rates(symbol, timeframe, count):
|
||||
return df
|
||||
|
||||
# 获取最近 100 根 H1 K 线
|
||||
df = get_rates("XAUUSDc", "H1", 100)
|
||||
df = get_rates("XAUUSD", "H1", 100)
|
||||
print(df.head())
|
||||
```
|
||||
|
||||
@@ -236,7 +236,7 @@ def check_order(symbol, volume, order_type, price, sl=None, tp=None, magic=0, co
|
||||
print("❌ 不可下单")
|
||||
return result
|
||||
|
||||
check_order("XAUUSDc", 0.01, 0, 4180.0, sl=4170.0, tp=4190.0)
|
||||
check_order("XAUUSD", 0.01, 0, 4180.0, sl=4170.0, tp=4190.0)
|
||||
```
|
||||
|
||||
---
|
||||
@@ -269,7 +269,7 @@ def send_order(symbol, volume, order_type, price, sl=None, tp=None, magic=0, com
|
||||
return result
|
||||
|
||||
# 市价买入 0.01 手 XAUUSD
|
||||
result = send_order("XAUUSDc", 0.01, 0, 4180.0, sl=4170.0, tp=4190.0)
|
||||
result = send_order("XAUUSD", 0.01, 0, 4180.0, sl=4170.0, tp=4190.0)
|
||||
```
|
||||
|
||||
**order_type 说明:**
|
||||
@@ -295,7 +295,7 @@ GET /history/deals?date_from={from}&date_to={to}&symbol={symbol}
|
||||
deals = api("/history/deals", params={
|
||||
"date_from": "2026-07-01",
|
||||
"date_to": "2026-07-03",
|
||||
"symbol": "XAUUSDc"
|
||||
"symbol": "XAUUSD"
|
||||
})["data"]
|
||||
|
||||
for d in deals:
|
||||
@@ -324,7 +324,7 @@ GET /gvar
|
||||
```python
|
||||
gvars = api("/gvar")
|
||||
print(gvars)
|
||||
# {"data": [{"name": "AT_Trend_XAUUSDc", "value": 1}, ...], "count": 5}
|
||||
# {"data": [{"name": "AT_Trend_XAUUSD", "value": 1}, ...], "count": 5}
|
||||
```
|
||||
|
||||
#### 读取指定变量
|
||||
@@ -334,7 +334,7 @@ GET /gvar/{name}
|
||||
```
|
||||
|
||||
```python
|
||||
trend = api("/gvar/AT_Trend_XAUUSDc")["value"]
|
||||
trend = api("/gvar/AT_Trend_XAUUSD")["value"]
|
||||
print(f"趋势方向: {'多头' if trend == 1 else '空头'}")
|
||||
```
|
||||
|
||||
@@ -390,8 +390,8 @@ print(f"指标信号: {signal}")
|
||||
如果你仍在使用旧版 `Alpha Trend.ex5`,则读取方式应继续对应旧键名,例如:
|
||||
|
||||
```python
|
||||
trend = api("/gvar/AT_Trend_XAUUSDc")["value"]
|
||||
buy_signal = api("/gvar/AT_Buy_XAUUSDc")["value"]
|
||||
trend = api("/gvar/AT_Trend_XAUUSD")["value"]
|
||||
buy_signal = api("/gvar/AT_Buy_XAUUSD")["value"]
|
||||
```
|
||||
|
||||
### 第三步:根据信号做决策
|
||||
@@ -402,8 +402,8 @@ def on_tick():
|
||||
if signal != 1:
|
||||
return # 没信号,不动
|
||||
|
||||
if not bridge.has_position("XAUUSDc"):
|
||||
bid, ask = bridge.tick("XAUUSDc")
|
||||
if not bridge.has_position("XAUUSD"):
|
||||
bid, ask = bridge.tick("XAUUSD")
|
||||
bridge.buy("XAUUSDc", 0.01, ask, sl=ask - 50, tp=ask + 100)
|
||||
print("指标发出买入信号,已开多")
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user