mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
fix deploy
This commit is contained in:
parent
ce89835a7d
commit
62e27957c1
|
@ -5,6 +5,7 @@ import (
|
|||
"github.com/adshao/go-binance"
|
||||
"github.com/c9s/bbgo/pkg/bbgo/types"
|
||||
binance2 "github.com/c9s/bbgo/pkg/exchange/binance"
|
||||
types2 "github.com/c9s/bbgo/pkg/types"
|
||||
"github.com/c9s/bbgo/pkg/util"
|
||||
"github.com/slack-go/slack"
|
||||
"math"
|
||||
|
@ -125,7 +126,7 @@ func (d *KLineDetector) String() string {
|
|||
return name
|
||||
}
|
||||
|
||||
func (d *KLineDetector) NewOrder(e *binance2.KLineEvent, tradingCtx *TradingContext) *Order {
|
||||
func (d *KLineDetector) NewOrder(e *binance2.KLineEvent, tradingCtx *TradingContext) *types2.Order {
|
||||
var kline types.KLineOrWindow = e.KLine
|
||||
if d.EnableLookBack {
|
||||
klineWindow := tradingCtx.KLineWindows[e.KLine.Interval]
|
||||
|
@ -144,7 +145,7 @@ func (d *KLineDetector) NewOrder(e *binance2.KLineEvent, tradingCtx *TradingCont
|
|||
}
|
||||
|
||||
var volume = tradingCtx.Market.FormatVolume(VolumeByPriceChange(tradingCtx.Market, kline.GetClose(), kline.GetChange(), side))
|
||||
return &Order{
|
||||
return &types2.Order{
|
||||
Symbol: e.KLine.Symbol,
|
||||
Type: binance.OrderTypeMarket,
|
||||
Side: side,
|
||||
|
|
|
@ -1,49 +1,2 @@
|
|||
package bbgo
|
||||
|
||||
import (
|
||||
"github.com/adshao/go-binance"
|
||||
"github.com/slack-go/slack"
|
||||
)
|
||||
|
||||
const Green = "#228B22"
|
||||
const Red = "#800000"
|
||||
|
||||
type Order struct {
|
||||
Symbol string
|
||||
Side binance.SideType
|
||||
Type binance.OrderType
|
||||
VolumeStr string
|
||||
PriceStr string
|
||||
|
||||
TimeInForce binance.TimeInForceType
|
||||
}
|
||||
|
||||
func (o *Order) SlackAttachment() slack.Attachment {
|
||||
var fields = []slack.AttachmentField{
|
||||
{Title: "Symbol", Value: o.Symbol, Short: true},
|
||||
{Title: "Side", Value: string(o.Side), Short: true},
|
||||
{Title: "Volume", Value: o.VolumeStr, Short: true},
|
||||
}
|
||||
|
||||
if len(o.PriceStr) > 0 {
|
||||
fields = append(fields, slack.AttachmentField{Title: "Price", Value: o.PriceStr, Short: true})
|
||||
}
|
||||
|
||||
return slack.Attachment{
|
||||
Color: SideToColorName(o.Side),
|
||||
Title: string(o.Type) + " Order " + string(o.Side),
|
||||
// Text: "",
|
||||
Fields: fields,
|
||||
}
|
||||
}
|
||||
|
||||
func SideToColorName(side binance.SideType) string {
|
||||
if side == binance.SideTypeBuy {
|
||||
return Green
|
||||
}
|
||||
if side == binance.SideTypeSell {
|
||||
return Red
|
||||
}
|
||||
|
||||
return "#f0f0f0"
|
||||
}
|
||||
|
|
|
@ -171,7 +171,7 @@ func (t *Trader) ReportPnL() {
|
|||
}
|
||||
}
|
||||
|
||||
func (t *Trader) SubmitOrder(ctx context.Context, order *Order) {
|
||||
func (t *Trader) SubmitOrder(ctx context.Context, order *types.Order) {
|
||||
t.Infof(":memo: Submitting %s order on side %s with volume: %s", order.Type, order.Side, order.VolumeStr, order.SlackAttachment())
|
||||
|
||||
err := t.Exchange.SubmitOrder(ctx, order)
|
||||
|
|
|
@ -3,7 +3,6 @@ package binance
|
|||
import (
|
||||
"context"
|
||||
"github.com/adshao/go-binance"
|
||||
"github.com/c9s/bbgo/pkg/bbgo"
|
||||
"github.com/c9s/bbgo/pkg/types"
|
||||
"github.com/c9s/bbgo/pkg/util"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
@ -45,7 +44,7 @@ func (e *Exchange) NewPrivateStream(ctx context.Context) (*PrivateStream, error)
|
|||
}, nil
|
||||
}
|
||||
|
||||
func (e *Exchange) SubmitOrder(ctx context.Context, order *bbgo.Order) error {
|
||||
func (e *Exchange) SubmitOrder(ctx context.Context, order *types.Order) error {
|
||||
/*
|
||||
limit order example
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@ package types
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/c9s/bbgo/pkg/bbgo"
|
||||
"github.com/c9s/bbgo/pkg/util"
|
||||
"github.com/slack-go/slack"
|
||||
"math"
|
||||
|
@ -122,9 +121,9 @@ func (k KLine) String() string {
|
|||
|
||||
func (k KLine) Color() string {
|
||||
if k.GetTrend() > 0 {
|
||||
return bbgo.Green
|
||||
return Green
|
||||
} else if k.GetTrend() < 0 {
|
||||
return bbgo.Red
|
||||
return Red
|
||||
}
|
||||
return "#f0f0f0"
|
||||
}
|
||||
|
@ -267,9 +266,9 @@ func (k KLineWindow) GetTrend() int {
|
|||
|
||||
func (k KLineWindow) Color() string {
|
||||
if k.GetTrend() > 0 {
|
||||
return bbgo.Green
|
||||
return Green
|
||||
} else if k.GetTrend() < 0 {
|
||||
return bbgo.Red
|
||||
return Red
|
||||
}
|
||||
return "#f0f0f0"
|
||||
}
|
||||
|
|
49
types/order.go
Normal file
49
types/order.go
Normal file
|
@ -0,0 +1,49 @@
|
|||
package types
|
||||
|
||||
import (
|
||||
"github.com/adshao/go-binance"
|
||||
"github.com/slack-go/slack"
|
||||
)
|
||||
|
||||
const Green = "#228B22"
|
||||
const Red = "#800000"
|
||||
|
||||
type Order struct {
|
||||
Symbol string
|
||||
Side binance.SideType
|
||||
Type binance.OrderType
|
||||
VolumeStr string
|
||||
PriceStr string
|
||||
|
||||
TimeInForce binance.TimeInForceType
|
||||
}
|
||||
|
||||
func (o *Order) SlackAttachment() slack.Attachment {
|
||||
var fields = []slack.AttachmentField{
|
||||
{Title: "Symbol", Value: o.Symbol, Short: true},
|
||||
{Title: "Side", Value: string(o.Side), Short: true},
|
||||
{Title: "Volume", Value: o.VolumeStr, Short: true},
|
||||
}
|
||||
|
||||
if len(o.PriceStr) > 0 {
|
||||
fields = append(fields, slack.AttachmentField{Title: "Price", Value: o.PriceStr, Short: true})
|
||||
}
|
||||
|
||||
return slack.Attachment{
|
||||
Color: SideToColorName(o.Side),
|
||||
Title: string(o.Type) + " Order " + string(o.Side),
|
||||
// Text: "",
|
||||
Fields: fields,
|
||||
}
|
||||
}
|
||||
|
||||
func SideToColorName(side binance.SideType) string {
|
||||
if side == binance.SideTypeBuy {
|
||||
return Green
|
||||
}
|
||||
if side == binance.SideTypeSell {
|
||||
return Red
|
||||
}
|
||||
|
||||
return "#f0f0f0"
|
||||
}
|
Loading…
Reference in New Issue
Block a user