mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
indicator/v2: rename volume profile indicator and fix tests
This commit is contained in:
parent
29301cbe7f
commit
4d84308b99
|
@ -16,11 +16,11 @@ const DefaultValueAreaPercentage = 0.68
|
||||||
|
|
||||||
type VolumeProfileStream struct {
|
type VolumeProfileStream struct {
|
||||||
*types.Float64Series
|
*types.Float64Series
|
||||||
VP VolumeProfile
|
VP VolumeProfileDetails
|
||||||
window int
|
window int
|
||||||
}
|
}
|
||||||
|
|
||||||
// VolumeProfile is a histogram of market price and volume.
|
// VolumeProfileDetails is a histogram of market price and volume.
|
||||||
// Intent is to show the price points with most volume during a period.
|
// Intent is to show the price points with most volume during a period.
|
||||||
// The profile gives key features such as:
|
// The profile gives key features such as:
|
||||||
//
|
//
|
||||||
|
@ -31,7 +31,7 @@ type VolumeProfileStream struct {
|
||||||
// Value area low (VAL)
|
// Value area low (VAL)
|
||||||
//
|
//
|
||||||
// Session High/Low
|
// Session High/Low
|
||||||
type VolumeProfile struct {
|
type VolumeProfileDetails struct {
|
||||||
|
|
||||||
// Bins is the histogram bins.
|
// Bins is the histogram bins.
|
||||||
Bins []float64
|
Bins []float64
|
||||||
|
@ -65,7 +65,7 @@ type VolumeLevel struct {
|
||||||
Volume float64
|
Volume float64
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewVolumeProfile(source KLineSubscription, window int) *VolumeProfileStream {
|
func VolumeProfile(source KLineSubscription, window int) *VolumeProfileStream {
|
||||||
prices := HLC3(source)
|
prices := HLC3(source)
|
||||||
volumes := Volumes(source)
|
volumes := Volumes(source)
|
||||||
|
|
||||||
|
|
|
@ -24,14 +24,14 @@ func TestVolumeProfile(t *testing.T) {
|
||||||
|
|
||||||
stream := &types.StandardStream{}
|
stream := &types.StandardStream{}
|
||||||
kLines := KLines(stream, "", "")
|
kLines := KLines(stream, "", "")
|
||||||
ind := NewVolumeProfile(kLines, 10)
|
ind := VolumeProfile(kLines, 10)
|
||||||
|
|
||||||
for _, candle := range candles {
|
for _, candle := range candles {
|
||||||
stream.EmitKLineClosed(candle)
|
stream.EmitKLineClosed(candle)
|
||||||
}
|
}
|
||||||
assert.InDelta(t, 36512.7, ind.VP.Low, 0.01, "VP.LOW")
|
assert.InDelta(t, 36512.7, ind.VP.Low, 0.01, "VP.LOW")
|
||||||
assert.InDelta(t, 36512.7, ind.VP.VAL, 0.01, "VP.VAL")
|
assert.InDelta(t, 36600.811, ind.VP.VAL, 0.01, "VP.VAL")
|
||||||
assert.InDelta(t, 36518.574, ind.VP.POC, 0.01, "VP.POC")
|
assert.InDelta(t, 36612.559, ind.VP.POC, 0.01, "VP.POC")
|
||||||
assert.InDelta(t, 36530.322, ind.VP.VAH, 0.01, "VP.VAH")
|
assert.InDelta(t, 36618.433, ind.VP.VAH, 0.01, "VP.VAH")
|
||||||
assert.InDelta(t, 36617.433, ind.VP.High, 0.01, "VP.HIGH")
|
assert.InDelta(t, 36617.433, ind.VP.High, 0.01, "VP.HIGH")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user