mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 14:55:16 +00:00
move strategy to the pkg/strategy
This commit is contained in:
parent
6c1f214d0f
commit
a105af35ce
|
@ -2,6 +2,7 @@ package binance
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
|
@ -60,10 +61,15 @@ func (e *Exchange) SubmitOrder(ctx context.Context, order *types.Order) error {
|
|||
Do(ctx)
|
||||
*/
|
||||
|
||||
orderType, err := toLocalOrderType(order.Type)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
req := e.Client.NewCreateOrderService().
|
||||
Symbol(order.Symbol).
|
||||
Side(binance.SideType(order.Side)).
|
||||
Type(order.Type).
|
||||
Type(orderType).
|
||||
Quantity(order.VolumeStr)
|
||||
|
||||
if len(order.PriceStr) > 0 {
|
||||
|
@ -78,6 +84,18 @@ func (e *Exchange) SubmitOrder(ctx context.Context, order *types.Order) error {
|
|||
return err
|
||||
}
|
||||
|
||||
func toLocalOrderType(orderType types.OrderType) (binance.OrderType, error) {
|
||||
switch orderType {
|
||||
case types.OrderTypeLimit:
|
||||
return binance.OrderTypeLimit, nil
|
||||
|
||||
case types.OrderTypeMarket:
|
||||
return binance.OrderTypeMarket, nil
|
||||
}
|
||||
|
||||
return "", fmt.Errorf("order type %s not supported", orderType)
|
||||
}
|
||||
|
||||
func (e *Exchange) QueryKLines(ctx context.Context, symbol, interval string, limit int) ([]types.KLine, error) {
|
||||
logrus.Infof("[binance] querying kline %s %s limit %d", symbol, interval, limit)
|
||||
|
||||
|
|
|
@ -5,10 +5,18 @@ import (
|
|||
"github.com/slack-go/slack"
|
||||
)
|
||||
|
||||
// OrderType define order type
|
||||
type OrderType string
|
||||
|
||||
const (
|
||||
OrderTypeLimit OrderType = "LIMIT"
|
||||
OrderTypeMarket OrderType = "MARKET"
|
||||
)
|
||||
|
||||
type Order struct {
|
||||
Symbol string
|
||||
Side SideType
|
||||
Type binance.OrderType
|
||||
Type OrderType
|
||||
VolumeStr string
|
||||
PriceStr string
|
||||
|
||||
|
@ -33,4 +41,3 @@ func (o *Order) SlackAttachment() slack.Attachment {
|
|||
Fields: fields,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user