import time
import requests # pip3 install requests
import json
# Extra headers
test_headers = {
'Content-Type' : 'application/json'
}
'''
github:https://github.com/alltick/realtime-forex-crypto-stock-tick-finance-websocket-api
申请免费token:https://alltick.co/register
官网:https://alltick.co
备用地址: https://alltick.io
将如下JSON进行url的encode,复制到http的查询字符串的query字段里
{"trace" : "python_http_test1","data" : {"code" : "USDJPY","kline_type" : 1,"kline_timestamp_end" : 0,"query_kline_num" : 2,"adjust_type": 0}}
{"trace" : "python_http_test2","data" : {"symbol_list": [{"code": "GOLD"}]}}
{"trace" : "python_http_test3","data" : {"symbol_list": [{"code": "GOLD"}]}}
'''
test_url1 = 'https://quote.aatest.online/quote-b-api/kline?token=3662a972-1a5d-4bb1-88b4-66ca0c402a03-1688712831841&query=%7B%22trace%22%20%3A%20%22python_http_test1%22%2C%22data%22%20%3A%20%7B%22code%22%20%3A%20%22USDJPY%22%2C%22kline_type%22%20%3A%201%2C%22kline_timestamp_end%22%20%3A%200%2C%22query_kline_num%22%20%3A%202%2C%22adjust_type%22%3A%200%7D%7D'
resp1 = requests.get(url=test_url1, headers=test_headers)
# Decoded text returned by the request
text1 = resp1.text
print(text1)
下面是测试返回的结果:
{
"ret":200,
"msg":"ok",
"cmd_id":14015,
"seq_id":123,
"ext":"3baaa938-f92c-4a74-a228-fd49d5e2f8bc-1678419657806",
"data":{
"data_list":[
{
"symbol_id": 1123,
"trade_type": 1,
"trade_mode": 0,
"kline_type": 1,
"price_digits": 2,
"kline_list":[
{
"timestamp": 1605509068,
"open_price": "651.12",
"close_price": "623.12",
"high_price": "674.12",
"low_price": "619.12",
"last_tick_time": 1605509068000001,
"last_tick_seq": 1605509068000001,
"transactions_number": "12345.6",
},
]
},
],
}
}
更多接入教程可以看文档。
点击查看更多内容
为 TA 点赞
评论
共同学习,写下你的评论
评论加载中...
作者其他优质文章
正在加载中
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦