mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-11 09:33:50 +00:00
32 lines
597 B
Go
32 lines
597 B
Go
package bbgo
|
|
|
|
import (
|
|
"context"
|
|
"github.com/adshao/go-binance"
|
|
"github.com/sirupsen/logrus"
|
|
)
|
|
|
|
type BinanceExchange struct {
|
|
Client *binance.Client
|
|
}
|
|
|
|
func (e *BinanceExchange) SubmitOrder(ctx context.Context, order Order) error {
|
|
req := e.Client.NewCreateOrderService().
|
|
Symbol(order.Symbol).
|
|
Side(order.Side).
|
|
Type(order.Type).
|
|
Quantity(order.VolumeStr)
|
|
|
|
if len(order.PriceStr) > 0 {
|
|
req.Price(order.PriceStr)
|
|
}
|
|
if len(order.TimeInForce) > 0 {
|
|
req.TimeInForce(order.TimeInForce)
|
|
}
|
|
|
|
retOrder, err := req.Do(ctx)
|
|
logrus.Infof("order created: %+v", retOrder)
|
|
return err
|
|
}
|
|
|