ccxt / ccxt

A JavaScript / TypeScript / Python / C# / PHP cryptocurrency trading API with support for more than 100 bitcoin/altcoin exchanges
https://docs.ccxt.com
MIT License
32.45k stars 7.46k forks source link

OKEX fetch1Currency function is using old API calls. #16473

Closed zydjohnHotmail closed 1 year ago

zydjohnHotmail commented 1 year ago

Operating System

Windows 10

Programming Languages

JS

CCXT Version

2.6.7

Description

Hello: I want to check one actively traded symbol ‘ATOM’ (COSMOS) on okex exchange, I got the following output:

C:\ArbitApps\CCXT\CCXTNodeByFunctions>node okex_fetch1Currency.js ATOM
2.6.7
{"code":"ATOM","id":"ATOM","name":"Cosmos","active":false,"deposit":true,"withdraw":true,"precision":0.000001,"limits":{"amount":{}},"networks":{"Cosmos":{"id":"ATOM-Cosmos","network":"Cosmos","active":true,"deposit":true,"withdraw":true,"fee":0.004,"precision":0.000001,"limits":{"withdraw":{"min":0.1,"max":307866}},"info":{"canDep":true,"canInternal":true,"canWd":true,"ccy":"ATOM","chain":"ATOM-Cosmos","depQuotaFixed":"","depQuoteDailyLayer2":"","logoLink":"https://static.coinall.ltd/cdn/assets/imgs/221/266359945E7A167A.png","mainNet":true,"maxFee":"0.008","maxWd":"307866","minDep":"0.00000001","minDepArrivalConfirm":"10","minFee":"0.004","minWd":"0.1","minWdUnlockConfirm":"15","name":"Cosmos","needTag":false,"usedDepQuotaFixed":"","usedWdQuota":"0","wdQuota":"500","wdTickSz":"6"}}}}

The wired information is: "active":false, So I asked okex API support on their telegram public channel, their answer is: This is not the data returned by the v5 api. This field is not available in the document. And they gave me the URL for API V5 document: Overview – OKX API guide | OKX technical support | OKX

I changed my code to use verbose output, but I can not see any API endpoint for fetch1Currency, please check the new API document and make some modification to reflex the latest API function calls. Thanks,

Code

const ccxt = require('ccxt');
console.log(ccxt.version);

if (process.argv.length != 3) {
    console.error('Usage: USDT');
    console.error('Fetch 1 currency at exchange');
    console.error('Please try again!');
    process.exit(1);
}
const [nodejs, script1, coin1] = process.argv;

let exchange = new ccxt.okex ({
    'options': {
        'adjustForTimeDifference': true,
        'fetchCurrencies': true,
        'verbose': true,
    }
});

const fetch1Currency = async (coin1) => {
    try {
        await exchange.loadMarkets();
        const currency1 = exchange.currency(coin1);
        if (typeof currency1 !== 'undefined') {
            const json_currency1 = JSON.stringify(currency1);
            console.log(json_currency1);
        }
        else {
            const obj_currency0 = ({ 'Symbol': coin1, 'Data': [] });
            const json_currency0 = JSON.stringify(obj_currency0);
            console.log(json_currency0);
        }
    }
    catch (err) {
        const obj_currency = ({ 'Symbol': coin1, 'Data': [] });
        const json_currency = JSON.stringify(obj_currency);
        console.log(json_currency);
    }
};

fetch1Currency(coin1);
samgermain commented 1 year ago

Use the class okex5 for the v5 api

zydjohnHotmail commented 1 year ago

Hi: The following is the output for using okex5:

D:\nodejs\CCXT_Tickers>node okex_fetch1Ticker.js ATOM
BadSymbol: okex5 does not have market symbol ATOM
    at okex5.market (D:\nodejs\CCXT_Tickers\node_modules\ccxt\js\base\Exchange.js:2567:15)
    at okex5.fetchTicker (D:\nodejs\CCXT_Tickers\node_modules\ccxt\js\okx.js:1445:29)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async fetch1Ticker (D:\nodejs\CCXT_Tickers\okex_fetch1Ticker.js:23:17) {
  constructor: [class BadSymbol extends BadRequest]
}

My related code part:

let exchange = new ccxt.okex5 ({
    'adjustForTimeDifference': true,
    defaultType: 'spot',
    'verbose': false
});

const fetch1Ticker = async (pair1) => {
    try {
        if (exchange.has['fetchTicker']) {
            const ticker1 = await exchange.fetchTicker(pair1);
            if (typeof ticker1 !== 'undefined') {
                const json_ticker1 = JSON.stringify(ticker1);
                console.log(json_ticker1);
            } else {
                const obj_jsonTicker0 = ({ 'Data': [] });
                const json_ticker0 = JSON.stringify(obj_jsonTicker0);
                console.log(json_ticker0);
            }
        }
    } catch (err) {
        console.error(err)
    }
};

fetch1Ticker(pair1);
samgermain commented 1 year ago

@zydjohnHotmail

ATOM alone isn't a pair or a market symbol, it's just a currency. A market symbol includes the base and quote currency, and some other things when trading derivatives

zydjohnHotmail commented 1 year ago

Hi, Sorry, I made a mistake, this issue can be closed now.