Skip to content
Open
Show file tree
Hide file tree
Changes from 250 commits
Commits
Show all changes
491 commits
Select commit Hold shift + click to select a range
7bb60a5
fix conflict and update unit tests
samuael May 2, 2025
21cd947
minor change
samuael May 2, 2025
89ff36a
update based on review comments
samuael May 6, 2025
31668c0
wrappers and time-in-force calling approach
samuael May 7, 2025
764eb37
minor change
samuael May 8, 2025
57e0744
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael May 8, 2025
eec47f5
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael May 10, 2025
9c6f10d
update gateio string to timeInForce conversion and unit test
samuael May 10, 2025
84dc671
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael May 10, 2025
c674865
Merge branch 'update_tif' into poloniex
samuael May 10, 2025
f95525c
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael May 20, 2025
fa9d9e2
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Jun 15, 2025
1fb57bf
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Jun 27, 2025
c646b28
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Jul 5, 2025
098eed6
set limiter to first level mock data list and updated unit tests
samuael Jul 5, 2025
1cf8f91
address nested slices length limit
samuael Jul 6, 2025
40e4bba
minor fix recording file and update unit tests
samuael Jul 8, 2025
888144d
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Jul 8, 2025
83c8671
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Jul 16, 2025
0562e59
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Jul 17, 2025
85b0754
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Jul 17, 2025
670e376
minor updates on unit tests
samuael Jul 22, 2025
92accc6
Merge branch 'mock_data_size_update' of https://github.com/samuael/go…
samuael Jul 22, 2025
71cc7cc
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Jul 29, 2025
2940b4c
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Aug 1, 2025
1863cf1
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Aug 1, 2025
85ccde0
Merge branch 'mock_data_size_update' into poloniex
samuael Aug 1, 2025
6144bf6
mock data update using the mock data trimmer
samuael Aug 3, 2025
4fcb8e8
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Aug 16, 2025
5c73285
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Aug 24, 2025
33bf089
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Sep 18, 2025
e6c89c3
fix minor linter issues
samuael Sep 18, 2025
899b4ce
mock file re-recording
samuael Sep 18, 2025
52c6e67
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Sep 23, 2025
e462ebf
feedback: overall update based on feedback
samuael Sep 23, 2025
aaed63e
misc issue fix
samuael Sep 23, 2025
98f10ff
update websocket based on multi connection and other wrapper updates
samuael Sep 23, 2025
74fb18a
overall update with unit tests added and endpoints removed
samuael Sep 24, 2025
546e2a5
endpoint functions and unit tests update
samuael Sep 25, 2025
d59d69a
update endpoints and types naming
samuael Sep 26, 2025
da029aa
nitpicks
samuael Sep 26, 2025
9bd48ad
unit tests update
samuael Sep 27, 2025
9b699e8
overall unit tests update and websocket handlers fix
samuael Sep 28, 2025
7ed1aec
overall update on endpoints, websocket handlers, and testing
samuael Sep 29, 2025
19cf25e
rm comments based on gk's feedback
samuael Sep 29, 2025
7c5a3ef
response declaration and return change, and diverse update
samuael Sep 30, 2025
f4b21c0
feedback: apply change requests
samuael Oct 1, 2025
926516b
Merge branch 'poloniex' of https://github.com/samuael/gocryptotrader;…
samuael Oct 1, 2025
99f7534
fix websocket runtime errors
samuael Oct 2, 2025
51fb22c
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Oct 2, 2025
4634584
minor orderbook fix
samuael Oct 2, 2025
aa4fd23
improve code coverage and overall code update
samuael Oct 3, 2025
12f1199
shorten error check expression
samuael Oct 3, 2025
7f37b79
types, unit tests, and websocket handlers update
samuael Oct 5, 2025
66402fb
endpoints, websocket handlers, and unit tests update
samuael Oct 7, 2025
2a44fda
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Oct 7, 2025
ba2511e
apply websocket templating with minor fix
samuael Oct 8, 2025
062cfd8
update websocket handlers
samuael Oct 9, 2025
7eb8c75
update unit endpoints, and mock file
samuael Oct 10, 2025
aa00f65
mock file update and reduction
samuael Oct 10, 2025
17f7daa
rm HTTPRecording value assign
samuael Oct 10, 2025
4306faa
update wrapper, fix unit text and websocket update
samuael Oct 11, 2025
5855bc1
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Oct 11, 2025
4cc6bbc
config and wrapper endpoints fix and unit tests update
samuael Oct 12, 2025
4697794
suppress misc error
samuael Oct 12, 2025
cd20241
revert the last
samuael Oct 12, 2025
26febf6
split spot public and private subscriptions and handlers
samuael Oct 14, 2025
862c57c
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Oct 15, 2025
b1263e4
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Oct 16, 2025
d646b08
minor cleanups
samuael Oct 16, 2025
5cc1700
futures websocket update, added endpoints, updated endpoints and types
samuael Oct 17, 2025
b27846f
added and updated endpoint methods and fix websocket issues
samuael Oct 19, 2025
986c637
wrapper loops and error returns update
samuael Oct 21, 2025
91ff592
unit test functions naming updates
samuael Oct 22, 2025
1d57d0c
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Oct 22, 2025
ead03bb
wrapper methods and types update
samuael Oct 23, 2025
380c428
input validation fix and testing
samuael Oct 23, 2025
606f05e
rest endpoints and unit tests fix
samuael Oct 24, 2025
7f6e3b1
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Oct 24, 2025
a9ba4bf
fix ID generation
samuael Oct 24, 2025
00a3ace
updated SubmitOrder parameter validations and update unit tests accor…
samuael Oct 24, 2025
a4a5885
change based og gks feedback
samuael Oct 25, 2025
48e1894
actioned gk's feedback comments
samuael Oct 26, 2025
4a0c8f9
based on shazberts feedback: updated futures endpoints and correcspon…
samuael Oct 27, 2025
98b426a
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Oct 28, 2025
b6b6de4
overall wrapper, unit tests, and types marshaling update
samuael Oct 28, 2025
0c10d8b
remove unnecessary code
samuael Oct 28, 2025
a669a6c
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Oct 28, 2025
c549c62
update on wrapper request params types
samuael Oct 29, 2025
a1fd9c3
rm
samuael Oct 29, 2025
b11ed26
update smart orders, live tested, and unit tests update
samuael Oct 29, 2025
7d9ce0b
based on gk's and scott's feedback: wrapper and types update
samuael Oct 30, 2025
91a1b34
types, unmarshalers, wrapper handler update
samuael Oct 31, 2025
645fe34
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Oct 31, 2025
4a213b4
wrapper params fix
samuael Nov 2, 2025
ccc8b22
comments, code coverage update, and mock recording
samuael Nov 3, 2025
39d2f9b
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Nov 3, 2025
c19b026
overall types, wrapper functions, and mock records update
samuael Nov 4, 2025
4fc0f8f
types, time handling, ratelimiter,and endpoints update
samuael Nov 5, 2025
380bda7
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Nov 5, 2025
4dd2e47
rate-limiters update
samuael Nov 5, 2025
3ed7e14
uint8 to string
samuael Nov 5, 2025
6f27e04
added missing state order PENDING_CANCEL
samuael Nov 6, 2025
f3a1375
added missing state order PENDING_CANCEL
samuael Nov 6, 2025
f0f3624
overall update on types, endpoints, wrapper, and rate limiters
samuael Nov 7, 2025
3e5b654
wrapper endpoints input type change
samuael Nov 12, 2025
83eeae7
overall wrapper and unit tests update, and live tests fix
samuael Nov 13, 2025
a012e60
Trigger CI
samuael Nov 13, 2025
f3838f3
revert linter version
samuael Nov 13, 2025
1282204
poloniex overall update
samuael Nov 13, 2025
a35f5b5
Merge branch 'poloniex' of https://github.com/samuael/gocryptotrader …
samuael Nov 13, 2025
a2ad436
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Nov 13, 2025
69ab30a
gk and scotts review feedbacks: unit test and wrapper update
samuael Nov 14, 2025
62a39e0
update linter to 2.6.1
samuael Nov 15, 2025
6c0e71c
linter issues resolve
samuael Nov 15, 2025
900a5e5
Poloniex: Proof of Concept resps can contain errors
gbjk Nov 16, 2025
84bc186
trade endpoints response update
samuael Nov 16, 2025
c58aaab
rm panic and fix endpoint limit
samuael Nov 17, 2025
1e8f0a8
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Nov 17, 2025
3d20c41
trade endpoints and requester error wrapper and checker update
samuael Nov 17, 2025
0a2b102
update smartorder endpoints and types
samuael Nov 18, 2025
ec7dad8
smart orders endpoint and mock data update
samuael Nov 19, 2025
de84d08
rename Test name to TestStatusCodeUnmarshal
samuael Nov 19, 2025
ec0883d
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Nov 19, 2025
9eb8c25
Proof-of-simplicity
gbjk Nov 20, 2025
e7949d7
rn unit test name
samuael Nov 20, 2025
22952d8
updata onceWebsocketOrderbookCache lock in loop
samuael Nov 20, 2025
02712c8
spot websocket order book update and endpoints fix
samuael Nov 21, 2025
71c9ec5
manual update mock file and revert nil result check
samuael Nov 21, 2025
1d6f7c2
update wrapper and websocket handlers
samuael Nov 23, 2025
1a046e2
wrapepr batch order cancellation and minor updates
samuael Nov 24, 2025
c02acd4
linter issues fix
samuael Nov 24, 2025
c674376
fix linter issue
samuael Nov 25, 2025
02842aa
change v2 currency endpoint limiter
samuael Nov 25, 2025
fb6b7da
added poloniex config upgrade
samuael Nov 25, 2025
48e447e
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Nov 25, 2025
2bc3411
minor linter fix
samuael Nov 25, 2025
3b269be
rm legacy url migration from wrapper
samuael Nov 26, 2025
f544a7b
move config change to v11 and register
samuael Nov 26, 2025
fe993a0
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Nov 27, 2025
c2f9c27
GetOrders feedback
gbjk Nov 27, 2025
a088583
getorder update and version upgrade fix
samuael Nov 27, 2025
66e9189
update futures websocket iteration and wrapper handlers
samuael Nov 27, 2025
a6f10dc
minor linter fix
samuael Nov 27, 2025
e5bd13a
fix race condition and update websocket slice object access
samuael Nov 28, 2025
4deb965
fix linter issue
samuael Nov 28, 2025
7bd5127
rm lock var
samuael Nov 28, 2025
c1affb2
change v11 config upgrade from replace to delete
samuael Nov 29, 2025
9021b39
improve v11 config unit test
samuael Dec 1, 2025
673f07c
added test coverage and updated endpoints and types
samuael Dec 2, 2025
b284380
update on types, requester, and unit tests
samuael Dec 2, 2025
58a5bd6
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Dec 2, 2025
79cc356
minor linter fix
samuael Dec 2, 2025
1c0a0f6
update type to use currency.Pair and revert order.Type use
samuael Dec 3, 2025
c4297ad
minor fixes on websocket data handling
samuael Dec 4, 2025
96a8f5e
websocket subscriptions and handlers update
samuael Dec 5, 2025
bbb6a7d
update way of subscribing parallely
samuael Dec 7, 2025
9aac140
reuse manage subscriptions and update subscription handling
samuael Dec 7, 2025
d4e2bc1
rm time.Sleep
samuael Dec 8, 2025
77e7c54
gk's nits: minor types and websocket update
samuael Dec 9, 2025
653112d
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Dec 9, 2025
ff51cc1
sams feedbacks: websocket, types, and websocket handlers update
samuael Dec 9, 2025
06063b3
linter issue fix
samuael Dec 9, 2025
05140d7
removed interface check
samuael Dec 10, 2025
9a64ef8
gks feedback: update websocket trade endpoint and minor fixed on wrapper
samuael Dec 11, 2025
36c8ca5
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Dec 11, 2025
aa54838
minot linter fix
samuael Dec 11, 2025
882a3bf
improve unit tests and test coverage, and update on wrapper and mock …
samuael Dec 12, 2025
aaa0a4e
add more coverage and unti test update
samuael Dec 12, 2025
41f7c29
rm print stmts
samuael Dec 12, 2025
16cedac
gk and scott's feedback: updated requester functions and others
samuael Dec 15, 2025
767038f
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Dec 15, 2025
4fefe6b
futures type variables, endpoints, and wrapper handlers update
samuael Dec 16, 2025
3abab86
minor fixes on types
samuael Dec 16, 2025
fa3c6b0
added boolean type and fixed futures and websocket handler, and mock …
samuael Dec 16, 2025
218298c
remove some non-sense from code
samuael Dec 17, 2025
b1a4bf3
resolve websocket response error check from within slice
samuael Dec 17, 2025
6756caf
update to websocket wrapper handlers and minor fix to unit tests
samuael Dec 17, 2025
4b4eaa9
suppress a nillness check
samuael Dec 17, 2025
d857f8e
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Dec 17, 2025
c47cab3
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Dec 18, 2025
d50e626
resolve issue with websocket requester
samuael Dec 19, 2025
3869f96
fix minor linter issue
samuael Dec 19, 2025
5bfccaa
linter fix 2
samuael Dec 19, 2025
9c4a22f
update websocekt slice interfaces wrapper handlers
samuael Dec 21, 2025
2433e00
gk and sams feedback: overall update
samuael Dec 23, 2025
2dded56
codespell fix
samuael Dec 23, 2025
2c5f832
sams feedback: futures endpoint functions update
samuael Dec 23, 2025
c846b5c
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Dec 26, 2025
97042fd
add new requesters for batched validated order response handling
samuael Dec 28, 2025
29ede04
linter issue fix
samuael Dec 28, 2025
13afe2e
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Dec 29, 2025
56700a8
fix test issue, added missing endpoint, and improve test coverage
samuael Dec 30, 2025
c9ae7dc
sam's feedback: update types, and add unit test coverage
samuael Dec 30, 2025
cb77233
minor change to smart order unit test
samuael Dec 30, 2025
dbb2c21
futures types update
samuael Dec 30, 2025
bc2a47f
add candle interval hour_8
samuael Dec 30, 2025
d9ab0f8
fix futures mark price candles fields unmarshal sequence
samuael Dec 30, 2025
4b40530
update authenticated requester and update on wrapper and endpoint fun…
samuael Jan 3, 2026
b0c052f
fix test issues caused by update on requester
samuael Jan 5, 2026
7181aea
lint
samuael Jan 5, 2026
56b0fc7
sams feedback: types update, increase unit test coverage
samuael Jan 6, 2026
61b8269
sams feedbacks: futures websocket update
samuael Jan 6, 2026
5871357
unit tests improvement and mock file update
samuael Jan 9, 2026
66ff080
update wrapper, endpoints, and unit tests handling
samuael Jan 12, 2026
ce3a96a
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Jan 12, 2026
6fa294a
re- add missing comment
samuael Jan 12, 2026
4b10713
minor fix on types
samuael Jan 14, 2026
04de26f
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Jan 14, 2026
410f982
change to types handling
samuael Jan 14, 2026
ae59218
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Jan 17, 2026
2c697aa
update webscket handlers, endpoints, and add unit test coverage
samuael Jan 18, 2026
1f1005f
codespell fix
samuael Jan 18, 2026
853afbc
minor unit test fixes
samuael Jan 18, 2026
db71bdc
fix live test issues
samuael Jan 18, 2026
ad3da1a
comment fix
samuael Jan 18, 2026
852e5ed
rm casting
samuael Jan 18, 2026
73a7337
temporrary fix to GetOrderbook unit test scale value
samuael Jan 19, 2026
d46bc99
update mock file, improve wrapper, and added test coverage
samuael Jan 20, 2026
653b518
rm unnecessary comment
samuael Jan 20, 2026
8e92d5f
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Jan 20, 2026
51b8bf8
rn ineffectual assignment
samuael Jan 20, 2026
2943275
fix platform-dependent error
samuael Jan 20, 2026
69bd301
add ticker processor to UpdateTicker
samuael Jan 21, 2026
0350ba4
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Jan 21, 2026
aaa90d1
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Jan 22, 2026
dd1996e
linter fix
samuael Jan 22, 2026
0b2e2f7
error return from DataHandler
samuael Jan 22, 2026
aabfe5f
Minor stream data test fix
samuael Jan 22, 2026
60ed0f3
fix live test issue
samuael Jan 23, 2026
f11ece6
fix to wrapper balance handling
samuael Jan 27, 2026
dd671f2
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Jan 27, 2026
954e9e9
orderbook depth update fix
samuael Feb 2, 2026
fe7a7a0
fix sams feedbacks
samuael Feb 3, 2026
605505b
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Feb 3, 2026
95c6f7f
update wrapper handlers, types, and mock data
samuael Feb 3, 2026
0bb055b
fix linter issue
samuael Feb 3, 2026
a4c9f35
minor fix to unmarshaler
samuael Feb 4, 2026
5d0a305
minor improvement on unmarshaler unit test
samuael Feb 6, 2026
7ff57ac
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Feb 6, 2026
40a4674
rename filename
samuael Feb 8, 2026
c5a71e5
added test coverage and update wrapper handlers
samuael Feb 10, 2026
6c3b824
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Feb 10, 2026
8dbf649
improve trade order wrapper functions
samuael Feb 10, 2026
0663c2b
fix linter issue
samuael Feb 10, 2026
86a3b66
minor order unit test fix
samuael Feb 11, 2026
252ae90
adrian's feedback: added unit tests, fix nits, update types, and others
samuael Feb 12, 2026
5e821b3
codespell fixes
samuael Feb 13, 2026
b19d79c
formatting issue fix
samuael Feb 13, 2026
bf81aa4
revert codespell fixes on other exchanges
samuael Feb 13, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -613,8 +613,7 @@ var unsupportedAssets = []asset.Item{
var unsupportedExchangeNames = []string{
"testexch",
"bitflyer", // Bitflyer has many "ErrNotYetImplemented, which is true, but not what we care to test for here
"btse", // TODO rm once timeout issues resolved
"poloniex", // outdated API // TODO rm once updated
"btse", // TODO rm once timeout issues resolved
}

// cryptoChainPerExchange holds the deposit address chain per exchange
Expand Down
2 changes: 2 additions & 0 deletions config/versions/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
v0 "github.com/thrasher-corp/gocryptotrader/config/versions/v0"
v1 "github.com/thrasher-corp/gocryptotrader/config/versions/v1"
v10 "github.com/thrasher-corp/gocryptotrader/config/versions/v10"
v11 "github.com/thrasher-corp/gocryptotrader/config/versions/v11"
v2 "github.com/thrasher-corp/gocryptotrader/config/versions/v2"
v3 "github.com/thrasher-corp/gocryptotrader/config/versions/v3"
v4 "github.com/thrasher-corp/gocryptotrader/config/versions/v4"
Expand All @@ -26,4 +27,5 @@ func init() {
Manager.registerVersion(8, &v8.Version{})
Manager.registerVersion(9, &v9.Version{})
Manager.registerVersion(10, &v10.Version{})
Manager.registerVersion(11, &v11.Version{})
}
34 changes: 34 additions & 0 deletions config/versions/v11/v11.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package v11

import (
"context"
"errors"

"github.com/buger/jsonparser"
)

// Version is an ExchangeVersion to replace deprecated WS and REST endpoints for Poloniex
type Version struct{}

// Exchanges returns just Poloniex
func (v *Version) Exchanges() []string { return []string{"Poloniex"} }

// UpgradeExchange replaces deprecated WS and REST endpoints
func (v *Version) UpgradeExchange(_ context.Context, e []byte) ([]byte, error) {
for _, key := range []string{"WebsocketSpotURL", "RestSpotURL"} {
url, err := jsonparser.GetString(e, "api", "urlEndpoints", key)
if err != nil && !errors.Is(err, jsonparser.KeyPathNotFoundError) {
return e, err
}
switch url {
case "wss://api2.poloniex.com", "https://poloniex.com":
e = jsonparser.Delete(e, "api", "urlEndpoints", key)
}
}
return e, nil
}

// DowngradeExchange is a no-op for v11
func (v *Version) DowngradeExchange(_ context.Context, e []byte) ([]byte, error) {
return e, nil
}
54 changes: 54 additions & 0 deletions config/versions/v11/v11_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package v11_test

import (
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
v11 "github.com/thrasher-corp/gocryptotrader/config/versions/v11"
)

func TestExchanges(t *testing.T) {
t.Parallel()
assert.Equal(t, []string{"Poloniex"}, new(v11.Version).Exchanges())
}

func TestUpgradeExchange(t *testing.T) {
t.Parallel()

for _, tt := range []struct {
in string
urlType string
exp string
}{
{"https://poloniex.com", "RestSpotURL", ""},
{"https://poloniex.private-proxy.com", "RestSpotURL", `"RestSpotURL": "https://poloniex.private-proxy.com"`},
{"wss://api2.poloniex.com", "WebsocketSpotURL", ""},
{"wss://poloniex.private-proxy.com", "WebsocketSpotURL", `"WebsocketSpotURL": "wss://poloniex.private-proxy.com"`},
} {
t.Run(tt.in, func(t *testing.T) {
t.Parallel()
in := []byte(`{"name":"Poloniex","api":{"urlEndpoints":{"` + tt.urlType + `": "` + tt.in + `"}}}`)
out, err := new(v11.Version).UpgradeExchange(t.Context(), in)
require.NoError(t, err)
exp := `{"name":"Poloniex","api":{"urlEndpoints":{` + tt.exp + `}}}`
assert.Equal(t, exp, string(out))
})
}

in := []byte(`{"name":"Poloniex","api":{}`)
out, err := new(v11.Version).UpgradeExchange(t.Context(), in)
require.NoError(t, err, "UpgradeExchange must not error when urlEndpoints is missing")
assert.Equal(t, string(in), string(out), "UpgradeExchange should return same input and no error when urlEndpoints is missing")

_, err = new(v11.Version).UpgradeExchange(t.Context(), []byte(`{"name":"Poloniex","api":{"urlEndpoints":{"WebsocketSpotURL": 42}}}`))
require.ErrorContains(t, err, "Value is not a string", "UpgradeExchange must error correctly on string value")
}

func TestDowngradeExchange(t *testing.T) {
t.Parallel()
in := []byte(`{"name":"Poloniex","api":{"urlEndpoints":{"WebsocketSpotURL": 42}}}`)
out, err := new(v11.Version).DowngradeExchange(t.Context(), in)
require.NoError(t, err)
require.Equal(t, string(in), string(out), "DowngradeExchange must not change json")
}
31 changes: 18 additions & 13 deletions config_example.json
Original file line number Diff line number Diff line change
Expand Up @@ -2308,31 +2308,36 @@
"delimiter": "_"
},
"useGlobalFormat": true,
"assetTypes": [
"spot"
],
"pairs": {
"spot": {
"assetEnabled": true,
"enabled": "BTC_LTC,BTC_ETH,BTC_DOGE,BTC_DASH,BTC_XRP",
"available": "BTC_SC,BTC_GNT,USDC_LTC,PAX_ETH,USDT_BSVBEAR,BUSD_BNB,USDT_WRX,USDT_IBVOL,USDT_ETH,BTC_ETC,USDC_ETH,BTC_POLY,BTC_ATOM,USDT_ATOM,TRX_STEEM,USDT_NEO,USDT_XRPBULL,USDT_AVA,USDT_DASH,USDT_ZRX,USDT_TRXBEAR,USDT_PAX,DAI_ETH,BTC_NEO,TRX_JST,BTC_FXC,USDT_ETC,USDT_ZEC,BTC_STORJ,USDT_GNT,USDT_QTUM,BTC_FOAM,TRX_BTT,USDT_BCHC,BTC_XFIL,USDC_XMR,TRX_WIN,USDT_SNX,BTC_LEND,USDT_BSVBULL,BTC_DOGE,BTC_REP,USDT_REP,BTC_STRAT,USDT_EOS,BTC_BAT,BTC_BCHABC,USDT_BUSD,BTC_XRP,BTC_ARDR,USDT_LINKBULL,BTC_CHR,USDT_CUSDT,TRX_WRX,USDT_XRP,ETH_ZEC,BTC_KNC,USDT_DOGE,BTC_LPT,USDT_BTT,ETH_COMP,USDC_GRIN,USDC_DASH,USDT_GRIN,USDT_XTZ,BTC_GAS,USDT_DAI,TRX_NEO,USDT_LINKBEAR,TRX_CHR,BTC_MDT,USDT_XMR,BTC_DCR,BTC_CVC,USDT_BNB,BTC_NXT,BTC_LSK,BTC_OMG,BTC_QTUM,BTC_BCHSV,BTC_SNX,BTC_MANA,USDC_EOS,DAI_BTC,BTC_SWFTC,TRX_BNB,BTC_STEEM,USDJ_BTC,USDJ_BTT,USDT_LRC,USDT_BAL,BNB_BTC,USDC_DOGE,BTC_TRX,BTC_XTZ,TRX_XTZ,USDT_MATIC,USDT_BCHBEAR,USDT_SWFTC,BTC_LTC,USDC_XRP,BTC_NMR,TRX_MATIC,USDT_XRPBEAR,BTC_ZEC,BTC_SNT,USDT_SC,USDT_BCHSV,TRX_ETH,BUSD_BTC,BTC_DASH,ETH_BAT,BTC_LOOM,TRX_SNX,ETH_ZRX,USDC_BCHABC,USDC_ETC,USDT_BULL,PAX_BTC,USDJ_TRX,BTC_WRX,BTC_BTS,USDT_LTC,BTC_LINK,USDT_USDJ,TRX_SWFTC,USDT_LINK,TRX_AVA,USDC_USDT,USDT_JST,TRX_FXC,USDT_CHR,USDT_XFIL,BTC_ETHBNT,BTC_LRC,USDT_BAT,USDC_ATOM,USDT_WIN,ETH_EOS,USDT_TRX,TRX_MDT,BTC_AVA,BTC_XEM,USDT_BTC,BTC_EOS,USDT_LSK,BTC_MATIC,USDT_FXC,USDT_STEEM,USDC_BCHSV,USDT_TRXBULL,USDT_EOSBULL,USDT_LEND,ETH_ETC,USDT_MANA,USDT_ETHBULL,USDT_REN,USDT_COMP,BTC_XMR,BTC_ETH,BTC_ZRX,USDC_BTC,TRX_XRP,USDT_ETHBEAR,USDT_BVOL,ETH_BAL,USDT_MDT,BTC_BNT,USDC_ZEC,USDT_BCHABC,TRX_LINK,BTC_MKR,USDT_BCN,USDT_EOSBEAR,BTC_REN,USDT_STR,USDC_STR,USDT_BEAR,USDT_BCHBULL,BTC_STR,USDC_TRX,USDT_MKR"
},
"futures": {
"assetEnabled": true,
"enabled": "XBT_USDT_PERP,ETH_USDT_PERP,BCH_USDT_PERP",
"available": "BNB_USDT_PERP,TRX_USDT_PERP,LTC_USDT_PERP,APT_USDT_PERP,1000PEPE_USDT_PERP,1000SHIB_USDT_PERP,BTC_USDT_PERP,DOGE_USDT_PERP,AVAX_USDT_PERP,XRP_USDT_PERP,SOL_USDT_PERP,ETH_USDT_PERP,BCH_USDT_PERP"
}
}
},
"api": {
"authenticatedSupport": false,
"authenticatedWebsocketApiSupport": false,
"endpoints": {
"url": "NON_DEFAULT_HTTP_LINK_TO_EXCHANGE_API",
"urlSecondary": "NON_DEFAULT_HTTP_LINK_TO_EXCHANGE_API",
"websocketURL": "NON_DEFAULT_HTTP_LINK_TO_WEBSOCKET_EXCHANGE_API"
},
"authenticatedSupport": true,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"authenticatedSupport": true,
"authenticatedSupport": false,

"authenticatedWebsocketApiSupport": true,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"authenticatedWebsocketApiSupport": true,
"authenticatedWebsocketApiSupport": false,

"credentials": {
"key": "Key",
"secret": "Secret"
"key": "",
"secret": ""
},
"credentialsValidator": {
"requiresKey": true,
"requiresSecret": true
},
"urlEndpoints": {
"RestSpotURL": "https://api.poloniex.com",
"WebsocketPrivateURL": "wss://ws.poloniex.com/ws/private",
"WebsocketSpotURL": "wss://ws.poloniex.com/ws/public",
"WebsocketFuturesURL": "wss://ws.poloniex.com/ws/v3/public",
"WebsocketFuturesPrivateURL": "wss://ws.poloniex.com/ws/v3/private"
}
},
"features": {
Expand All @@ -2347,7 +2352,7 @@
},
"enabled": {
"autoPairUpdates": true,
"websocketAPI": false
"websocketAPI": true
}
},
"bankAccounts": [
Expand Down
8 changes: 8 additions & 0 deletions exchanges/exchange.go
Original file line number Diff line number Diff line change
Expand Up @@ -1364,6 +1364,10 @@ func (u URL) String() string {
return websocketPrivateURL
case WebsocketSpotSupplementary:
return websocketSpotSupplementaryURL
case WebsocketFutures:
return websocketFuturesURL
case WebsocketFuturesPrivate:
return websocketFuturesPrivateURL
case ChainAnalysis:
return chainAnalysisURL
case EdgeCase1:
Expand Down Expand Up @@ -1414,6 +1418,10 @@ func getURLTypeFromString(ep string) (URL, error) {
return WebsocketPrivate, nil
case websocketSpotSupplementaryURL:
return WebsocketSpotSupplementary, nil
case websocketFuturesURL:
return WebsocketFutures, nil
case websocketFuturesPrivateURL:
return WebsocketFuturesPrivate, nil
case chainAnalysisURL:
return ChainAnalysis, nil
case edgeCase1URL:
Expand Down
4 changes: 4 additions & 0 deletions exchanges/exchange_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1649,6 +1649,8 @@ func TestString(t *testing.T) {
{WebsocketTrade, websocketTradeURL},
{WebsocketPrivate, websocketPrivateURL},
{WebsocketSpotSupplementary, websocketSpotSupplementaryURL},
{WebsocketFutures, websocketFuturesURL},
{WebsocketFuturesPrivate, websocketFuturesPrivateURL},
{ChainAnalysis, chainAnalysisURL},
{EdgeCase1, edgeCase1URL},
{EdgeCase2, edgeCase2URL},
Expand Down Expand Up @@ -1813,6 +1815,8 @@ func TestGetGetURLTypeFromString(t *testing.T) {
{Endpoint: websocketTradeURL, Expected: WebsocketTrade},
{Endpoint: websocketPrivateURL, Expected: WebsocketPrivate},
{Endpoint: websocketSpotSupplementaryURL, Expected: WebsocketSpotSupplementary},
{Endpoint: websocketFuturesURL, Expected: WebsocketFutures},
{Endpoint: websocketFuturesPrivateURL, Expected: WebsocketFuturesPrivate},
{Endpoint: chainAnalysisURL, Expected: ChainAnalysis},
{Endpoint: edgeCase1URL, Expected: EdgeCase1},
{Endpoint: edgeCase2URL, Expected: EdgeCase2},
Expand Down
6 changes: 6 additions & 0 deletions exchanges/exchange_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,8 @@ const (
WebsocketTrade
WebsocketPrivate
WebsocketSpotSupplementary
WebsocketFutures
WebsocketFuturesPrivate
ChainAnalysis
EdgeCase1
EdgeCase2
Expand All @@ -304,6 +306,8 @@ const (
websocketTradeURL = "WebsocketTradeURL"
websocketPrivateURL = "WebsocketPrivateURL"
websocketSpotSupplementaryURL = "WebsocketSpotSupplementaryURL"
websocketFuturesURL = "WebsocketFuturesURL"
websocketFuturesPrivateURL = "WebsocketFuturesPrivateURL"
chainAnalysisURL = "ChainAnalysisURL"
edgeCase1URL = "EdgeCase1URL"
edgeCase2URL = "EdgeCase2URL"
Expand All @@ -328,6 +332,8 @@ var keyURLs = []URL{
WebsocketTrade,
WebsocketPrivate,
WebsocketSpotSupplementary,
WebsocketFutures,
WebsocketFuturesPrivate,
ChainAnalysis,
EdgeCase1,
EdgeCase2,
Expand Down
1 change: 1 addition & 0 deletions exchanges/kline/kline_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ type Candle struct {
Low float64
Close float64
Volume float64
QuoteVolume float64
ValidationIssues string
}

Expand Down
9 changes: 4 additions & 5 deletions exchanges/mock/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,15 +253,13 @@ func MatchAndGetResponse(mockData []HTTPResponse, requestVals url.Values, isQuer
}

mockVals := url.Values{}
var err error
if json.Valid([]byte(data)) {
something := make(map[string]any)
err = json.Unmarshal([]byte(data), &something)
if err != nil {
dataMap := make(map[string]any)
if err := json.Unmarshal([]byte(data), &dataMap); err != nil {
return nil, err
}

for k, v := range something {
for k, v := range dataMap {
switch val := v.(type) {
case string:
mockVals.Add(k, val)
Expand All @@ -277,6 +275,7 @@ func MatchAndGetResponse(mockData []HTTPResponse, requestVals url.Values, isQuer
}
}
} else {
var err error
mockVals, err = url.ParseQuery(data)
if err != nil {
return nil, err
Expand Down
29 changes: 29 additions & 0 deletions exchanges/order/order_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,8 @@ func TestOrderIs(t *testing.T) {
{Type: StopMarket, Targets: []Type{Stop, Market}},
{Type: TrailingStop, Targets: []Type{TrailingStop}},
{Type: UnknownType | Limit, Targets: []Type{Limit}},
{Type: TrailingStop | Limit, Targets: []Type{TrailingStopLimit, Limit}},
{Type: LimitMaker, Targets: []Type{LimitMaker}},
{Type: TakeProfitMarket, Targets: []Type{TakeProfit, Market}},
}
for _, oType := range orderComparisonList {
Expand Down Expand Up @@ -358,6 +360,9 @@ func TestOrderTypeToString(t *testing.T) {
{AnyType, "ANY"},
{UnknownType | Limit, "LIMIT"},
{StopMarket | ConditionalStop, "UNKNOWN"},
{TrailingStop | Limit, "TRAILING_STOP_LIMIT"},
{TrailingStopLimit, "TRAILING_STOP_LIMIT"},
{LimitMaker, "LIMIT_MAKER"},
}
for _, tt := range orderToToStringsList {
t.Run(tt.String, func(t *testing.T) {
Expand Down Expand Up @@ -846,6 +851,10 @@ func TestStringToOrderType(t *testing.T) {
{"TRIGGER_bracket", Bracket, nil},
{"optimal_limit", OptimalLimit, nil},
{"OPTIMAL_LIMIT", OptimalLimit, nil},
{"TRAILING_STOP_LIMIT", TrailingStopLimit, nil},
{"trailing_stop_limit", TrailingStopLimit, nil},
{"LIMIT_MAKER", LimitMaker, nil},
{"Limit Maker", LimitMaker, nil},
}
for i := range cases {
testData := &cases[i]
Expand Down Expand Up @@ -1755,3 +1764,23 @@ func TestAdd(t *testing.T) {
c.Add("order1", "cancelled")
assert.Equal(t, "cancelled", c.Status["order1"])
}

func TestPosition(t *testing.T) {
t.Parallel()
input := []struct {
sides []Side
side Side
err error
}{
{[]Side{Short, Sell, Ask}, Short, nil},
{[]Side{Long, Buy, Bid}, Long, nil},
{[]Side{Side(123)}, UnknownSide, ErrPositionSideUnsupported},
}
for _, a := range input {
for _, sd := range a.sides {
side, err := sd.Position()
assert.Equal(t, a.side, side)
assert.ErrorIs(t, err, a.err)
}
}
}
22 changes: 13 additions & 9 deletions exchanges/order/order_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ var (
ErrCannotLiquidate = errors.New("cannot liquidate position")

ErrUnknownTrackingMode = errors.New("unknown tracking mode")
ErrGetFailed = errors.New("get order failed")
ErrPlaceFailed = errors.New("place order failed")
ErrCancelFailed = errors.New("cancel order failed")
)

// Submit contains all properties of an order that may be required
Expand Down Expand Up @@ -372,6 +375,7 @@ const (
AnyType
Liquidation
Trigger
LimitMaker
OCO // One-cancels-the-other order
ConditionalStop // One-way stop order
TWAP // time-weighted average price
Expand All @@ -380,10 +384,11 @@ const (
MarketMakerProtection

// Hybrid order types
StopLimit = Stop | Limit
StopMarket = Stop | Market
TakeProfitMarket = TakeProfit | Market
Bracket = Stop | TakeProfit
StopLimit = Stop | Limit
StopMarket = Stop | Market
TakeProfitMarket = TakeProfit | Market
TrailingStopLimit = TrailingStop | Limit
Bracket = Stop | TakeProfit
)

// order-type string representations
Expand All @@ -399,9 +404,11 @@ const (
orderTakeProfit = "TAKE PROFIT"
orderTakeProfitMarket = "TAKE PROFIT MARKET"
orderTrailingStop = "TRAILING_STOP"
orderTrailingStopLimit = "TRAILING_STOP_LIMIT"
orderIOS = "IOS"
orderLiquidation = "LIQUIDATION"
orderTrigger = "TRIGGER"
orderLimitMaker = "LIMIT_MAKER"
orderOCO = "OCO"
orderOptimalLimit = "OPTIMAL_LIMIT"
orderMarketMakerProtection = "MMP"
Expand All @@ -413,22 +420,19 @@ const (
var AllOrderTypes = Limit |
Market |
Stop |
StopLimit |
StopMarket |
TakeProfit |
TakeProfitMarket |
TrailingStop |
IOS |
AnyType |
Liquidation |
Trigger |
LimitMaker |
OCO |
ConditionalStop |
TWAP |
Chase |
OptimalLimit |
MarketMakerProtection |
Bracket
MarketMakerProtection

// Side enforces a standard for order sides across the code base
type Side uint32
Expand Down
Loading
Loading