You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.1 KiB
44 lines
1.1 KiB
package okx |
|
|
|
import ( |
|
"context" |
|
"fmt" |
|
"sig-pub/pkg/types" |
|
"testing" |
|
"time" |
|
) |
|
|
|
func TestFetchHistoryKlines(t *testing.T) { |
|
okxFetcher := NewOkxFetcher("http://192.168.1.5:7890") |
|
|
|
// get inst+interval before, if=0 -> global before |
|
|
|
// for interval, adder := range types.SupportedIntervals { |
|
// _, _ = interval, adder |
|
// } |
|
interval := types.Interval5m |
|
intervalAdder := types.SupportedIntervals[interval] |
|
before := intervalAdder(KlineBefore0, -1) |
|
for range 10 { |
|
after := intervalAdder(before, 10) |
|
klines, err := okxFetcher.FetchHistoryKlines(context.Background(), "BTC-USDT", interval, after, before) |
|
if err != nil { |
|
t.Error(err) |
|
return |
|
} |
|
lastTs := intervalAdder(after, -1) // todo ts(last kline)-1 |
|
before = lastTs |
|
for _, kline := range klines { |
|
fmt.Println(kline) |
|
} |
|
fmt.Println("-----------------------------------------------------") |
|
} |
|
} |
|
|
|
func TestA(t *testing.T) { |
|
begin := time.UnixMilli(KlineBefore0) |
|
before := begin.AddDate(0, -1, 0) |
|
after := begin.AddDate(0, 3, 0) |
|
fmt.Println("before:", before.UnixMilli()) |
|
fmt.Println("after:", after.UnixMilli()) |
|
}
|
|
|