mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-21 22:43:52 +00:00
feature: basic grpc server (#514)
This commit is contained in:
parent
ed57ae6eb9
commit
4cd646e346
33
Makefile
33
Makefile
|
@ -108,8 +108,6 @@ bbgo-slim-dnum-darwin-amd64: $(BIN_DIR)
|
|||
bbgo-slim-dnum-darwin: bbgo-slim-dnum-darwin-amd64 bbgo-slim-dnum-darwin-arm64
|
||||
|
||||
|
||||
clean:
|
||||
rm -rf $(BUILD_DIR) $(DIST_DIR) $(FRONTEND_EXPORT_DIR)
|
||||
|
||||
$(OSX_APP_CONTENTS_DIR):
|
||||
mkdir -p $@
|
||||
|
@ -235,10 +233,31 @@ embed: pkg/server/assets.go
|
|||
|
||||
static: frontend/out/index.html pkg/server/assets.go
|
||||
|
||||
.PHONY: bbgo bbgo-slim-darwin bbgo-slim-darwin-amd64 bbgo-slim-darwin-arm64 bbgo-darwin version dist pack migrations static embed desktop .FORCE
|
||||
|
||||
protobuf:
|
||||
protoc -I=$(PWD)/pkg/pb --go_out=$(PWD)/pkg/pb $(PWD)/pkg/pb/bbgo.proto
|
||||
PROTOS := \
|
||||
$(wildcard pkg/pb/*.proto)
|
||||
|
||||
protobuf-py:
|
||||
python -m grpc_tools.protoc -I$(PWD)/pkg/pb --python_out=$(PWD)/python/bbgo --grpc_python_out=$(PWD)/python/bbgo $(PWD)/pkg/pb/bbgo.proto
|
||||
GRPC_GO_DEPS := $(subst .proto,.pb.go,$(PROTOS))
|
||||
|
||||
%.pb.go: %.proto .FORCE
|
||||
protoc --go-grpc_out=. --go-grpc_opt=paths=source_relative --go_out=paths=source_relative:. --proto_path=. $<
|
||||
|
||||
grpc-go: $(GRPC_GO_DEPS)
|
||||
|
||||
grpc: grpc-go grpc-py
|
||||
|
||||
install-grpc-tools:
|
||||
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.26
|
||||
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.1
|
||||
pip install grpcio-tools
|
||||
|
||||
grpc-py:
|
||||
python -m grpc_tools.protoc -I$(PWD)/pkg/pb \
|
||||
--python_out=$(PWD)/python/bbgo \
|
||||
--grpc_python_out=$(PWD)/python/bbgo \
|
||||
$(PWD)/pkg/pb/bbgo.proto
|
||||
|
||||
clean:
|
||||
rm -rf $(BUILD_DIR) $(DIST_DIR) $(FRONTEND_EXPORT_DIR) $(GRPC_GO_DEPS) pkg/pb/*.pb.go
|
||||
|
||||
.PHONY: bbgo bbgo-slim-darwin bbgo-slim-darwin-amd64 bbgo-slim-darwin-arm64 bbgo-darwin version dist pack migrations static embed desktop grpc grpc-go grpc-py .FORCE
|
||||
|
|
48
doc/topics/grpc.md
Normal file
48
doc/topics/grpc.md
Normal file
|
@ -0,0 +1,48 @@
|
|||
# GRPC server
|
||||
|
||||
## Integrating GRPC services
|
||||
|
||||
### Install Evans
|
||||
|
||||
```shell
|
||||
brew install evans
|
||||
```
|
||||
|
||||
Start your bbgo with gRPC server option:
|
||||
|
||||
```shell
|
||||
go run ./cmd/bbgo run --config grid_kucoin.yaml --debug --enable-grpc
|
||||
```
|
||||
|
||||
The gRPC server port is located at 6688, you can use evans to connect to the gRPC server:
|
||||
|
||||
```shell
|
||||
evans --host localhost --port 6688 -r repl
|
||||
```
|
||||
|
||||
```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 |
|
||||
+-----------+-------------+----------+
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
10
go.mod
10
go.mod
|
@ -40,7 +40,8 @@ require (
|
|||
go.uber.org/multierr v1.7.0
|
||||
golang.org/x/time v0.0.0-20201208040808-7e3f01d25324
|
||||
gonum.org/v1/gonum v0.8.1
|
||||
google.golang.org/protobuf v1.27.1
|
||||
google.golang.org/grpc v1.45.0
|
||||
google.golang.org/protobuf v1.28.0
|
||||
gopkg.in/tucnak/telebot.v2 v2.5.0
|
||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
|
||||
)
|
||||
|
@ -101,11 +102,12 @@ require (
|
|||
go.opentelemetry.io/otel/trace v0.19.0 // indirect
|
||||
go.uber.org/atomic v1.9.0 // indirect
|
||||
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad // indirect
|
||||
golang.org/x/net v0.0.0-20211205041911-012df41ee64c // indirect
|
||||
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 // indirect
|
||||
golang.org/x/net v0.0.0-20220403103023-749bd193bc2b // indirect
|
||||
golang.org/x/sys v0.0.0-20220406163625-3f8b81556e12 // indirect
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
|
||||
golang.org/x/text v0.3.7 // indirect
|
||||
golang.org/x/tools v0.1.9 // indirect
|
||||
google.golang.org/genproto v0.0.0-20220405205423-9d709892a2bf // indirect
|
||||
gopkg.in/ini.v1 v1.62.0 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
nhooyr.io/websocket v1.8.7 // indirect
|
||||
|
|
39
go.sum
39
go.sum
|
@ -45,6 +45,7 @@ github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuy
|
|||
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho=
|
||||
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
|
||||
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
|
||||
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY=
|
||||
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
|
||||
|
@ -75,6 +76,11 @@ github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5P
|
|||
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
|
||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
|
||||
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
|
||||
github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI=
|
||||
github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
|
||||
github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
|
||||
github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
|
||||
github.com/cockroachdb/apd v1.1.0 h1:3LFP3629v+1aKXU5Q37mxmRxX/pIu1nijXydLShEq5I=
|
||||
github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ=
|
||||
github.com/codingconcepts/env v0.0.0-20200821220118-a8fbf8d84482 h1:5/aEFreBh9hH/0G+33xtczJCvMaulqsm9nDuu2BZUEo=
|
||||
|
@ -98,6 +104,8 @@ github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8
|
|||
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
|
||||
github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
|
||||
github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0=
|
||||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||
github.com/fastly/go-utils v0.0.0-20180712184237-d95a45783239 h1:Ghm4eQYC0nEPnSJdVkTrXpu9KtoVCSo1hg7mtI7G9KU=
|
||||
github.com/fastly/go-utils v0.0.0-20180712184237-d95a45783239/go.mod h1:Gdwt2ce0yfBxPvZrHkprdPPTTS3N5rwmLE8T22KBXlw=
|
||||
|
@ -211,6 +219,7 @@ github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hf
|
|||
github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
|
||||
github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
|
||||
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
||||
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
|
||||
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
|
||||
|
@ -223,6 +232,7 @@ github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/ad
|
|||
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
|
||||
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
|
||||
github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
|
||||
github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
|
||||
github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q=
|
||||
github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8=
|
||||
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
|
||||
|
@ -397,6 +407,7 @@ github.com/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5/go.mod h1:GEXHk5H
|
|||
github.com/robfig/cron/v3 v3.0.0 h1:kQ6Cb7aHOHTSzNVNEhmp8EcWKLb4CbiMW9h9VyIhO4E=
|
||||
github.com/robfig/cron/v3 v3.0.0/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
|
||||
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
|
||||
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
|
||||
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||
github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
|
||||
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
|
@ -489,6 +500,7 @@ go.opentelemetry.io/otel/oteltest v0.19.0 h1:YVfA0ByROYqTwOxqHVZYZExzEpfZor+MU1r
|
|||
go.opentelemetry.io/otel/oteltest v0.19.0/go.mod h1:tI4yxwh8U21v7JD6R3BcA/2+RBoTKFexE/PJ/nSO7IA=
|
||||
go.opentelemetry.io/otel/trace v0.19.0 h1:1ucYlenXIDA1OlHVLDZKX0ObXV5RLaq06DtUKz5e5zc=
|
||||
go.opentelemetry.io/otel/trace v0.19.0/go.mod h1:4IXiNextNOpPnRlI4ryK69mn5iC84bjBWZQA5DXz/qg=
|
||||
go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
|
||||
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
|
||||
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
|
||||
go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE=
|
||||
|
@ -579,10 +591,11 @@ golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81R
|
|||
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
|
||||
golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20211205041911-012df41ee64c h1:7SfqwP5fxEtl/P02w5IhKc86ziJ+A25yFrkVgoy2FT8=
|
||||
golang.org/x/net v0.0.0-20211205041911-012df41ee64c/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20220403103023-749bd193bc2b h1:vI32FkLJNAWtGD4BwkThwEy6XS7ZLLMHkSkYfF8M0W0=
|
||||
golang.org/x/net v0.0.0-20220403103023-749bd193bc2b/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
|
@ -645,20 +658,26 @@ golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7w
|
|||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM=
|
||||
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220406163625-3f8b81556e12 h1:QyVthZKMsyaQwBTJE04jdNN0Pp5Fn9Qga0mrgxyERQM=
|
||||
golang.org/x/sys v0.0.0-20220406163625-3f8b81556e12/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 h1:JGgROgKl9N8DuW20oFS5gxc+lE67/N3FcwmBPMe7ArY=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
|
@ -772,12 +791,15 @@ google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfG
|
|||
google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U=
|
||||
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
|
||||
google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA=
|
||||
google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/genproto v0.0.0-20220405205423-9d709892a2bf h1:JTjwKJX9erVpsw17w+OIPP7iAgEkN/r8urhWSunEDTs=
|
||||
google.golang.org/genproto v0.0.0-20220405205423-9d709892a2bf/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo=
|
||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
|
||||
google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
|
||||
|
@ -790,6 +812,10 @@ google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKa
|
|||
google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk=
|
||||
google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
|
||||
google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
|
||||
google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0=
|
||||
google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
|
||||
google.golang.org/grpc v1.45.0 h1:NEpgUqV3Z+ZjkqMsxMg11IaDrXY4RY6CQukSGK0uI1M=
|
||||
google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ=
|
||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
||||
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
||||
|
@ -802,8 +828,8 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj
|
|||
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
|
||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||
google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ=
|
||||
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||
google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw=
|
||||
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
|
@ -824,6 +850,7 @@ gopkg.in/tucnak/telebot.v2 v2.5.0/go.mod h1:BgaIIx50PSRS9pG59JH+geT82cfvoJU/IaI5
|
|||
gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
|
||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
|
|
|
@ -17,6 +17,7 @@ import (
|
|||
|
||||
"github.com/c9s/bbgo/pkg/bbgo"
|
||||
"github.com/c9s/bbgo/pkg/cmd/cmdutil"
|
||||
"github.com/c9s/bbgo/pkg/grpc"
|
||||
"github.com/c9s/bbgo/pkg/server"
|
||||
)
|
||||
|
||||
|
@ -28,8 +29,12 @@ func init() {
|
|||
RunCmd.Flags().String("totp-account-name", "", "")
|
||||
RunCmd.Flags().Bool("enable-webserver", false, "enable webserver")
|
||||
RunCmd.Flags().Bool("enable-web-server", false, "legacy option, this is renamed to --enable-webserver")
|
||||
RunCmd.Flags().String("cpu-profile", "", "cpu profile")
|
||||
RunCmd.Flags().String("webserver-bind", ":8080", "webserver binding")
|
||||
|
||||
RunCmd.Flags().Bool("enable-grpc", false, "enable grpc server")
|
||||
RunCmd.Flags().String("grpc-bind", ":6688", "grpc server binding")
|
||||
|
||||
RunCmd.Flags().String("cpu-profile", "", "cpu profile")
|
||||
RunCmd.Flags().Bool("setup", false, "use setup mode")
|
||||
RootCmd.AddCommand(RunCmd)
|
||||
}
|
||||
|
@ -40,7 +45,7 @@ var RunCmd = &cobra.Command{
|
|||
|
||||
// SilenceUsage is an option to silence usage when an error occurs.
|
||||
SilenceUsage: true,
|
||||
RunE: run,
|
||||
RunE: run,
|
||||
}
|
||||
|
||||
func runSetup(baseCtx context.Context, userConfig *bbgo.Config, enableApiServer bool) error {
|
||||
|
@ -144,6 +149,19 @@ func runConfig(basectx context.Context, cmd *cobra.Command, userConfig *bbgo.Con
|
|||
enableWebServer = true
|
||||
}
|
||||
|
||||
enableGrpc, err := cmd.Flags().GetBool("enable-grpc")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
grpcBind, err := cmd.Flags().GetString("grpc-bind")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_ = grpcBind
|
||||
_ = enableGrpc
|
||||
|
||||
ctx, cancelTrading := context.WithCancel(basectx)
|
||||
defer cancelTrading()
|
||||
|
||||
|
@ -184,7 +202,20 @@ func runConfig(basectx context.Context, cmd *cobra.Command, userConfig *bbgo.Con
|
|||
}
|
||||
|
||||
if err := s.Run(ctx, webServerBind); err != nil {
|
||||
log.WithError(err).Errorf("server error")
|
||||
log.WithError(err).Errorf("http server bind error")
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
if enableGrpc {
|
||||
go func() {
|
||||
s := &grpc.Server{
|
||||
Config: userConfig,
|
||||
Environ: environ,
|
||||
Trader: trader,
|
||||
}
|
||||
if err := s.ListenAndServe(grpcBind); err != nil {
|
||||
log.WithError(err).Errorf("grpc server bind error")
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
|
88
pkg/grpc/server.go
Normal file
88
pkg/grpc/server.go
Normal file
|
@ -0,0 +1,88 @@
|
|||
package grpc
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/reflection"
|
||||
|
||||
"github.com/c9s/bbgo/pkg/bbgo"
|
||||
"github.com/c9s/bbgo/pkg/pb"
|
||||
"github.com/c9s/bbgo/pkg/types"
|
||||
)
|
||||
|
||||
type Server struct {
|
||||
Config *bbgo.Config
|
||||
Environ *bbgo.Environment
|
||||
Trader *bbgo.Trader
|
||||
|
||||
pb.UnimplementedMarketDataServiceServer
|
||||
}
|
||||
|
||||
func (s *Server) Subscribe(request *pb.SubscribeRequest, server pb.MarketDataService_SubscribeServer) error {
|
||||
panic("implement me")
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Server) QueryKLines(ctx context.Context, request *pb.QueryKLinesRequest) (*pb.QueryKLinesResponse, error) {
|
||||
exchangeName, err := types.ValidExchangeName(request.Exchange)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for _, session := range s.Environ.Sessions() {
|
||||
if session.ExchangeName == exchangeName {
|
||||
response := &pb.QueryKLinesResponse{
|
||||
Klines: nil,
|
||||
Error: nil,
|
||||
}
|
||||
|
||||
options := types.KLineQueryOptions{
|
||||
Limit: int(request.Limit),
|
||||
}
|
||||
|
||||
klines, err := session.Exchange.QueryKLines(ctx, request.Symbol, types.Interval(request.Interval), options)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for _, kline := range klines {
|
||||
response.Klines = append(response.Klines, &pb.KLine{
|
||||
Exchange: kline.Exchange.String(),
|
||||
Symbol: kline.Symbol,
|
||||
Timestamp: kline.StartTime.Unix(),
|
||||
Open: kline.Open.Float64(),
|
||||
High: kline.High.Float64(),
|
||||
Low: kline.Low.Float64(),
|
||||
Close: kline.Close.Float64(),
|
||||
Volume: kline.Volume.Float64(),
|
||||
QuoteVolume: kline.QuoteVolume.Float64(),
|
||||
})
|
||||
}
|
||||
|
||||
return response, nil
|
||||
}
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (s *Server) ListenAndServe(bind string) error {
|
||||
conn, err := net.Listen("tcp", bind)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to bind network at %s", bind)
|
||||
}
|
||||
|
||||
var grpcServer = grpc.NewServer()
|
||||
pb.RegisterMarketDataServiceServer(grpcServer, s)
|
||||
|
||||
reflection.Register(grpcServer)
|
||||
|
||||
if err := grpcServer.Serve(conn); err != nil {
|
||||
return errors.Wrap(err, "failed to serve grpc connections")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
1288
pkg/pb/bbgo.pb.go
1288
pkg/pb/bbgo.pb.go
File diff suppressed because it is too large
Load Diff
|
@ -1,256 +1,262 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package pb;
|
||||
package bbgo;
|
||||
|
||||
option go_package = "../pb";
|
||||
|
||||
service BBGO {
|
||||
// should support streaming
|
||||
rpc Subcribe(SubscribeRequest) returns (stream SubscribeResponse) {}
|
||||
rpc SubcribeUserData(Empty) returns (stream SubscribeResponse) {}
|
||||
service MarketDataService {
|
||||
rpc Subscribe(SubscribeRequest) returns (stream SubscribeResponse) {}
|
||||
rpc QueryKLines(QueryKLinesRequest) returns (QueryKLinesResponse) {}
|
||||
}
|
||||
|
||||
// request-response
|
||||
rpc SubmitOrder(SubmitOrderRequest) returns (SubmitOrderResponse) {}
|
||||
rpc CancelOrder(CancelOrderRequest) returns (CancelOrderResponse) {}
|
||||
rpc QueryOrder(QueryOrderRequest) returns (QueryOrderResponse) {}
|
||||
rpc QueryOrders(QueryOrdersRequest) returns (QueryOrdersResponse) {}
|
||||
rpc QueryTrades(QueryTradesRequest) returns (QueryTradesResponse) {}
|
||||
rpc QueryKLines(QueryKLinesRequest) returns (QueryKLinesResponse) {}
|
||||
service UserDataService {
|
||||
// should support streaming
|
||||
rpc SubscribeUserData(Empty) returns (stream SubscribeResponse) {}
|
||||
}
|
||||
|
||||
service TradingService {
|
||||
// request-response
|
||||
rpc SubmitOrder(SubmitOrderRequest) returns (SubmitOrderResponse) {}
|
||||
rpc CancelOrder(CancelOrderRequest) returns (CancelOrderResponse) {}
|
||||
rpc QueryOrder(QueryOrderRequest) returns (QueryOrderResponse) {}
|
||||
rpc QueryOrders(QueryOrdersRequest) returns (QueryOrdersResponse) {}
|
||||
rpc QueryTrades(QueryTradesRequest) returns (QueryTradesResponse) {}
|
||||
}
|
||||
|
||||
enum Event {
|
||||
ERROR = 0;
|
||||
SUBSCRIBED = 1;
|
||||
UNSUBSCRIBED = 2;
|
||||
SNAPSHOT = 3;
|
||||
UPDATE = 4;
|
||||
AUTHENTICATED = 5;
|
||||
ORDER_SNAPSHOT = 6;
|
||||
ORDER_UPDATE = 7;
|
||||
TRADE_SNAPSHOT = 8;
|
||||
TRADE_UPDATE = 9;
|
||||
ACCOUNT_SNAPSHOT = 10;
|
||||
ACCOUNT_UPDATE = 11;
|
||||
UNKNOWN = 0;
|
||||
SUBSCRIBED = 1;
|
||||
UNSUBSCRIBED = 2;
|
||||
SNAPSHOT = 3;
|
||||
UPDATE = 4;
|
||||
AUTHENTICATED = 5;
|
||||
ORDER_SNAPSHOT = 6;
|
||||
ORDER_UPDATE = 7;
|
||||
TRADE_SNAPSHOT = 8;
|
||||
TRADE_UPDATE = 9;
|
||||
ACCOUNT_SNAPSHOT = 10;
|
||||
ACCOUNT_UPDATE = 11;
|
||||
ERROR = 99;
|
||||
}
|
||||
|
||||
enum Channel {
|
||||
BOOK = 0;
|
||||
TRADE = 1;
|
||||
TICKER = 2;
|
||||
USER = 3;
|
||||
BOOK = 0;
|
||||
TRADE = 1;
|
||||
TICKER = 2;
|
||||
USER = 3;
|
||||
}
|
||||
|
||||
enum Side {
|
||||
BUY = 0;
|
||||
SELL = 1;
|
||||
BUY = 0;
|
||||
SELL = 1;
|
||||
}
|
||||
|
||||
enum OrderType {
|
||||
MARKET = 0;
|
||||
LIMIT = 1;
|
||||
STOP_MARKET = 2;
|
||||
STOP_LIMIT = 3;
|
||||
POST_ONLY = 4;
|
||||
IOC_LIMIT = 5;
|
||||
MARKET = 0;
|
||||
LIMIT = 1;
|
||||
STOP_MARKET = 2;
|
||||
STOP_LIMIT = 3;
|
||||
POST_ONLY = 4;
|
||||
IOC_LIMIT = 5;
|
||||
}
|
||||
|
||||
message Empty {}
|
||||
|
||||
message Error {
|
||||
int64 error_code = 1;
|
||||
string error_message = 2;
|
||||
int64 error_code = 1;
|
||||
string error_message = 2;
|
||||
}
|
||||
|
||||
message SubscribeRequest {
|
||||
repeated Subscription subscriptions = 1;
|
||||
repeated Subscription subscriptions = 1;
|
||||
}
|
||||
|
||||
message Subscription {
|
||||
string exchange = 1;
|
||||
Channel channel = 2; // book, trade, ticker
|
||||
string symbol = 3;
|
||||
int64 depth = 4;
|
||||
string exchange = 1;
|
||||
Channel channel = 2; // book, trade, ticker
|
||||
string symbol = 3;
|
||||
int64 depth = 4;
|
||||
}
|
||||
|
||||
message SubscribeResponse {
|
||||
string exchange = 1;
|
||||
string symbol = 2;
|
||||
Channel channel = 3; // book, trade, ticker, user
|
||||
Event event = 4; // snapshot, update, order_snapshot, ...
|
||||
Depth depth = 5;
|
||||
repeated Trade trades = 6;
|
||||
Ticker ticker = 7;
|
||||
repeated Order orders = 8;
|
||||
repeated Balance balances = 9;
|
||||
int64 subscribed_at = 10;
|
||||
Error error = 11;
|
||||
string exchange = 1;
|
||||
string symbol = 2;
|
||||
Channel channel = 3; // book, trade, ticker, user
|
||||
Event event = 4; // snapshot, update, order_snapshot, ...
|
||||
Depth depth = 5;
|
||||
repeated Trade trades = 6;
|
||||
Ticker ticker = 7;
|
||||
repeated Order orders = 8;
|
||||
repeated Balance balances = 9;
|
||||
int64 subscribed_at = 10;
|
||||
Error error = 11;
|
||||
}
|
||||
|
||||
message Depth {
|
||||
string exchange = 1;
|
||||
string symbol = 2;
|
||||
repeated PriceVolume asks = 3;
|
||||
repeated PriceVolume bids = 4;
|
||||
string exchange = 1;
|
||||
string symbol = 2;
|
||||
repeated PriceVolume asks = 3;
|
||||
repeated PriceVolume bids = 4;
|
||||
}
|
||||
|
||||
message PriceVolume {
|
||||
int64 price = 1;
|
||||
int64 volume = 2;
|
||||
int64 price = 1;
|
||||
int64 volume = 2;
|
||||
}
|
||||
|
||||
// https://maicoin.github.io/max-websocket-docs/#/private_channels?id=trade-response
|
||||
// https://maicoin.github.io/max-websocket-docs/#/public_trade?id=success-response
|
||||
message Trade {
|
||||
string exchange = 1;
|
||||
string symbol = 2;
|
||||
string id = 3;
|
||||
double price = 4;
|
||||
double volume = 5;
|
||||
int64 created_at = 6;
|
||||
Side side = 7;
|
||||
double fee = 8;
|
||||
string fee_currency = 9;
|
||||
bool maker = 10;
|
||||
string trend = 11;
|
||||
string exchange = 1;
|
||||
string symbol = 2;
|
||||
string id = 3;
|
||||
double price = 4;
|
||||
double volume = 5;
|
||||
int64 created_at = 6;
|
||||
Side side = 7;
|
||||
double fee = 8;
|
||||
string fee_currency = 9;
|
||||
bool maker = 10;
|
||||
string trend = 11;
|
||||
}
|
||||
|
||||
// https://maicoin.github.io/max-websocket-docs/#/public_ticker?id=success-response
|
||||
message Ticker {
|
||||
string exchange = 1;
|
||||
string symbol = 2;
|
||||
double open = 3;
|
||||
double high = 4;
|
||||
double low = 5;
|
||||
double close = 6;
|
||||
double volume = 7;
|
||||
string exchange = 1;
|
||||
string symbol = 2;
|
||||
double open = 3;
|
||||
double high = 4;
|
||||
double low = 5;
|
||||
double close = 6;
|
||||
double volume = 7;
|
||||
}
|
||||
|
||||
// https://maicoin.github.io/max-websocket-docs/#/private_channels?id=snapshot
|
||||
message Order {
|
||||
string exchange = 1;
|
||||
string symbol = 2;
|
||||
string id = 3;
|
||||
Side side = 4;
|
||||
OrderType order_type = 5;
|
||||
double price = 6;
|
||||
double stop_price = 7;
|
||||
double avg_price = 8;
|
||||
string status = 9;
|
||||
int64 created_at = 10;
|
||||
double quantity = 11;
|
||||
double executed_volume = 12;
|
||||
int64 trades_count = 13;
|
||||
string client_order_id = 14;
|
||||
int64 group_id = 15;
|
||||
string exchange = 1;
|
||||
string symbol = 2;
|
||||
string id = 3;
|
||||
Side side = 4;
|
||||
OrderType order_type = 5;
|
||||
double price = 6;
|
||||
double stop_price = 7;
|
||||
double avg_price = 8;
|
||||
string status = 9;
|
||||
int64 created_at = 10;
|
||||
double quantity = 11;
|
||||
double executed_volume = 12;
|
||||
int64 trades_count = 13;
|
||||
string client_order_id = 14;
|
||||
int64 group_id = 15;
|
||||
}
|
||||
|
||||
message SubmitOrder {
|
||||
string exchange = 1;
|
||||
string symbol = 2;
|
||||
Side side = 3;
|
||||
double quantity = 4;
|
||||
double price = 5;
|
||||
double stop_price = 6;
|
||||
OrderType order_type = 7;
|
||||
string client_order_id = 8;
|
||||
int64 group_id = 9;
|
||||
string exchange = 1;
|
||||
string symbol = 2;
|
||||
Side side = 3;
|
||||
double quantity = 4;
|
||||
double price = 5;
|
||||
double stop_price = 6;
|
||||
OrderType order_type = 7;
|
||||
string client_order_id = 8;
|
||||
int64 group_id = 9;
|
||||
}
|
||||
|
||||
// https://maicoin.github.io/max-websocket-docs/#/private_channels?id=account-response
|
||||
message Balance {
|
||||
string exchange = 1;
|
||||
string currency = 2;
|
||||
double available = 3;
|
||||
double locked = 4;
|
||||
string exchange = 1;
|
||||
string currency = 2;
|
||||
double available = 3;
|
||||
double locked = 4;
|
||||
}
|
||||
|
||||
message SubmitOrderRequest {
|
||||
SubmitOrder submit_order = 1;
|
||||
SubmitOrder submit_order = 1;
|
||||
}
|
||||
|
||||
message SubmitOrderResponse {
|
||||
Order order = 1;
|
||||
Error error = 2;
|
||||
Order order = 1;
|
||||
Error error = 2;
|
||||
}
|
||||
|
||||
message CancelOrderRequest {
|
||||
string exchange = 1;
|
||||
string id = 2;
|
||||
string client_order_id = 3;
|
||||
string exchange = 1;
|
||||
string id = 2;
|
||||
string client_order_id = 3;
|
||||
}
|
||||
|
||||
message CancelOrderResponse {
|
||||
Order order = 1;
|
||||
Error error = 2;
|
||||
Order order = 1;
|
||||
Error error = 2;
|
||||
}
|
||||
|
||||
message QueryOrderRequest {
|
||||
string exchange = 1;
|
||||
string id = 2;
|
||||
string client_order_id = 3;
|
||||
string exchange = 1;
|
||||
string id = 2;
|
||||
string client_order_id = 3;
|
||||
}
|
||||
|
||||
message QueryOrderResponse {
|
||||
Order order = 1;
|
||||
Error error = 2;
|
||||
Order order = 1;
|
||||
Error error = 2;
|
||||
}
|
||||
|
||||
message QueryOrdersRequest {
|
||||
string exchange = 1;
|
||||
string symbol = 2;
|
||||
repeated string state = 3;
|
||||
string order_by = 4;
|
||||
int64 group_id = 5;
|
||||
bool pagination = 6;
|
||||
int64 page = 7;
|
||||
int64 limit = 8;
|
||||
int64 offset = 9;
|
||||
string exchange = 1;
|
||||
string symbol = 2;
|
||||
repeated string state = 3;
|
||||
string order_by = 4;
|
||||
int64 group_id = 5;
|
||||
bool pagination = 6;
|
||||
int64 page = 7;
|
||||
int64 limit = 8;
|
||||
int64 offset = 9;
|
||||
}
|
||||
|
||||
message QueryOrdersResponse {
|
||||
repeated Order orders = 1;
|
||||
Error error = 2;
|
||||
repeated Order orders = 1;
|
||||
Error error = 2;
|
||||
}
|
||||
|
||||
message QueryTradesRequest {
|
||||
string exchange = 1;
|
||||
string symbol = 2;
|
||||
int64 timestamp = 3;
|
||||
int64 from = 4;
|
||||
int64 to = 5;
|
||||
string order_by = 6;
|
||||
bool pagination = 7;
|
||||
int64 page = 8;
|
||||
int64 limit = 9;
|
||||
int64 offset = 10;
|
||||
string exchange = 1;
|
||||
string symbol = 2;
|
||||
int64 timestamp = 3;
|
||||
int64 from = 4;
|
||||
int64 to = 5;
|
||||
string order_by = 6;
|
||||
bool pagination = 7;
|
||||
int64 page = 8;
|
||||
int64 limit = 9;
|
||||
int64 offset = 10;
|
||||
}
|
||||
|
||||
message QueryTradesResponse {
|
||||
repeated Trade trades = 1;
|
||||
Error error = 2;
|
||||
repeated Trade trades = 1;
|
||||
Error error = 2;
|
||||
}
|
||||
|
||||
message QueryKLinesRequest {
|
||||
string exchange = 1;
|
||||
string symbol = 2;
|
||||
int64 limit = 3;
|
||||
int64 interval = 4; // time period of K line in minute
|
||||
int64 timestamp = 5;
|
||||
string exchange = 1;
|
||||
string symbol = 2;
|
||||
string interval = 3; // time period of K line in minute
|
||||
int64 timestamp = 4;
|
||||
int64 limit = 5;
|
||||
}
|
||||
|
||||
message QueryKLinesResponse {
|
||||
repeated KLine klines = 1;
|
||||
Error error = 2;
|
||||
repeated KLine klines = 1;
|
||||
Error error = 2;
|
||||
}
|
||||
|
||||
message KLine {
|
||||
string exchange = 1;
|
||||
string symbol = 2;
|
||||
int64 timestamp = 3;
|
||||
double open = 4;
|
||||
double high = 5;
|
||||
double low = 6;
|
||||
double close = 7;
|
||||
double volume = 8;
|
||||
double quote_volume = 9;
|
||||
string exchange = 1;
|
||||
string symbol = 2;
|
||||
int64 timestamp = 3;
|
||||
double open = 4;
|
||||
double high = 5;
|
||||
double low = 6;
|
||||
double close = 7;
|
||||
double volume = 8;
|
||||
double quote_volume = 9;
|
||||
}
|
||||
|
|
512
pkg/pb/bbgo_grpc.pb.go
Normal file
512
pkg/pb/bbgo_grpc.pb.go
Normal file
|
@ -0,0 +1,512 @@
|
|||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
|
||||
package pb
|
||||
|
||||
import (
|
||||
context "context"
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
// Requires gRPC-Go v1.32.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion7
|
||||
|
||||
// MarketDataServiceClient is the client API for MarketDataService service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
type MarketDataServiceClient interface {
|
||||
Subscribe(ctx context.Context, in *SubscribeRequest, opts ...grpc.CallOption) (MarketDataService_SubscribeClient, error)
|
||||
QueryKLines(ctx context.Context, in *QueryKLinesRequest, opts ...grpc.CallOption) (*QueryKLinesResponse, error)
|
||||
}
|
||||
|
||||
type marketDataServiceClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewMarketDataServiceClient(cc grpc.ClientConnInterface) MarketDataServiceClient {
|
||||
return &marketDataServiceClient{cc}
|
||||
}
|
||||
|
||||
func (c *marketDataServiceClient) Subscribe(ctx context.Context, in *SubscribeRequest, opts ...grpc.CallOption) (MarketDataService_SubscribeClient, error) {
|
||||
stream, err := c.cc.NewStream(ctx, &MarketDataService_ServiceDesc.Streams[0], "/bbgo.MarketDataService/Subscribe", opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
x := &marketDataServiceSubscribeClient{stream}
|
||||
if err := x.ClientStream.SendMsg(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := x.ClientStream.CloseSend(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return x, nil
|
||||
}
|
||||
|
||||
type MarketDataService_SubscribeClient interface {
|
||||
Recv() (*SubscribeResponse, error)
|
||||
grpc.ClientStream
|
||||
}
|
||||
|
||||
type marketDataServiceSubscribeClient struct {
|
||||
grpc.ClientStream
|
||||
}
|
||||
|
||||
func (x *marketDataServiceSubscribeClient) Recv() (*SubscribeResponse, error) {
|
||||
m := new(SubscribeResponse)
|
||||
if err := x.ClientStream.RecvMsg(m); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
func (c *marketDataServiceClient) QueryKLines(ctx context.Context, in *QueryKLinesRequest, opts ...grpc.CallOption) (*QueryKLinesResponse, error) {
|
||||
out := new(QueryKLinesResponse)
|
||||
err := c.cc.Invoke(ctx, "/bbgo.MarketDataService/QueryKLines", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// MarketDataServiceServer is the server API for MarketDataService service.
|
||||
// All implementations must embed UnimplementedMarketDataServiceServer
|
||||
// for forward compatibility
|
||||
type MarketDataServiceServer interface {
|
||||
Subscribe(*SubscribeRequest, MarketDataService_SubscribeServer) error
|
||||
QueryKLines(context.Context, *QueryKLinesRequest) (*QueryKLinesResponse, error)
|
||||
mustEmbedUnimplementedMarketDataServiceServer()
|
||||
}
|
||||
|
||||
// UnimplementedMarketDataServiceServer must be embedded to have forward compatible implementations.
|
||||
type UnimplementedMarketDataServiceServer struct {
|
||||
}
|
||||
|
||||
func (UnimplementedMarketDataServiceServer) Subscribe(*SubscribeRequest, MarketDataService_SubscribeServer) error {
|
||||
return status.Errorf(codes.Unimplemented, "method Subscribe not implemented")
|
||||
}
|
||||
func (UnimplementedMarketDataServiceServer) QueryKLines(context.Context, *QueryKLinesRequest) (*QueryKLinesResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method QueryKLines not implemented")
|
||||
}
|
||||
func (UnimplementedMarketDataServiceServer) mustEmbedUnimplementedMarketDataServiceServer() {}
|
||||
|
||||
// UnsafeMarketDataServiceServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to MarketDataServiceServer will
|
||||
// result in compilation errors.
|
||||
type UnsafeMarketDataServiceServer interface {
|
||||
mustEmbedUnimplementedMarketDataServiceServer()
|
||||
}
|
||||
|
||||
func RegisterMarketDataServiceServer(s grpc.ServiceRegistrar, srv MarketDataServiceServer) {
|
||||
s.RegisterService(&MarketDataService_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _MarketDataService_Subscribe_Handler(srv interface{}, stream grpc.ServerStream) error {
|
||||
m := new(SubscribeRequest)
|
||||
if err := stream.RecvMsg(m); err != nil {
|
||||
return err
|
||||
}
|
||||
return srv.(MarketDataServiceServer).Subscribe(m, &marketDataServiceSubscribeServer{stream})
|
||||
}
|
||||
|
||||
type MarketDataService_SubscribeServer interface {
|
||||
Send(*SubscribeResponse) error
|
||||
grpc.ServerStream
|
||||
}
|
||||
|
||||
type marketDataServiceSubscribeServer struct {
|
||||
grpc.ServerStream
|
||||
}
|
||||
|
||||
func (x *marketDataServiceSubscribeServer) Send(m *SubscribeResponse) error {
|
||||
return x.ServerStream.SendMsg(m)
|
||||
}
|
||||
|
||||
func _MarketDataService_QueryKLines_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(QueryKLinesRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(MarketDataServiceServer).QueryKLines(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/bbgo.MarketDataService/QueryKLines",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(MarketDataServiceServer).QueryKLines(ctx, req.(*QueryKLinesRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// MarketDataService_ServiceDesc is the grpc.ServiceDesc for MarketDataService service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var MarketDataService_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "bbgo.MarketDataService",
|
||||
HandlerType: (*MarketDataServiceServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "QueryKLines",
|
||||
Handler: _MarketDataService_QueryKLines_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{
|
||||
{
|
||||
StreamName: "Subscribe",
|
||||
Handler: _MarketDataService_Subscribe_Handler,
|
||||
ServerStreams: true,
|
||||
},
|
||||
},
|
||||
Metadata: "pkg/pb/bbgo.proto",
|
||||
}
|
||||
|
||||
// UserDataServiceClient is the client API for UserDataService service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
type UserDataServiceClient interface {
|
||||
// should support streaming
|
||||
SubscribeUserData(ctx context.Context, in *Empty, opts ...grpc.CallOption) (UserDataService_SubscribeUserDataClient, error)
|
||||
}
|
||||
|
||||
type userDataServiceClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewUserDataServiceClient(cc grpc.ClientConnInterface) UserDataServiceClient {
|
||||
return &userDataServiceClient{cc}
|
||||
}
|
||||
|
||||
func (c *userDataServiceClient) SubscribeUserData(ctx context.Context, in *Empty, opts ...grpc.CallOption) (UserDataService_SubscribeUserDataClient, error) {
|
||||
stream, err := c.cc.NewStream(ctx, &UserDataService_ServiceDesc.Streams[0], "/bbgo.UserDataService/SubscribeUserData", opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
x := &userDataServiceSubscribeUserDataClient{stream}
|
||||
if err := x.ClientStream.SendMsg(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := x.ClientStream.CloseSend(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return x, nil
|
||||
}
|
||||
|
||||
type UserDataService_SubscribeUserDataClient interface {
|
||||
Recv() (*SubscribeResponse, error)
|
||||
grpc.ClientStream
|
||||
}
|
||||
|
||||
type userDataServiceSubscribeUserDataClient struct {
|
||||
grpc.ClientStream
|
||||
}
|
||||
|
||||
func (x *userDataServiceSubscribeUserDataClient) Recv() (*SubscribeResponse, error) {
|
||||
m := new(SubscribeResponse)
|
||||
if err := x.ClientStream.RecvMsg(m); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// UserDataServiceServer is the server API for UserDataService service.
|
||||
// All implementations must embed UnimplementedUserDataServiceServer
|
||||
// for forward compatibility
|
||||
type UserDataServiceServer interface {
|
||||
// should support streaming
|
||||
SubscribeUserData(*Empty, UserDataService_SubscribeUserDataServer) error
|
||||
mustEmbedUnimplementedUserDataServiceServer()
|
||||
}
|
||||
|
||||
// UnimplementedUserDataServiceServer must be embedded to have forward compatible implementations.
|
||||
type UnimplementedUserDataServiceServer struct {
|
||||
}
|
||||
|
||||
func (UnimplementedUserDataServiceServer) SubscribeUserData(*Empty, UserDataService_SubscribeUserDataServer) error {
|
||||
return status.Errorf(codes.Unimplemented, "method SubscribeUserData not implemented")
|
||||
}
|
||||
func (UnimplementedUserDataServiceServer) mustEmbedUnimplementedUserDataServiceServer() {}
|
||||
|
||||
// UnsafeUserDataServiceServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to UserDataServiceServer will
|
||||
// result in compilation errors.
|
||||
type UnsafeUserDataServiceServer interface {
|
||||
mustEmbedUnimplementedUserDataServiceServer()
|
||||
}
|
||||
|
||||
func RegisterUserDataServiceServer(s grpc.ServiceRegistrar, srv UserDataServiceServer) {
|
||||
s.RegisterService(&UserDataService_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _UserDataService_SubscribeUserData_Handler(srv interface{}, stream grpc.ServerStream) error {
|
||||
m := new(Empty)
|
||||
if err := stream.RecvMsg(m); err != nil {
|
||||
return err
|
||||
}
|
||||
return srv.(UserDataServiceServer).SubscribeUserData(m, &userDataServiceSubscribeUserDataServer{stream})
|
||||
}
|
||||
|
||||
type UserDataService_SubscribeUserDataServer interface {
|
||||
Send(*SubscribeResponse) error
|
||||
grpc.ServerStream
|
||||
}
|
||||
|
||||
type userDataServiceSubscribeUserDataServer struct {
|
||||
grpc.ServerStream
|
||||
}
|
||||
|
||||
func (x *userDataServiceSubscribeUserDataServer) Send(m *SubscribeResponse) error {
|
||||
return x.ServerStream.SendMsg(m)
|
||||
}
|
||||
|
||||
// UserDataService_ServiceDesc is the grpc.ServiceDesc for UserDataService service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var UserDataService_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "bbgo.UserDataService",
|
||||
HandlerType: (*UserDataServiceServer)(nil),
|
||||
Methods: []grpc.MethodDesc{},
|
||||
Streams: []grpc.StreamDesc{
|
||||
{
|
||||
StreamName: "SubscribeUserData",
|
||||
Handler: _UserDataService_SubscribeUserData_Handler,
|
||||
ServerStreams: true,
|
||||
},
|
||||
},
|
||||
Metadata: "pkg/pb/bbgo.proto",
|
||||
}
|
||||
|
||||
// TradingServiceClient is the client API for TradingService service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
type TradingServiceClient interface {
|
||||
// request-response
|
||||
SubmitOrder(ctx context.Context, in *SubmitOrderRequest, opts ...grpc.CallOption) (*SubmitOrderResponse, error)
|
||||
CancelOrder(ctx context.Context, in *CancelOrderRequest, opts ...grpc.CallOption) (*CancelOrderResponse, error)
|
||||
QueryOrder(ctx context.Context, in *QueryOrderRequest, opts ...grpc.CallOption) (*QueryOrderResponse, error)
|
||||
QueryOrders(ctx context.Context, in *QueryOrdersRequest, opts ...grpc.CallOption) (*QueryOrdersResponse, error)
|
||||
QueryTrades(ctx context.Context, in *QueryTradesRequest, opts ...grpc.CallOption) (*QueryTradesResponse, error)
|
||||
}
|
||||
|
||||
type tradingServiceClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewTradingServiceClient(cc grpc.ClientConnInterface) TradingServiceClient {
|
||||
return &tradingServiceClient{cc}
|
||||
}
|
||||
|
||||
func (c *tradingServiceClient) SubmitOrder(ctx context.Context, in *SubmitOrderRequest, opts ...grpc.CallOption) (*SubmitOrderResponse, error) {
|
||||
out := new(SubmitOrderResponse)
|
||||
err := c.cc.Invoke(ctx, "/bbgo.TradingService/SubmitOrder", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *tradingServiceClient) CancelOrder(ctx context.Context, in *CancelOrderRequest, opts ...grpc.CallOption) (*CancelOrderResponse, error) {
|
||||
out := new(CancelOrderResponse)
|
||||
err := c.cc.Invoke(ctx, "/bbgo.TradingService/CancelOrder", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *tradingServiceClient) QueryOrder(ctx context.Context, in *QueryOrderRequest, opts ...grpc.CallOption) (*QueryOrderResponse, error) {
|
||||
out := new(QueryOrderResponse)
|
||||
err := c.cc.Invoke(ctx, "/bbgo.TradingService/QueryOrder", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *tradingServiceClient) QueryOrders(ctx context.Context, in *QueryOrdersRequest, opts ...grpc.CallOption) (*QueryOrdersResponse, error) {
|
||||
out := new(QueryOrdersResponse)
|
||||
err := c.cc.Invoke(ctx, "/bbgo.TradingService/QueryOrders", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *tradingServiceClient) QueryTrades(ctx context.Context, in *QueryTradesRequest, opts ...grpc.CallOption) (*QueryTradesResponse, error) {
|
||||
out := new(QueryTradesResponse)
|
||||
err := c.cc.Invoke(ctx, "/bbgo.TradingService/QueryTrades", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// TradingServiceServer is the server API for TradingService service.
|
||||
// All implementations must embed UnimplementedTradingServiceServer
|
||||
// for forward compatibility
|
||||
type TradingServiceServer interface {
|
||||
// request-response
|
||||
SubmitOrder(context.Context, *SubmitOrderRequest) (*SubmitOrderResponse, error)
|
||||
CancelOrder(context.Context, *CancelOrderRequest) (*CancelOrderResponse, error)
|
||||
QueryOrder(context.Context, *QueryOrderRequest) (*QueryOrderResponse, error)
|
||||
QueryOrders(context.Context, *QueryOrdersRequest) (*QueryOrdersResponse, error)
|
||||
QueryTrades(context.Context, *QueryTradesRequest) (*QueryTradesResponse, error)
|
||||
mustEmbedUnimplementedTradingServiceServer()
|
||||
}
|
||||
|
||||
// UnimplementedTradingServiceServer must be embedded to have forward compatible implementations.
|
||||
type UnimplementedTradingServiceServer struct {
|
||||
}
|
||||
|
||||
func (UnimplementedTradingServiceServer) SubmitOrder(context.Context, *SubmitOrderRequest) (*SubmitOrderResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method SubmitOrder not implemented")
|
||||
}
|
||||
func (UnimplementedTradingServiceServer) CancelOrder(context.Context, *CancelOrderRequest) (*CancelOrderResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method CancelOrder not implemented")
|
||||
}
|
||||
func (UnimplementedTradingServiceServer) QueryOrder(context.Context, *QueryOrderRequest) (*QueryOrderResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method QueryOrder not implemented")
|
||||
}
|
||||
func (UnimplementedTradingServiceServer) QueryOrders(context.Context, *QueryOrdersRequest) (*QueryOrdersResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method QueryOrders not implemented")
|
||||
}
|
||||
func (UnimplementedTradingServiceServer) QueryTrades(context.Context, *QueryTradesRequest) (*QueryTradesResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method QueryTrades not implemented")
|
||||
}
|
||||
func (UnimplementedTradingServiceServer) mustEmbedUnimplementedTradingServiceServer() {}
|
||||
|
||||
// UnsafeTradingServiceServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to TradingServiceServer will
|
||||
// result in compilation errors.
|
||||
type UnsafeTradingServiceServer interface {
|
||||
mustEmbedUnimplementedTradingServiceServer()
|
||||
}
|
||||
|
||||
func RegisterTradingServiceServer(s grpc.ServiceRegistrar, srv TradingServiceServer) {
|
||||
s.RegisterService(&TradingService_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _TradingService_SubmitOrder_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(SubmitOrderRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(TradingServiceServer).SubmitOrder(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/bbgo.TradingService/SubmitOrder",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(TradingServiceServer).SubmitOrder(ctx, req.(*SubmitOrderRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _TradingService_CancelOrder_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(CancelOrderRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(TradingServiceServer).CancelOrder(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/bbgo.TradingService/CancelOrder",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(TradingServiceServer).CancelOrder(ctx, req.(*CancelOrderRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _TradingService_QueryOrder_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(QueryOrderRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(TradingServiceServer).QueryOrder(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/bbgo.TradingService/QueryOrder",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(TradingServiceServer).QueryOrder(ctx, req.(*QueryOrderRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _TradingService_QueryOrders_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(QueryOrdersRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(TradingServiceServer).QueryOrders(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/bbgo.TradingService/QueryOrders",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(TradingServiceServer).QueryOrders(ctx, req.(*QueryOrdersRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _TradingService_QueryTrades_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(QueryTradesRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(TradingServiceServer).QueryTrades(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/bbgo.TradingService/QueryTrades",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(TradingServiceServer).QueryTrades(ctx, req.(*QueryTradesRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// TradingService_ServiceDesc is the grpc.ServiceDesc for TradingService service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var TradingService_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "bbgo.TradingService",
|
||||
HandlerType: (*TradingServiceServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "SubmitOrder",
|
||||
Handler: _TradingService_SubmitOrder_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "CancelOrder",
|
||||
Handler: _TradingService_CancelOrder_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "QueryOrder",
|
||||
Handler: _TradingService_QueryOrder_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "QueryOrders",
|
||||
Handler: _TradingService_QueryOrders_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "QueryTrades",
|
||||
Handler: _TradingService_QueryTrades_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "pkg/pb/bbgo.proto",
|
||||
}
|
File diff suppressed because one or more lines are too long
|
@ -2,10 +2,10 @@
|
|||
"""Client and server classes corresponding to protobuf-defined services."""
|
||||
import grpc
|
||||
|
||||
from . import bbgo_pb2 as bbgo__pb2
|
||||
import bbgo_pb2 as bbgo__pb2
|
||||
|
||||
|
||||
class BBGOStub(object):
|
||||
class MarketDataServiceStub(object):
|
||||
"""Missing associated documentation comment in .proto file."""
|
||||
|
||||
def __init__(self, channel):
|
||||
|
@ -14,63 +14,191 @@ class BBGOStub(object):
|
|||
Args:
|
||||
channel: A grpc.Channel.
|
||||
"""
|
||||
self.Subcribe = channel.unary_stream(
|
||||
'/pb.BBGO/Subcribe',
|
||||
self.Subscribe = channel.unary_stream(
|
||||
'/pb.MarketDataService/Subscribe',
|
||||
request_serializer=bbgo__pb2.SubscribeRequest.SerializeToString,
|
||||
response_deserializer=bbgo__pb2.SubscribeResponse.FromString,
|
||||
)
|
||||
self.SubcribeUserData = channel.unary_stream(
|
||||
'/pb.BBGO/SubcribeUserData',
|
||||
request_serializer=bbgo__pb2.Empty.SerializeToString,
|
||||
response_deserializer=bbgo__pb2.SubscribeResponse.FromString,
|
||||
)
|
||||
self.SubmitOrder = channel.unary_unary(
|
||||
'/pb.BBGO/SubmitOrder',
|
||||
request_serializer=bbgo__pb2.SubmitOrderRequest.SerializeToString,
|
||||
response_deserializer=bbgo__pb2.SubmitOrderResponse.FromString,
|
||||
)
|
||||
self.CancelOrder = channel.unary_unary(
|
||||
'/pb.BBGO/CancelOrder',
|
||||
request_serializer=bbgo__pb2.CancelOrderRequest.SerializeToString,
|
||||
response_deserializer=bbgo__pb2.CancelOrderResponse.FromString,
|
||||
)
|
||||
self.QueryOrder = channel.unary_unary(
|
||||
'/pb.BBGO/QueryOrder',
|
||||
request_serializer=bbgo__pb2.QueryOrderRequest.SerializeToString,
|
||||
response_deserializer=bbgo__pb2.QueryOrderResponse.FromString,
|
||||
)
|
||||
self.QueryOrders = channel.unary_unary(
|
||||
'/pb.BBGO/QueryOrders',
|
||||
request_serializer=bbgo__pb2.QueryOrdersRequest.SerializeToString,
|
||||
response_deserializer=bbgo__pb2.QueryOrdersResponse.FromString,
|
||||
)
|
||||
self.QueryTrades = channel.unary_unary(
|
||||
'/pb.BBGO/QueryTrades',
|
||||
request_serializer=bbgo__pb2.QueryTradesRequest.SerializeToString,
|
||||
response_deserializer=bbgo__pb2.QueryTradesResponse.FromString,
|
||||
)
|
||||
self.QueryKLines = channel.unary_unary(
|
||||
'/pb.BBGO/QueryKLines',
|
||||
'/pb.MarketDataService/QueryKLines',
|
||||
request_serializer=bbgo__pb2.QueryKLinesRequest.SerializeToString,
|
||||
response_deserializer=bbgo__pb2.QueryKLinesResponse.FromString,
|
||||
)
|
||||
|
||||
|
||||
class BBGOServicer(object):
|
||||
class MarketDataServiceServicer(object):
|
||||
"""Missing associated documentation comment in .proto file."""
|
||||
|
||||
def Subcribe(self, request, context):
|
||||
def Subscribe(self, request, context):
|
||||
"""Missing associated documentation comment in .proto file."""
|
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
||||
context.set_details('Method not implemented!')
|
||||
raise NotImplementedError('Method not implemented!')
|
||||
|
||||
def QueryKLines(self, request, context):
|
||||
"""Missing associated documentation comment in .proto file."""
|
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
||||
context.set_details('Method not implemented!')
|
||||
raise NotImplementedError('Method not implemented!')
|
||||
|
||||
|
||||
def add_MarketDataServiceServicer_to_server(servicer, server):
|
||||
rpc_method_handlers = {
|
||||
'Subscribe': grpc.unary_stream_rpc_method_handler(
|
||||
servicer.Subscribe,
|
||||
request_deserializer=bbgo__pb2.SubscribeRequest.FromString,
|
||||
response_serializer=bbgo__pb2.SubscribeResponse.SerializeToString,
|
||||
),
|
||||
'QueryKLines': grpc.unary_unary_rpc_method_handler(
|
||||
servicer.QueryKLines,
|
||||
request_deserializer=bbgo__pb2.QueryKLinesRequest.FromString,
|
||||
response_serializer=bbgo__pb2.QueryKLinesResponse.SerializeToString,
|
||||
),
|
||||
}
|
||||
generic_handler = grpc.method_handlers_generic_handler(
|
||||
'pb.MarketDataService', rpc_method_handlers)
|
||||
server.add_generic_rpc_handlers((generic_handler,))
|
||||
|
||||
|
||||
# This class is part of an EXPERIMENTAL API.
|
||||
class MarketDataService(object):
|
||||
"""Missing associated documentation comment in .proto file."""
|
||||
|
||||
@staticmethod
|
||||
def Subscribe(request,
|
||||
target,
|
||||
options=(),
|
||||
channel_credentials=None,
|
||||
call_credentials=None,
|
||||
insecure=False,
|
||||
compression=None,
|
||||
wait_for_ready=None,
|
||||
timeout=None,
|
||||
metadata=None):
|
||||
return grpc.experimental.unary_stream(request, target, '/pb.MarketDataService/Subscribe',
|
||||
bbgo__pb2.SubscribeRequest.SerializeToString,
|
||||
bbgo__pb2.SubscribeResponse.FromString,
|
||||
options, channel_credentials,
|
||||
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
|
||||
|
||||
@staticmethod
|
||||
def QueryKLines(request,
|
||||
target,
|
||||
options=(),
|
||||
channel_credentials=None,
|
||||
call_credentials=None,
|
||||
insecure=False,
|
||||
compression=None,
|
||||
wait_for_ready=None,
|
||||
timeout=None,
|
||||
metadata=None):
|
||||
return grpc.experimental.unary_unary(request, target, '/pb.MarketDataService/QueryKLines',
|
||||
bbgo__pb2.QueryKLinesRequest.SerializeToString,
|
||||
bbgo__pb2.QueryKLinesResponse.FromString,
|
||||
options, channel_credentials,
|
||||
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
|
||||
|
||||
|
||||
class UserDataServiceStub(object):
|
||||
"""Missing associated documentation comment in .proto file."""
|
||||
|
||||
def __init__(self, channel):
|
||||
"""Constructor.
|
||||
|
||||
Args:
|
||||
channel: A grpc.Channel.
|
||||
"""
|
||||
self.SubscribeUserData = channel.unary_stream(
|
||||
'/pb.UserDataService/SubscribeUserData',
|
||||
request_serializer=bbgo__pb2.Empty.SerializeToString,
|
||||
response_deserializer=bbgo__pb2.SubscribeResponse.FromString,
|
||||
)
|
||||
|
||||
|
||||
class UserDataServiceServicer(object):
|
||||
"""Missing associated documentation comment in .proto file."""
|
||||
|
||||
def SubscribeUserData(self, request, context):
|
||||
"""should support streaming
|
||||
"""
|
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
||||
context.set_details('Method not implemented!')
|
||||
raise NotImplementedError('Method not implemented!')
|
||||
|
||||
def SubcribeUserData(self, request, context):
|
||||
"""Missing associated documentation comment in .proto file."""
|
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
||||
context.set_details('Method not implemented!')
|
||||
raise NotImplementedError('Method not implemented!')
|
||||
|
||||
def add_UserDataServiceServicer_to_server(servicer, server):
|
||||
rpc_method_handlers = {
|
||||
'SubscribeUserData': grpc.unary_stream_rpc_method_handler(
|
||||
servicer.SubscribeUserData,
|
||||
request_deserializer=bbgo__pb2.Empty.FromString,
|
||||
response_serializer=bbgo__pb2.SubscribeResponse.SerializeToString,
|
||||
),
|
||||
}
|
||||
generic_handler = grpc.method_handlers_generic_handler(
|
||||
'pb.UserDataService', rpc_method_handlers)
|
||||
server.add_generic_rpc_handlers((generic_handler,))
|
||||
|
||||
|
||||
# This class is part of an EXPERIMENTAL API.
|
||||
class UserDataService(object):
|
||||
"""Missing associated documentation comment in .proto file."""
|
||||
|
||||
@staticmethod
|
||||
def SubscribeUserData(request,
|
||||
target,
|
||||
options=(),
|
||||
channel_credentials=None,
|
||||
call_credentials=None,
|
||||
insecure=False,
|
||||
compression=None,
|
||||
wait_for_ready=None,
|
||||
timeout=None,
|
||||
metadata=None):
|
||||
return grpc.experimental.unary_stream(request, target, '/pb.UserDataService/SubscribeUserData',
|
||||
bbgo__pb2.Empty.SerializeToString,
|
||||
bbgo__pb2.SubscribeResponse.FromString,
|
||||
options, channel_credentials,
|
||||
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
|
||||
|
||||
|
||||
class TradingServiceStub(object):
|
||||
"""Missing associated documentation comment in .proto file."""
|
||||
|
||||
def __init__(self, channel):
|
||||
"""Constructor.
|
||||
|
||||
Args:
|
||||
channel: A grpc.Channel.
|
||||
"""
|
||||
self.SubmitOrder = channel.unary_unary(
|
||||
'/pb.TradingService/SubmitOrder',
|
||||
request_serializer=bbgo__pb2.SubmitOrderRequest.SerializeToString,
|
||||
response_deserializer=bbgo__pb2.SubmitOrderResponse.FromString,
|
||||
)
|
||||
self.CancelOrder = channel.unary_unary(
|
||||
'/pb.TradingService/CancelOrder',
|
||||
request_serializer=bbgo__pb2.CancelOrderRequest.SerializeToString,
|
||||
response_deserializer=bbgo__pb2.CancelOrderResponse.FromString,
|
||||
)
|
||||
self.QueryOrder = channel.unary_unary(
|
||||
'/pb.TradingService/QueryOrder',
|
||||
request_serializer=bbgo__pb2.QueryOrderRequest.SerializeToString,
|
||||
response_deserializer=bbgo__pb2.QueryOrderResponse.FromString,
|
||||
)
|
||||
self.QueryOrders = channel.unary_unary(
|
||||
'/pb.TradingService/QueryOrders',
|
||||
request_serializer=bbgo__pb2.QueryOrdersRequest.SerializeToString,
|
||||
response_deserializer=bbgo__pb2.QueryOrdersResponse.FromString,
|
||||
)
|
||||
self.QueryTrades = channel.unary_unary(
|
||||
'/pb.TradingService/QueryTrades',
|
||||
request_serializer=bbgo__pb2.QueryTradesRequest.SerializeToString,
|
||||
response_deserializer=bbgo__pb2.QueryTradesResponse.FromString,
|
||||
)
|
||||
|
||||
|
||||
class TradingServiceServicer(object):
|
||||
"""Missing associated documentation comment in .proto file."""
|
||||
|
||||
def SubmitOrder(self, request, context):
|
||||
"""request-response
|
||||
|
@ -103,25 +231,9 @@ class BBGOServicer(object):
|
|||
context.set_details('Method not implemented!')
|
||||
raise NotImplementedError('Method not implemented!')
|
||||
|
||||
def QueryKLines(self, request, context):
|
||||
"""Missing associated documentation comment in .proto file."""
|
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
||||
context.set_details('Method not implemented!')
|
||||
raise NotImplementedError('Method not implemented!')
|
||||
|
||||
|
||||
def add_BBGOServicer_to_server(servicer, server):
|
||||
def add_TradingServiceServicer_to_server(servicer, server):
|
||||
rpc_method_handlers = {
|
||||
'Subcribe': grpc.unary_stream_rpc_method_handler(
|
||||
servicer.Subcribe,
|
||||
request_deserializer=bbgo__pb2.SubscribeRequest.FromString,
|
||||
response_serializer=bbgo__pb2.SubscribeResponse.SerializeToString,
|
||||
),
|
||||
'SubcribeUserData': grpc.unary_stream_rpc_method_handler(
|
||||
servicer.SubcribeUserData,
|
||||
request_deserializer=bbgo__pb2.Empty.FromString,
|
||||
response_serializer=bbgo__pb2.SubscribeResponse.SerializeToString,
|
||||
),
|
||||
'SubmitOrder': grpc.unary_unary_rpc_method_handler(
|
||||
servicer.SubmitOrder,
|
||||
request_deserializer=bbgo__pb2.SubmitOrderRequest.FromString,
|
||||
|
@ -147,55 +259,16 @@ def add_BBGOServicer_to_server(servicer, server):
|
|||
request_deserializer=bbgo__pb2.QueryTradesRequest.FromString,
|
||||
response_serializer=bbgo__pb2.QueryTradesResponse.SerializeToString,
|
||||
),
|
||||
'QueryKLines': grpc.unary_unary_rpc_method_handler(
|
||||
servicer.QueryKLines,
|
||||
request_deserializer=bbgo__pb2.QueryKLinesRequest.FromString,
|
||||
response_serializer=bbgo__pb2.QueryKLinesResponse.SerializeToString,
|
||||
),
|
||||
}
|
||||
generic_handler = grpc.method_handlers_generic_handler(
|
||||
'pb.BBGO', rpc_method_handlers)
|
||||
'pb.TradingService', rpc_method_handlers)
|
||||
server.add_generic_rpc_handlers((generic_handler,))
|
||||
|
||||
|
||||
# This class is part of an EXPERIMENTAL API.
|
||||
class BBGO(object):
|
||||
class TradingService(object):
|
||||
"""Missing associated documentation comment in .proto file."""
|
||||
|
||||
@staticmethod
|
||||
def Subcribe(request,
|
||||
target,
|
||||
options=(),
|
||||
channel_credentials=None,
|
||||
call_credentials=None,
|
||||
insecure=False,
|
||||
compression=None,
|
||||
wait_for_ready=None,
|
||||
timeout=None,
|
||||
metadata=None):
|
||||
return grpc.experimental.unary_stream(request, target, '/pb.BBGO/Subcribe',
|
||||
bbgo__pb2.SubscribeRequest.SerializeToString,
|
||||
bbgo__pb2.SubscribeResponse.FromString,
|
||||
options, channel_credentials,
|
||||
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
|
||||
|
||||
@staticmethod
|
||||
def SubcribeUserData(request,
|
||||
target,
|
||||
options=(),
|
||||
channel_credentials=None,
|
||||
call_credentials=None,
|
||||
insecure=False,
|
||||
compression=None,
|
||||
wait_for_ready=None,
|
||||
timeout=None,
|
||||
metadata=None):
|
||||
return grpc.experimental.unary_stream(request, target, '/pb.BBGO/SubcribeUserData',
|
||||
bbgo__pb2.Empty.SerializeToString,
|
||||
bbgo__pb2.SubscribeResponse.FromString,
|
||||
options, channel_credentials,
|
||||
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
|
||||
|
||||
@staticmethod
|
||||
def SubmitOrder(request,
|
||||
target,
|
||||
|
@ -207,7 +280,7 @@ class BBGO(object):
|
|||
wait_for_ready=None,
|
||||
timeout=None,
|
||||
metadata=None):
|
||||
return grpc.experimental.unary_unary(request, target, '/pb.BBGO/SubmitOrder',
|
||||
return grpc.experimental.unary_unary(request, target, '/pb.TradingService/SubmitOrder',
|
||||
bbgo__pb2.SubmitOrderRequest.SerializeToString,
|
||||
bbgo__pb2.SubmitOrderResponse.FromString,
|
||||
options, channel_credentials,
|
||||
|
@ -224,7 +297,7 @@ class BBGO(object):
|
|||
wait_for_ready=None,
|
||||
timeout=None,
|
||||
metadata=None):
|
||||
return grpc.experimental.unary_unary(request, target, '/pb.BBGO/CancelOrder',
|
||||
return grpc.experimental.unary_unary(request, target, '/pb.TradingService/CancelOrder',
|
||||
bbgo__pb2.CancelOrderRequest.SerializeToString,
|
||||
bbgo__pb2.CancelOrderResponse.FromString,
|
||||
options, channel_credentials,
|
||||
|
@ -241,7 +314,7 @@ class BBGO(object):
|
|||
wait_for_ready=None,
|
||||
timeout=None,
|
||||
metadata=None):
|
||||
return grpc.experimental.unary_unary(request, target, '/pb.BBGO/QueryOrder',
|
||||
return grpc.experimental.unary_unary(request, target, '/pb.TradingService/QueryOrder',
|
||||
bbgo__pb2.QueryOrderRequest.SerializeToString,
|
||||
bbgo__pb2.QueryOrderResponse.FromString,
|
||||
options, channel_credentials,
|
||||
|
@ -258,7 +331,7 @@ class BBGO(object):
|
|||
wait_for_ready=None,
|
||||
timeout=None,
|
||||
metadata=None):
|
||||
return grpc.experimental.unary_unary(request, target, '/pb.BBGO/QueryOrders',
|
||||
return grpc.experimental.unary_unary(request, target, '/pb.TradingService/QueryOrders',
|
||||
bbgo__pb2.QueryOrdersRequest.SerializeToString,
|
||||
bbgo__pb2.QueryOrdersResponse.FromString,
|
||||
options, channel_credentials,
|
||||
|
@ -275,25 +348,8 @@ class BBGO(object):
|
|||
wait_for_ready=None,
|
||||
timeout=None,
|
||||
metadata=None):
|
||||
return grpc.experimental.unary_unary(request, target, '/pb.BBGO/QueryTrades',
|
||||
return grpc.experimental.unary_unary(request, target, '/pb.TradingService/QueryTrades',
|
||||
bbgo__pb2.QueryTradesRequest.SerializeToString,
|
||||
bbgo__pb2.QueryTradesResponse.FromString,
|
||||
options, channel_credentials,
|
||||
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
|
||||
|
||||
@staticmethod
|
||||
def QueryKLines(request,
|
||||
target,
|
||||
options=(),
|
||||
channel_credentials=None,
|
||||
call_credentials=None,
|
||||
insecure=False,
|
||||
compression=None,
|
||||
wait_for_ready=None,
|
||||
timeout=None,
|
||||
metadata=None):
|
||||
return grpc.experimental.unary_unary(request, target, '/pb.BBGO/QueryKLines',
|
||||
bbgo__pb2.QueryKLinesRequest.SerializeToString,
|
||||
bbgo__pb2.QueryKLinesResponse.FromString,
|
||||
options, channel_credentials,
|
||||
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
|
||||
|
|
Loading…
Reference in New Issue
Block a user