mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
add broker id on max
This commit is contained in:
parent
5d2296eddd
commit
e87c2e271f
|
@ -309,10 +309,7 @@ func toMaxSubmitOrder(o types.SubmitOrder) (*maxapi.Order, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
clientOrderID := o.ClientOrderID
|
||||
if len(clientOrderID) == 0 {
|
||||
clientOrderID = uuid.New().String()
|
||||
}
|
||||
clientOrderID := newSpotClientOrderID(o.ClientOrderID)
|
||||
|
||||
volumeInString := o.QuantityString
|
||||
if len(volumeInString) == 0 {
|
||||
|
@ -818,3 +815,30 @@ func (e *Exchange) QueryAveragePrice(ctx context.Context, symbol string) (float6
|
|||
|
||||
return (util.MustParseFloat(ticker.Sell) + util.MustParseFloat(ticker.Buy)) / 2, nil
|
||||
}
|
||||
|
||||
|
||||
// BBGO is a broker on MAX
|
||||
const spotBrokerID = "bbgo-"
|
||||
|
||||
func newSpotClientOrderID(originalID string) (clientOrderID string) {
|
||||
prefix := "x-" + spotBrokerID
|
||||
prefixLen := len(prefix)
|
||||
|
||||
if originalID != "" {
|
||||
// try to keep the whole original client order ID if user specifies it.
|
||||
if prefixLen + len(originalID) > 32 {
|
||||
return originalID
|
||||
}
|
||||
|
||||
clientOrderID = prefix + originalID
|
||||
return clientOrderID
|
||||
}
|
||||
|
||||
clientOrderID = uuid.New().String()
|
||||
clientOrderID = prefix + clientOrderID
|
||||
if len(clientOrderID) > 32 {
|
||||
return clientOrderID[0:32]
|
||||
}
|
||||
|
||||
return clientOrderID
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user