import requests
|
|
|
|
def fetch_precision_info(platform):
|
|
# 定义请求URL
|
|
url = "http://43.133.213.20:8001/api/v1/PrecisionInfo/platform"
|
|
|
|
# 定义请求数据
|
|
request_data = {"platform": platform}
|
|
price_tick_info = {}
|
|
|
|
try:
|
|
# 发送GET请求
|
|
response = requests.get(url, params=request_data, timeout=15)
|
|
|
|
# 检查响应状态码并输出
|
|
if response.status_code == 200:
|
|
precisions = response.json()
|
|
print(f"Precision Information: {precisions.get('btcusdt', 'No data available')}")
|
|
for symbol, precision in precisions.items():
|
|
symbol = symbol.lower()
|
|
price_tick_info[symbol] = precision["price_decimal"]
|
|
# 可以选择打印更多信息
|
|
# print(f"Symbol: {symbol}, Price Precision: {precision['price_precision']}, Quantity Precision: {precision['quantity_precision']}")
|
|
return price_tick_info
|
|
else:
|
|
print(f"Error: {response.status_code}, {response.text}")
|
|
return None
|
|
except requests.RequestException as e:
|
|
print(f"Request failed: {e}")
|
|
return None
|
|
|
|
# 示例调用
|
|
platform = "gate_swap_u"
|
|
precision_info = fetch_precision_info(platform)
|
|
if precision_info:
|
|
print("Price Tick Information:", precision_info)
|
|
|
|
|
|
import requests
|
|
|
|
def fetch_depth(exchange, symbol):
|
|
url = "http://43.133.213.20:8001/api/v1/depth/"
|
|
payload = {"exchange": exchange, "symbol": symbol}
|
|
|
|
response = requests.post(url, json=payload, timeout=5)
|
|
|
|
if response.status_code == 200:
|
|
return response.json()
|
|
else:
|
|
print(f"Error: {response.status_code}, {response.json()}")
|
|
return None
|
|
|
|
|
|
# 示例参数
|
|
exchange = "gate_swap_u"
|
|
symbol = "BTC/USDT"
|
|
|
|
# 发送请求
|
|
depth_data = fetch_depth(exchange, symbol)
|
|
print(depth_data)
|