??
This commit is contained in:
parent
8fbb8d9775
commit
b22d565d44
2 changed files with 10 additions and 3 deletions
|
@ -78,9 +78,8 @@ func (mhr *MarketHoursRange) GetTicks(vf ValueFormatter) []Tick {
|
||||||
// figure out how to advance one ticke per market day.
|
// figure out how to advance one ticke per market day.
|
||||||
var ticks []Tick
|
var ticks []Tick
|
||||||
|
|
||||||
cursor := date.On(mhr.MarketOpen, mhr.Min)
|
cursor := date.On(mhr.MarketClose, mhr.Min)
|
||||||
maxClose := date.On(mhr.MarketClose, mhr.Max)
|
maxClose := date.On(mhr.MarketClose, mhr.Max)
|
||||||
|
|
||||||
for date.BeforeDate(cursor, maxClose) {
|
for date.BeforeDate(cursor, maxClose) {
|
||||||
if date.IsWeekDay(cursor.Weekday()) && !mhr.GetHolidayProvider()(cursor) {
|
if date.IsWeekDay(cursor.Weekday()) && !mhr.GetHolidayProvider()(cursor) {
|
||||||
ticks = append(ticks, Tick{
|
ticks = append(ticks, Tick{
|
||||||
|
@ -92,6 +91,13 @@ func (mhr *MarketHoursRange) GetTicks(vf ValueFormatter) []Tick {
|
||||||
cursor = cursor.AddDate(0, 0, 1)
|
cursor = cursor.AddDate(0, 0, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
endMarketClose := date.On(mhr.MarketClose, cursor)
|
||||||
|
if date.IsWeekDay(endMarketClose.Weekday()) && !mhr.GetHolidayProvider()(endMarketClose) {
|
||||||
|
ticks = append(ticks, Tick{
|
||||||
|
Value: TimeToFloat64(endMarketClose),
|
||||||
|
Label: vf(endMarketClose),
|
||||||
|
})
|
||||||
|
}
|
||||||
return ticks
|
return ticks
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,7 @@ func TestMarketHoursRangeGetTicks(t *testing.T) {
|
||||||
|
|
||||||
ticks := r.GetTicks(TimeValueFormatter)
|
ticks := r.GetTicks(TimeValueFormatter)
|
||||||
assert.NotEmpty(ticks)
|
assert.NotEmpty(ticks)
|
||||||
assert.Equal(TimeToFloat64(r.Min), ticks[0].Value)
|
assert.Len(ticks, 5)
|
||||||
|
assert.NotEqual(TimeToFloat64(r.Min), ticks[0].Value)
|
||||||
assert.NotEmpty(ticks[0].Label)
|
assert.NotEmpty(ticks[0].Label)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue