mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 00:35:15 +00:00
move exchange and order struct to the bbgo package
This commit is contained in:
parent
e62f1f2479
commit
965ab59580
31
bbgo/binance_exchange.go
Normal file
31
bbgo/binance_exchange.go
Normal file
|
@ -0,0 +1,31 @@
|
|||
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
|
||||
}
|
||||
|
14
bbgo/order.go
Normal file
14
bbgo/order.go
Normal file
|
@ -0,0 +1,14 @@
|
|||
package bbgo
|
||||
|
||||
import "github.com/adshao/go-binance"
|
||||
|
||||
type Order struct {
|
||||
Symbol string
|
||||
Side binance.SideType
|
||||
Type binance.OrderType
|
||||
VolumeStr string
|
||||
PriceStr string
|
||||
|
||||
TimeInForce binance.TimeInForceType
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user