Skip to content
This repository was archived by the owner on Aug 12, 2024. It is now read-only.

Commit d8e59db

Browse files
authored
Merge pull request #3 from sh7ning-mirror/master
v2
2 parents d0f1b0d + 2a75db8 commit d8e59db

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+5163
-1500
lines changed

.dockerignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
.idea
2+
vendor
3+
4+
config*.yaml
5+
!config.example.yaml
6+
7+
kucoin-market-for-linux
8+
kucoin-market-for-mac
9+
kucoin-market-for-windows.exe
10+
kucoin_market
11+
12+
runtime/*
13+
14+
demo/*

.env

Lines changed: 0 additions & 16 deletions
This file was deleted.

.env-sandbox

Lines changed: 0 additions & 16 deletions
This file was deleted.

.gitignore

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
.idea
22
vendor
3-
kucoin_market
4-
.env.local
5-
__pycache__
6-
go.sum
3+
4+
config*.yaml
5+
!config.example.yaml
6+
77
kucoin-market-for-linux
88
kucoin-market-for-mac
9-
kucoin-market-for-windows.exe
9+
kucoin-market-for-windows.exe
10+
kucoin_market

Dockerfile

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ RUN export GO111MODULE=on \
77
COPY . /go/src/github.com/Kucoin/kucoin-level3-sdk
88

99
RUN cd /go/src/github.com/Kucoin/kucoin-level3-sdk \
10-
&& CGO_ENABLED=0 go build -ldflags '-s -w' -o /go/bin/kucoin_market kucoin_market.go
10+
&& CGO_ENABLED=0 go build -ldflags '-s -w' -o /go/bin/kucoin_market cmd/main/market.go
1111

1212
FROM debian:stretch
1313

@@ -22,7 +22,4 @@ VOLUME /app
2222

2323
EXPOSE 9090
2424

25-
COPY docker-entrypoint.sh /usr/local/bin/
26-
ENTRYPOINT ["docker-entrypoint.sh"]
27-
28-
CMD ["kucoin_market", "-c", "/app/.env", "-symbol", "BTC-USDT", "-p", "9090", "-rpckey", "BTC-USDT"]
25+
CMD ["kucoin_market", "start", "-c", "config.yaml"]

README.md

Lines changed: 58 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,53 @@
1-
# Kucoin Level3 market
1+
# Kucoin Level3 Market
22

3-
## guide
3+
## Guide
44
[中文文档](README_CN.md)
55

66
## Installation
77

8-
1. install dependencies
8+
1. build
99

1010
```
11-
go get github.com/JetBlink/orderbook
12-
go get github.com/go-redis/redis
13-
go get github.com/gorilla/websocket
14-
go get github.com/joho/godotenv
15-
go get github.com/Kucoin/kucoin-go-sdk
16-
go get github.com/shopspring/decimal
17-
```
18-
19-
2. build
20-
21-
```
22-
CGO_ENABLED=0 go build -ldflags '-s -w' -o kucoin_market kucoin_market.go
11+
CGO_ENABLED=0 go build -ldflags '-s -w' -o kucoin_market cmd/main/market.go
2312
```
2413

2514
or you can download the latest available [release](https://github.com/Kucoin/kucoin-level3-sdk/releases)
2615

2716
## Usage
2817

29-
1. [vim .env](.env):
30-
```
31-
# API_SKIP_VERIFY_TLS=1
32-
33-
API_BASE_URI=https://api.kucoin.com
18+
1. [vim config.yaml](config.example.yaml):
19+
```
20+
app_debug: true
3421
35-
# If open order book true otherwise false
36-
ENABLE_ORDER_BOOK=true
22+
symbol: KCS-USDT
23+
#symbol: XBTUSDM
3724
38-
# If open event watcher true otherwise false
39-
ENABLE_EVENT_WATCHER=true
25+
app:
26+
name: market
27+
log_file: "./runtime/log/market.log"
4028
41-
# Password for RPS calls. Pass the same when calling
42-
RPC_TOKEN=market-token
29+
api_server:
30+
network: tcp
31+
address: 0.0.0.0:9090
32+
token: your-rpc-token
4333
44-
REDIS_HOST=127.0.0.1:6379
45-
REDIS_PASSWORD=
46-
REDIS_DB=
34+
market.kucoin_v2:
35+
url: "https://api.kucoin.com"
36+
type: "spot"
37+
# url: "https://api-futures.kucoin.com"
38+
# type: "future"
39+
40+
redis:
41+
addr: 127.0.0.1:6379
42+
password: ""
43+
db: 0
4744
```
4845
4946
1. Run Command:
5047
5148
```
52-
./kucoin_market -c .env -symbol BTC-USDT -p 9090 -rpckey BTC-USDT
49+
./kucoin_market start -c config.yaml
5350
```
54-
5551
5652
## Docker Usage
5753
@@ -61,47 +57,64 @@ or you can download the latest available [release](https://github.com/Kucoin/kuc
6157
docker build -t kucoin_market .
6258
```
6359
64-
1. [vim .env](.env)
60+
1. [vim config.yaml](config.example.yaml):
61+
```
62+
app_debug: true
63+
64+
symbol: KCS-USDT
65+
#symbol: XBTUSDM
66+
67+
app:
68+
name: market
69+
log_file: "./runtime/log/market.log"
70+
71+
api_server:
72+
network: tcp
73+
address: 0.0.0.0:9090
74+
token: your-rpc-token
75+
76+
market.kucoin_v2:
77+
url: "https://api.kucoin.com"
78+
type: "spot"
79+
# url: "https://api-futures.kucoin.com"
80+
# type: "future"
81+
82+
redis:
83+
addr: 127.0.0.1:6379
84+
password: ""
85+
db: 0
86+
```
6587
6688
1. Run
6789
6890
```
69-
docker run --rm -it -v $(pwd)/.env:/app/.env --net=host kucoin_market
91+
docker run --rm -it -v $(pwd)/config.yaml:/app/config.yaml --net=host kucoin_market
7092
```
7193
7294
## RPC Method
7395
74-
> endpoint : 127.0.0.1:9090
96+
> default endpoint : 127.0.0.1:9090
7597
> the sdk rpc is based on golang jsonrpc 1.0 over tcp.
7698
7799
see:[python jsonrpc client demo](./demo/python-demo/level3/rpc.py)
78100
79101
* Get Part Order Book
80102
```
81-
{"method": "Server.GetPartOrderBook", "params": [{"token": "your-rpc-token", "number": 1}], "id": 0}
82-
```
83-
84-
* Get Full Order Book
85-
```
86-
{"method": "Server.GetOrderBook", "params": [{"token": "your-rpc-token"}], "id": 0}
103+
{"method": "Server.GetOrderBook", "params": [{"token": "your-rpc-token", "number": 1}], "id": 0}
87104
```
88105
89106
* Add Event ClientOids To Channels
90107
```
91108
{"method": "Server.AddEventClientOidsToChannels", "params": [{"token": "your-rpc-token", "data": {"clientOid": ["channel-1", "channel-2"]}}], "id": 0}
92109
```
93110
94-
* Add Event OrderIds To Channels
95-
```
96-
{"method": "Server.AddEventOrderIdsToChannels", "params": [{"token": "your-rpc-token", "data": {"orderId": ["channel-1", "channel-2"]}}], "id": 0}
97-
```
98111
## Python-Demo
99112
100113
> the demo including orderbook display
101114
102115
see:[python use_level3 demo](./demo/python-demo/order_book_demo.py)
103116
- Run order_book.py
104117
```
105-
command: python order_book.py
118+
command: python3 order_book_demo.py
106119
describe: display orderbook
107120
```

0 commit comments

Comments
 (0)