-
Notifications
You must be signed in to change notification settings - Fork 0
/
biz_test.go
71 lines (68 loc) · 1.42 KB
/
biz_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package banexg
import (
"testing"
)
func TestSetOptions(t *testing.T) {
FakeApiKey := "123"
e := Exchange{
Options: map[string]interface{}{
OptMarketType: MarketMargin,
OptApiKey: FakeApiKey,
},
}
e.Init()
_, creds, err := e.GetAccountCreds("default")
if err != nil {
panic(err)
}
if creds.ApiKey == FakeApiKey {
t.Logf("Pass ApiKey")
} else {
t.Errorf("Fail ApiKey, cur %v, expect: %v", creds.ApiKey, FakeApiKey)
}
if e.MarketType == MarketMargin {
t.Logf("Pass MarketType")
} else {
t.Errorf("Fail MarketType, cur %v, expect: %v", e.MarketType, MarketMargin)
}
}
func TestCalcFee(t *testing.T) {
symbol := "FOO/BAR"
exg := Exchange{
ExgInfo: &ExgInfo{
Markets: map[string]*Market{
symbol: {
ID: "foobar",
Symbol: symbol,
Base: "FOO",
Quote: "BAR",
Settle: "BAR",
Taker: 0.002,
Maker: 0.001,
Precision: &Precision{
Price: 8,
Amount: 8,
ModePrice: PrecModeDecimalPlace,
ModeAmount: PrecModeDecimalPlace,
},
},
},
},
}
amount := 10.
price := 100.
fee, err := exg.CalculateFee(symbol, OdTypeLimit, OdSideBuy, amount, price, false, nil)
if err != nil {
panic(err)
}
if fee.Cost != 2.0 {
t.Errorf("taker fee: %v", fee)
}
fee, err = exg.CalculateFee(symbol, OdTypeLimit, OdSideBuy, amount, price, true, nil)
if err != nil {
panic(err)
}
if fee.Cost != 1.0 {
t.Errorf("maker fee: %v", fee)
}
}