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.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").
AddStrategy(bondtrade.New, bondtrade.New).
Symbols("btcusdt", "bnbusdt")

View File

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