数字货币量化交易-区块Gateio API接口
1、接口文档网址:https://www.gate.ac/docs/developers/apiv4/zh_CN/#futures
2、安装python工具:pip3 install gateapi-python
3、下载https://github.com/gateio/gateapi-python
4、解压下载好的gateapi-python-master.zip
5、将gateapi-python-master文件夹下的gate_api文件夹复制到lib/site-packages文件夹下,即可再pycharm中使用import gate_api导入该库。
6、新增config.py文件
class Config:
GATEIO_API_KEY = '你申请的api key'
GATEIO_API_SECRET = '你申请的secret key'
GATEIO_HOST = 'https://fx-api.gateio.ws/api/v4'
'''
实盘交易: https://api.gateio.ws/api/v4
合约模拟交易: https://fx-api-testnet.gateio.ws/api/v4
合约实盘交易备选入口(只适用合约 API):
https://fx-api.gateio.ws/api/v4单纯的获取Gate BTC区块产品价格:
import requests
url = "https://api.gateio.ws/api/v4/spot/tickers"
params = {"currency_pair": "BTC_USDT"}
response = requests.get(url, params=params)
data = response.json()
if data and isinstance(data, list) and len(data) > 0:
ticker = data[0]
c_price = ticker['last']
else:
print("Failed to fetch the latest price.")
通过以上代码,可以获取BTC实时价格