mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-21 22:43:52 +00:00
add MarkPriceUpdateEvent
This commit is contained in:
parent
aceca1b49f
commit
a36739f119
|
@ -1,6 +1,6 @@
|
|||
import axios from "axios";
|
||||
|
||||
const baseURL = process.env.NODE_ENV === "development" ? "http://localhost:8080" : ""
|
||||
const baseURL = "http://66.228.52.222:8080"//process.env.NODE_ENV === "development" ? "http://localhost:8080" : ""
|
||||
|
||||
export function ping(cb) {
|
||||
return axios.get(baseURL + '/api/ping').then(response => {
|
||||
|
|
2
go.mod
2
go.mod
|
@ -7,6 +7,7 @@ go 1.13
|
|||
require (
|
||||
github.com/DATA-DOG/go-sqlmock v1.5.0
|
||||
github.com/adshao/go-binance/v2 v2.3.2
|
||||
github.com/c9s/callbackgen v0.0.0-20200923145104-900eb6f89ba4 // indirect
|
||||
github.com/c9s/rockhopper v1.2.1-0.20210217093258-2661955904a9
|
||||
github.com/codingconcepts/env v0.0.0-20200821220118-a8fbf8d84482
|
||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible // indirect
|
||||
|
@ -49,6 +50,7 @@ require (
|
|||
github.com/spf13/viper v1.7.1
|
||||
github.com/stretchr/testify v1.7.0
|
||||
github.com/tebeka/strftime v0.1.3 // indirect
|
||||
github.com/tools/godep v0.0.0-20180126220526-ce0bfadeb516 // indirect
|
||||
github.com/ugorji/go v1.2.3 // indirect
|
||||
github.com/valyala/fastjson v1.5.1
|
||||
github.com/webview/webview v0.0.0-20210216142346-e0bfdf0e5d90
|
||||
|
|
4
go.sum
4
go.sum
|
@ -55,6 +55,8 @@ github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 h1:DDGfHa7BWjL4Yn
|
|||
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4=
|
||||
github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc h1:biVzkmvwrH8WK8raXaxBx6fRVTlJILwEwQGL1I/ByEI=
|
||||
github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8=
|
||||
github.com/c9s/callbackgen v0.0.0-20200923145104-900eb6f89ba4 h1:VNfmuE5QUUwFLU5YIPio1fI3MqCfgRb00inu4QKn/uI=
|
||||
github.com/c9s/callbackgen v0.0.0-20200923145104-900eb6f89ba4/go.mod h1:LKqRir4fL00uSbKpY3L2Tx8Uu65QrpbrZeKcYfZqPDE=
|
||||
github.com/c9s/rockhopper v1.2.1-0.20210217093258-2661955904a9 h1:Wlr5DjDOf5Kygoo0LoUthxwAhNwLEXMWHqCKXbMHCsw=
|
||||
github.com/c9s/rockhopper v1.2.1-0.20210217093258-2661955904a9/go.mod h1:KJnQjZSrWA83jjwGF/+O7Y96VCVirYTYEvXJJOc6kMU=
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1 h1:glEXhBS5PSLLv4IXzLA5yPRVX4bilULVyxxbrfOtDAk=
|
||||
|
@ -467,6 +469,8 @@ github.com/tebeka/strftime v0.1.3 h1:5HQXOqWKYRFfNyBMNVc9z5+QzuBtIXy03psIhtdJYto
|
|||
github.com/tebeka/strftime v0.1.3/go.mod h1:7wJm3dZlpr4l/oVK0t1HYIc4rMzQ2XJlOMIUJUJH6XQ=
|
||||
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5 h1:LnC5Kc/wtumK+WB441p7ynQJzVuNRJiqddSIE3IlSEQ=
|
||||
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
|
||||
github.com/tools/godep v0.0.0-20180126220526-ce0bfadeb516 h1:h4a8ZFxjlRVGsFGP4l/AdnoUYcF3pfxzyepS3oKZ8mE=
|
||||
github.com/tools/godep v0.0.0-20180126220526-ce0bfadeb516/go.mod h1:OGh2HQGYVW+2+ZdB+DgJhI75kivkKWtVcIxI/pesDsY=
|
||||
github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
|
||||
github.com/ugorji/go v1.2.3 h1:WbFSXLxDFKVN69Sk8t+XHGzVCD7R8UoAATR8NqZgTbk=
|
||||
github.com/ugorji/go v1.2.3/go.mod h1:5l8GZ8hZvmL4uMdy+mhCO1LjswGRYco9Q3HfuisB21A=
|
||||
|
|
|
@ -292,6 +292,11 @@ func ParseEvent(message string) (interface{}, error) {
|
|||
|
||||
case "depthUpdate":
|
||||
return parseDepthEvent(val)
|
||||
|
||||
case "markPriceUpdate":
|
||||
var event MarkPriceUpdateEvent
|
||||
err := json.Unmarshal([]byte(message), &event)
|
||||
return &event, err
|
||||
|
||||
default:
|
||||
id := val.GetInt("id")
|
||||
|
@ -489,6 +494,33 @@ func (k *KLine) KLine() types.KLine {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
type MarkPriceUpdateEvent struct {
|
||||
EventBase
|
||||
|
||||
Symbol string `json:"s"`
|
||||
|
||||
MarkPrice fixedpoint.Value `json:"p"`
|
||||
IndexPrice fixedpoint.Value `json:"i"`
|
||||
EstimatedPrice fixedpoint.Value `json:"P"`
|
||||
|
||||
FundingRate fixedpoint.Value `json:"r"`
|
||||
NextFundingTime int64 `json:"T"`
|
||||
}
|
||||
|
||||
/*
|
||||
{
|
||||
"e": "markPriceUpdate", // Event type
|
||||
"E": 1562305380000, // Event time
|
||||
"s": "BTCUSDT", // Symbol
|
||||
"p": "11794.15000000", // Mark price
|
||||
"i": "11784.62659091", // Index price
|
||||
"P": "11784.25641265", // Estimated Settle Price, only useful in the last hour before the settlement starts
|
||||
"r": "0.00038167", // Funding rate
|
||||
"T": 1562306400000 // Next funding time
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
kline
|
||||
|
|
|
@ -58,7 +58,7 @@ type StreamRequest struct {
|
|||
//go:generate callbackgen -type Stream -interface
|
||||
type Stream struct {
|
||||
types.MarginSettings
|
||||
|
||||
types.FuturesSettings
|
||||
types.StandardStream
|
||||
|
||||
Client *binance.Client
|
||||
|
@ -75,6 +75,8 @@ type Stream struct {
|
|||
kLineEventCallbacks []func(e *KLineEvent)
|
||||
kLineClosedEventCallbacks []func(e *KLineEvent)
|
||||
|
||||
MarkPriceUpdateEventCallbacks []func(e *MarkPriceUpdateEvent)
|
||||
|
||||
balanceUpdateEventCallbacks []func(event *BalanceUpdateEvent)
|
||||
outboundAccountInfoEventCallbacks []func(event *OutboundAccountInfoEvent)
|
||||
outboundAccountPositionEventCallbacks []func(event *OutboundAccountPositionEvent)
|
||||
|
@ -538,6 +540,9 @@ func (s *Stream) read(ctx context.Context) {
|
|||
|
||||
case *ExecutionReportEvent:
|
||||
s.EmitExecutionReportEvent(e)
|
||||
|
||||
case *MarkPriceUpdateEvent:
|
||||
s.EmitMarkPriceUpdateEvent(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,6 +34,16 @@ func (s *Stream) EmitKLineClosedEvent(e *KLineEvent) {
|
|||
}
|
||||
}
|
||||
|
||||
func (s *Stream) OnMarkPriceUpdateEvent(cb func(e *MarkPriceUpdateEvent)) {
|
||||
s.MarkPriceUpdateEventCallbacks = append(s.MarkPriceUpdateEventCallbacks, cb)
|
||||
}
|
||||
|
||||
func (s *Stream) EmitMarkPriceUpdateEvent(e *MarkPriceUpdateEvent) {
|
||||
for _, cb := range s.MarkPriceUpdateEventCallbacks {
|
||||
cb(e)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Stream) OnBalanceUpdateEvent(cb func(event *BalanceUpdateEvent)) {
|
||||
s.balanceUpdateEventCallbacks = append(s.balanceUpdateEventCallbacks, cb)
|
||||
}
|
||||
|
@ -81,6 +91,8 @@ type StreamEventHub interface {
|
|||
|
||||
OnKLineClosedEvent(cb func(e *KLineEvent))
|
||||
|
||||
OnMarkPriceUpdateEvent(cb func(e *MarkPriceUpdateEvent))
|
||||
|
||||
OnBalanceUpdateEvent(cb func(event *BalanceUpdateEvent))
|
||||
|
||||
OnOutboundAccountInfoEvent(cb func(event *OutboundAccountInfoEvent))
|
||||
|
|
Loading…
Reference in New Issue
Block a user