mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
import buyandhold strategy
This commit is contained in:
parent
aea6a7c03d
commit
9c751f377a
|
@ -14,12 +14,14 @@ import (
|
||||||
"github.com/c9s/bbgo/pkg/config"
|
"github.com/c9s/bbgo/pkg/config"
|
||||||
"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/strategy/buyandhold"
|
||||||
)
|
)
|
||||||
|
|
||||||
var errSlackTokenUndefined = errors.New("slack token is not defined.")
|
var errSlackTokenUndefined = errors.New("slack token is not defined.")
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
runCmd.Flags().String("config", "", "strategy config file")
|
runCmd.Flags().String("config", "config/bbgo.yaml", "strategy config file")
|
||||||
runCmd.Flags().String("since", "", "pnl since time")
|
runCmd.Flags().String("since", "", "pnl since time")
|
||||||
RootCmd.AddCommand(runCmd)
|
RootCmd.AddCommand(runCmd)
|
||||||
}
|
}
|
||||||
|
@ -56,7 +58,6 @@ var runCmd = &cobra.Command{
|
||||||
|
|
||||||
log.AddHook(slacklog.NewLogHook(slackToken, viper.GetString("slack-error-channel")))
|
log.AddHook(slacklog.NewLogHook(slackToken, viper.GetString("slack-error-channel")))
|
||||||
|
|
||||||
// TODO: load channel from config file
|
|
||||||
var notifier = slacknotifier.New(slackToken, viper.GetString("slack-channel"))
|
var notifier = slacknotifier.New(slackToken, viper.GetString("slack-channel"))
|
||||||
|
|
||||||
db, err := cmdutil.ConnectMySQL()
|
db, err := cmdutil.ConnectMySQL()
|
||||||
|
@ -71,11 +72,13 @@ var runCmd = &cobra.Command{
|
||||||
|
|
||||||
for _, entry := range userConfig.ExchangeStrategies {
|
for _, entry := range userConfig.ExchangeStrategies {
|
||||||
for _, mount := range entry.Mounts {
|
for _, mount := range entry.Mounts {
|
||||||
|
log.Infof("attaching strategy %T on %s...", entry.Strategy, mount)
|
||||||
trader.AttachStrategyOn(mount, entry.Strategy)
|
trader.AttachStrategyOn(mount, entry.Strategy)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, strategy := range userConfig.CrossExchangeStrategies {
|
for _, strategy := range userConfig.CrossExchangeStrategies {
|
||||||
|
log.Infof("attaching strategy %T", strategy)
|
||||||
trader.AttachCrossExchangeStrategy(strategy)
|
trader.AttachCrossExchangeStrategy(strategy)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,9 +22,9 @@ sessions:
|
||||||
secretVar: BINANCE_API_SECRET
|
secretVar: BINANCE_API_SECRET
|
||||||
|
|
||||||
exchangeStrategies:
|
exchangeStrategies:
|
||||||
- on: binance
|
- on: binance
|
||||||
buyandhold:
|
buyandhold:
|
||||||
symbol: "BTCUSDT"
|
symbol: "BTCUSDT"
|
||||||
interval: "1m"
|
interval: "1m"
|
||||||
baseQuantity: 0.1
|
baseQuantity: 0.1
|
||||||
minDropPercentage: -0.05
|
minDropPercentage: -0.05
|
||||||
|
|
|
@ -100,6 +100,7 @@ func loadExchangeStrategies(stash Stash) (strategies []SingleExchangeStrategyCon
|
||||||
exchangeStrategiesConf, ok := stash["exchangeStrategies"]
|
exchangeStrategiesConf, ok := stash["exchangeStrategies"]
|
||||||
if !ok {
|
if !ok {
|
||||||
return strategies, nil
|
return strategies, nil
|
||||||
|
// return nil, errors.New("exchangeStrategies is not defined")
|
||||||
}
|
}
|
||||||
|
|
||||||
configList, ok := exchangeStrategiesConf.([]interface{})
|
configList, ok := exchangeStrategiesConf.([]interface{})
|
||||||
|
|
Loading…
Reference in New Issue
Block a user