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

Commit

Permalink
Merge pull request #3 from sh7ning-mirror/master
Browse files Browse the repository at this point in the history
v2
  • Loading branch information
Ive20 authored Oct 12, 2020
2 parents d0f1b0d + 2a75db8 commit d8e59db
Show file tree
Hide file tree
Showing 78 changed files with 5,163 additions and 1,500 deletions.
14 changes: 14 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.idea
vendor

config*.yaml
!config.example.yaml

kucoin-market-for-linux
kucoin-market-for-mac
kucoin-market-for-windows.exe
kucoin_market

runtime/*

demo/*
16 changes: 0 additions & 16 deletions .env

This file was deleted.

16 changes: 0 additions & 16 deletions .env-sandbox

This file was deleted.

11 changes: 6 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
.idea
vendor
kucoin_market
.env.local
__pycache__
go.sum

config*.yaml
!config.example.yaml

kucoin-market-for-linux
kucoin-market-for-mac
kucoin-market-for-windows.exe
kucoin-market-for-windows.exe
kucoin_market
7 changes: 2 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ RUN export GO111MODULE=on \
COPY . /go/src/github.com/Kucoin/kucoin-level3-sdk

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

FROM debian:stretch

Expand All @@ -22,7 +22,4 @@ VOLUME /app

EXPOSE 9090

COPY docker-entrypoint.sh /usr/local/bin/
ENTRYPOINT ["docker-entrypoint.sh"]

CMD ["kucoin_market", "-c", "/app/.env", "-symbol", "BTC-USDT", "-p", "9090", "-rpckey", "BTC-USDT"]
CMD ["kucoin_market", "start", "-c", "config.yaml"]
103 changes: 58 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,57 +1,53 @@
# Kucoin Level3 market
# Kucoin Level3 Market

## guide
## Guide
[中文文档](README_CN.md)

## Installation

1. install dependencies
1. build

```
go get github.com/JetBlink/orderbook
go get github.com/go-redis/redis
go get github.com/gorilla/websocket
go get github.com/joho/godotenv
go get github.com/Kucoin/kucoin-go-sdk
go get github.com/shopspring/decimal
```

2. build

```
CGO_ENABLED=0 go build -ldflags '-s -w' -o kucoin_market kucoin_market.go
CGO_ENABLED=0 go build -ldflags '-s -w' -o kucoin_market cmd/main/market.go
```

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

## Usage

1. [vim .env](.env):
```
# API_SKIP_VERIFY_TLS=1
API_BASE_URI=https://api.kucoin.com
1. [vim config.yaml](config.example.yaml):
```
app_debug: true
# If open order book true otherwise false
ENABLE_ORDER_BOOK=true
symbol: KCS-USDT
#symbol: XBTUSDM
# If open event watcher true otherwise false
ENABLE_EVENT_WATCHER=true
app:
name: market
log_file: "./runtime/log/market.log"
# Password for RPS calls. Pass the same when calling
RPC_TOKEN=market-token
api_server:
network: tcp
address: 0.0.0.0:9090
token: your-rpc-token
REDIS_HOST=127.0.0.1:6379
REDIS_PASSWORD=
REDIS_DB=
market.kucoin_v2:
url: "https://api.kucoin.com"
type: "spot"
# url: "https://api-futures.kucoin.com"
# type: "future"
redis:
addr: 127.0.0.1:6379
password: ""
db: 0
```
1. Run Command:
```
./kucoin_market -c .env -symbol BTC-USDT -p 9090 -rpckey BTC-USDT
./kucoin_market start -c config.yaml
```
## Docker Usage
Expand All @@ -61,47 +57,64 @@ or you can download the latest available [release](https://github.com/Kucoin/kuc
docker build -t kucoin_market .
```
1. [vim .env](.env)
1. [vim config.yaml](config.example.yaml):
```
app_debug: true
symbol: KCS-USDT
#symbol: XBTUSDM
app:
name: market
log_file: "./runtime/log/market.log"
api_server:
network: tcp
address: 0.0.0.0:9090
token: your-rpc-token
market.kucoin_v2:
url: "https://api.kucoin.com"
type: "spot"
# url: "https://api-futures.kucoin.com"
# type: "future"
redis:
addr: 127.0.0.1:6379
password: ""
db: 0
```
1. Run
```
docker run --rm -it -v $(pwd)/.env:/app/.env --net=host kucoin_market
docker run --rm -it -v $(pwd)/config.yaml:/app/config.yaml --net=host kucoin_market
```
## RPC Method
> endpoint : 127.0.0.1:9090
> default endpoint : 127.0.0.1:9090
> the sdk rpc is based on golang jsonrpc 1.0 over tcp.
see:[python jsonrpc client demo](./demo/python-demo/level3/rpc.py)
* Get Part Order Book
```
{"method": "Server.GetPartOrderBook", "params": [{"token": "your-rpc-token", "number": 1}], "id": 0}
```
* Get Full Order Book
```
{"method": "Server.GetOrderBook", "params": [{"token": "your-rpc-token"}], "id": 0}
{"method": "Server.GetOrderBook", "params": [{"token": "your-rpc-token", "number": 1}], "id": 0}
```
* Add Event ClientOids To Channels
```
{"method": "Server.AddEventClientOidsToChannels", "params": [{"token": "your-rpc-token", "data": {"clientOid": ["channel-1", "channel-2"]}}], "id": 0}
```
* Add Event OrderIds To Channels
```
{"method": "Server.AddEventOrderIdsToChannels", "params": [{"token": "your-rpc-token", "data": {"orderId": ["channel-1", "channel-2"]}}], "id": 0}
```
## Python-Demo
> the demo including orderbook display
see:[python use_level3 demo](./demo/python-demo/order_book_demo.py)
- Run order_book.py
```
command: python order_book.py
command: python3 order_book_demo.py
describe: display orderbook
```
Loading

0 comments on commit d8e59db

Please sign in to comment.