Trading: components 161-180
This commit is contained in:
105 files changed
+6042
-1
No files matched your search
@@ -0,0 +1,42 @@
|
||||
package mujica
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/egoist/mygo/ui"
|
||||
)
|
||||
|
||||
func TestSpreadIndicatorValueAndThreshold(t *testing.T) {
|
||||
bid, ask := 99.95, 100.05
|
||||
tt := tradingTester(GreenUp, 400, 100, func(c *ui.Context) {
|
||||
SpreadIndicator(c, bid, ask, SpreadIndicatorOptions{WarnPercent: 0.5})
|
||||
})
|
||||
if !tt.HasText("0.10 (0.100%)") || tt.HasText("Wide spread") {
|
||||
t.Fatalf("narrow: %q", tt.Texts())
|
||||
}
|
||||
ask = 101
|
||||
tt.Frame()
|
||||
if !tt.HasText("Wide spread") {
|
||||
t.Fatalf("wide: %q", tt.Texts())
|
||||
}
|
||||
ask = 99
|
||||
tt.Frame()
|
||||
if !tt.HasText("Crossed market") {
|
||||
t.Fatalf("crossed: %q", tt.Texts())
|
||||
}
|
||||
defer func() {
|
||||
if recover() == nil {
|
||||
t.Fatal("negative threshold accepted")
|
||||
}
|
||||
}()
|
||||
tradingTester(GreenUp, 100, 100, func(c *ui.Context) { SpreadIndicator(c, 1, 2, SpreadIndicatorOptions{WarnPercent: -1}) })
|
||||
}
|
||||
|
||||
func TestSpreadIndicatorSnapshot(t *testing.T) {
|
||||
snapshot(t, "spread_indicator", 380, 100, func(c *ui.Context) {
|
||||
ui.Column(c).Padding(20).Gap(10).Children(func() {
|
||||
SpreadIndicator(c, 99.95, 100.05, SpreadIndicatorOptions{WarnPercent: 0.5})
|
||||
SpreadIndicator(c, 99, 101, SpreadIndicatorOptions{WarnPercent: 0.5})
|
||||
})
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user