2022-04-08 11:21:57 +00:00
|
|
|
# GRPC server
|
|
|
|
|
|
|
|
## Integrating GRPC services
|
|
|
|
|
|
|
|
### Install Evans
|
|
|
|
|
|
|
|
```shell
|
2022-04-12 12:40:24 +00:00
|
|
|
brew tap ktr0731/evans
|
|
|
|
brew install evans
|
2022-04-08 11:21:57 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
Start your bbgo with gRPC server option:
|
|
|
|
|
|
|
|
```shell
|
|
|
|
go run ./cmd/bbgo run --config grid_kucoin.yaml --debug --enable-grpc
|
|
|
|
```
|
|
|
|
|
2022-04-13 12:33:42 +00:00
|
|
|
The gRPC server port is located at 50051 (default port), you can use evans to connect to the gRPC server:
|
2022-04-08 11:21:57 +00:00
|
|
|
|
|
|
|
```shell
|
2022-04-13 12:33:42 +00:00
|
|
|
evans --host localhost --port 50051 -r repl
|
2022-04-08 11:21:57 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
```shell
|
|
|
|
bbgo@localhost:6688> package bbgo
|
|
|
|
bbgo@localhost:6688> show service
|
|
|
|
bbgo@localhost:6688> show message
|
|
|
|
```
|
|
|
|
|
|
|
|
You can use evans to get the description of a message:
|
|
|
|
|
|
|
|
```shell
|
|
|
|
bbgo@localhost:6688> desc QueryKLinesRequest
|
|
|
|
+-----------+-------------+----------+
|
|
|
|
| FIELD | TYPE | REPEATED |
|
|
|
|
+-----------+-------------+----------+
|
|
|
|
| exchange | TYPE_STRING | false |
|
|
|
|
| interval | TYPE_STRING | false |
|
|
|
|
| limit | TYPE_INT64 | false |
|
|
|
|
| symbol | TYPE_STRING | false |
|
|
|
|
| timestamp | TYPE_INT64 | false |
|
|
|
|
+-----------+-------------+----------+
|
|
|
|
```
|
|
|
|
|
|
|
|
|
2022-04-13 12:33:42 +00:00
|
|
|
You can send the request via evans:
|
2022-04-08 11:21:57 +00:00
|
|
|
|
2022-04-13 12:33:42 +00:00
|
|
|
```shell
|
|
|
|
evans -r cli call --file evans/userDataService/subscribe.json bbgo.UserDataService.Subscribe
|
|
|
|
evans -r cli call --file evans/marketDataService/subscribe_kline.json bbgo.MarketDataService.Subscribe
|
|
|
|
```
|
2022-04-08 11:21:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
|