Skip to content

Commit 6d73fa4

Browse files
[Automated changes] GO files
1 parent e555548 commit 6d73fa4

File tree

437 files changed

+500120
-455925
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

437 files changed

+500120
-455925
lines changed

go/tests/base/test.account.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
package base
2+
23
import "github.com/ccxt/ccxt/go/v4"
34

45
// PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
56
// https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
67

7-
8-
func TestAccount(exchange ccxt.ICoreExchange, skippedProperties interface{}, method interface{}, entry interface{}) {
9-
var format interface{} = map[string]interface{} {
10-
"info": map[string]interface{} {},
11-
"code": "BTC",
12-
"type": "spot",
13-
"id": "12345",
14-
}
15-
var emptyAllowedFor interface{} = []interface{}{"code", "id"}
16-
AssertStructure(exchange, skippedProperties, method, entry, format, emptyAllowedFor)
17-
AssertCurrencyCode(exchange, skippedProperties, method, entry, GetValue(entry, "code"))
18-
}
8+
func TestAccount(exchange ccxt.ICoreExchange, skippedProperties interface{}, method interface{}, entry interface{}) {
9+
var format interface{} = map[string]interface{}{
10+
"info": map[string]interface{}{},
11+
"code": "BTC",
12+
"type": "spot",
13+
"id": "12345",
14+
}
15+
var emptyAllowedFor interface{} = []interface{}{"code", "id"}
16+
AssertStructure(exchange, skippedProperties, method, entry, format, emptyAllowedFor)
17+
AssertCurrencyCode(exchange, skippedProperties, method, entry, GetValue(entry, "code"))
18+
}

go/tests/base/test.afterConstructor.go

Lines changed: 87 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,97 @@
11
package base
2+
23
import ccxt "github.com/ccxt/ccxt/go/v4"
34

45
// PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
56
// https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
67

7-
func HelperTestInitThrottler() {
8-
exchange := ccxt.NewExchange().(*ccxt.Exchange); exchange.DerivedExchange = exchange; exchange.InitParent(map[string]interface{} {
9-
"id": "sampleexchange",
10-
"rateLimit": 10.8,
11-
}, map[string]interface{}{}, exchange)
12-
// todo: assert (exchange.MAX_VALUE !== undefined);
13-
var tokenBucket interface{} = exchange.GetProperty(exchange, "tokenBucket") // trick for uncamelcase transpilation
14-
if ccxt.IsTrue(ccxt.IsEqual(tokenBucket, nil)) {
15-
tokenBucket = exchange.GetProperty(exchange, "TokenBucket")
16-
}
17-
Assert(!ccxt.IsEqual(tokenBucket, nil))
18-
19-
// fix decimal/integer issues across langs
20-
Assert(exchange.InArray(ccxt.GetValue(tokenBucket, "capacity"), []interface{}{1, 1}))
21-
var cost interface{} = exchange.ParseToNumeric(exchange.SafeString2(tokenBucket, "cost", "defaultCost")) // python sync, todo fix
22-
Assert(exchange.InArray(cost, []interface{}{1, 1}))
23-
Assert(!ccxt.IsTrue((ccxt.InOp(tokenBucket, "maxCapacity"))) || ccxt.IsTrue(exchange.InArray(ccxt.GetValue(tokenBucket, "maxCapacity"), []interface{}{1000, 1000})))
8+
func HelperTestInitThrottler() {
9+
exchange := ccxt.NewExchange().(*ccxt.Exchange)
10+
exchange.DerivedExchange = exchange
11+
exchange.InitParent(map[string]interface{}{
12+
"id": "sampleexchange",
13+
"rateLimit": 10.8,
14+
}, map[string]interface{}{}, exchange)
15+
// todo: assert (exchange.MAX_VALUE !== undefined);
16+
var tokenBucket interface{} = exchange.GetProperty(exchange, "tokenBucket") // trick for uncamelcase transpilation
17+
if ccxt.IsTrue(ccxt.IsEqual(tokenBucket, nil)) {
18+
tokenBucket = exchange.GetProperty(exchange, "TokenBucket")
19+
}
20+
Assert(!ccxt.IsEqual(tokenBucket, nil))
21+
22+
// fix decimal/integer issues across langs
23+
Assert(exchange.InArray(ccxt.GetValue(tokenBucket, "capacity"), []interface{}{1, 1}))
24+
var cost interface{} = exchange.ParseToNumeric(exchange.SafeString2(tokenBucket, "cost", "defaultCost")) // python sync, todo fix
25+
Assert(exchange.InArray(cost, []interface{}{1, 1}))
26+
Assert(!ccxt.IsTrue((ccxt.InOp(tokenBucket, "maxCapacity"))) || ccxt.IsTrue(exchange.InArray(ccxt.GetValue(tokenBucket, "maxCapacity"), []interface{}{1000, 1000})))
27+
}
28+
func HelperTestSandboxState(exchange *ccxt.Exchange, optionalArgs ...interface{}) {
29+
shouldBeEnabled := ccxt.GetArg(optionalArgs, 0, true)
30+
_ = shouldBeEnabled
31+
Assert(!ccxt.IsEqual(exchange.Urls, nil))
32+
Assert(ccxt.InOp(exchange.Urls, "test"))
33+
2434
}
25-
func HelperTestSandboxState(exchange *ccxt.Exchange, optionalArgs ...interface{}) {
26-
shouldBeEnabled := ccxt.GetArg(optionalArgs, 0, true)
27-
_ = shouldBeEnabled
28-
Assert(!ccxt.IsEqual(exchange.Urls, nil))
29-
Assert(ccxt.InOp(exchange.Urls, "test"))
30-
35+
func HelperTestInitSandbox() {
36+
// todo: sandbox for real exchanges
37+
var opts map[string]interface{} = map[string]interface{}{
38+
"id": "sampleexchange",
39+
"options": map[string]interface{}{
40+
"sandbox": false,
41+
},
42+
"urls": map[string]interface{}{
43+
"api": map[string]interface{}{
44+
"public": "https://example.com",
45+
},
46+
"test": map[string]interface{}{
47+
"public": "https://example.org",
48+
},
49+
},
50+
}
51+
//
52+
// CASE A: when sandbox is not enabled
53+
//
54+
exchange3 := ccxt.NewExchange().(*ccxt.Exchange)
55+
exchange3.DerivedExchange = exchange3
56+
exchange3.InitParent(opts, map[string]interface{}{}, exchange3)
57+
HelperTestSandboxState(exchange3, false)
58+
exchange3.SetSandboxMode(true)
59+
HelperTestSandboxState(exchange3, true)
60+
//
61+
// CASE B: when sandbox is enabled
62+
//
63+
ccxt.AddElementToObject(ccxt.GetValue(opts, "options"), "sandbox", true)
64+
exchange4 := ccxt.NewExchange().(*ccxt.Exchange)
65+
exchange4.DerivedExchange = exchange4
66+
exchange4.InitParent(opts, map[string]interface{}{}, exchange4)
67+
HelperTestSandboxState(exchange4, true)
68+
exchange4.SetSandboxMode(false)
69+
HelperTestSandboxState(exchange4, false)
3170
}
32-
func HelperTestInitSandbox() {
33-
// todo: sandbox for real exchanges
34-
var opts map[string]interface{} = map[string]interface{} {
35-
"id": "sampleexchange",
36-
"options": map[string]interface{} {
37-
"sandbox": false,
38-
},
39-
"urls": map[string]interface{} {
40-
"api": map[string]interface{} {
41-
"public": "https://example.com",
42-
},
43-
"test": map[string]interface{} {
44-
"public": "https://example.org",
45-
},
46-
},
47-
}
48-
//
49-
// CASE A: when sandbox is not enabled
50-
//
51-
exchange3 := ccxt.NewExchange().(*ccxt.Exchange); exchange3.DerivedExchange = exchange3; exchange3.InitParent(opts, map[string]interface{}{}, exchange3)
52-
HelperTestSandboxState(exchange3, false)
53-
exchange3.SetSandboxMode(true)
54-
HelperTestSandboxState(exchange3, true)
55-
//
56-
// CASE B: when sandbox is enabled
57-
//
58-
ccxt.AddElementToObject(ccxt.GetValue(opts, "options"), "sandbox", true)
59-
exchange4 := ccxt.NewExchange().(*ccxt.Exchange); exchange4.DerivedExchange = exchange4; exchange4.InitParent(opts, map[string]interface{}{}, exchange4)
60-
HelperTestSandboxState(exchange4, true)
61-
exchange4.SetSandboxMode(false)
62-
HelperTestSandboxState(exchange4, false)
71+
func HelperTestInitMarket() {
72+
// ############# markets ############# //
73+
var sampleMarket map[string]interface{} = map[string]interface{}{
74+
"id": "BtcUsd",
75+
"symbol": "BTC/USD",
76+
"base": "BTC",
77+
"quote": "USD",
78+
"baseId": "Btc",
79+
"quoteId": "Usd",
80+
"type": "spot",
81+
"spot": true,
82+
}
83+
exchange2 := ccxt.NewExchange().(*ccxt.Exchange)
84+
exchange2.DerivedExchange = exchange2
85+
exchange2.InitParent(map[string]interface{}{
86+
"id": "sampleexchange",
87+
"markets": map[string]interface{}{
88+
"BTC/USD": sampleMarket,
89+
},
90+
}, map[string]interface{}{}, exchange2)
91+
Assert(!ccxt.IsEqual(ccxt.GetValue(exchange2.Markets, "BTC/USD"), nil))
6392
}
64-
func HelperTestInitMarket() {
65-
// ############# markets ############# //
66-
var sampleMarket map[string]interface{} = map[string]interface{} {
67-
"id": "BtcUsd",
68-
"symbol": "BTC/USD",
69-
"base": "BTC",
70-
"quote": "USD",
71-
"baseId": "Btc",
72-
"quoteId": "Usd",
73-
"type": "spot",
74-
"spot": true,
75-
}
76-
exchange2 := ccxt.NewExchange().(*ccxt.Exchange); exchange2.DerivedExchange = exchange2; exchange2.InitParent(map[string]interface{} {
77-
"id": "sampleexchange",
78-
"markets": map[string]interface{} {
79-
"BTC/USD": sampleMarket,
80-
},
81-
}, map[string]interface{}{}, exchange2)
82-
Assert(!ccxt.IsEqual(ccxt.GetValue(exchange2.Markets, "BTC/USD"), nil))
93+
func TestAfterConstructor() {
94+
HelperTestInitThrottler()
95+
HelperTestInitSandbox()
96+
HelperTestInitMarket()
8397
}
84-
func TestAfterConstructor() {
85-
HelperTestInitThrottler()
86-
HelperTestInitSandbox()
87-
HelperTestInitMarket()
88-
}

go/tests/base/test.arraysConcat.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
package base
2+
23
import ccxt "github.com/ccxt/ccxt/go/v4"
34

45
// PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
56
// https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
67

7-
func TestArraysConcat() {
8-
exchange := ccxt.NewExchange().(*ccxt.Exchange); exchange.DerivedExchange = exchange; exchange.InitParent(map[string]interface{} {
9-
"id": "sampleexchange",
10-
}, map[string]interface{}{}, exchange)
11-
AssertDeepEqual(exchange, nil, "testArraysConcat", exchange.ArraysConcat([]interface{}{[]interface{}{"b"}, []interface{}{"a", "c"}}), []interface{}{"b", "a", "c"})
12-
}
8+
func TestArraysConcat() {
9+
exchange := ccxt.NewExchange().(*ccxt.Exchange)
10+
exchange.DerivedExchange = exchange
11+
exchange.InitParent(map[string]interface{}{
12+
"id": "sampleexchange",
13+
}, map[string]interface{}{}, exchange)
14+
AssertDeepEqual(exchange, nil, "testArraysConcat", exchange.ArraysConcat([]interface{}{[]interface{}{"b"}, []interface{}{"a", "c"}}), []interface{}{"b", "a", "c"})
15+
}

go/tests/base/test.balance.go

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,48 @@
11
package base
2+
23
import "github.com/ccxt/ccxt/go/v4"
34

45
// PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
56
// https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
67

7-
8-
func TestBalance(exchange ccxt.ICoreExchange, skippedProperties interface{}, method interface{}, entry interface{}) {
9-
var format interface{} = map[string]interface{} {
10-
"free": map[string]interface{} {},
11-
"used": map[string]interface{} {},
12-
"total": map[string]interface{} {},
13-
"info": map[string]interface{} {},
14-
}
15-
AssertStructure(exchange, skippedProperties, method, entry, format)
16-
var logText interface{} = LogTemplate(exchange, method, entry)
17-
//
18-
var codesTotal interface{} = ObjectKeys(GetValue(entry, "total"))
19-
var codesFree interface{} = ObjectKeys(GetValue(entry, "free"))
20-
var codesUsed interface{} = ObjectKeys(GetValue(entry, "used"))
21-
AssertNonEmtpyArray(exchange, skippedProperties, method, codesTotal, "total")
22-
AssertNonEmtpyArray(exchange, skippedProperties, method, codesFree, "free")
23-
AssertNonEmtpyArray(exchange, skippedProperties, method, codesUsed, "used")
24-
var allCodes interface{} = exchange.ArrayConcat(codesTotal, codesFree)
25-
allCodes = exchange.ArrayConcat(allCodes, codesUsed)
26-
var codesLength interface{} = GetArrayLength(codesTotal)
27-
var freeLength interface{} = GetArrayLength(codesFree)
28-
var usedLength interface{} = GetArrayLength(codesUsed)
29-
Assert(IsTrue((IsEqual(codesLength, freeLength))) || IsTrue((IsEqual(codesLength, usedLength))), Add("free and total and used codes have different lengths", logText))
30-
for i := 0; IsLessThan(i, GetArrayLength(allCodes)); i++ {
31-
var code interface{} = GetValue(allCodes, i)
32-
// AssertCurrencyCode (exchange, skippedProperties, method, entry, code);
33-
Assert(InOp(GetValue(entry, "total"), code), Add(Add(Add("code ", code), " not in total"), logText))
34-
Assert(InOp(GetValue(entry, "free"), code), Add(Add(Add("code ", code), " not in free"), logText))
35-
Assert(InOp(GetValue(entry, "used"), code), Add(Add(Add("code ", code), " not in used"), logText))
36-
var total interface{} = exchange.SafeString(GetValue(entry, "total"), code)
37-
var free interface{} = exchange.SafeString(GetValue(entry, "free"), code)
38-
var used interface{} = exchange.SafeString(GetValue(entry, "used"), code)
39-
Assert(!IsEqual(total, nil), Add("total is undefined", logText))
40-
Assert(!IsEqual(free, nil), Add("free is undefined", logText))
41-
Assert(!IsEqual(used, nil), Add("used is undefined", logText))
42-
Assert(ccxt.Precise.StringGe(total, "0"), Add("total is not positive", logText))
43-
Assert(ccxt.Precise.StringGe(free, "0"), Add("free is not positive", logText))
44-
Assert(ccxt.Precise.StringGe(used, "0"), Add("used is not positive", logText))
45-
var sumFreeUsed interface{} = ccxt.Precise.StringAdd(free, used)
46-
Assert(ccxt.Precise.StringEq(total, sumFreeUsed), Add("free and used do not sum to total", logText))
47-
}
48-
}
8+
func TestBalance(exchange ccxt.ICoreExchange, skippedProperties interface{}, method interface{}, entry interface{}) {
9+
var format interface{} = map[string]interface{}{
10+
"free": map[string]interface{}{},
11+
"used": map[string]interface{}{},
12+
"total": map[string]interface{}{},
13+
"info": map[string]interface{}{},
14+
}
15+
AssertStructure(exchange, skippedProperties, method, entry, format)
16+
var logText interface{} = LogTemplate(exchange, method, entry)
17+
//
18+
var codesTotal interface{} = ObjectKeys(GetValue(entry, "total"))
19+
var codesFree interface{} = ObjectKeys(GetValue(entry, "free"))
20+
var codesUsed interface{} = ObjectKeys(GetValue(entry, "used"))
21+
AssertNonEmtpyArray(exchange, skippedProperties, method, codesTotal, "total")
22+
AssertNonEmtpyArray(exchange, skippedProperties, method, codesFree, "free")
23+
AssertNonEmtpyArray(exchange, skippedProperties, method, codesUsed, "used")
24+
var allCodes interface{} = exchange.ArrayConcat(codesTotal, codesFree)
25+
allCodes = exchange.ArrayConcat(allCodes, codesUsed)
26+
var codesLength interface{} = GetArrayLength(codesTotal)
27+
var freeLength interface{} = GetArrayLength(codesFree)
28+
var usedLength interface{} = GetArrayLength(codesUsed)
29+
Assert(IsTrue((IsEqual(codesLength, freeLength))) || IsTrue((IsEqual(codesLength, usedLength))), Add("free and total and used codes have different lengths", logText))
30+
for i := 0; IsLessThan(i, GetArrayLength(allCodes)); i++ {
31+
var code interface{} = GetValue(allCodes, i)
32+
// AssertCurrencyCode (exchange, skippedProperties, method, entry, code);
33+
Assert(InOp(GetValue(entry, "total"), code), Add(Add(Add("code ", code), " not in total"), logText))
34+
Assert(InOp(GetValue(entry, "free"), code), Add(Add(Add("code ", code), " not in free"), logText))
35+
Assert(InOp(GetValue(entry, "used"), code), Add(Add(Add("code ", code), " not in used"), logText))
36+
var total interface{} = exchange.SafeString(GetValue(entry, "total"), code)
37+
var free interface{} = exchange.SafeString(GetValue(entry, "free"), code)
38+
var used interface{} = exchange.SafeString(GetValue(entry, "used"), code)
39+
Assert(!IsEqual(total, nil), Add("total is undefined", logText))
40+
Assert(!IsEqual(free, nil), Add("free is undefined", logText))
41+
Assert(!IsEqual(used, nil), Add("used is undefined", logText))
42+
Assert(ccxt.Precise.StringGe(total, "0"), Add("total is not positive", logText))
43+
Assert(ccxt.Precise.StringGe(free, "0"), Add("free is not positive", logText))
44+
Assert(ccxt.Precise.StringGe(used, "0"), Add("used is not positive", logText))
45+
var sumFreeUsed interface{} = ccxt.Precise.StringAdd(free, used)
46+
Assert(ccxt.Precise.StringEq(total, sumFreeUsed), Add("free and used do not sum to total", logText))
47+
}
48+
}
Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
package base
2+
23
import "github.com/ccxt/ccxt/go/v4"
34

45
// PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
56
// https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
67

7-
8-
func TestBorrowInterest(exchange ccxt.ICoreExchange, skippedProperties interface{}, method interface{}, entry interface{}, requestedCode interface{}, requestedSymbol interface{}) {
9-
var format interface{} = map[string]interface{} {
10-
"info": map[string]interface{} {},
11-
"account": "BTC/USDT",
12-
"currency": "USDT",
13-
"interest": exchange.ParseNumber("0.1444"),
14-
"interestRate": exchange.ParseNumber("0.0006"),
15-
"amountBorrowed": exchange.ParseNumber("30.0"),
16-
"timestamp": 1638230400000,
17-
"datetime": "2021-11-30T00:00:00.000Z",
18-
}
19-
var emptyAllowedFor interface{} = []interface{}{"account"}
20-
AssertStructure(exchange, skippedProperties, method, entry, format, emptyAllowedFor)
21-
AssertTimestampAndDatetime(exchange, skippedProperties, method, entry)
22-
AssertCurrencyCode(exchange, skippedProperties, method, entry, GetValue(entry, "currency"), requestedCode)
23-
AssertSymbol(exchange, skippedProperties, method, entry, GetValue(entry, "account"), requestedSymbol)
24-
AssertGreater(exchange, skippedProperties, method, entry, "interest", "0")
25-
AssertGreater(exchange, skippedProperties, method, entry, "interestRate", "0")
26-
AssertGreater(exchange, skippedProperties, method, entry, "amountBorrowed", "0")
27-
}
8+
func TestBorrowInterest(exchange ccxt.ICoreExchange, skippedProperties interface{}, method interface{}, entry interface{}, requestedCode interface{}, requestedSymbol interface{}) {
9+
var format interface{} = map[string]interface{}{
10+
"info": map[string]interface{}{},
11+
"account": "BTC/USDT",
12+
"currency": "USDT",
13+
"interest": exchange.ParseNumber("0.1444"),
14+
"interestRate": exchange.ParseNumber("0.0006"),
15+
"amountBorrowed": exchange.ParseNumber("30.0"),
16+
"timestamp": 1638230400000,
17+
"datetime": "2021-11-30T00:00:00.000Z",
18+
}
19+
var emptyAllowedFor interface{} = []interface{}{"account"}
20+
AssertStructure(exchange, skippedProperties, method, entry, format, emptyAllowedFor)
21+
AssertTimestampAndDatetime(exchange, skippedProperties, method, entry)
22+
AssertCurrencyCode(exchange, skippedProperties, method, entry, GetValue(entry, "currency"), requestedCode)
23+
AssertSymbol(exchange, skippedProperties, method, entry, GetValue(entry, "account"), requestedSymbol)
24+
AssertGreater(exchange, skippedProperties, method, entry, "interest", "0")
25+
AssertGreater(exchange, skippedProperties, method, entry, "interestRate", "0")
26+
AssertGreater(exchange, skippedProperties, method, entry, "amountBorrowed", "0")
27+
}

0 commit comments

Comments
 (0)