mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-21 22:43:52 +00:00
backtest: add kline fixture generator
Signed-off-by: c9s <yoanlin93@gmail.com>
This commit is contained in:
parent
118928d388
commit
66f923ad0d
|
@ -68,12 +68,14 @@ func (g *KLineFixtureGenerator) Generate(ctx context.Context, c chan types.KLine
|
|||
}
|
||||
|
||||
func TestKLineFixtureGenerator(t *testing.T) {
|
||||
startTime := time.Date(2022, time.January, 1, 0, 0, 0, 0, time.Local)
|
||||
endTime := time.Date(2022, time.January, 31, 0, 0, 0, 0, time.Local)
|
||||
ctx := context.Background()
|
||||
g := &KLineFixtureGenerator{
|
||||
Symbol: "BTCUSDT",
|
||||
Interval: types.Interval1m,
|
||||
StartTime: time.Date(2022, time.January, 1, 0, 0, 0, 0, time.Local),
|
||||
EndTime: time.Date(2022, time.January, 31, 0, 0, 0, 0, time.Local),
|
||||
StartTime: startTime,
|
||||
EndTime: endTime,
|
||||
StartPrice: fixedpoint.NewFromFloat(18000.0),
|
||||
}
|
||||
|
||||
|
@ -85,5 +87,7 @@ func TestKLineFixtureGenerator(t *testing.T) {
|
|||
for k := range c {
|
||||
// high must higher than low
|
||||
assert.True(t, k.High.Compare(k.Low) > 0)
|
||||
assert.True(t, k.StartTime.After(startTime) || k.StartTime.Equal(startTime))
|
||||
assert.True(t, k.StartTime.Before(endTime))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -165,6 +165,10 @@ func (t Time) UnixMilli() int64 {
|
|||
return time.Time(t).UnixMilli()
|
||||
}
|
||||
|
||||
func (t Time) Equal(time2 time.Time) bool {
|
||||
return time.Time(t).Equal(time2)
|
||||
}
|
||||
|
||||
func (t Time) After(time2 time.Time) bool {
|
||||
return time.Time(t).After(time2)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user