Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exchanges: Okx Update #1420

Open
wants to merge 134 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 119 commits
Commits
Show all changes
134 commits
Select commit Hold shift + click to select a range
1c049bb
update acccount ratelimits and added missing endpoints
samuael Nov 7, 2023
5ba4043
completed mapping missing trade accoung REST endpoints and Rate Limit
samuael Nov 8, 2023
57ebd02
added orderbook trading missing REST endpoints
samuael Nov 10, 2023
372a0be
Added few missing endpoints and unit tests
samuael Nov 11, 2023
b448b2d
Completed grid trading and signal bot trading with unit tests
samuael Nov 12, 2023
c8ec145
Added Recurring Buy endpoints and corresponding unit tests
samuael Nov 13, 2023
de333e1
Added copy trading endpoints and unit tests
samuael Nov 14, 2023
474b7ee
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Nov 15, 2023
5e44c1c
added newly added block trading and spread endpoints
samuael Nov 17, 2023
b25bca0
completed mapping spread endpoints
samuael Nov 18, 2023
6444789
Added new endpoints and unit tests
samuael Nov 19, 2023
02581e0
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Nov 23, 2023
29c2901
Added round 1: Okx types and converts update.
samuael Nov 23, 2023
af5a97b
Update endpoints handling and types update
samuael Nov 25, 2023
3112408
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Nov 25, 2023
9d19df1
Removed constants, updated unit tests, and updated endpoint methods
samuael Nov 26, 2023
8cbcca1
Slight endpoint and unit test update
samuael Nov 26, 2023
716c294
Added spread and other websocket endpoints and update
samuael Nov 29, 2023
a8e6f43
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Nov 29, 2023
770b878
completed Spread WS Orderbook handler
samuael Nov 29, 2023
32a0bce
Added missing spread channels and handlers
samuael Nov 30, 2023
1a7f33c
Adding Bussinss websocket and missing subscriptions, update unit test…
samuael Dec 3, 2023
fe3c28e
Added spread endpoints to wrapper and unit tests update
samuael Dec 4, 2023
6a6cd71
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Dec 4, 2023
42a9826
Added missing websocket subscriptions and copy trading endpoints
samuael Dec 9, 2023
b20386c
Added missing endpoints and re-organize business websocket handlers
samuael Dec 10, 2023
ddb379d
Docs update
samuael Dec 10, 2023
0bf59bc
Endpoints code updates
samuael Dec 11, 2023
7360c8e
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Dec 11, 2023
6c60fde
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Dec 17, 2023
ab5ff5e
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Dec 22, 2023
b472922
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Dec 31, 2023
7579c09
types, unit test and endpoints update
samuael Jan 15, 2024
3c6524f
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Jan 15, 2024
340f5a8
Minor unit tests update
samuael Jan 21, 2024
44ce688
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Jan 21, 2024
2834e29
spelling fix
samuael Jan 21, 2024
d7143fa
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Jan 24, 2024
3c82295
fix unit test issues
samuael Jan 30, 2024
6ab81da
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Jan 30, 2024
bdddb53
Updating unit tests error handling
samuael Feb 5, 2024
b4de8e5
Updating unit tests error handling
samuael Feb 5, 2024
41174d1
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Feb 8, 2024
c6d4274
Unit tests assertion handling update
samuael Feb 15, 2024
70f57b8
Unit tests update
samuael Feb 15, 2024
b971949
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Feb 15, 2024
1ef68e5
Resolve linter issues
samuael Feb 16, 2024
f383383
linter issues fix
samuael Feb 16, 2024
960c2b3
Orderbook unit test error fix
samuael Feb 16, 2024
314d5b4
Minor fixes
samuael Feb 19, 2024
9a36a29
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Feb 21, 2024
a20435b
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Feb 28, 2024
03ad8e5
Change on test handling and types
samuael Feb 28, 2024
fdf7e4a
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael May 21, 2024
b6b2e3e
Updating unit tests and cleanups
samuael May 23, 2024
ede9af8
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael May 28, 2024
54f3a0a
Fix unit test issues
samuael May 29, 2024
8106d20
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael May 29, 2024
efa96e8
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Jun 10, 2024
4b4c518
Add ratelimit test and update unit tests and methods
samuael Jun 11, 2024
c647b48
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Jun 22, 2024
40d97d0
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Jul 12, 2024
e7c2b7c
Update method parameters and error declarations
samuael Jul 12, 2024
213888f
Added lending endpoints, unit tests, and update endpoint methods and …
samuael Jul 13, 2024
719f310
Update ratelimiters, add missing lending and trading endpoints and un…
samuael Jul 15, 2024
804b839
Update websocket authentication and subscription handling
samuael Jul 17, 2024
58685b5
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Sep 6, 2024
0c2265d
Minor update to unit test and types
samuael Sep 6, 2024
cfc8519
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Sep 24, 2024
fb7fa19
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Oct 17, 2024
9a9711b
Types, error handling, and other minor updates
samuael Oct 17, 2024
d6dbee7
Update unit tests and endpoint functions
samuael Oct 19, 2024
7c07649
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Oct 19, 2024
d388a4b
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Oct 25, 2024
980d30a
error declarations update and unit tests
samuael Oct 25, 2024
b8c5264
Overall update on unit endpoint, unit tests, and types
samuael Oct 29, 2024
95dc4e0
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Oct 29, 2024
e406221
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Nov 1, 2024
06300af
Adding review fixes
samuael Nov 1, 2024
82a77d0
Update on endpoints, order types, and unit tests
samuael Nov 2, 2024
6c08ec3
Update unit tests and endpoint functions
samuael Nov 3, 2024
439c460
Update on endpoint and update missing parameters
samuael Nov 4, 2024
9394e26
Implemented and tested newly added trading endpoints
samuael Nov 5, 2024
e877122
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Nov 5, 2024
b77e1d8
endpoints update and unit tests
samuael Nov 6, 2024
0a55411
Update missing endpoints and update overall code
samuael Nov 7, 2024
14dd03a
added and testing funding and fiat related endpoints
samuael Nov 9, 2024
87c1a37
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Nov 9, 2024
f003f9b
Update on convert and fiat related endpoints
samuael Nov 10, 2024
8985235
linter fix, types, endpoints, and unit tests update
samuael Nov 11, 2024
b3e7d71
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Nov 11, 2024
736e267
linter issues fix
samuael Nov 11, 2024
30e576e
revert changes on tempos
samuael Nov 12, 2024
c00ce6d
Fix Panic and update websocket auth calls handling
samuael Nov 12, 2024
6266ad2
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Nov 12, 2024
5ffd43f
config linter issue fix
samuael Nov 12, 2024
c16906d
Fix panic issues and update unit tests
samuael Nov 13, 2024
ef765f4
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Nov 13, 2024
f5e0728
Fix race condition, TestAllExchangeWrappers unit test issues
samuael Nov 14, 2024
43624d7
Fix withdrawal manager test issue
samuael Nov 17, 2024
f6220a4
Rename ClosePositionForContractrID --> ClosePositionForContractID
samuael Nov 17, 2024
f75c7e5
Rename ClosePositionForContractrID --> ClosePositionForContractID
samuael Nov 17, 2024
d7a6065
Fix error
samuael Nov 17, 2024
5d1e0d7
endpoints update and fix unit test issues
samuael Nov 18, 2024
2e4e1a1
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Nov 18, 2024
735728c
Merge branch 'okx_update' of https://github.com/samuael/gocryptotrade…
samuael Nov 18, 2024
567c9c3
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Nov 20, 2024
f89574c
added unit tests, updated comments, and code sections
samuael Nov 21, 2024
36792ea
revert change in defaultSubscriptions
samuael Nov 21, 2024
c27d51b
few types comments update
samuael Nov 21, 2024
5a9edd5
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Nov 25, 2024
90479fe
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Nov 28, 2024
22fdf03
Minor changes
samuael Nov 28, 2024
9bd5e7e
remove lending endpoints
samuael Dec 3, 2024
d485dcb
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Dec 3, 2024
b52b6d7
rm mistakenly added code
samuael Dec 3, 2024
5406298
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Dec 5, 2024
53fe0c7
fix unit test
samuael Dec 5, 2024
084753b
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Dec 7, 2024
cf31fb5
minor unit test fix
samuael Dec 9, 2024
1429501
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Dec 9, 2024
62fac9c
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Dec 12, 2024
d884ecb
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Dec 16, 2024
121b6a0
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Dec 17, 2024
18badd9
Adding offline error tests, update endpoints function, config update
samuael Dec 17, 2024
076719b
Update unit test coverage for offline error handliing
samuael Dec 18, 2024
7c1cb10
Updating wrapper algo order coverage, endpoint calls, and unit tests
samuael Dec 19, 2024
0291113
Updating wrapper trade functions to accomodate algo orders
samuael Dec 20, 2024
cdddf2e
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Dec 21, 2024
53e09ce
update wrapper unit tests
samuael Dec 21, 2024
2df3ee7
Fix wrapper order functions offline errors handling
samuael Dec 22, 2024
d2ccc2d
Tested and updated wrapper order functions
samuael Dec 23, 2024
131126f
Address review comments
samuael Dec 23, 2024
54ac698
Merge branch 'master' of http://github.com/thrasher-corp/gocryptotrad…
samuael Dec 26, 2024
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
1 change: 1 addition & 0 deletions common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ var (
ErrCannotCalculateOffline = errors.New("cannot calculate offline, unsupported")
ErrNoResponse = errors.New("no response")
ErrTypeAssertFailure = errors.New("type assert failure")
ErrNoResults = errors.New("no results found")
ErrUnknownError = errors.New("unknown error")
)

Expand Down
8 changes: 7 additions & 1 deletion config_example.json

Large diffs are not rendered by default.

9 changes: 2 additions & 7 deletions database/repository/withdraw/withdraw.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package withdraw
import (
"context"
"database/sql"
"errors"
"time"

"github.com/gofrs/uuid"
"github.com/thrasher-corp/gocryptotrader/common"
"github.com/thrasher-corp/gocryptotrader/currency"
"github.com/thrasher-corp/gocryptotrader/database"
modelPSQL "github.com/thrasher-corp/gocryptotrader/database/models/postgres"
Expand All @@ -19,11 +19,6 @@ import (
"github.com/thrasher-corp/sqlboiler/queries/qm"
)

var (
// ErrNoResults is the error returned if no results are found
ErrNoResults = errors.New("no results found")
)

// Event stores Withdrawal Response details in database
func Event(res *withdraw.Response) {
if database.DB.SQL == nil {
Expand Down Expand Up @@ -424,7 +419,7 @@ func getByColumns(q []qm.QueryMod) ([]*withdraw.Response, error) {
}
}
if len(resp) == 0 {
return nil, ErrNoResults
return nil, common.ErrNoResults
}
return resp, nil
}
5 changes: 3 additions & 2 deletions database/repository/withdraw/withdraw_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"testing"
"time"

"github.com/thrasher-corp/gocryptotrader/common"
"github.com/thrasher-corp/gocryptotrader/currency"
"github.com/thrasher-corp/gocryptotrader/database"
"github.com/thrasher-corp/gocryptotrader/database/drivers"
Expand Down Expand Up @@ -159,7 +160,7 @@ func withdrawHelper(t *testing.T) {

_, err := GetEventByUUID(withdraw.DryRunID.String())
if err != nil {
if !errors.Is(err, ErrNoResults) {
if !errors.Is(err, common.ErrNoResults) {
t.Fatal(err)
}
}
Expand All @@ -181,7 +182,7 @@ func withdrawHelper(t *testing.T) {
if len(v) > 0 {
_, err = GetEventByUUID(v[0].ID.String())
if err != nil {
if !errors.Is(err, ErrNoResults) {
if !errors.Is(err, common.ErrNoResults) {
t.Error(err)
}
}
Expand Down
8 changes: 7 additions & 1 deletion exchanges/asset/asset.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const (
MarginFunding
Index
Binary
Spread
Copy link
Collaborator

Choose a reason for hiding this comment

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

This can be moved to below the futures section since it involves at least one futures contract

// Futures asset consts must come below this comment for method `IsFutures`
Futures
PerpetualContract
Expand Down Expand Up @@ -68,12 +69,13 @@ const (
options = "options"
optionCombo = "option_combo"
futureCombo = "future_combo"
spread = "spread"
linearContract = "linearcontract"
all = "all"
)

var (
supportedList = Items{Spot, Margin, CrossMargin, MarginFunding, Index, Binary, PerpetualContract, PerpetualSwap, Futures, DeliveryFutures, UpsideProfitContract, DownsideProfitContract, CoinMarginedFutures, USDTMarginedFutures, USDCMarginedFutures, Options, LinearContract, OptionCombo, FutureCombo}
supportedList = Items{Spot, Margin, CrossMargin, MarginFunding, Index, Binary, PerpetualContract, PerpetualSwap, Futures, DeliveryFutures, UpsideProfitContract, DownsideProfitContract, CoinMarginedFutures, USDTMarginedFutures, USDCMarginedFutures, Options, LinearContract, OptionCombo, FutureCombo, Spread}
)

// Supported returns a list of supported asset types
Expand Down Expand Up @@ -116,6 +118,8 @@ func (a Item) String() string {
return usdcMarginedFutures
case Options:
return options
case Spread:
return spread
case OptionCombo:
return optionCombo
case FutureCombo:
Expand Down Expand Up @@ -234,6 +238,8 @@ func New(input string) (Item, error) {
return USDCMarginedFutures, nil
case options, "option":
return Options, nil
case spread:
return Spread, nil
case optionCombo:
return OptionCombo, nil
case futureCombo:
Expand Down
1 change: 1 addition & 0 deletions exchanges/asset/asset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ func TestNew(t *testing.T) {
{Input: "Future", Error: ErrNotSupported},
{Input: "option_combo", Expected: OptionCombo},
{Input: "future_combo", Expected: FutureCombo},
{Input: "spread", Expected: Spread},
{Input: "linearContract", Expected: LinearContract},
}

Expand Down
2 changes: 2 additions & 0 deletions exchanges/collateral/collateral.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ func (t Mode) String() string {
return multiCollateralStr
case PortfolioMode:
return portfolioCollateralStr
case SpotFuturesMode:
return spotFuturesCollateralStr
case UnknownMode:
return unknownCollateralStr
}
Expand Down
3 changes: 3 additions & 0 deletions exchanges/collateral/collateral_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ func TestValidCollateralType(t *testing.T) {
if !PortfolioMode.Valid() {
t.Fatal("expected 'true', received 'false'")
}
if !SpotFuturesMode.Valid() {
t.Fatal("expected 'true', received 'false'")
}
if UnsetMode.Valid() {
t.Fatal("expected 'false', received 'true'")
}
Expand Down
15 changes: 9 additions & 6 deletions exchanges/collateral/collateral_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,23 @@ const (
PortfolioMode
// UnknownMode has collateral allocated in an unknown manner at present, but is not unset
UnknownMode
// SpotFuturesMode has collateral allocated across spot and futures accounts
SpotFuturesMode
)

const (
unsetCollateralStr = "unset"
singleCollateralStr = "single"
multiCollateralStr = "multi"
portfolioCollateralStr = "portfolio"
unknownCollateralStr = "unknown"
unsetCollateralStr = "unset"
singleCollateralStr = "single"
multiCollateralStr = "multi"
portfolioCollateralStr = "portfolio"
spotFuturesCollateralStr = "spot_futures"
unknownCollateralStr = "unknown"
)

// ErrInvalidCollateralMode is returned when converting invalid string to collateral mode
var ErrInvalidCollateralMode = errors.New("invalid collateral mode")

var supportedCollateralModes = SingleMode | MultiMode | PortfolioMode
var supportedCollateralModes = SingleMode | MultiMode | PortfolioMode | SpotFuturesMode

// ByPosition shows how much collateral is used
// from positions
Expand Down
Loading
Loading