mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-13 02:23:51 +00:00
drop legacy OrderProcessor and remove slack debug
This commit is contained in:
parent
468864302e
commit
b22e0370b3
|
@ -144,7 +144,6 @@ func (e *BasicRiskControlOrderExecutor) SubmitOrders(ctx context.Context, orders
|
||||||
e.Notify(":memo: Submitting %s %s %s order with quantity %s @ %s", o.Symbol, o.Side, o.Type, o.QuantityString, o.PriceString, o)
|
e.Notify(":memo: Submitting %s %s %s order with quantity %s @ %s", o.Symbol, o.Side, o.Type, o.QuantityString, o.PriceString, o)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return e.session.Exchange.SubmitOrders(ctx, formattedOrders...)
|
return e.session.Exchange.SubmitOrders(ctx, formattedOrders...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,7 @@
|
||||||
package bbgo
|
package bbgo
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
"github.com/c9s/bbgo/pkg/types"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -17,27 +13,7 @@ var (
|
||||||
ErrAssetBalanceLevelTooHigh = errors.New("asset balance level too high")
|
ErrAssetBalanceLevelTooHigh = errors.New("asset balance level too high")
|
||||||
)
|
)
|
||||||
|
|
||||||
// OrderProcessor does:
|
/*
|
||||||
// - Check quote balance
|
|
||||||
// - Check and control the order amount
|
|
||||||
// - Adjust order amount due to the minAmount configuration and maxAmount configuration
|
|
||||||
// - Canonicalize the volume precision base on the given exchange
|
|
||||||
type OrderProcessor struct {
|
|
||||||
// balance control
|
|
||||||
MinQuoteBalance float64 `json:"minQuoteBalance"`
|
|
||||||
MaxAssetBalance float64 `json:"maxBaseAssetBalance"`
|
|
||||||
MinAssetBalance float64 `json:"minBaseAssetBalance"`
|
|
||||||
MaxOrderAmount float64 `json:"maxOrderAmount"`
|
|
||||||
|
|
||||||
// MinProfitSpread is used when submitting sell orders, it check if there the selling can make the profit.
|
|
||||||
MinProfitSpread float64 `json:"minProfitSpread"`
|
|
||||||
|
|
||||||
|
|
||||||
Exchange types.Exchange `json:"-"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *OrderProcessor) Submit(ctx context.Context, order types.SubmitOrder) error {
|
|
||||||
/*
|
|
||||||
tradingCtx := p.OrderExecutor.Context
|
tradingCtx := p.OrderExecutor.Context
|
||||||
currentPrice := tradingCtx.CurrentPrice
|
currentPrice := tradingCtx.CurrentPrice
|
||||||
market := order.Market
|
market := order.Market
|
||||||
|
@ -123,12 +99,7 @@ func (p *OrderProcessor) Submit(ctx context.Context, order types.SubmitOrder) er
|
||||||
|
|
||||||
order.Quantity = quantity
|
order.Quantity = quantity
|
||||||
order.QuantityString = market.FormatVolume(quantity)
|
order.QuantityString = market.FormatVolume(quantity)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
createdOrders, err := p.Exchange.SubmitOrders(ctx, order)
|
|
||||||
_ = createdOrders
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
func adjustQuantityByMinAmount(quantity float64, currentPrice float64, minAmount float64) float64 {
|
func adjustQuantityByMinAmount(quantity float64, currentPrice float64, minAmount float64) float64 {
|
||||||
// modify quantity for the min amount
|
// modify quantity for the min amount
|
||||||
|
|
|
@ -24,7 +24,6 @@ import (
|
||||||
"github.com/c9s/bbgo/pkg/notifier/slacknotifier"
|
"github.com/c9s/bbgo/pkg/notifier/slacknotifier"
|
||||||
"github.com/c9s/bbgo/pkg/slack/slacklog"
|
"github.com/c9s/bbgo/pkg/slack/slacklog"
|
||||||
"github.com/c9s/bbgo/pkg/types"
|
"github.com/c9s/bbgo/pkg/types"
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var errSlackTokenUndefined = errors.New("slack token is not defined.")
|
var errSlackTokenUndefined = errors.New("slack token is not defined.")
|
||||||
|
@ -117,7 +116,7 @@ func runConfig(ctx context.Context, userConfig *bbgo.Config) error {
|
||||||
log.AddHook(slacklog.NewLogHook(slackToken, conf.ErrorChannel))
|
log.AddHook(slacklog.NewLogHook(slackToken, conf.ErrorChannel))
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Infof("adding slack notifier...")
|
log.Infof("adding slack notifier with default channel: %s", conf.DefaultChannel)
|
||||||
var notifier = slacknotifier.New(slackToken, conf.DefaultChannel)
|
var notifier = slacknotifier.New(slackToken, conf.DefaultChannel)
|
||||||
trader.AddNotifier(notifier)
|
trader.AddNotifier(notifier)
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,8 @@ type Notifier struct {
|
||||||
type NotifyOption func(notifier *Notifier)
|
type NotifyOption func(notifier *Notifier)
|
||||||
|
|
||||||
func New(token, channel string, options ...NotifyOption) *Notifier {
|
func New(token, channel string, options ...NotifyOption) *Notifier {
|
||||||
var client = slack.New(token, slack.OptionDebug(true))
|
// var client = slack.New(token, slack.OptionDebug(true))
|
||||||
|
var client = slack.New(token)
|
||||||
|
|
||||||
notifier := &Notifier{
|
notifier := &Notifier{
|
||||||
channel: channel,
|
channel: channel,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user