mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-30 23:16:52 +00:00
currency/exchanges: Add bespoke exchange translator and pair matching helper (#1556)
* currency: translation and matching pairs * Update exchanges/exchange_types.go Co-authored-by: Scott <gloriousCode@users.noreply.github.com> * glorious: nits * linter: fix? * translation * fix cherry pick * gateio: translation for mbabydoge with 1e6 divisor * okx: add translation * cherry-pick: fix * glorious: todos * thrasher: nits --------- Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io> Co-authored-by: Scott <gloriousCode@users.noreply.github.com>
This commit is contained in:
@@ -3166,7 +3166,6 @@ func (ok *Okx) GetCandlestickData(ctx context.Context, instrumentID string, inte
|
||||
return nil, errMissingInstrumentID
|
||||
}
|
||||
params.Set("instId", instrumentID)
|
||||
var resp [][7]string
|
||||
params.Set("limit", strconv.FormatInt(limit, 10))
|
||||
if !before.IsZero() {
|
||||
params.Set("before", strconv.FormatInt(before.UnixMilli(), 10))
|
||||
@@ -3178,6 +3177,7 @@ func (ok *Okx) GetCandlestickData(ctx context.Context, instrumentID string, inte
|
||||
if bar != "" {
|
||||
params.Set("bar", bar)
|
||||
}
|
||||
var resp [][7]string
|
||||
err := ok.SendHTTPRequest(ctx, exchange.RestSpot, rateLimit, http.MethodGet, common.EncodeURLValues(route, params), nil, &resp, false)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -1241,7 +1241,7 @@ type AccountDetail struct {
|
||||
AvailableBalance types.Number `json:"availBal"`
|
||||
AvailableEquity types.Number `json:"availEq"`
|
||||
CashBalance types.Number `json:"cashBal"` // Cash Balance
|
||||
Currency string `json:"ccy"`
|
||||
Currency currency.Code `json:"ccy"`
|
||||
CrossLiab types.Number `json:"crossLiab"`
|
||||
DiscountEquity types.Number `json:"disEq"`
|
||||
EquityOfCurrency types.Number `json:"eq"`
|
||||
@@ -1270,7 +1270,7 @@ type AccountPosition struct {
|
||||
AvailablePosition string `json:"availPos"` // Position that can be closed Only applicable to MARGIN, FUTURES/SWAP in the long-short mode, OPTION in Simple and isolated OPTION in margin Account.
|
||||
AveragePrice types.Number `json:"avgPx"`
|
||||
CreationTime okxUnixMilliTime `json:"cTime"`
|
||||
Currency string `json:"ccy"`
|
||||
Currency currency.Code `json:"ccy"`
|
||||
DeltaBS string `json:"deltaBS"` // delta:Black-Scholes Greeks in dollars,only applicable to OPTION
|
||||
DeltaPA string `json:"deltaPA"` // delta:Greeks in coins,only applicable to OPTION
|
||||
GammaBS string `json:"gammaBS"` // gamma:Black-Scholes Greeks in dollars,only applicable to OPTION
|
||||
|
||||
@@ -63,6 +63,11 @@ func (ok *Okx) SetDefaults() {
|
||||
|
||||
// Fill out the capabilities/features that the exchange supports
|
||||
ok.Features = exchange.Features{
|
||||
CurrencyTranslations: currency.NewTranslations(map[currency.Code]currency.Code{
|
||||
currency.NewCode("USDT-SWAP"): currency.USDT,
|
||||
currency.NewCode("USD-SWAP"): currency.USD,
|
||||
currency.NewCode("USDC-SWAP"): currency.USDC,
|
||||
}),
|
||||
Supports: exchange.FeaturesSupported{
|
||||
REST: true,
|
||||
Websocket: true,
|
||||
@@ -518,7 +523,7 @@ func (ok *Okx) UpdateAccountInfo(ctx context.Context, assetType asset.Item) (acc
|
||||
for i := range accountBalances {
|
||||
for j := range accountBalances[i].Details {
|
||||
currencyBalances = append(currencyBalances, account.Balance{
|
||||
Currency: currency.NewCode(accountBalances[i].Details[j].Currency),
|
||||
Currency: accountBalances[i].Details[j].Currency,
|
||||
Total: accountBalances[i].Details[j].EquityOfCurrency.Float64(),
|
||||
Hold: accountBalances[i].Details[j].FrozenBalance.Float64(),
|
||||
Free: accountBalances[i].Details[j].AvailableBalance.Float64(),
|
||||
@@ -1848,7 +1853,7 @@ func (ok *Okx) GetFuturesPositionSummary(ctx context.Context, req *futures.Posit
|
||||
)
|
||||
|
||||
for i := range acc[0].Details {
|
||||
if acc[0].Details[i].Currency != positionSummary.Currency {
|
||||
if !acc[0].Details[i].Currency.Equal(positionSummary.Currency) {
|
||||
continue
|
||||
}
|
||||
freeCollateral = acc[0].Details[i].AvailableBalance.Decimal()
|
||||
@@ -1877,7 +1882,7 @@ func (ok *Okx) GetFuturesPositionSummary(ctx context.Context, req *futures.Posit
|
||||
Asset: req.Asset,
|
||||
MarginType: marginMode,
|
||||
CollateralMode: collateralMode,
|
||||
Currency: currency.NewCode(positionSummary.Currency),
|
||||
Currency: positionSummary.Currency,
|
||||
AvailableEquity: availableEquity,
|
||||
CashBalance: cashBalance,
|
||||
DiscountEquity: discountEquity,
|
||||
|
||||
Reference in New Issue
Block a user