diff --git a/README.md b/README.md
new file mode 100644
index 0000000..ac495be
--- /dev/null
+++ b/README.md
@@ -0,0 +1,105 @@
+# 免费开源股票API、港股API、美股API、沪深股票API、A股API实时股票行情数据
+
+简单好用易上手的免费开源股票API、港股API、美股API、沪深股票API、A股API、外汇API、商品贵金属API、加密货币API等实时行情数据
+
+## 功能特性:
+
+- 免费开源
+
+- 获取港股实时行情API
+
+- 获取港股实时10档盘口API
+
+- 获取港股K线数据API
+
+- 获取美股实时行情API
+
+- 获取美股实时一档盘口API
+
+- 获取美股K线数据API
+
+- 获取沪深A股实时行情API
+
+- 获取沪深A股实时5档盘口API
+
+- 获取沪深A股K线数据API
+
+- 获取加密货币实时行情API
+
+- 获取加密货币实时多档盘口API
+
+- 获取加密货币K线数据API
+
+- 获取外汇实时行情API
+
+- 获取外汇实时5档盘口API
+
+- 获取外汇K线数据API
+
+- 获取贵金属实时行情API
+
+- 获取贵金属实时5档盘口API
+
+- 获取贵金属K线数据API
+
+
+
+
+## 接口介绍
+- [接入指南](./接入指南.md)
+- [错误码说明](./错误码说明.md)
+- [产品code列表-A股](./产品code列表-A股.md)
+- [产品code列表-港股](./产品code列表-港股.md)
+- [产品code列表-加密货币(数字币)](./产品code列表-加密货币(数字币).md)
+- [产品code列表-美股](./产品code列表-美股.md)
+- [产品code列表-商品(贵金属)](./产品code列表-商品(贵金属).md)
+- [产品code列表-外汇](./产品code列表-外汇.md)
+
+### http接口
+- [行情API地址说明](./http接口/API地址说明.md)
+- [接口限制](./http接口/接口限制.md)
+- [通用标准头](./http接口/通用标准头.md)
+- [获取最新成交报价查询](./http接口/最新成交报价查询.md)
+- [最新盘口报价查询](./http接口/最新盘口报价查询.md)
+- [K线查询](./http接口/K线查询.md)
+- [批量K线查询](./http接口/批量K线查询.md)
+
+### websocket接口
+- [行情API地址说明](./websocket接口/API地址说明.md)
+- [接口限制](./websocket接口/接口限制.md)
+- [通用标准头](./websocket接口/通用标准头.md)
+- [心跳](./websocket接口/心跳.md)
+- [成交报价订阅](./websocket接口/成交报价订阅.md)
+- [盘口报价订阅](./websocket接口/盘口报价订阅.md)
+- [取消报价订阅](./websocket接口/取消报价订阅.md)
+
+## 免费token获取
+- [token申请](./token申请.md)
+
+## 使用示例,超简单上手
+### php:
+
+- [http请求示例](./example/php/php_http_curl.php)
+- [websocket请求示例](./example/php/php_websocket_workerman.php)
+
+### python:
+
+- [http请求示例](./example/python/http_python_example.py)
+- [websocket请求示例](./example/python/websocket_python_example.py)
+
+### go:
+- [http请求示例](./example/go/http_go_example.go)
+- [websocket请求示例](./example/go/websocket_go_example.go)
+
+### java:
+- [http请求示例](./example/java/HttpJavaExample.java)
+- [websocket请求示例](./example/java/WebSocketJavaExample.java)
+
+
+## 联系我们
+
+- Telegram: https://t.me/TS_SUPPORT_Lester
+- Email: lester.lin@chixi88.com
+
+## 其他作品
+
diff --git a/example/go/go.mod b/example/go/go.mod
new file mode 100644
index 0000000..8110fbc
--- /dev/null
+++ b/example/go/go.mod
@@ -0,0 +1,8 @@
+module go_example
+
+go 1.13
+
+require (
+ github.com/google/uuid v1.6.0
+ github.com/gorilla/websocket v1.5.0
+)
diff --git a/example/go/go.sum b/example/go/go.sum
new file mode 100644
index 0000000..f7d7d4b
--- /dev/null
+++ b/example/go/go.sum
@@ -0,0 +1,4 @@
+github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
+github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
+github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
+github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
diff --git a/example/go/http_go_example.go b/example/go/http_go_example.go
new file mode 100644
index 0000000..25ea72f
--- /dev/null
+++ b/example/go/http_go_example.go
@@ -0,0 +1,64 @@
+package main
+
+import (
+ "fmt"
+ "log"
+ "strings"
+ "io/ioutil"
+ "net/http"
+)
+
+func http_example() {
+
+ /*
+ 将如下JSON进行url的encode,复制到http的查询字符串的query字段里
+ {"trace" : "go_http_test1","data" : {"code" : "700.HK","kline_type" : 1,"kline_timestamp_end" : 0,"query_kline_num" : 2,"adjust_type": 0}}
+
+ 特别注意:
+ github: https://github.com/alltick/free-quote
+ token申请:https://alltick.co
+ 把下面url中的testtoken替换为您自己的token
+ 外汇,加密货币(数字币),贵金属的api址:
+ https://quote.tradeswitcher.com/quote-b-api
+ 股票api地址:
+ https://quote.tradeswitcher.com/quote-stock-b-api
+ */
+ url := "https://quote.tradeswitcher.com/quote-stock-b-api/batch-kline?token=testtoken"
+ log.Println("请求内容:", url)
+ // 创建一个http.Client对象
+ client := &http.Client{}
+
+ body := strings.NewReader(`{"trace": "3380a7a-3e1f-c3a5-5ee3-9e5be0ec8c241692805461","data": {"data_list": [
+{"code": "700.HK","kline_type": 1,"kline_timestamp_end": 0,"query_kline_num": 1000,"adjust_type": 0},
+{"code": "USDJPY","kline_type": 1,"kline_timestamp_end": 0,"query_kline_num": 1000,"adjust_type": 0},
+{"code": "AAPL.US","kline_type": 1,"kline_timestamp_end": 0,"query_kline_num": 1000,"adjust_type": 0},
+{"code": "GOLD","kline_type": 1,"kline_timestamp_end": 0,"query_kline_num": 1000,"adjust_type": 0}
+]}}`) // 请求body
+
+ req, err := http.NewRequest("GET", url, body)
+ if err != nil {
+ fmt.Println("Error creating request:", err)
+ return
+ }
+
+ // 发送请求
+ resp, err := client.Do(req)
+ if err != nil {
+ fmt.Println("Error sending request:", err)
+ return
+ }
+ defer resp.Body.Close()
+
+ body2, err := ioutil.ReadAll(resp.Body)
+
+ if err != nil {
+
+ log.Println("读取响应失败:", err)
+
+ return
+
+ }
+
+ log.Println("响应内容:", len(body2))
+
+}
diff --git a/example/go/main.go b/example/go/main.go
new file mode 100644
index 0000000..aa85fc6
--- /dev/null
+++ b/example/go/main.go
@@ -0,0 +1,11 @@
+package main
+
+func main(){
+ //for {
+ // go http_example()
+ // time.Sleep(time.Millisecond*10000)
+ //}
+
+ //time.Sleep(time.Second*1000000)
+ websocket_example()
+}
\ No newline at end of file
diff --git a/example/go/websocket_go_example.go b/example/go/websocket_go_example.go
new file mode 100644
index 0000000..c5c37f9
--- /dev/null
+++ b/example/go/websocket_go_example.go
@@ -0,0 +1,130 @@
+
+package main
+
+import (
+ "encoding/json"
+ "github.com/google/uuid"
+ "github.com/gorilla/websocket"
+ "log"
+ "time"
+)
+
+type Symbol struct {
+ Code string `json:"code"`
+ DepthLevel int `json:"depth_level"`
+}
+
+type Data struct {
+ SymbolList []Symbol `json:"symbol_list"`
+}
+
+type Request struct {
+ CmdID int `json:"cmd_id"`
+ SeqID int `json:"seq_id"`
+ Trace string `json:"trace"`
+ Data Data `json:"data"`
+}
+
+/*
+ 特别注意:
+ github: https://github.com/alltick/free-quote
+ token申请:https://alltick.co
+ 把下面url中的testtoken替换为您自己的token
+ 外汇,加密货币(数字币),贵金属的api址:
+ wss://quote.tradeswitcher.com/quote-b-ws-api
+ 股票api地址:
+ wss://quote.tradeswitcher.com/quote-stock-b-ws-api
+*/
+const(
+ url ="wss://quote.tradeswitcher.com/quote-b-ws-api?token=testtoken"
+)
+
+func websocket_example() {
+
+ log.Println("Connecting to server at", url)
+
+ c, _, err := websocket.DefaultDialer.Dial(url, nil)
+ if err != nil {
+ log.Fatal("dial:", err)
+ }
+ defer c.Close()
+
+ //定时10秒发一次心跳
+ go func() {
+ for range time.NewTicker(10*time.Second).C{
+ req := Request{
+ CmdID: 22000,
+ SeqID: 123,
+ Trace: "3380a7a-3e1f-c3a5-5ee3-9e5be0ec8c241692805462",
+ Data: Data{},
+ }
+ messageBytes, err := json.Marshal(req)
+ if err != nil {
+ log.Println("json.Marshal error:", err)
+ return
+ }
+ log.Println("req data:", string(messageBytes))
+
+ err = c.WriteMessage(websocket.TextMessage, messageBytes)
+ if err != nil {
+ log.Println("write:", err)
+ }
+ }
+ }()
+
+ req := Request{
+ CmdID: 22002,
+ SeqID: 123,
+ Trace: uuid.New().String(),
+ Data: Data{SymbolList: []Symbol{
+ {"GOLD",5},
+ {"AAPL.US",5},
+ {"700.HK",5},
+ {"USDJPY",5},
+ }},
+ }
+ messageBytes, err := json.Marshal(req)
+ if err != nil {
+ log.Println("json.Marshal error:", err)
+ return
+ }
+ log.Println("req data:", string(messageBytes))
+
+ err = c.WriteMessage(websocket.TextMessage, messageBytes)
+ if err != nil {
+ log.Println("write:", err)
+ }
+
+ req.CmdID = 22004
+ messageBytes, err = json.Marshal(req)
+ if err != nil {
+ log.Println("json.Marshal error:", err)
+ return
+ }
+ log.Println("req data:", string(messageBytes))
+
+ err = c.WriteMessage(websocket.TextMessage, messageBytes)
+ if err != nil {
+ log.Println("write:", err)
+ }
+
+ rece_count := 0
+ for{
+ _, message, err := c.ReadMessage()
+
+ if err != nil {
+ log.Println("read:", err)
+ break
+ } else {
+ log.Println("Received message:", string(message))
+ }
+
+ rece_count++
+ if rece_count % 10000 == 0 {
+ log.Println("count:", rece_count, " Received message:", string(message))
+ }
+ }
+
+
+}
+
diff --git a/example/java/HttpJavaExample.java b/example/java/HttpJavaExample.java
new file mode 100644
index 0000000..fa11268
--- /dev/null
+++ b/example/java/HttpJavaExample.java
@@ -0,0 +1,73 @@
+
+import java.io.BufferedReader;
+
+import java.io.InputStreamReader;
+
+import java.net.HttpURLConnection;
+
+import java.net.URL;
+
+
+
+public class HttpJavaExample {
+
+ public static void main(String[] args) {
+
+ try {
+
+ /*
+ 将如下JSON进行url的encode,复制到http的查询字符串的query字段里
+ {"trace" : "java_http_test1","data" : {"code" : "700.HK","kline_type" : 1,"kline_timestamp_end" : 0,"query_kline_num" : 2,"adjust_type": 0}}
+ 特别注意:
+ github: https://github.com/alltick/free-quote
+ token申请:https://alltick.co
+ 把下面url中的testtoken替换为您自己的token
+ 外汇,加密货币(数字币),贵金属的api址:
+ https://quote.tradeswitcher.com/quote-b-api
+ 股票api地址:
+ https://quote.tradeswitcher.com/quote-stock-b-api
+ */
+ String url = "http://quote.tradeswitcher.com/quote-stock-b-api/kline?token=testtoken&query=%7B%22trace%22%20%3A%20%22java_http_test1%22%2C%22data%22%20%3A%20%7B%22code%22%20%3A%20%22700.HK%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";
+
+ URL obj = new URL(url);
+
+ HttpURLConnection con = (HttpURLConnection) obj.openConnection();
+
+ con.setRequestMethod("GET");
+
+ int responseCode = con.getResponseCode();
+
+ System.out.println("Response Code: " + responseCode);
+
+
+
+ BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
+
+ String inputLine;
+
+ StringBuffer response = new StringBuffer();
+
+
+
+ while ((inputLine = in.readLine()) != null) {
+
+ response.append(inputLine);
+
+ }
+
+ in.close();
+
+
+
+ System.out.println(response.toString());
+
+ } catch (Exception e) {
+
+ e.printStackTrace();
+
+ }
+
+ }
+
+}
+
diff --git a/example/java/WebSocketJavaExample.java b/example/java/WebSocketJavaExample.java
new file mode 100644
index 0000000..fecc744
--- /dev/null
+++ b/example/java/WebSocketJavaExample.java
@@ -0,0 +1,112 @@
+
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.net.URI;
+
+import java.net.URISyntaxException;
+
+import javax.websocket.*;
+
+// 特别注意:
+// github: https://github.com/alltick/free-quote
+// token申请:https://alltick.co
+// 把下面url中的testtoken替换为您自己的token
+// 外汇,加密货币(数字币),贵金属的api址:
+// wss://quote.tradeswitcher.com/quote-b-ws-api
+// 股票api地址:
+// wss://quote.tradeswitcher.com/quote-stock-b-ws-api
+
+@ClientEndpoint
+
+public class WebSocketJavaExample {
+
+
+
+ private Session session;
+
+
+
+ @OnOpen
+
+ public void onOpen(Session session) {
+
+ System.out.println("Connected to server");
+
+ this.session = session;
+
+ }
+
+
+
+ @OnMessage
+
+ public void onMessage(String message) {
+
+ System.out.println("Received message: " + message);
+
+ }
+
+
+
+ @OnClose
+
+ public void onClose(Session session, CloseReason closeReason) {
+
+ System.out.println("Disconnected from server");
+
+ }
+
+
+
+ @OnError
+
+ public void onError(Throwable throwable) {
+
+ System.err.println("Error: " + throwable.getMessage());
+
+ }
+
+
+
+ public void sendMessage(String message) throws Exception {
+
+ this.session.getBasicRemote().sendText(message);
+
+ }
+
+
+
+ public static void main(String[] args) throws Exception, URISyntaxException, DeploymentException, IOException, IllegalArgumentException, SecurityException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
+
+ // 特别注意:
+ // github: https://github.com/alltick/free-quote
+ // token申请:https://alltick.co
+ // 把下面url中的testtoken替换为您自己的token
+ // 外汇,加密货币(数字币),贵金属的api址:
+ // wss://quote.tradeswitcher.com/quote-b-ws-api
+ // 股票api地址:
+ // wss://quote.tradeswitcher.com/quote-stock-b-ws-api
+
+ WebSocketContainer container = ContainerProvider.getWebSocketContainer();
+ URI uri = new URI("wss://quote.tradeswitcher.com/quote-stock-b-ws-api?token=testtoken"); // Replace with your websocket endpoint URL
+
+ WebSocketJavaExample client = new WebSocketJavaExample();
+
+ container.connectToServer(client, uri);
+
+
+
+ // Send messages to the server using the sendMessage() method
+
+ //如果希望长时间运行,除了需要发送订阅之外,还需要修改代码,定时发送心跳,避免连接断开,具体查看接口文档
+ client.sendMessage("{\"cmd_id\": 22002, \"seq_id\": 123,\"trace\":\"3baaa938-f92c-4a74-a228-fd49d5e2f8bc-1678419657806\",\"data\":{\"symbol_list\":[{\"code\": \"700.HK\",\"depth_level\": 5},{\"code\": \"UNH.US\",\"depth_level\": 5}]}}");
+
+
+ // Wait for the client to be disconnected from the server (or until the user presses Enter)
+
+ System.in.read(); // Wait for user input before closing the program
+
+ }
+
+}
+
diff --git a/example/php/php_http_curl.php b/example/php/php_http_curl.php
new file mode 100644
index 0000000..dea4974
--- /dev/null
+++ b/example/php/php_http_curl.php
@@ -0,0 +1,51 @@
+ 10, CURLOPT_RETURNTRANSFER => 1, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => false);
+
+/* 根据请求类型设置特定参数 */
+switch (strtoupper($method)) {
+case 'GET':
+ $opts[CURLOPT_URL] = $url;
+ $opts[CURLOPT_CUSTOMREQUEST] = 'GET';
+ $opts[CURLOPT_POSTFIELDS] = $params;
+
+ break;
+case 'POST':
+ //判断是否传输文件
+ $params = http_build_query($params);
+ $opts[CURLOPT_URL] = $url;
+ $opts[CURLOPT_POST] = 1;
+ $opts[CURLOPT_POSTFIELDS] = $params;
+
+ break;
+default:
+}
+
+/* 初始化并执行curl请求 */
+$ch = curl_init();
+curl_setopt_array($ch, $opts);
+$data = curl_exec($ch);
+$error = curl_error($ch);
+curl_close($ch);
+
+if ($error) {
+ $data = null;
+}
+
+echo $data;
diff --git a/example/php/php_websocket_workerman.php b/example/php/php_websocket_workerman.php
new file mode 100644
index 0000000..56806d5
--- /dev/null
+++ b/example/php/php_websocket_workerman.php
@@ -0,0 +1,55 @@
+onWorkerStart = function()
+{
+ // 以websocket协议连接远程websocket服务器
+ $ws_connection = new AsyncTcpConnection("ws://quote.tradeswitcher.com/quote-stock-b-ws-api?token=testtoken");
+ // 每隔55秒向服务端发送一个opcode为0x9的websocket心跳
+ $ws_connection->websocketPingInterval = 10;
+ $ws_connection->websocketType = Ws::BINARY_TYPE_BLOB; // BINARY_TYPE_BLOB为文本 BINARY_TYPE_ARRAYBUFFER为二进制
+ // 当TCP完成三次握手后
+ $ws_connection->onConnect = function($connection){
+ echo "tcp connected\n";
+ // 发送订阅请求
+ $connection->send('{"cmd_id":22002,"seq_id":123,"trace":"3baaa938-f92c-4a74-a228-fd49d5e2f8bc-1678419657806","data":{"symbol_list":[{"code":"700.HK","depth_level":5,},{"code":"AAPL.US","depth_level":5,}]}}');
+ };
+ // 当websocket完成握手后
+ $ws_connection->onWebSocketConnect = function(AsyncTcpConnection $con, $response) {
+ echo $response;
+ };
+ // 远程websocket服务器发来消息时
+ $ws_connection->onMessage = function($connection, $data){
+ echo "recv: $data\n";
+ };
+ // 连接上发生错误时,一般是连接远程websocket服务器失败错误
+ $ws_connection->onError = function($connection, $code, $msg){
+ echo "error: $msg\n";
+ };
+ // 当连接远程websocket服务器的连接断开时
+ $ws_connection->onClose = function($connection){
+ echo "connection closed and try to reconnect\n";
+ // 如果连接断开,1秒后重连
+ $connection->reConnect(1);
+ };
+ // 设置好以上各种回调后,执行连接操作
+ $ws_connection->connect();
+
+
+};
+Worker::runAll();
diff --git a/example/python/http_python_example.py b/example/python/http_python_example.py
new file mode 100644
index 0000000..8c23968
--- /dev/null
+++ b/example/python/http_python_example.py
@@ -0,0 +1,44 @@
+import time
+
+import requests # pip3 install requests
+import json
+
+# Extra headers
+test_headers = {
+ 'Content-Type' : 'application/json'
+}
+
+
+'''
+# 特别注意:
+# github: https://github.com/alltick/free-quote
+# token申请:https://alltick.co
+# 把下面url中的testtoken替换为您自己的token
+# 外汇,加密货币(数字币),贵金属的api址:
+# https://quote.tradeswitcher.com/quote-b-ws-api
+# 股票api地址:
+# https://quote.tradeswitcher.com/quote-stock-b-ws-api
+将如下JSON进行url的encode,复制到http的查询字符串的query字段里
+{"trace" : "python_http_test1","data" : {"code" : "700.HK","kline_type" : 1,"kline_timestamp_end" : 0,"query_kline_num" : 2,"adjust_type": 0}}
+{"trace" : "python_http_test2","data" : {"symbol_list": [{"code": "700.HK"},{"code": "UNH.US"}]}}
+{"trace" : "python_http_test3","data" : {"symbol_list": [{"code": "700.HK"},{"code": "UNH.US"}]}}
+'''
+test_url1 = 'https://quote.tradeswitcher.com/quote-stock-b-api/kline?token=testtoken&query=%7B%22trace%22%20%3A%20%22python_http_test1%22%2C%22data%22%20%3A%20%7B%22code%22%20%3A%20%22700.HK%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'
+test_url2 = 'https://quote.tradeswitcher.com/quote-stock-b-api/depth-tick?token=testtoken&query=%7B%22trace%22%20%3A%20%22python_http_test2%22%2C%22data%22%20%3A%20%7B%22symbol_list%22%3A%20%5B%7B%22code%22%3A%20%22700.HK%22%7D%2C%7B%22code%22%3A%20%22UNH.US%22%7D%5D%7D%7D'
+test_url3 = 'https://quote.tradeswitcher.com/quote-stock-b-api/trade-tick?token=testtoken&query=%7B%22trace%22%20%3A%20%22python_http_test3%22%2C%22data%22%20%3A%20%7B%22symbol_list%22%3A%20%5B%7B%22code%22%3A%20%22700.HK%22%7D%2C%7B%22code%22%3A%20%22UNH.US%22%7D%5D%7D%7D'
+
+resp1 = requests.get(url=test_url1, headers=test_headers)
+time.sleep(1)
+resp2 = requests.get(url=test_url2, headers=test_headers)
+time.sleep(1)
+resp3 = requests.get(url=test_url3, headers=test_headers)
+
+# Decoded text returned by the request
+text1 = resp1.text
+print(text1)
+
+text2 = resp2.text
+print(text2)
+
+text3 = resp3.text
+print(text3)
diff --git a/example/python/websocket_python_example.py b/example/python/websocket_python_example.py
new file mode 100644
index 0000000..5e707c2
--- /dev/null
+++ b/example/python/websocket_python_example.py
@@ -0,0 +1,106 @@
+import json
+import websocket # pip install websocket-client
+
+'''
+# 特别注意:
+# github: https://github.com/alltick/free-quote
+# token申请:https://alltick.co
+# 把下面url中的testtoken替换为您自己的token
+# 外汇,加密货币(数字币),贵金属的api址:
+# wss://quote.tradeswitcher.com/quote-b-ws-api
+# 股票api地址:
+# wss://quote.tradeswitcher.com/quote-stock-b-ws-api
+'''
+
+class Feed(object):
+
+ def __init__(self):
+ self.url = 'wss://quote.tradeswitcher.com/quote-stock-b-ws-api?token=testtoken' # 这里输入websocket的url
+ self.ws = None
+
+ def on_open(self, ws):
+ """
+ Callback object which is called at opening websocket.
+ 1 argument:
+ @ ws: the WebSocketApp object
+ """
+ print('A new WebSocketApp is opened!')
+
+ # 开始订阅(举个例子)
+ sub_param = {
+ "cmd_id": 22002,
+ "seq_id": 123,
+ "trace":"3baaa938-f92c-4a74-a228-fd49d5e2f8bc-1678419657806",
+ "data":{
+ "symbol_list":[
+ {
+ "code": "700.HK",
+ "depth_level": 5,
+ },
+ {
+ "code": "UNH.US",
+ "depth_level": 5,
+ }
+ ]
+ }
+ }
+
+ #如果希望长时间运行,除了需要发送订阅之外,还需要修改代码,定时发送心跳,避免连接断开,具体查看接口文档
+ sub_str = json.dumps(sub_param)
+ ws.send(sub_str)
+ print("depth quote are subscribed!")
+
+ def on_data(self, ws, string, type, continue_flag):
+ """
+ 4 argument.
+ The 1st argument is this class object.
+ The 2nd argument is utf-8 string which we get from the server.
+ The 3rd argument is data type. ABNF.OPCODE_TEXT or ABNF.OPCODE_BINARY will be came.
+ The 4th argument is continue flag. If 0, the data continue
+ """
+
+ def on_message(self, ws, message):
+ """
+ Callback object which is called when received data.
+ 2 arguments:
+ @ ws: the WebSocketApp object
+ @ message: utf-8 data received from the server
+ """
+ # 对收到的message进行解析
+ result = eval(message)
+ print(result)
+
+ def on_error(self, ws, error):
+ """
+ Callback object which is called when got an error.
+ 2 arguments:
+ @ ws: the WebSocketApp object
+ @ error: exception object
+ """
+ print(error)
+
+ def on_close(self, ws, close_status_code, close_msg):
+ """
+ Callback object which is called when the connection is closed.
+ 2 arguments:
+ @ ws: the WebSocketApp object
+ @ close_status_code
+ @ close_msg
+ """
+ print('The connection is closed!')
+
+ def start(self):
+ self.ws = websocket.WebSocketApp(
+ self.url,
+ on_open=self.on_open,
+ on_message=self.on_message,
+ on_data=self.on_data,
+ on_error=self.on_error,
+ on_close=self.on_close,
+ )
+ self.ws.run_forever()
+
+
+if __name__ == "__main__":
+ feed = Feed()
+ feed.start()
diff --git "a/http\346\216\245\345\217\243/API\345\234\260\345\235\200\350\257\264\346\230\216.md" "b/http\346\216\245\345\217\243/API\345\234\260\345\235\200\350\257\264\346\230\216.md"
new file mode 100644
index 0000000..f813c6d
--- /dev/null
+++ "b/http\346\216\245\345\217\243/API\345\234\260\345\235\200\350\257\264\346\230\216.md"
@@ -0,0 +1,27 @@
+# API地址说明
+
+## 股票HTTP接口API地址
+/quote-stock-b-api 股票查询API
+
+查询API为https协议,完整的url为:
https://quote.tradeswitcher.com/quote-stock-b-api
+
+每发送一次查询请求时,需要带上方法名和token信息
+
+请求示例:
+
+https://quote.tradeswitcher.com/quote-stock-b-api/kline?token=你的token&query=queryData
+
+具体调用方式,请查看http接口列表
+
+## 外汇,加密货币(数字币),商品(贵金属) HTTP接口API地址
+/quote-b-api 外汇,加密货币(数字币),商品(贵金属)查询API
+
+查询API为https协议,完整的url为:
https://quote.tradeswitcher.com/quote-b-api
+
+每发送一次查询请求时,需要带上方法名和token信息
+
+请求示例:
+
+https://quote.tradeswitcher.com/quote-b-api/kline?token=你的token&query=queryData
+
+具体调用方式,请查看http接口列表
\ No newline at end of file
diff --git "a/http\346\216\245\345\217\243/K\347\272\277\346\237\245\350\257\242.md" "b/http\346\216\245\345\217\243/K\347\272\277\346\237\245\350\257\242.md"
new file mode 100644
index 0000000..f193aec
--- /dev/null
+++ "b/http\346\216\245\345\217\243/K\347\272\277\346\237\245\350\257\242.md"
@@ -0,0 +1,101 @@
+## GET K线查询
+
+GET /quote-stock-b-api/kline
+
+### 请求参数
+
+| 名称 | 位置 | 类型 | 必选 | 说明 |
+| ---------------------- | ----- | ------- | ---- | ------------------------------------------------------------ |
+| token | query | string | 否 | |
+| query | query | string | 否 | 查看query请求参数说明 |
+
+> query 请求参数
+
+将如下json进行UrlEncode编码,赋值到url的查询字符串的query里
+```json
+{
+ "trace": "3baaa938-f92c-4a74-a228-fd49d5e2f8bc-1678419657806",
+ "data": {
+ "code": "857.HK",
+ "kline_type": 1,
+ "kline_timestamp_end": 0,
+ "query_kline_num": 2,
+ "adjust_type": 0
+ }
+}
+```
+
+### query请求参数
+
+| 名称 | 类型 | 必选 | 说明 |
+| ---------------------- | ------- | ---- | ------------------------------------------------------------ |
+| trace | string | 是 | 追踪码,用来查询日志使用,请保证每次请求时唯一 |
+| data | object | 是 | |
+| » code | string | 是 | 请查看code列表,选择你要查询的code |
+| » kline_type | integer | 是 | k线类型,1分钟K,2为5分钟K,3为15分钟K,4为30分钟K,5为小时K,6为2小时K,7为4小时K,8为日K,9为周K,10为月K |
+| » kline_timestamp_end | integer | 是 | 从那个时间点往前查,为0表示从当前时间,默认为0 |
+| » query_kline_num | integer | 是 | 查询多少根K线,最多1000根 |
+| » adjust_type | integer | 是 | 复权类型,对于股票类的code才有效,例如:0:除权,1:前复权 |
+
+> 返回示例
+
+> OK
+
+```json
+{
+ "ret": 200,
+ "msg": "ok",
+ "trace": "asdfsdfa",
+ "data": {
+ "code": "857.HK",
+ "kline_type": 1,
+ "kline_list": [
+ {
+ "timestamp": "1677829200",
+ "open_price": "136.421",
+ "close_price": "136.412",
+ "high_price": "136.422",
+ "low_price": "136.407",
+ "volume": "0",
+ "turnover": "0"
+ },
+ {
+ "timestamp": "1677829260",
+ "open_price": "136.412",
+ "close_price": "136.401",
+ "high_price": "136.415",
+ "low_price": "136.397",
+ "volume": "0",
+ "turnover": "0"
+ }
+ ]
+ }
+}
+```
+
+### 返回结果
+
+| 状态码 | 状态码含义 | 说明 | 数据模型 |
+| ------ | ------------------------------------------------------- | ---- | -------- |
+| 200 | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | OK | Inline |
+
+### 返回数据结构
+
+状态码 **200**
+
+| 名称 | 类型 | 必选 | 约束 | 中文名 | 说明 |
+| --------------- | -------- | ---- | ---- | ------ | ------------------------------------------------------------ |
+| » ret | integer | true | | | |
+| » msg | string | true | | | |
+| » trace | string | true | | | |
+| » data | object | true | | | |
+| »» code | string | true | | | 代码 |
+| »» kline_type | integer | true | | | k线类型,1分钟K,2为5分钟K,3为15分钟K,4为30分钟K,5为小时K,6为2小时K,7为4小时K,8为日K,9为周K,10为月K |
+| »» kline_list | [object] | true | | | |
+| »»» timestamp | string | true | | | 该K线时间戳 |
+| »»» open_price | string | true | | | 该K线开盘价 |
+| »»» close_price | string | true | | | 该K线收盘价 |
+| »»» high_price | string | true | | | 该K线最高价 |
+| »»» low_price | string | true | | | 该K线最低价 |
+| »»» volume | string | true | | | 该K线成交数量 |
+| »»» turnover | string | true | | | 该K线成交金额 |
diff --git "a/http\346\216\245\345\217\243/\346\211\271\351\207\217K\347\272\277\346\237\245\350\257\242.md" "b/http\346\216\245\345\217\243/\346\211\271\351\207\217K\347\272\277\346\237\245\350\257\242.md"
new file mode 100644
index 0000000..0d7ef46
--- /dev/null
+++ "b/http\346\216\245\345\217\243/\346\211\271\351\207\217K\347\272\277\346\237\245\350\257\242.md"
@@ -0,0 +1,138 @@
+## GET 批量K线查询
+
+GET /quote-b-api/batch-kline
+
+批量查询K线功能,由于批量查询参数比较多,放入body中,url参数中只保留token字段参数。
+
+> Body 请求参数
+
+```json
+{
+ "trace": "py_http_test1",
+ "data": {
+ "data_list": [
+ {
+ "code": "700.HK",
+ "kline_type": 1,
+ "kline_timestamp_end": 0,
+ "query_kline_num": 2,
+ "adjust_type": 0
+ },
+ {
+ "code": "GOOGL.US",
+ "kline_type": 1,
+ "kline_timestamp_end": 0,
+ "query_kline_num": 2,
+ "adjust_type": 0
+ }
+ ]
+ }
+}
+```
+
+### 请求参数
+
+|名称|位置|类型|必选|说明|
+|---|---|---|---|---|
+|token|query|string| 是 |如果不知道你的token,请联系相关人员索要|
+|body|body|object| 否 ||
+|» trace|body|string| 是 |追踪码,用来查询日志使用,请保证每次请求时唯一|
+|» data|body|object| 是 ||
+|»» data_list|body|[object]| 是 ||
+|»»» code|body|string| 是 |请查看code列表,选择你要查询的code|
+|»»» kline_type|body|integer| 是 |k线类型,1分钟K,2为5分钟K,3为15分钟K,4为30分钟K,5为小时K,6为2小时K,7为4小时K,8为日K,9为周K,10为月K|
+|»»» kline_timestamp_end|body|integer| 是 |从那个时间点往前查,为0表示从当前时间,非股票类的code才有效|
+|»»» query_kline_num|body|integer| 是 |查询多少根K线,最多1000根|
+|»»» adjust_type|body|integer| 是 |复权类型,对于股票类的code才有效,例如:0:除权,1:前复权|
+
+> 返回示例
+
+> OK
+
+```json
+{
+ "ret": 200,
+ "msg": "ok",
+ "trace": "asdfsdfa",
+ "data": {
+ "kline_list": [
+ {
+ "code": "700.HK",
+ "kline_type": 1,
+ "kline_data": [
+ {
+ "timestamp": "1677829200",
+ "open_price": "136.421",
+ "close_price": "136.412",
+ "high_price": "136.422",
+ "low_price": "136.407",
+ "volume": "0",
+ "turnover": "0"
+ },
+ {
+ "timestamp": "1677829260",
+ "open_price": "136.412",
+ "close_price": "136.401",
+ "high_price": "136.415",
+ "low_price": "136.397",
+ "volume": "0",
+ "turnover": "0"
+ }
+ ]
+ },
+ {
+ "code": "GOOGL.US",
+ "kline_type": 1,
+ "kline_data": [
+ {
+ "timestamp": "1677829200",
+ "open_price": "136.421",
+ "close_price": "136.412",
+ "high_price": "136.422",
+ "low_price": "136.407",
+ "volume": "0",
+ "turnover": "0"
+ },
+ {
+ "timestamp": "1677829260",
+ "open_price": "136.412",
+ "close_price": "136.401",
+ "high_price": "136.415",
+ "low_price": "136.397",
+ "volume": "0",
+ "turnover": "0"
+ }
+ ]
+ }
+ ]
+ }
+}
+```
+
+### 返回结果
+
+|状态码|状态码含义|说明|数据模型|
+|---|---|---|---|
+|200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|OK|Inline|
+
+### 返回数据结构
+
+状态码 **200**
+
+|名称|类型|必选|约束|中文名|说明|
+|---|---|---|---|---|---|
+|» ret|integer|true||||
+|» msg|string|true||||
+|» trace|string|true||||
+|» data|object|true||||
+|»» kline_list|[array]|true||||
+|»»» code|string|true|||产品代码|
+|»»» kline_type|integer|true|||k线类型,1分钟K,2为5分钟K,3为15分钟K,4为30分钟K,5为小时K,6为2小时K,7为4小时K,8为日K,9为周K,10为月K|
+|»»» kline_data|[array]|true||||
+|»»»» timestamp|string|true|||该K线时间戳|
+|»»»» open_price|string|true|||该K线开盘价|
+|»»»» close_price|string|true|||该K线收盘价|
+|»»»» high_price|string|true|||该K线最高价|
+|»»»» low_price|string|true|||该K线最低价|
+|»»»» volume|string|true|||该K线成交数量|
+|»»»» turnover|string|true|||该K线成交金额|
\ No newline at end of file
diff --git "a/http\346\216\245\345\217\243/\346\216\245\345\217\243\351\231\220\345\210\266.md" "b/http\346\216\245\345\217\243/\346\216\245\345\217\243\351\231\220\345\210\266.md"
new file mode 100644
index 0000000..50c2008
--- /dev/null
+++ "b/http\346\216\245\345\217\243/\346\216\245\345\217\243\351\231\220\345\210\266.md"
@@ -0,0 +1,20 @@
+# http接口限制
+
+## http接口限制1-IP类限制(免费试用)
+相同IP的多次请求,按接口确定具体次数限制,互不影响
+
+- /kline 每10秒只能请求1次
+- /depth-tick 每秒只能请求1次
+- /trade-tick 每秒只能请求1次
+### 举例:
+- IP为A,调用/kline接口查询K线,14:03:01请求了1次,并且它也在这一分钟调用了/trade-tick接口查询成交报价1次,后台服务都能正常提供服务
+- IP为A,调用/kline接口查询K线,14:03:01请求了2次,前1次后台服务都能正常提供服务,最后1次给出错误回应
+
+## http接口限制2-连接数限制(免费试用)
+为避免过多请求对于后台服务造成过大压力,stock-api的最大连接数限制在100个,视后续服务运行表现再进行调节,超过限制的请求,直接会断开连接
+
+## http接口限制3-K线查询限制(免费试用)
+一次只能查询1个code的K线,一次最多只能查询1000根K线,对于查询超过1000根以上的,则按1000根来进行查询
+
+## http接口限制4-报价查询限制(免费试用)
+一次查询,最多只能查询5个code,对于查询超过5个以上的,则按5个来查询
\ No newline at end of file
diff --git "a/http\346\216\245\345\217\243/\346\234\200\346\226\260\346\210\220\344\272\244\346\212\245\344\273\267\346\237\245\350\257\242.md" "b/http\346\216\245\345\217\243/\346\234\200\346\226\260\346\210\220\344\272\244\346\212\245\344\273\267\346\237\245\350\257\242.md"
new file mode 100644
index 0000000..ed9d0b6
--- /dev/null
+++ "b/http\346\216\245\345\217\243/\346\234\200\346\226\260\346\210\220\344\272\244\346\212\245\344\273\267\346\237\245\350\257\242.md"
@@ -0,0 +1,88 @@
+## GET 最新成交报价查询
+
+GET /quote-stock-b-api/trade-tick
+
+### 请求参数
+
+| 名称 | 位置 | 类型 | 必选 | 说明 |
+| ---------------------- | ----- | ------- | ---- | ------------------------------------------------------------ |
+| token | query | string | 否 | |
+| query | query | string | 否 | 查看query请求参数说明 |
+
+> query 请求参数
+
+将如下json进行UrlEncode编码,赋值到url的查询字符串的query里
+```json
+{
+ "trace": "pariatur",
+ "data": {
+ "symbol_list": [
+ {
+ "code": "857.HK"
+ },
+ {
+ "code": "UNH.US"
+ }
+ ]
+ }
+}
+```
+
+### query请求参数
+
+| 名称 | 类型 | 必选 | 说明 |
+| -------------- | -------- | ---- | ---- |
+| trace | string | 是 | |
+| data | object | 是 | |
+| » symbol_list | [object] | 是 | |
+| »» code | string | 否 | 代码 |
+
+> 返回示例
+
+> OK
+
+```json
+{
+ "ret": 200,
+ "msg": "ok",
+ "trace": "asdfsdfa",
+ "data": {
+ "tick_list": [
+ {
+ "code": "857.HK",
+ "seq": "30841439",
+ "tick_time": "1677831545217",
+ "price": "136.302",
+ "volume": "0",
+ "turnover": "0",
+ "trade_direction": 0
+ }
+ ]
+ }
+}
+```
+
+### 返回结果
+
+| 状态码 | 状态码含义 | 说明 | 数据模型 |
+| ------ | ------------------------------------------------------- | ---- | -------- |
+| 200 | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | OK | Inline |
+
+### 返回数据结构
+
+状态码 **200**
+
+| 名称 | 类型 | 必选 | 约束 | 中文名 | 说明 |
+| ------------------- | -------- | ----- | ---- | ------ | ------------------------------------ |
+| » ret | integer | true | | | 返回code |
+| » msg | string | true | | | 返回code对应消息 |
+| » trace | string | true | | | 请求的trace |
+| » data | object | true | | | |
+| »» tick_list | [object] | true | | | |
+| »»» code | string | false | | | 代码 |
+| »»» seq | string | false | | | 序号 |
+| »»» tick_time | string | false | | | 时间戳 |
+| »»» price | string | false | | | 成交价 |
+| »»» volume | string | false | | | 成交量 |
+| »»» turnover | string | false | | | 成交额 |
+| »»» trade_direction | integer | false | | | 交易方向,0为默认值,1为BUY,2为SELL |
\ No newline at end of file
diff --git "a/http\346\216\245\345\217\243/\346\234\200\346\226\260\347\233\230\345\217\243\346\212\245\344\273\267\346\237\245\350\257\242.md" "b/http\346\216\245\345\217\243/\346\234\200\346\226\260\347\233\230\345\217\243\346\212\245\344\273\267\346\237\245\350\257\242.md"
new file mode 100644
index 0000000..84682aa
--- /dev/null
+++ "b/http\346\216\245\345\217\243/\346\234\200\346\226\260\347\233\230\345\217\243\346\212\245\344\273\267\346\237\245\350\257\242.md"
@@ -0,0 +1,98 @@
+## GET 最新盘口报价查询
+
+GET /quote-stock-b-api/depth-tick
+
+### 请求参数
+
+| 名称 | 位置 | 类型 | 必选 | 说明 |
+| ---------------------- | ----- | ------- | ---- | ------------------------------------------------------------ |
+| token | query | string | 否 | |
+| query | query | string | 否 | 查看query请求参数说明 |
+
+> query 请求参数
+
+将如下json进行UrlEncode编码,赋值到url的查询字符串的query里
+```json
+{
+ "trace": "enim occaecat dolore esse voluptate",
+ "data": {
+ "symbol_list": [
+ {
+ "code": "857.HK"
+ },
+ {
+ "code": "UNH.US"
+ }
+ ]
+ }
+}
+```
+
+### query请求参数
+
+|名称|类型|必选|说明|
+|---|---|---|---|
+|trace|string| 是 ||
+|data|object| 是 ||
+|» symbol_list|[object]| 是 ||
+|»» code|string| 否 |代码|
+
+> 返回示例
+
+> OK
+
+```json
+{
+ "ret": 200,
+ "msg": "ok",
+ "trace": "asdfsdfa",
+ "data": {
+ "tick_list": [
+ {
+ "code": "857.HK",
+ "seq": "30686349",
+ "tick_time": "1677830357227",
+ "bids": [
+ {
+ "price": "136.424",
+ "volume": "100000.00"
+ }
+ ],
+ "asks": [
+ {
+ "price": "136.427",
+ "volume": "400000.00"
+ }
+ ]
+ }
+ ]
+ }
+}
+```
+
+### 返回结果
+
+|状态码|状态码含义|说明|数据模型|
+|---|---|---|---|
+|200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|OK|Inline|
+
+### 返回数据结构
+
+状态码 **200**
+
+|名称|类型|必选|约束|中文名|说明|
+|---|---|---|---|---|---|
+|» ret|integer|true|||返回code|
+|» msg|string|true|||返回code对应消息|
+|» trace|string|true|||请求的trace|
+|» data|object|true||||
+|»» tick_list|[object]|true||||
+|»»» code|string|false|||代码|
+|»»» seq|string|false|||报价序号|
+|»»» tick_time|string|false|||报价时间戳|
+|»»» bids|[object]|false|||bid列表|
+|»»»» price|string|false|||价|
+|»»»» volume|string|false|||量|
+|»»» asks|[object]|false|||ask列表|
+|»»»» price|string|false|||价|
+|»»»» volume|string|false|||量|
diff --git "a/http\346\216\245\345\217\243/\351\200\232\347\224\250\346\240\207\345\207\206\345\244\264.md" "b/http\346\216\245\345\217\243/\351\200\232\347\224\250\346\240\207\345\207\206\345\244\264.md"
new file mode 100644
index 0000000..3cfc393
--- /dev/null
+++ "b/http\346\216\245\345\217\243/\351\200\232\347\224\250\346\240\207\345\207\206\345\244\264.md"
@@ -0,0 +1,31 @@
+# 请求通用标准头介绍
+
+| 字段 | 名称 | 类型 | 必填项 | 说明 |
+| ----- | ------ | ------ | ------ | ----------------------------------------------- |
+| trace | 跟踪号 | string | 是 | 请求者生成唯一,响应与请求将保持一致,最大长度64 |
+| data | 数据体 | object | 是 | 具体数据格式见各个接口定义 |
+```json
+{
+ "trace":"asdfsdfa",
+ "data":{
+ }
+}
+```
+
+# 应答通用标准头介绍
+
+| 字段 | 名称 | 类型 | 说明 |
+| ----- | ------ | ------ | ----------------------------------------------- |
+| ret | 返回值 | int32 | [错误码说明](doc-2138451) |
+| msg | 消息 | string | 对成功或者失败具体的描述 |
+| trace | 跟踪号 | string | 请求者生成唯一,响应与请求将保持一致,最大长度64 |
+| data | 数据体 | object | 具体数据格式见各个接口定义 |
+```json
+{
+ "ret":202,
+ "msg":"request data param invalid",
+ "trace":"asdfsdfa",
+ "data":{
+ }
+}
+```
\ No newline at end of file
diff --git "a/token\347\224\263\350\257\267.md" "b/token\347\224\263\350\257\267.md"
new file mode 100644
index 0000000..34daa0b
--- /dev/null
+++ "b/token\347\224\263\350\257\267.md"
@@ -0,0 +1,9 @@
+# 官网地址:https://alltick.co
+
+# Token申请地址:https://alltick.co/register
+
+# 申请流程
+## 第1步:在Token申请地址页面依次填写邮箱,密码(注意大小写,特殊字符,数字),邮箱验证码
+## 第2步:填写完毕,点击"注册"按钮,等待片刻就会申请完毕
+## 第3步:申请完毕,页面会回到仪表盘,就会进入dashboard界面,在"API keys"就能找到你的Token了
+
diff --git "a/websocket\346\216\245\345\217\243/API\345\234\260\345\235\200\350\257\264\346\230\216.md" "b/websocket\346\216\245\345\217\243/API\345\234\260\345\235\200\350\257\264\346\230\216.md"
new file mode 100644
index 0000000..df2ef0e
--- /dev/null
+++ "b/websocket\346\216\245\345\217\243/API\345\234\260\345\235\200\350\257\264\346\230\216.md"
@@ -0,0 +1,27 @@
+# API地址说明
+
+## 股票websocket接口API地址
+
+/quote-stock-b-ws-api 股票订阅API
+
+订阅API为websocket协议,完整的url为:
wss://quote.tradeswitcher.com/quote-stock-b-ws-api
+
+每一次建立连接时,需要带上token信息:
wss://quote.tradeswitcher.com/quote-stock-b-ws-api?token=你的token
+
+建立连接之后,就可以订阅具体的接口数据了,具体调用方式,请查看websocket接口列表
+
+
+
+## 外汇,加密货币(数字币),商品(贵金属) webscoket接口API地址
+
+/quote-b-ws-api 外汇,加密货币(数字币),商品(贵金属) webscoket订阅API
+
+订阅API为websocket协议,完整的url为:
+
+wss://quote.tradeswitcher.com/quote-b-ws-api
+
+每一次建立连接时,需要带上token信息:
+wss://quote.tradeswitcher.com/quote-stock-b-ws-api?token=你的token
+
+建立连接之后,就可以订阅具体的接口数据了,具体调用方式,请查看websocket接口列表
+
diff --git "a/websocket\346\216\245\345\217\243/\345\217\226\346\266\210\346\212\245\344\273\267\350\256\242\351\230\205.md" "b/websocket\346\216\245\345\217\243/\345\217\226\346\266\210\346\212\245\344\273\267\350\256\242\351\230\205.md"
new file mode 100644
index 0000000..703862e
--- /dev/null
+++ "b/websocket\346\216\245\345\217\243/\345\217\226\346\266\210\346\212\245\344\273\267\350\256\242\351\230\205.md"
@@ -0,0 +1,38 @@
+# 接口说明
+# 请求-协议号:22006
+## 数据格式:json
+## 数据结构
+### data定义
+| 字段 | 名称 | 类型 | 必填项 | 说明 |
+| ----------- | -------- | ------ | ------ | ------------------------------------------------------------ |
+| cancel_type | 取消类型 | uint32 | 是 | 0:取消所有报价订阅,1:取消盘口报价订阅,2:取消成交报价订阅 |
+## 请求示例
+```json
+{
+ "cmd_id":22006,
+ "seq_id":123,
+ "trace":"asdfsdfa",
+ "data":{
+ "cancel_type": 1,
+ }
+}
+```
+# 应答-协议号:22007
+## 数据格式:json
+## 数据结构
+### data定义
+| 字段 | 名称 | 类型 | 说明 |
+| --- | --- | --- | --- |
+| | | | |
+## 应答示例
+```json
+{
+ "ret":200,
+ "msg":"ok",
+ "cmd_id":22007,
+ "seq_id":123,
+ "trace":"asdfsdfa",
+ "data":{
+ }
+}
+```
\ No newline at end of file
diff --git "a/websocket\346\216\245\345\217\243/\345\277\203\350\267\263.md" "b/websocket\346\216\245\345\217\243/\345\277\203\350\267\263.md"
new file mode 100644
index 0000000..26b6fdc
--- /dev/null
+++ "b/websocket\346\216\245\345\217\243/\345\277\203\350\267\263.md"
@@ -0,0 +1,36 @@
+# 接口说明
+要求请求者每10秒发送一次,在30秒内如果没有收到心跳请求,就会认为超时,断开请求者的websocket连接
+# 请求-协议号:22000
+## 数据格式:json
+## 数据结构
+### data定义
+| 字段 | 名称 | 类型 | 必填项 | 说明 |
+| --- | --- | --- | --- | --- |
+## 请求示例
+```json
+{
+ "cmd_id":22000,
+ "seq_id":123,
+ "trace":"asdfsdfa",
+ "data":{
+ }
+}
+```
+# 应答-协议号:22001
+## 数据格式:json
+## 数据结构
+### data定义
+| 字段 | 名称 | 类型 | 说明 |
+| --- | --- | --- | --- |
+## 应答示例
+```json
+{
+ "ret":200,
+ "msg":"ok",
+ "cmd_id":22001,
+ "seq_id":123,
+ "trace":"asdfsdfa",
+ "data":{
+ }
+}
+```
\ No newline at end of file
diff --git "a/websocket\346\216\245\345\217\243/\346\210\220\344\272\244\346\212\245\344\273\267\350\256\242\351\230\205.md" "b/websocket\346\216\245\345\217\243/\346\210\220\344\272\244\346\212\245\344\273\267\350\256\242\351\230\205.md"
new file mode 100644
index 0000000..68d9019
--- /dev/null
+++ "b/websocket\346\216\245\345\217\243/\346\210\220\344\272\244\346\212\245\344\273\267\350\256\242\351\230\205.md"
@@ -0,0 +1,78 @@
+# 接口说明
+
+该接口特性为对于每一个websocket连接,每发送一次该请求,后台会默认覆盖上一次订阅请求。订阅成功后会进行推送数据。
+# 请求-协议号:22004
+## 数据格式:json
+## 数据结构
+### data定义
+| 字段 | 名称 | 类型 | 必填项 | 说明 |
+| ----------- | -------- | ----- | ------ | ------------------------ |
+| symbol_list | 产品列表 | array | 是 | 具体格式见下面symbol定义 |
+### symbol定义
+| 字段 | 名称 | 类型 | 必填项 | 说明 |
+| ---- | ---- | ------ | ------ | ------------------------ |
+| code | 代码 | string | 是 | 具体内容,请查阅code列表 |
+## 请求示例
+```json
+{
+ "cmd_id":22004,
+ "seq_id":106254124,
+ "trace":"3baaa938-f92c-4a74-a228-fd49d5e2",
+ "data":{
+ "symbol_list": [
+ {
+ "code": "1288.HK"
+ },{
+ "code": "AAPL.US"
+ },
+ ],
+ }
+}
+```
+# 应答-协议号:22005
+## 数据格式:json
+## 数据结构
+### data定义
+| 字段 | 名称 | 类型 | 说明 |
+| --- | --- | --- | --- |
+| | | | |
+## 应答示例
+```json
+{
+ "ret":200,
+ "msg":"ok",
+ "cmd_id":22005,
+ "seq_id":106254124,
+ "trace":"3baaa938-f92c-4a74-a228-fd49d5e2",
+ "data":{
+ }
+}
+```
+# 推送-协议号:22998
+## 数据格式:json
+## 数据结构
+### data定义
+| 字段 | 名称 | 类型 | 说明 |
+| --------------- | ---------- | ------ | -------------------------- |
+| code | 代码 | string | 具体内容,请查阅code列表 |
+| seq | 报价序号 | string | |
+| tick_time | 报价时间戳 | string | 单位毫秒 |
+| price | 成交价 | string | |
+| volume | 成交量 | string | |
+| turnover | 成交额 | string | |
+| trade_direction | 成交方向 | uint32 | 0为默认值,1为BUY,2为SELL |
+## 应答示例
+```json
+{
+ "cmd_id":22998,
+ "data":{
+ "code": "1288.HK",
+ "seq": "1605509068000001",
+ "tick_time": "1605509068",
+ "price": "651.12",
+ "volume": "300",
+ "turnover": "12345.6",
+ "trade_direction": 1,
+ }
+}
+```
\ No newline at end of file
diff --git "a/websocket\346\216\245\345\217\243/\346\216\245\345\217\243\351\231\220\345\210\266.md" "b/websocket\346\216\245\345\217\243/\346\216\245\345\217\243\351\231\220\345\210\266.md"
new file mode 100644
index 0000000..c6271b8
--- /dev/null
+++ "b/websocket\346\216\245\345\217\243/\346\216\245\345\217\243\351\231\220\345\210\266.md"
@@ -0,0 +1,13 @@
+# websocket接口限制
+
+### websocket接口限制1-IP类限制(免费试用)
+相同的token,相同的IP的,只能建立一个websocket连接
+
+### websocket接口限制2-连接数限制(免费试用)
+为避免过多请求对于后台服务造成过大压力,stock-ws-api的最大连接数限制在100个,视后续服务运行表现再进行调节,超过限制的,则直接断开连接
+
+### websocket接口限制3-接口调用频率限制(免费试用)
+一个websocket连接的多次请求需要间隔1秒发送,比如A在28分30秒时调用了stock-ws-api ,不管是否断开该Websocket连接,如果A接着又调用stock-ws-api ,此时时间还是28分30秒,那第二次请求会被拒绝
+
+### websocket接口限制4-报价订阅限制(免费试用)
+一次订阅,最多只能订阅5个code,如果订阅超过5个,则按5个来订阅
\ No newline at end of file
diff --git "a/websocket\346\216\245\345\217\243/\347\233\230\345\217\243\346\212\245\344\273\267\350\256\242\351\230\205.md" "b/websocket\346\216\245\345\217\243/\347\233\230\345\217\243\346\212\245\344\273\267\350\256\242\351\230\205.md"
new file mode 100644
index 0000000..b0d3c97
--- /dev/null
+++ "b/websocket\346\216\245\345\217\243/\347\233\230\345\217\243\346\212\245\344\273\267\350\256\242\351\230\205.md"
@@ -0,0 +1,95 @@
+# 接口说明
+该接口特性为对于每一个websocket连接,每发送一次该请求,后台会默认覆盖上一次订阅请求。订阅成功后会进行推送数据。
+# 请求-协议号:22002
+## 数据格式:json
+## 数据结构
+### data定义
+| 字段 | 名称 | 类型 | 必填项 | 说明 |
+| ----------- | -------- | ----- | ------ | ------------------------ |
+| symbol_list | 产品列表 | array | 是 | 具体格式见下面symbol定义 |
+### symbol定义
+| 字段 | 名称 | 类型 | 必填项 | 说明 |
+| ----------- | -------- | ------ | ------ | ------------------------------------------------------------ |
+| code | 代码 | string | 是 | 具体内容,请查阅code列表 |
+| depth_level | 深度层级 | uint32 | 否 | 如果没有depth_level字段时,后台只会提供一层的报价,请求的层级大于实际报价层级,或者如果没有depth_level字段时,则后台按实际报价有多少层给多少层 |
+## 请求示例
+```json
+{
+ "cmd_id":22002,
+ "seq_id":123,
+ "trace":"asdfsdfa",
+ "data":{
+ "symbol_list": [
+ {
+ "code": "HK-1288",
+ "depth_level": 5,
+ },
+ ],
+ }
+}
+```
+# 应答-协议号:22003
+## 数据格式:json
+## 数据结构
+### data定义
+| 字段 | 名称 | 类型 | 说明 |
+| --- | --- | --- | --- |
+| | | | |
+
+
+## 应答示例
+```json
+{
+ "ret":200,
+ "msg":"ok",
+ "cmd_id":22003,
+ "seq_id":123,
+ "trace":"asdfsdfa",
+ "data":{
+ }
+}
+```
+# 推送-协议号:22999
+## 数据格式:json
+## 数据结构
+### data定义
+| 字段 | 名称 | 类型 | 说明 |
+| --------- | ---------- | ------ | ------------------------ |
+| code | 代码 | string | 具体内容,请查阅code列表 |
+| seq | 报价序号 | string | |
+| tick_time | 报价时间戳 | string | 单位毫秒 |
+| bids | bid深度 | array | 见下面bids定义 |
+| asks | ask深度 | array | 见下面asks定义 |
+### bids定义
+| 字段 | 名称 | 类型 | 说明 |
+| ------ | ---------------- | ------ | ---- |
+| price | 买一价,买盘价格 | string | |
+| volume | 买一量,买盘量 | string | |
+### asks定义
+| 字段 | 名称 | 类型 | 说明 |
+| ------ | ---------------- | ------ | ---- |
+| price | 买一价,买盘价格 | string | |
+| volume | 买一量,买盘量 | string | |
+## 应答示例
+```json
+{
+ "cmd_id":22999,
+ "data":{
+ "code": "HK-1288",
+ "seq": "1605509068000001",
+ "tick_time": "1605509068",
+ "bids": [
+ {
+ "pric": "9.12",
+ "volume": "9.12",
+ },
+ ],
+ "asks": [
+ {
+ "price": "147.12",
+ "volume": "147.12",
+ },
+ ],
+ }
+}
+```
\ No newline at end of file
diff --git "a/websocket\346\216\245\345\217\243/\351\200\232\347\224\250\346\240\207\345\207\206\345\244\264.md" "b/websocket\346\216\245\345\217\243/\351\200\232\347\224\250\346\240\207\345\207\206\345\244\264.md"
new file mode 100644
index 0000000..df9ccce
--- /dev/null
+++ "b/websocket\346\216\245\345\217\243/\351\200\232\347\224\250\346\240\207\345\207\206\345\244\264.md"
@@ -0,0 +1,39 @@
+# 请求通用标准头介绍
+
+| 字段 | 名称 | 类型 | 必填项 | 说明 |
+| ------ | ------ | ------ | ---------------------- | ----------------------------------------------- |
+| cmd_id | 协议号 | uint32 | 详见各个接口定义有提供 | |
+| seq_id | 序列号 | uint32 | 是 | 请求者生成唯一,响应与请求将保持一致 |
+| trace | 跟踪号 | string | 是 | 请求者生成唯一,响应与请求将保持一致,最大长度64 |
+| data | 数据体 | object | 是 | 具体数据格式见各个接口定义 |
+```json
+{
+ "cmd_id":22000,
+ "seq_id":123,
+ "trace":"asdfsdfa",
+ "data":{
+ }
+}
+```
+
+# 应答通用标准头介绍
+
+| 字段 | 名称 | 类型 | 说明 |
+| ------ | ------ | ------ | ----------------------------------------------- |
+| ret | 返回值 | int32 | [错误码说明](doc-2138451) |
+| msg | 消息 | string | 对成功或者失败具体的描述 |
+| cmd_id | 协议号 | uint32 | 详见各个接口定义有提供 |
+| seq_id | 序列号 | uint32 | 请求者生成唯一,响应与请求将保持一致 |
+| trace | 跟踪号 | string | 请求者生成唯一,响应与请求将保持一致,最大长度64 |
+| data | 数据体 | object | 具体数据格式见各个接口定义 |
+```json
+{
+ "ret":201,
+ "msg":"request header param invalid",
+ "cmd_id":0,
+ "seq_id":0,
+ "trace":"",
+ "data":{
+ }
+}
+```
\ No newline at end of file
diff --git "a/\344\272\247\345\223\201code\345\210\227\350\241\250-A\350\202\241.md" "b/\344\272\247\345\223\201code\345\210\227\350\241\250-A\350\202\241.md"
new file mode 100644
index 0000000..e5936ce
--- /dev/null
+++ "b/\344\272\247\345\223\201code\345\210\227\350\241\250-A\350\202\241.md"
@@ -0,0 +1,18 @@
+# 免费试用Token仅支持以下code
+
+## 需要更多产品可直接联系:
+- Telegram: https://t.me/TS_SUPPORT_Lester
+- Email: lester.lin@chixi88.com
+
+| code | 名称 |
+| ------- | ------------------------- |
+| 000627.SZ | 天茂集团 |
+| 600416.SH | 湘电股份 |
+| 002009.SZ | 天奇股份 |
+| 600206.SH | 有研新材 |
+| 600076.SH | 康欣新材 |
+| 600152.SH | 维科技术 |
+| 000690.SZ | 宝新能源 |
+| 000415.SZ | 渤海租赁 |
+| 002035.SZ | 华帝股份 |
+| 000055.SZ | 方大集团 |
\ No newline at end of file
diff --git "a/\344\272\247\345\223\201code\345\210\227\350\241\250-\345\212\240\345\257\206\350\264\247\345\270\201(\346\225\260\345\255\227\345\270\201).md" "b/\344\272\247\345\223\201code\345\210\227\350\241\250-\345\212\240\345\257\206\350\264\247\345\270\201(\346\225\260\345\255\227\345\270\201).md"
new file mode 100644
index 0000000..36d0e8f
--- /dev/null
+++ "b/\344\272\247\345\223\201code\345\210\227\350\241\250-\345\212\240\345\257\206\350\264\247\345\270\201(\346\225\260\345\255\227\345\270\201).md"
@@ -0,0 +1,18 @@
+# 免费试用Token仅支持以下code
+
+## 需要更多产品可直接联系:
+- Telegram: https://t.me/TS_SUPPORT_Lester
+- Email: lester.lin@chixi88.com
+
+| 类别 | name | code |
+| --- | --- | --- |
+|加密货币|AAVE/USDT|AAVEUSDT|
+|加密货币|ADA/USDT|ADAUSDT|
+|加密货币|ALGO/USDT|ALGOUSDT|
+|加密货币|APE/USDT|APEUSDT|
+|加密货币|ATOM/USDT|ATOMUSDT|
+|加密货币|AVAX/USDT|AVAXUSDT|
+|加密货币|AXS/USDT|AXSUSDT|
+|加密货币|BCH/USDT|BCHUSDT|
+|加密货币|BNB/USDT|BNBUSDT|
+|加密货币|BTC/USDT|BTCUSDT|
\ No newline at end of file
diff --git "a/\344\272\247\345\223\201code\345\210\227\350\241\250-\345\225\206\345\223\201(\350\264\265\351\207\221\345\261\236).md" "b/\344\272\247\345\223\201code\345\210\227\350\241\250-\345\225\206\345\223\201(\350\264\265\351\207\221\345\261\236).md"
new file mode 100644
index 0000000..40e4e17
--- /dev/null
+++ "b/\344\272\247\345\223\201code\345\210\227\350\241\250-\345\225\206\345\223\201(\350\264\265\351\207\221\345\261\236).md"
@@ -0,0 +1,18 @@
+# 免费试用Token仅支持以下code
+
+## 需要更多产品可直接联系:
+- Telegram: https://t.me/TS_SUPPORT_Lester
+- Email: lester.lin@chixi88.com
+
+| 类别 | name | code |
+| --- | --- | --- |
+| 商品 | UKOIL | UKOIL |
+| 商品 | USOIL | USOIL |
+| 商品 | Silver | Silver |
+| 商品 | Aluminum | Aluminum |
+| 商品 | GOLD | GOLD |
+| 商品 | COPPER | COPPER |
+| 商品 | NGAS | NGAS |
+| 商品 | Palladium | Palladium |
+| 商品 | Platinum | Platinum |
+| 商品 | Nickel | Nickel |
\ No newline at end of file
diff --git "a/\344\272\247\345\223\201code\345\210\227\350\241\250-\345\244\226\346\261\207.md" "b/\344\272\247\345\223\201code\345\210\227\350\241\250-\345\244\226\346\261\207.md"
new file mode 100644
index 0000000..56a4287
--- /dev/null
+++ "b/\344\272\247\345\223\201code\345\210\227\350\241\250-\345\244\226\346\261\207.md"
@@ -0,0 +1,18 @@
+# 免费试用Token仅支持以下code
+
+## 需要更多产品可直接联系:
+- Telegram: https://t.me/TS_SUPPORT_Lester
+- Email: lester.lin@chixi88.com
+
+| 类别 | name | code |
+| --- | --- | --- |
+| 外汇 | AUD/JPY | AUDJPY |
+| 外汇 | AUD/NZD | AUDNZD |
+| 外汇 | AUD/USD | AUDUSD |
+| 外汇 | CAD/CHF | CADCHF |
+| 外汇 | CAD/JPY | CADJPY |
+| 外汇 | CHF/JPY | CHFJPY |
+| 外汇 | EUR/AUD | EURAUD |
+| 外汇 | EUR/CAD | EURCAD |
+| 外汇 | EUR/CHF | EURCHF |
+| 外汇 | EUR/GBP | EURGBP |
\ No newline at end of file
diff --git "a/\344\272\247\345\223\201code\345\210\227\350\241\250-\346\270\257\350\202\241.md" "b/\344\272\247\345\223\201code\345\210\227\350\241\250-\346\270\257\350\202\241.md"
new file mode 100644
index 0000000..5f9c345
--- /dev/null
+++ "b/\344\272\247\345\223\201code\345\210\227\350\241\250-\346\270\257\350\202\241.md"
@@ -0,0 +1,18 @@
+# 免费试用Token仅支持以下code
+
+## 需要更多产品可直接联系:
+- Telegram: https://t.me/TS_SUPPORT_Lester
+- Email: lester.lin@chixi88.com
+
+| code | 名称 |
+| ------- | ------------------------- |
+| 700.HK | 腾讯控股 |
+| 9988.HK | 阿里巴巴 |
+| 1398.HK | 工商银行 |
+| 939.HK | 建设银行 |
+| 1288.HK | 农业银行 |
+| 857.HK | 中国石油股份 |
+| 941.HK | 中国移动 |
+| 3690.HK | 美团 |
+| 3988.HK | 中國銀行 |
+| 3968.HK | 招商銀行 |
\ No newline at end of file
diff --git "a/\344\272\247\345\223\201code\345\210\227\350\241\250-\347\276\216\350\202\241.md" "b/\344\272\247\345\223\201code\345\210\227\350\241\250-\347\276\216\350\202\241.md"
new file mode 100644
index 0000000..d130fae
--- /dev/null
+++ "b/\344\272\247\345\223\201code\345\210\227\350\241\250-\347\276\216\350\202\241.md"
@@ -0,0 +1,18 @@
+# 免费试用Token仅支持以下code
+
+## 需要更多产品可直接联系:
+- Telegram: https://t.me/TS_SUPPORT_Lester
+- Email: lester.lin@chixi88.com
+
+| code | 名称 |
+| ------- | ------------------------- |
+| AAPL.US | Apple, Inc. |
+| MSFT.US | Microsoft Corp. |
+| GOOG.US | Alphabet, Inc. |
+| AMZN.US | Amazon.com, Inc. |
+| TSLA.US | Tesla, Inc. |
+| UNH.US | UnitedHealth Group, Inc. |
+| JNJ.US | Johnson & Johnson |
+| META.US | Meta Platforms, Inc. |
+| V.US | Visa, Inc. |
+| XOM.US | Exxon Mobil Corp. |
\ No newline at end of file
diff --git "a/\346\216\245\345\205\245\346\214\207\345\215\227.md" "b/\346\216\245\345\205\245\346\214\207\345\215\227.md"
new file mode 100644
index 0000000..d63a96f
--- /dev/null
+++ "b/\346\216\245\345\205\245\346\214\207\345\215\227.md"
@@ -0,0 +1,72 @@
+# 简介
+本文档主要目的是对外提供免费的行情接口快速接入方法。
+主要功能如下:
+- 获取港股实时行情API
+- 获取港股实时10档盘口API
+- 获取港股K线数据API
+- 获取美股实时行情API
+- 获取美股实时一档盘口API
+- 获取美股K线数据API
+- 获取沪深A股实时行情API
+- 获取沪深A股实时5档盘口API
+- 获取沪深A股K线数据API
+- 获取加密货币实时行情API
+- 获取加密货币实时多档盘口API
+- 获取加密货币K线数据API
+- 获取外汇实时行情API
+- 获取外汇实时5档盘口API
+
+- 获取外汇K线数据API
+
+- 获取贵金属实时行情API
+
+- 获取贵金属实时5档盘口API
+
+- 获取贵金属K线数据API
+
+# 接口分类
+接口分为http接口和websocket接口两大类。
+
+## http接口主要提供:
+- K线查询
+- 批量K线查询
+- 最新盘口报价查询
+- 最新成交报价查询
+
+## websocket接口主要提供:
+- 心跳
+- 盘口报价订阅
+- 成交报价订阅
+- 订阅取消
+
+# 接入流程
+### 第1步:通过行情地址说明文档了解接口的访问url以及请求时携带的参数
+- [http行情API地址说明](./http接口/API地址说明.md)
+- [websocket行情API地址说明](./websocket接口/API地址说明.md)
+### 第2步:申请属于你的token
+- [token申请](./token申请.md)
+### 第3步:请看接口限制说明文档,了解调用时应该有那些需要注意的地方,避免调用被拒绝
+- [http接口限制](./http接口/接口限制.md)
+- [websocket接口限制](./websocket接口/接口限制.md)
+- [错误码说明](./错误码说明.md)
+### 第4步:请查看通用标准头说明文档,了解请求和响应的数据格式如何
+- [http通用标准头](./http接口/通用标准头.md)
+- [websocket通用标准头](./websocket接口/通用标准头.md)
+### 第5步:请查看code列表文档,好决定要那一个产品的行情数据
+- [产品code列表-A股](./产品code列表-A股.md)
+- [产品code列表-港股](./产品code列表-港股.md)
+- [产品code列表-加密货币(数字币)](./产品code列表-加密货币(数字币).md)
+- [产品code列表-美股](./产品code列表-美股.md)
+- [产品code列表-商品(贵金属)](./产品code列表-商品(贵金属).md)
+- [产品code列表-外汇](./产品code列表-外汇.md)
+### 第6步:请求具体接口获取你想要的数据
+#### http接口
+- [获取最新成交报价查询](./http接口/最新成交报价查询.md)
+- [最新盘口报价查询](./http接口/最新盘口报价查询.md)
+- [K线查询](./http接口/K线查询.md)
+- [批量K线查询](./http接口/批量K线查询.md)
+#### websocket接口
+- [心跳](./websocket接口/心跳.md)
+- [成交报价订阅](./websocket接口/成交报价订阅.md)
+- [盘口报价订阅](./websocket接口/盘口报价订阅.md)
+- [取消报价订阅](./websocket接口/取消报价订阅.md)
diff --git "a/\351\224\231\350\257\257\347\240\201\350\257\264\346\230\216.md" "b/\351\224\231\350\257\257\347\240\201\350\257\264\346\230\216.md"
new file mode 100644
index 0000000..f1b6c8d
--- /dev/null
+++ "b/\351\224\231\350\257\257\347\240\201\350\257\264\346\230\216.md"
@@ -0,0 +1,11 @@
+# 错误码说明
+
+| 错误码 | 含义 |
+| ------ | ---------------------------- |
+| 200 | ok |
+| 400 | request header param invalid |
+| 400 | request data param invalid |
+| 401 | token invalid |
+| 429 | rate limit |
+| 600 | code invalid |
+| 601 | body empty |
\ No newline at end of file