mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-22 07:26:50 +00:00
okx: GetDefaultConfig fix & ticker field improvements (#1227)
* okx: updaterooo (cherry pick) * okx: add in target currency handling in spot market orders * okx:don't adjust order.Submit variables. * spell checker * okx_wrapper: updateTradablePairs true bool * thrasher: nits * purge default env vars * point to CI env var * print out environment * lol --------- Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
This commit is contained in:
@@ -73,8 +73,8 @@ type TickerResponse struct {
|
||||
LastTradeSize okxNumericalValue `json:"lastSz"`
|
||||
BestAskPrice okxNumericalValue `json:"askPx"`
|
||||
BestAskSize okxNumericalValue `json:"askSz"`
|
||||
BidPrice okxNumericalValue `json:"bidPx"`
|
||||
BidSize okxNumericalValue `json:"bidSz"`
|
||||
BestBidPrice okxNumericalValue `json:"bidPx"`
|
||||
BestBidSize okxNumericalValue `json:"bidSz"`
|
||||
Open24H okxNumericalValue `json:"open24h"`
|
||||
High24H okxNumericalValue `json:"high24h"`
|
||||
Low24H okxNumericalValue `json:"low24h"`
|
||||
|
||||
@@ -1218,9 +1218,9 @@ func (ok *Okx) wsProcessTickers(data []byte) error {
|
||||
QuoteVolume: quoteVolume,
|
||||
High: response.Data[i].High24H.Float64(),
|
||||
Low: response.Data[i].Low24H.Float64(),
|
||||
Bid: response.Data[i].BidPrice.Float64(),
|
||||
Bid: response.Data[i].BestBidPrice.Float64(),
|
||||
Ask: response.Data[i].BestAskPrice.Float64(),
|
||||
BidSize: response.Data[i].BidSize.Float64(),
|
||||
BidSize: response.Data[i].BestBidSize.Float64(),
|
||||
AskSize: response.Data[i].BestAskSize.Float64(),
|
||||
Last: response.Data[i].LastTradePrice.Float64(),
|
||||
AssetType: a,
|
||||
|
||||
@@ -43,13 +43,13 @@ func (ok *Okx) GetDefaultConfig(ctx context.Context) (*config.Exchange, error) {
|
||||
exchCfg.HTTPTimeout = exchange.DefaultHTTPTimeout
|
||||
exchCfg.BaseCurrencies = ok.BaseCurrencies
|
||||
|
||||
err := ok.Setup(exchCfg)
|
||||
err := ok.SetupDefaults(exchCfg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if ok.Features.Supports.RESTCapabilities.AutoPairUpdates {
|
||||
err := ok.UpdateTradablePairs(ctx, false)
|
||||
err = ok.UpdateTradablePairs(ctx, true)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -381,8 +381,10 @@ func (ok *Okx) UpdateTicker(ctx context.Context, p currency.Pair, a asset.Item)
|
||||
Last: mdata.LastTradePrice.Float64(),
|
||||
High: mdata.High24H.Float64(),
|
||||
Low: mdata.Low24H.Float64(),
|
||||
Bid: mdata.BidPrice.Float64(),
|
||||
Bid: mdata.BestBidPrice.Float64(),
|
||||
BidSize: mdata.BestBidSize.Float64(),
|
||||
Ask: mdata.BestAskPrice.Float64(),
|
||||
AskSize: mdata.BestAskSize.Float64(),
|
||||
Volume: baseVolume,
|
||||
QuoteVolume: quoteVolume,
|
||||
Open: mdata.Open24H.Float64(),
|
||||
@@ -424,8 +426,10 @@ func (ok *Okx) UpdateTickers(ctx context.Context, assetType asset.Item) error {
|
||||
Last: ticks[y].LastTradePrice.Float64(),
|
||||
High: ticks[y].High24H.Float64(),
|
||||
Low: ticks[y].Low24H.Float64(),
|
||||
Bid: ticks[y].BidPrice.Float64(),
|
||||
Bid: ticks[y].BestBidPrice.Float64(),
|
||||
BidSize: ticks[y].BestBidSize.Float64(),
|
||||
Ask: ticks[y].BestAskPrice.Float64(),
|
||||
AskSize: ticks[y].BestAskSize.Float64(),
|
||||
Volume: ticks[y].Vol24H.Float64(),
|
||||
QuoteVolume: ticks[y].VolCcy24H.Float64(),
|
||||
Open: ticks[y].Open24H.Float64(),
|
||||
@@ -762,14 +766,26 @@ func (ok *Okx) SubmitOrder(ctx context.Context, s *order.Submit) (*order.SubmitR
|
||||
} else {
|
||||
sideType = order.Sell.Lower()
|
||||
}
|
||||
|
||||
amount := s.Amount
|
||||
var targetCurrency string
|
||||
if s.AssetType == asset.Spot && s.Type == order.Market {
|
||||
targetCurrency = "base_ccy" // Default to base currency
|
||||
if s.QuoteAmount > 0 {
|
||||
amount = s.QuoteAmount
|
||||
targetCurrency = "quote_ccy"
|
||||
}
|
||||
}
|
||||
|
||||
var orderRequest = &PlaceOrderRequestParam{
|
||||
InstrumentID: instrumentID,
|
||||
TradeMode: tradeMode,
|
||||
Side: sideType,
|
||||
OrderType: s.Type.Lower(),
|
||||
Amount: s.Amount,
|
||||
Amount: amount,
|
||||
ClientSupplierOrderID: s.ClientOrderID,
|
||||
Price: s.Price,
|
||||
QuantityType: targetCurrency,
|
||||
}
|
||||
switch s.Type.Lower() {
|
||||
case OkxOrderLimit, OkxOrderPostOnly, OkxOrderFOK, OkxOrderIOC:
|
||||
|
||||
Reference in New Issue
Block a user