更新脚本
This commit is contained in:
@@ -13,6 +13,7 @@ import (
|
||||
"github.com/banbox/banbot/config"
|
||||
"github.com/banbox/banbot/core"
|
||||
"github.com/banbox/banbot/orm"
|
||||
"github.com/banbox/banexg/errs"
|
||||
)
|
||||
|
||||
var columns = []string{
|
||||
@@ -27,6 +28,7 @@ func main() {
|
||||
endMS := flag.Int64("end-ms", 0, "exclusive end timestamp in milliseconds")
|
||||
timeframe := flag.String("timeframe", "8h", "bar timeframe (8h or 1d)")
|
||||
outDir := flag.String("out-dir", "", "CSV output directory")
|
||||
skipUnavailable := flag.Bool("skip-unavailable", true, "skip pairs unavailable on the exchange and absent from the local cache")
|
||||
flag.Parse()
|
||||
if (*timeframe != "8h" && *timeframe != "1d") || *configPath == "" || *dataDir == "" || *pairs == "" || *outDir == "" || *startMS <= 0 || *endMS <= *startMS {
|
||||
flag.Usage()
|
||||
@@ -57,6 +59,9 @@ func main() {
|
||||
}
|
||||
exs, err := orm.GetExSymbolCur(pair)
|
||||
if err != nil {
|
||||
if *skipUnavailable && isUnavailablePair(err) {
|
||||
continue
|
||||
}
|
||||
fail(err)
|
||||
}
|
||||
_, rows, err := orm.GetSeries(exs, *timeframe, *startMS, *endMS, 0, false)
|
||||
@@ -70,6 +75,10 @@ func main() {
|
||||
}
|
||||
}
|
||||
|
||||
func isUnavailablePair(err *errs.Error) bool {
|
||||
return err != nil && err.Code == errs.CodeNoMarketForPair
|
||||
}
|
||||
|
||||
func writeCSV(path string, rows []*orm.DataSeries, exs *orm.ExSymbol) error {
|
||||
file, err := os.Create(path)
|
||||
if err != nil {
|
||||
|
||||
16
cmd/cbpred-export/main_test.go
Normal file
16
cmd/cbpred-export/main_test.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/banbox/banexg/errs"
|
||||
)
|
||||
|
||||
func TestIsUnavailablePair(t *testing.T) {
|
||||
if !isUnavailablePair(errs.NewMsg(errs.CodeNoMarketForPair, "missing")) {
|
||||
t.Fatal("NoMarketForPair should be skipped")
|
||||
}
|
||||
if isUnavailablePair(errs.NewMsg(errs.CodeInvalidData, "bad data")) {
|
||||
t.Fatal("non-market errors must not be skipped")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user