mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-24 15:55:14 +00:00
solved all deprecated, comment all unused variables and functions
This commit is contained in:
parent
a8f163bfd3
commit
8b17d78a48
|
@ -2,7 +2,7 @@ package accounting
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io/ioutil"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
@ -16,7 +16,7 @@ func TestStockManager(t *testing.T) {
|
||||||
t.Run("testdata", func(t *testing.T) {
|
t.Run("testdata", func(t *testing.T) {
|
||||||
var trades []types.Trade
|
var trades []types.Trade
|
||||||
|
|
||||||
out, err := ioutil.ReadFile("testdata/btcusdt-trades.json")
|
out, err := os.ReadFile("testdata/btcusdt-trades.json")
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
err = json.Unmarshal(out, &trades)
|
err = json.Unmarshal(out, &trades)
|
||||||
|
|
|
@ -136,12 +136,6 @@ func (e *Exchange) resetMatchingBooks() {
|
||||||
e.matchingBooksMutex.Unlock()
|
e.matchingBooksMutex.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *Exchange) addMatchingBook(symbol string, market types.Market) {
|
|
||||||
e.matchingBooksMutex.Lock()
|
|
||||||
e._addMatchingBook(symbol, market)
|
|
||||||
e.matchingBooksMutex.Unlock()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e *Exchange) _addMatchingBook(symbol string, market types.Market) {
|
func (e *Exchange) _addMatchingBook(symbol string, market types.Market) {
|
||||||
matching := &SimplePriceMatching{
|
matching := &SimplePriceMatching{
|
||||||
currentTime: e.currentTime,
|
currentTime: e.currentTime,
|
||||||
|
|
|
@ -48,6 +48,7 @@ func init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// SimplePriceMatching implements a simple kline data driven matching engine for backtest
|
// SimplePriceMatching implements a simple kline data driven matching engine for backtest
|
||||||
|
//
|
||||||
//go:generate callbackgen -type SimplePriceMatching
|
//go:generate callbackgen -type SimplePriceMatching
|
||||||
type SimplePriceMatching struct {
|
type SimplePriceMatching struct {
|
||||||
Symbol string
|
Symbol string
|
||||||
|
|
|
@ -3,7 +3,6 @@ package backtest
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -55,7 +54,7 @@ type SummaryReport struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func ReadSummaryReport(filename string) (*SummaryReport, error) {
|
func ReadSummaryReport(filename string) (*SummaryReport, error) {
|
||||||
o, err := ioutil.ReadFile(filename)
|
o, err := os.ReadFile(filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -247,7 +246,7 @@ func loadReportIndexLocked(indexFilePath string) (*ReportIndex, error) {
|
||||||
if fileInfo, err := os.Stat(indexFilePath); err != nil {
|
if fileInfo, err := os.Stat(indexFilePath); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else if fileInfo.Size() != 0 {
|
} else if fileInfo.Size() != 0 {
|
||||||
o, err := ioutil.ReadFile(indexFilePath)
|
o, err := os.ReadFile(indexFilePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,7 +70,7 @@ func (b *ActiveOrderBook) BindStream(stream types.Stream) {
|
||||||
stream.OnOrderUpdate(b.orderUpdateHandler)
|
stream.OnOrderUpdate(b.orderUpdateHandler)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *ActiveOrderBook) waitClear(
|
func (b *ActiveOrderBook) waitOrderClear(
|
||||||
ctx context.Context, order types.Order, waitTime, timeout time.Duration,
|
ctx context.Context, order types.Order, waitTime, timeout time.Duration,
|
||||||
) (bool, error) {
|
) (bool, error) {
|
||||||
if !b.orders.Exists(order.OrderID) {
|
if !b.orders.Exists(order.OrderID) {
|
||||||
|
|
|
@ -4,7 +4,6 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
@ -51,7 +50,7 @@ func generateRunFile(filepath string, config *Config, imports []string) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return ioutil.WriteFile(filepath, buf.Bytes(), 0644)
|
return os.WriteFile(filepath, buf.Bytes(), 0644)
|
||||||
}
|
}
|
||||||
|
|
||||||
// compilePackage generates the main.go file of the wrapper package
|
// compilePackage generates the main.go file of the wrapper package
|
||||||
|
@ -80,7 +79,7 @@ func Build(ctx context.Context, userConfig *Config, targetConfig BuildTargetConf
|
||||||
buildDir = "build"
|
buildDir = "build"
|
||||||
}
|
}
|
||||||
|
|
||||||
packageDir, err := ioutil.TempDir(buildDir, "bbgow-") // with prefix bbgow
|
packageDir, err := os.MkdirTemp(buildDir, "bbgow-") // with prefix bbgow
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"os"
|
||||||
"reflect"
|
"reflect"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -496,7 +496,7 @@ func loadStash(config []byte) (Stash, error) {
|
||||||
func LoadBuildConfig(configFile string) (*Config, error) {
|
func LoadBuildConfig(configFile string) (*Config, error) {
|
||||||
var config Config
|
var config Config
|
||||||
|
|
||||||
content, err := ioutil.ReadFile(configFile)
|
content, err := os.ReadFile(configFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -526,7 +526,7 @@ func LoadBuildConfig(configFile string) (*Config, error) {
|
||||||
func Load(configFile string, loadStrategies bool) (*Config, error) {
|
func Load(configFile string, loadStrategies bool) (*Config, error) {
|
||||||
var config Config
|
var config Config
|
||||||
|
|
||||||
content, err := ioutil.ReadFile(configFile)
|
content, err := os.ReadFile(configFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ package bbgo
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"io/ioutil"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
@ -128,7 +128,7 @@ func TestLoadConfig(t *testing.T) {
|
||||||
yamlText, err := config.YAML()
|
yamlText, err := config.YAML()
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
yamlTextSource, err := ioutil.ReadFile("testdata/strategy.yaml")
|
yamlTextSource, err := os.ReadFile("testdata/strategy.yaml")
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
var sourceMap map[string]interface{}
|
var sourceMap map[string]interface{}
|
||||||
|
|
|
@ -5,7 +5,6 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"image/png"
|
"image/png"
|
||||||
"io/ioutil"
|
|
||||||
stdlog "log"
|
stdlog "log"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"os"
|
"os"
|
||||||
|
@ -34,7 +33,7 @@ import (
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
// randomize pulling
|
// randomize pulling
|
||||||
rand.Seed(time.Now().UnixNano())
|
rand.New(rand.NewSource(time.Now().UnixNano()))
|
||||||
}
|
}
|
||||||
|
|
||||||
var defaultSyncBufferPeriod = 30 * time.Minute
|
var defaultSyncBufferPeriod = 30 * time.Minute
|
||||||
|
@ -69,8 +68,6 @@ func RegisterStrategy(key string, s interface{}) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var emptyTime time.Time
|
|
||||||
|
|
||||||
type SyncStatus int
|
type SyncStatus int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -971,7 +968,7 @@ func writeOTPKeyAsQRCodePNG(key *otp.Key, imagePath string) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := ioutil.WriteFile(imagePath, buf.Bytes(), 0644); err != nil {
|
if err := os.WriteFile(imagePath, buf.Bytes(), 0644); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,6 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"path"
|
"path"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/c9s/bbgo/pkg/dynamic"
|
"github.com/c9s/bbgo/pkg/dynamic"
|
||||||
"github.com/c9s/bbgo/pkg/fixedpoint"
|
"github.com/c9s/bbgo/pkg/fixedpoint"
|
||||||
|
@ -556,19 +554,6 @@ func getStrategySignature(strategy SingleExchangeStrategy) (string, error) {
|
||||||
return signature, nil
|
return signature, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseFloatPercent(s string, bitSize int) (f float64, err error) {
|
|
||||||
i := strings.Index(s, "%")
|
|
||||||
if i < 0 {
|
|
||||||
return strconv.ParseFloat(s, bitSize)
|
|
||||||
}
|
|
||||||
|
|
||||||
f, err = strconv.ParseFloat(s[:i], bitSize)
|
|
||||||
if err != nil {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
return f / 100.0, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func getStrategySignatures(exchangeStrategies map[string]SingleExchangeStrategy) []string {
|
func getStrategySignatures(exchangeStrategies map[string]SingleExchangeStrategy) []string {
|
||||||
var strategies []string
|
var strategies []string
|
||||||
for signature := range exchangeStrategies {
|
for signature := range exchangeStrategies {
|
||||||
|
|
|
@ -3,7 +3,6 @@ package bbgo
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
"go.uber.org/multierr"
|
"go.uber.org/multierr"
|
||||||
|
|
||||||
"github.com/c9s/bbgo/pkg/core"
|
"github.com/c9s/bbgo/pkg/core"
|
||||||
|
@ -14,8 +13,6 @@ import (
|
||||||
// This order executor does not handle position and profit stats update
|
// This order executor does not handle position and profit stats update
|
||||||
type SimpleOrderExecutor struct {
|
type SimpleOrderExecutor struct {
|
||||||
BaseOrderExecutor
|
BaseOrderExecutor
|
||||||
|
|
||||||
logger log.FieldLogger
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewSimpleOrderExecutor(session *ExchangeSession) *SimpleOrderExecutor {
|
func NewSimpleOrderExecutor(session *ExchangeSession) *SimpleOrderExecutor {
|
||||||
|
|
|
@ -13,7 +13,6 @@ type PnLReporter interface {
|
||||||
type baseReporter struct {
|
type baseReporter struct {
|
||||||
notifier Notifier
|
notifier Notifier
|
||||||
cron *cron.Cron
|
cron *cron.Cron
|
||||||
environment *Environment
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type PnLReporterManager struct {
|
type PnLReporterManager struct {
|
||||||
|
|
|
@ -209,6 +209,9 @@ func (session *ExchangeSession) Init(ctx context.Context, environ *Environment)
|
||||||
var err error
|
var err error
|
||||||
if util.SetEnvVarBool("DISABLE_MARKETS_CACHE", &disableMarketsCache); disableMarketsCache {
|
if util.SetEnvVarBool("DISABLE_MARKETS_CACHE", &disableMarketsCache); disableMarketsCache {
|
||||||
markets, err = session.Exchange.QueryMarkets(ctx)
|
markets, err = session.Exchange.QueryMarkets(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
markets, err = cache.LoadExchangeMarketsWithCache(ctx, session.Exchange)
|
markets, err = cache.LoadExchangeMarketsWithCache(ctx, session.Exchange)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
5
pkg/cache/cache.go
vendored
5
pkg/cache/cache.go
vendored
|
@ -4,7 +4,6 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
@ -99,7 +98,7 @@ func WithCache(key string, obj interface{}, fetcher DataFetcher) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := ioutil.WriteFile(cacheFile, out, 0666); err != nil {
|
if err := os.WriteFile(cacheFile, out, 0666); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,7 +112,7 @@ func WithCache(key string, obj interface{}, fetcher DataFetcher) error {
|
||||||
} else {
|
} else {
|
||||||
log.Debugf("cache %s found", cacheFile)
|
log.Debugf("cache %s found", cacheFile)
|
||||||
|
|
||||||
data, err := ioutil.ReadFile(cacheFile)
|
data, err := os.ReadFile(cacheFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,16 +4,16 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"os/signal"
|
||||||
|
"syscall"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/c9s/bbgo/pkg/optimizer"
|
"github.com/c9s/bbgo/pkg/optimizer"
|
||||||
"github.com/fatih/color"
|
"github.com/fatih/color"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
|
||||||
"os/signal"
|
|
||||||
"syscall"
|
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -69,7 +69,7 @@ var hoptimizeCmd = &cobra.Command{
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
yamlBody, err := ioutil.ReadFile(configFile)
|
yamlBody, err := os.ReadFile(configFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,11 +37,11 @@ var marginCmd = &cobra.Command{
|
||||||
Short: "margin related history",
|
Short: "margin related history",
|
||||||
SilenceUsage: true,
|
SilenceUsage: true,
|
||||||
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
|
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
|
||||||
if err := cobraLoadDotenv(cmd, args); err != nil {
|
if err := cobraLoadDotenv(cmd); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := cobraLoadConfig(cmd, args); err != nil {
|
if err := cobraLoadConfig(cmd); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
@ -60,7 +59,7 @@ var optimizeCmd = &cobra.Command{
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
yamlBody, err := ioutil.ReadFile(configFile)
|
yamlBody, err := os.ReadFile(configFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,6 @@ import (
|
||||||
"github.com/c9s/bbgo/pkg/util"
|
"github.com/c9s/bbgo/pkg/util"
|
||||||
|
|
||||||
_ "time/tzdata"
|
_ "time/tzdata"
|
||||||
|
|
||||||
_ "github.com/go-sql-driver/mysql"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var cpuProfileFile *os.File
|
var cpuProfileFile *os.File
|
||||||
|
@ -38,7 +36,7 @@ var RootCmd = &cobra.Command{
|
||||||
SilenceUsage: true,
|
SilenceUsage: true,
|
||||||
|
|
||||||
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
|
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
|
||||||
if err := cobraLoadDotenv(cmd, args); err != nil {
|
if err := cobraLoadDotenv(cmd); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,7 +99,7 @@ var RootCmd = &cobra.Command{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return cobraLoadConfig(cmd, args)
|
return cobraLoadConfig(cmd)
|
||||||
},
|
},
|
||||||
PersistentPostRunE: func(cmd *cobra.Command, args []string) error {
|
PersistentPostRunE: func(cmd *cobra.Command, args []string) error {
|
||||||
pprof.StopCPUProfile()
|
pprof.StopCPUProfile()
|
||||||
|
@ -116,7 +114,7 @@ var RootCmd = &cobra.Command{
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func cobraLoadDotenv(cmd *cobra.Command, args []string) error {
|
func cobraLoadDotenv(cmd *cobra.Command) error {
|
||||||
disableDotEnv, err := cmd.Flags().GetBool("no-dotenv")
|
disableDotEnv, err := cmd.Flags().GetBool("no-dotenv")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -137,7 +135,7 @@ func cobraLoadDotenv(cmd *cobra.Command, args []string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func cobraLoadConfig(cmd *cobra.Command, args []string) error {
|
func cobraLoadConfig(cmd *cobra.Command) error {
|
||||||
configFile, err := cmd.Flags().GetString("config")
|
configFile, err := cmd.Flags().GetString("config")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrapf(err, "failed to get the config flag")
|
return errors.Wrapf(err, "failed to get the config flag")
|
||||||
|
|
|
@ -2,7 +2,6 @@ package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
@ -308,7 +307,7 @@ func runWrapperBinary(ctx context.Context, cmd *cobra.Command, userConfig *bbgo.
|
||||||
|
|
||||||
// buildAndRun builds the package natively and run the binary with the given args
|
// buildAndRun builds the package natively and run the binary with the given args
|
||||||
func buildAndRun(ctx context.Context, userConfig *bbgo.Config, args ...string) (*exec.Cmd, error) {
|
func buildAndRun(ctx context.Context, userConfig *bbgo.Config, args ...string) (*exec.Cmd, error) {
|
||||||
packageDir, err := ioutil.TempDir("build", "bbgow")
|
packageDir, err := os.MkdirTemp("build", "bbgow")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
"github.com/spf13/cobra"
|
|
||||||
|
|
||||||
"github.com/c9s/bbgo/pkg/fixedpoint"
|
"github.com/c9s/bbgo/pkg/fixedpoint"
|
||||||
"github.com/c9s/bbgo/pkg/types"
|
"github.com/c9s/bbgo/pkg/types"
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
func cobraInitRequired(required []string) func(cmd *cobra.Command, args []string) error {
|
func cobraInitRequired(required []string) func(cmd *cobra.Command, args []string) error {
|
||||||
|
|
|
@ -867,7 +867,7 @@ type MarkPriceUpdateEvent struct {
|
||||||
type ContinuousKLineEvent struct {
|
type ContinuousKLineEvent struct {
|
||||||
EventBase
|
EventBase
|
||||||
Symbol string `json:"ps"`
|
Symbol string `json:"ps"`
|
||||||
ct string `json:"ct"`
|
CT string `json:"ct"`
|
||||||
KLine KLine `json:"k,omitempty"`
|
KLine KLine `json:"k,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ package optimizer
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
|
@ -57,7 +57,7 @@ var defaultLocalExecutorConfig = &LocalExecutorConfig{
|
||||||
}
|
}
|
||||||
|
|
||||||
func LoadConfig(yamlConfigFileName string) (*Config, error) {
|
func LoadConfig(yamlConfigFileName string) (*Config, error) {
|
||||||
configYaml, err := ioutil.ReadFile(yamlConfigFileName)
|
configYaml, err := os.ReadFile(yamlConfigFileName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,12 +3,10 @@ package server
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"regexp"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -525,7 +523,7 @@ func (s *Server) setupSaveConfig(c *gin.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := ioutil.WriteFile(filename, out, 0666); err != nil {
|
if err := os.WriteFile(filename, out, 0666); err != nil {
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -533,7 +531,7 @@ func (s *Server) setupSaveConfig(c *gin.Context) {
|
||||||
c.JSON(http.StatusOK, gin.H{"success": true})
|
c.JSON(http.StatusOK, gin.H{"success": true})
|
||||||
}
|
}
|
||||||
|
|
||||||
var pageRoutePattern = regexp.MustCompile("/[a-z]+$")
|
// var pageRoutePattern = regexp.MustCompile("/[a-z]+$")
|
||||||
|
|
||||||
func moveFileToBackup(filename string) error {
|
func moveFileToBackup(filename string) error {
|
||||||
stat, err := os.Stat(filename)
|
stat, err := os.Stat(filename)
|
||||||
|
|
|
@ -2,7 +2,6 @@ package service
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
)
|
)
|
||||||
|
@ -49,7 +48,7 @@ func (store JsonStore) Load(val interface{}) error {
|
||||||
return ErrPersistenceNotExists
|
return ErrPersistenceNotExists
|
||||||
}
|
}
|
||||||
|
|
||||||
data, err := ioutil.ReadFile(p)
|
data, err := os.ReadFile(p)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -74,5 +73,5 @@ func (store JsonStore) Save(val interface{}) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
p := filepath.Join(store.Directory, store.ID) + ".json"
|
p := filepath.Join(store.Directory, store.ID) + ".json"
|
||||||
return ioutil.WriteFile(p, data, 0666)
|
return os.WriteFile(p, data, 0666)
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
@ -108,7 +107,7 @@ func NewTestDataService(t *TestData) *TestDataService {
|
||||||
}
|
}
|
||||||
|
|
||||||
func readSpec(fileName string) (*TestData, error) {
|
func readSpec(fileName string) (*TestData, error) {
|
||||||
content, err := ioutil.ReadFile(fileName)
|
content, err := os.ReadFile(fileName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ package util
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ type Response struct {
|
||||||
|
|
||||||
// NewResponse is a wrapper of the http.Response instance, it reads the response body and close the file.
|
// NewResponse is a wrapper of the http.Response instance, it reads the response body and close the file.
|
||||||
func NewResponse(r *http.Response) (response *Response, err error) {
|
func NewResponse(r *http.Response) (response *Response, err error) {
|
||||||
body, err := ioutil.ReadAll(r.Body)
|
body, err := io.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ package util
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ func TestResponse_DecodeJSON(t *testing.T) {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
}
|
}
|
||||||
json := `{"name":"Test Name","a":"a"}`
|
json := `{"name":"Test Name","a":"a"}`
|
||||||
reader := ioutil.NopCloser(bytes.NewReader([]byte(json)))
|
reader := io.NopCloser(bytes.NewReader([]byte(json)))
|
||||||
resp, err := NewResponse(&http.Response{
|
resp, err := NewResponse(&http.Response{
|
||||||
StatusCode: 200,
|
StatusCode: 200,
|
||||||
Body: reader,
|
Body: reader,
|
||||||
|
|
|
@ -3,7 +3,6 @@ package util
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -13,7 +12,7 @@ func WriteJsonFile(p string, obj interface{}) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return ioutil.WriteFile(p, out, 0644)
|
return os.WriteFile(p, out, 0644)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ReadJsonFile(file string, obj interface{}) error {
|
func ReadJsonFile(file string, obj interface{}) error {
|
||||||
|
|
|
@ -4,7 +4,6 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
@ -119,14 +118,14 @@ func Embed(file string, dirs ...string) error {
|
||||||
|
|
||||||
log.Printf("packing %s...", path)
|
log.Printf("packing %s...", path)
|
||||||
|
|
||||||
b, err := ioutil.ReadFile(path)
|
b, err := os.ReadFile(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
path = filepath.ToSlash(path)
|
path = filepath.ToSlash(path)
|
||||||
fmt.Fprintf(w, ` assets[%q] = []byte{`, strings.TrimPrefix(path, dir))
|
fmt.Fprintf(w, ` assets[%q] = []byte{`, strings.TrimPrefix(path, dir))
|
||||||
fmt.Fprintf(w, formatBytes(b))
|
fmt.Fprint(w, formatBytes(b))
|
||||||
fmt.Fprintln(w, `}`)
|
fmt.Fprintln(w, `}`)
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue
Block a user