mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
test exponential scale with reverse range
This commit is contained in:
parent
3c9bcd8c9d
commit
83111c9eb9
|
@ -46,10 +46,15 @@ exchangeStrategies:
|
||||||
- on: max
|
- on: max
|
||||||
grid:
|
grid:
|
||||||
symbol: BTCUSDT
|
symbol: BTCUSDT
|
||||||
quantity: 0.001
|
# quantity: 0.001
|
||||||
|
scaleQuantity:
|
||||||
|
byPrice:
|
||||||
|
exp:
|
||||||
|
domain: [20_000, 30_000]
|
||||||
|
range: [0.2, 0.001]
|
||||||
gridNumber: 30
|
gridNumber: 30
|
||||||
profitSpread: 50.0
|
profitSpread: 50.0
|
||||||
upperPrice: 26800.0
|
upperPrice: 20_000.0
|
||||||
lowerPrice: 26500.0
|
lowerPrice: 30_000.0
|
||||||
long: true
|
long: true
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ import (
|
||||||
"github.com/c9s/bbgo/pkg/fixedpoint"
|
"github.com/c9s/bbgo/pkg/fixedpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestExpScale(t *testing.T) {
|
func TestExponentialScale(t *testing.T) {
|
||||||
// graph see: https://www.desmos.com/calculator/ip0ijbcbbf
|
// graph see: https://www.desmos.com/calculator/ip0ijbcbbf
|
||||||
scale := ExponentialScale{
|
scale := ExponentialScale{
|
||||||
Domain: [2]float64{1000, 2000},
|
Domain: [2]float64{1000, 2000},
|
||||||
|
@ -28,6 +28,25 @@ func TestExpScale(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestExponentialScale_Reverse(t *testing.T) {
|
||||||
|
scale := ExponentialScale{
|
||||||
|
Domain: [2]float64{1000, 2000},
|
||||||
|
Range: [2]float64{0.1, 0.001},
|
||||||
|
}
|
||||||
|
|
||||||
|
err := scale.Solve()
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
assert.Equal(t, "f(x) = 0.100000 * 0.995405 ^ (x - 1000.000000)", scale.String())
|
||||||
|
assert.Equal(t, fixedpoint.NewFromFloat(0.1), fixedpoint.NewFromFloat(scale.Call(1000.0)))
|
||||||
|
assert.Equal(t, fixedpoint.NewFromFloat(0.001), fixedpoint.NewFromFloat(scale.Call(2000.0)))
|
||||||
|
|
||||||
|
for x := 1000; x <= 2000; x += 100 {
|
||||||
|
y := scale.Call(float64(x))
|
||||||
|
t.Logf("%s = %f", scale.FormulaOf(float64(x)), y)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestLogScale(t *testing.T) {
|
func TestLogScale(t *testing.T) {
|
||||||
// see https://www.desmos.com/calculator/q1ufxx5gry
|
// see https://www.desmos.com/calculator/q1ufxx5gry
|
||||||
scale := LogarithmicScale{
|
scale := LogarithmicScale{
|
||||||
|
@ -63,7 +82,6 @@ func TestLinearScale(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func TestQuadraticScale(t *testing.T) {
|
func TestQuadraticScale(t *testing.T) {
|
||||||
// see https://www.desmos.com/calculator/vfqntrxzpr
|
// see https://www.desmos.com/calculator/vfqntrxzpr
|
||||||
scale := QuadraticScale{
|
scale := QuadraticScale{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user