mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-30 07:26:46 +00:00
* First pass at adding new logging system * NewLogger * NewLogger * WIP * silly bug fix * :D removed files * removed old logging interface * added tests * added tests * Started to add new lines to all f calls * Added subsystem log types * Logger improvements * Further performance improvements * changes to logger and sublogger creation * Renamed Logging types * removed old print statement * changes based on feedback * moved sublogger types to own file * :) * added console as output type * added get level command * added get/set log level via grpc command * added check for output being empty for migration support * first pass at log rotation * added log rotation * :D derp fixed * added tests * changes based on feedback * changed log type * comments * renamed file -> fileSettings * typo fix * changes based on feedback * gofmt ran on additional files * gofmt ran on additional files
80 lines
1.4 KiB
Go
80 lines
1.4 KiB
Go
package orderbook
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/thrasher-/gocryptotrader/currency"
|
|
)
|
|
|
|
func testSetup() Base {
|
|
return Base{
|
|
ExchangeName: "a",
|
|
Pair: currency.NewPair(currency.BTC, currency.USD),
|
|
Asks: []Item{
|
|
{Price: 7000, Amount: 1},
|
|
{Price: 7001, Amount: 2},
|
|
},
|
|
Bids: []Item{
|
|
{Price: 6999, Amount: 1},
|
|
{Price: 6998, Amount: 2},
|
|
},
|
|
}
|
|
}
|
|
|
|
func TestWhaleBomb(t *testing.T) {
|
|
t.Parallel()
|
|
b := testSetup()
|
|
|
|
// invalid price amout
|
|
_, err := b.WhaleBomb(-1, true)
|
|
if err == nil {
|
|
t.Error("unexpected result")
|
|
}
|
|
|
|
// valid
|
|
b.WhaleBomb(7001, true)
|
|
// invalid
|
|
b.WhaleBomb(7002, true)
|
|
|
|
// valid
|
|
b.WhaleBomb(6998, false)
|
|
// invalid
|
|
b.WhaleBomb(6997, false)
|
|
}
|
|
|
|
func TestSimulateOrder(t *testing.T) {
|
|
t.Parallel()
|
|
b := testSetup()
|
|
b.SimulateOrder(8000, true)
|
|
b.SimulateOrder(1.5, false)
|
|
}
|
|
|
|
func TestOrderSummary(t *testing.T) {
|
|
var o orderSummary
|
|
if p := o.MaximumPrice(false); p != 0 {
|
|
t.Error("unexpected result")
|
|
}
|
|
if p := o.MinimumPrice(false); p != 0 {
|
|
t.Error("unexpected result")
|
|
}
|
|
|
|
o = orderSummary{
|
|
{Price: 1337, Amount: 1},
|
|
{Price: 9001, Amount: 1},
|
|
}
|
|
if p := o.MaximumPrice(false); p != 1337 {
|
|
t.Error("unexpected result")
|
|
}
|
|
if p := o.MaximumPrice(true); p != 9001 {
|
|
t.Error("unexpected result")
|
|
}
|
|
if p := o.MinimumPrice(false); p != 1337 {
|
|
t.Error("unexpected result")
|
|
}
|
|
if p := o.MinimumPrice(true); p != 9001 {
|
|
t.Error("unexpected result")
|
|
}
|
|
|
|
o.Print()
|
|
}
|