replace api key secret var name

This commit is contained in:
c9s 2020-10-10 13:17:04 +08:00
parent 5fc6ecce05
commit fab8d0bbdf
2 changed files with 5 additions and 14 deletions

View File

@ -69,7 +69,7 @@ t := bbgo.New(bbgo.Config{
t.AddNotifier(slacknotifier.New(slackToken)) t.AddNotifier(slacknotifier.New(slackToken))
t.AddLogHook(slacklog.NewLogHook(slackToken)) t.AddLogHook(slacklog.NewLogHook(slackToken))
t.AddExchange("binance", binance.New(viper.Getenv("bn-key"), viper.Getenv("bn-secret")))). t.AddExchange("binance", binance.New(viper.Getenv("binance-api-key"), viper.Getenv("binance-api-secret")))).
Subscribe("binance", "btcusdt", "kline@5m", "book", "trade"). Subscribe("binance", "btcusdt", "kline@5m", "book", "trade").
AddStrategy(bondtrade.New, bondtrade.New). AddStrategy(bondtrade.New, bondtrade.New).
Symbols("btcusdt", "bnbusdt") Symbols("btcusdt", "bnbusdt")

View File

@ -6,7 +6,6 @@ import (
"strings" "strings"
"time" "time"
"github.com/adshao/go-binance"
"github.com/jmoiron/sqlx" "github.com/jmoiron/sqlx"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"github.com/spf13/cobra" "github.com/spf13/cobra"
@ -17,7 +16,6 @@ import (
binance2 "github.com/c9s/bbgo/exchange/binance" binance2 "github.com/c9s/bbgo/exchange/binance"
"github.com/c9s/bbgo/service" "github.com/c9s/bbgo/service"
"github.com/c9s/bbgo/types" "github.com/c9s/bbgo/types"
"github.com/c9s/bbgo/util"
) )
func init() { func init() {
@ -38,11 +36,9 @@ var pnlCmd = &cobra.Command{
return err return err
} }
binanceKey := viper.GetString("bn-key") binanceKey := viper.GetString("binance-api-key")
binanceSecret := viper.GetString("bn-secret") binanceSecret := viper.GetString("binance-api-secret")
binanceExchange := binance2.New(binanceKey, binanceSecret)
binanceClient := binance.NewClient(binanceKey, binanceSecret)
binanceExchange := &binance2.Exchange{Client: binanceClient}
mysqlURL := viper.GetString("mysql-url") mysqlURL := viper.GetString("mysql-url")
mysqlURL = fmt.Sprintf("%s?parseTime=true", mysqlURL) mysqlURL = fmt.Sprintf("%s?parseTime=true", mysqlURL)
@ -105,12 +101,7 @@ var pnlCmd = &cobra.Command{
logrus.Infof("found checkpoints: %+v", checkpoints) logrus.Infof("found checkpoints: %+v", checkpoints)
logrus.Infof("stock: %f", stockManager.Stocks.Quantity()) logrus.Infof("stock: %f", stockManager.Stocks.Quantity())
// query the last average price so that we can calculate the pnl currentPrice, err := binanceExchange.QueryAveragePrice(ctx, symbol)
resp, err := binanceClient.NewAveragePriceService().Symbol(symbol).Do(ctx)
if err != nil {
return err
}
currentPrice := util.MustParseFloat(resp.Price)
calculator := &accounting.ProfitAndLossCalculator{ calculator := &accounting.ProfitAndLossCalculator{
TradingFeeCurrency: tradingFeeCurrency, TradingFeeCurrency: tradingFeeCurrency,