ccxt icon indicating copy to clipboard operation
ccxt copied to clipboard

zonda fetchTicker new api path. fixes: #13921

Open samgermain opened this issue 2 years ago • 8 comments

For Zonda creates the methods

  • fetchTickerV1/fetchTickersV1
    • parsed response includes open, high, low, volume
  • fetchTickerV2/fetchTickersV2
    • parsed response includes timestamp, datetime, bid, ask, close, last, previousClose
  • fetchTickerV1AndV2/fetchTickersV1AndV2
    • parsed response includes all fields

The method chosen by fetchTicker/fetchTickers is determined via params['fetchTickerMethod']/params['fetchTickersMethod'] or this.options['fetchTickerMethod']/this.options['fetchTickersMethod']


PHP v8.1.7                                        Python v3.10.4                                                               Node.js: v18.4.0
CCXT v1.88.53                                     CCXT v1.88.53                                                                CCXT v1.88.53
zonda->fetchTicker(ADA/USDT, Array)               zonda.fetchTicker(ADA/USDT,{'fetchTickerMethod': 'fetchTickerV1AndV2'})      (node:12657) ExperimentalWarning: The Fetch API is an experimental feature. This feature could change at any time
Array                                             {'ask': 0.486166,                                                            (Use `node --trace-warnings ...` to show where the warning was created)
(                                                  'askVolume': None,                                                          zonda.fetchTicker (ADA/USDT, [object Object])
    [symbol] => ADA/USDT                           'average': None,                                                            2022-06-24T00:29:04.165Z iteration 0 passed in 2458 ms
    [timestamp] => 1656030469609                   'baseVolume': 1767.501309,                                                  
    [datetime] => 2022-06-24T00:27:49.609Z         'bid': 0.48,                                                                {
    [high] => 0.499999                             'bidVolume': None,                                                            symbol: 'ADA/USDT',
    [low] => 0.467341                              'change': None,                                                               timestamp: 1656030543288,
    [bid] => 0.48                                  'close': 0.48,                                                                datetime: '2022-06-24T00:29:03.288Z',
    [bidVolume] => Array                           'datetime': '2022-06-24T00:28:17.708Z',                                       high: 0.499999,
        (                                          'high': 0.499999,                                                             low: 0.467341,
        )                                          'info': {'h': '0.499999',                                                     bid: 0.48,
                                                            'highestBid': '0.48',                                                bidVolume: undefined,
    [ask] => 0.48624                                        'l': '0.467341',                                                     ask: 0.486141,
    [askVolume] => Array                                    'lowestAsk': '0.486166',                                             askVolume: undefined,
        (                                                   'm': 'ADA-USDT',                                                     vwap: undefined,
        )                                                   'market': {'amountPrecision': '6',                                   open: 0.45974,
                                                                       'code': 'ADA-USDT',                                       close: 0.48,
    [vwap] => Array                                                    'first': {'currency': 'ADA',                              last: 0.48,
        (                                                                        'minOffer': '0.21',                             previousClose: 0.468821,
        )                                                                        'scale': '6'},                                  change: undefined,
                                                                       'pricePrecision': '6',                                    percentage: undefined,
    [open] => 0.45974                                                  'ratePrecision': '6',                                     average: undefined,
    [close] => 0.48                                                    'second': {'currency': 'USDT',                            baseVolume: 1767.501309,
    [last] => 0.48                                                                'minOffer': '0.099',                           quoteVolume: undefined,
    [previousClose] => 0.468821                                                   'scale': '6'}},                                info: {
    [change] => Array                                       'previousRate': '0.468821',                                            market: {
        (                                                   'r24h': '0.45974',                                                       code: 'ADA-USDT',
        )                                                   'rate': '0.48',                                                          first: { currency: 'ADA', minOffer: '0.21', scale: '6' },
                                                            'time': '1656030497708',                                                 second: { currency: 'USDT', minOffer: '0.099', scale: '6' },
    [percentage] => Array                                   'v': '1767.501309'},                                                     amountPrecision: '6',
        (                                          'last': 0.48,                                                                     pricePrecision: '6',
        )                                          'low': 0.467341,                                                                  ratePrecision: '6'
                                                   'open': 0.45974,                                                                },
    [average] => Array                             'percentage': None,                                                             time: '1656030543288',
        (                                          'previousClose': 0.468821,                                                      highestBid: '0.48',
        )                                          'quoteVolume': None,                                                            lowestAsk: '0.486141',
                                                   'symbol': 'ADA/USDT',                                                           rate: '0.48',
    [baseVolume] => 1767.501309                    'timestamp': 1656030497708,                                                     previousRate: '0.468821',
    [quoteVolume] => Array                         'vwap': None}                                                                   m: 'ADA-USDT',
        (                                                                                                                          h: '0.499999',
        )                                                                                                                          l: '0.467341',
                                                                                                                                   v: '1767.501309',
    [info] => Array                                                                                                                r24h: '0.45974'
        (                                                                                                                        }
            [market] => Array                                                                                                  }
                (                                                                                                              2022-06-24T00:29:04.165Z iteration 1 passed in 2458 ms
                    [code] => ADA-USDT
                    [first] => Array
                        (
                            [currency] => ADA
                            [minOffer] => 0.21
                            [scale] => 6
                        )

                    [second] => Array
                        (
                            [currency] => USDT
                            [minOffer] => 0.099
                            [scale] => 6
                        )

                    [amountPrecision] => 6
                    [pricePrecision] => 6
                    [ratePrecision] => 6
                )

            [time] => 1656030469609
            [highestBid] => 0.48
            [lowestAsk] => 0.48624
            [rate] => 0.48
            [previousRate] => 0.468821
            [m] => ADA-USDT
            [h] => 0.499999
            [l] => 0.467341
            [v] => 1767.501309
            [r24h] => 0.45974
        )

)

2022-06-24T00:51:44.498Z
Node.js: v18.4.0                                                                             Python v3.10.4                                                               PHP v8.1.7
CCXT v1.88.53                                                                                CCXT v1.88.53                                                                CCXT v1.88.53
zonda.fetchTickers (, [object Object])                                                       zonda.fetchTickers(None,{'fetchTickersMethod': 'fetchTickersV1AndV2'})       zonda->fetchTickers(, Array)
2022-06-24T00:51:47.388Z iteration 0 passed in 2477 ms                                       {'AAVE/BTC': {'ask': 0.00339995,                                             Array
                                                                                                           'askVolume': None,                                             (
{                                                                                                          'average': None,                                                   [DAI/PLN] => Array
  'DAI/PLN': {                                                                                             'baseVolume': 0.32137497,                                              (
    symbol: 'DAI/PLN',                                                                                     'bid': 0.0031731,                                                          [symbol] => DAI/PLN
    timestamp: 1656016638523,                                                                              'bidVolume': None,                                                         [timestamp] => 1656016638523
    datetime: '2022-06-23T20:37:18.523Z',                                                                  'change': None,                                                            [datetime] => 2022-06-23T20:37:18.523Z
    high: 4.49,                                                                                            'close': 0.00311163,                                                       [high] => 4.49
    low: 4.46,                                                                                             'datetime': '2022-06-24T00:57:06.473Z',                                    [low] => 4.46
    bid: 4.48,                                                                                             'high': 0.00311163,                                                        [bid] => 4.48
    bidVolume: undefined,                                                                                  'info': {'h': '0.00311163',                                                [bidVolume] => Array
    ask: 4.49,                                                                                                      'highestBid': '0.0031731',                                            (
    askVolume: undefined,                                                                                           'l': '0.00311163',                                                    )
    vwap: undefined,                                                                                                'lowestAsk': '0.00339995',                            
    open: 4.46,                                                                                                     'm': 'AAVE-BTC',                                                  [ask] => 4.49
    close: 4.46,                                                                                                    'market': {'amountPrecision': '8',                                [askVolume] => Array
    last: 4.46,                                                                                                                'code': 'AAVE-BTC',                                        (
    previousClose: 4.49,                                                                                                       'first': {'currency': 'AAVE',                              )
    change: undefined,                                                                                                                   'minOffer': '0.0016',            
    percentage: undefined,                                                                                                               'scale': '8'},                               [vwap] => Array
    average: undefined,                                                                                                        'pricePrecision': '8',                                     (
    baseVolume: 1087.68146956,                                                                                                 'ratePrecision': '8',                                      )
    quoteVolume: undefined,                                                                                                    'second': {'currency': 'BTC',              
    info: {                                                                                                                               'minOffer': '0.00000468',                   [open] => 4.46
      market: {                                                                                                                           'scale': '8'}},                             [close] => 4.46
        code: 'DAI-PLN',                                                                                            'previousRate': '0.00322459',                                     [last] => 4.46
        first: { currency: 'DAI', minOffer: '0.99', scale: '8' },                                                   'r24h': '0.00322459',                                             [previousClose] => 4.49
        second: { currency: 'PLN', minOffer: '5', scale: '2' },                                                     'rate': '0.00311163',                                             [change] => Array
        amountPrecision: '8',                                                                                       'time': '1656032226473',                                              (
        pricePrecision: '2',                                                                                        'v': '0.32137497'},                                                   )
        ratePrecision: '2'                                                                                 'last': 0.00311163,                                            
      },                                                                                                   'low': 0.00311163,                                                         [percentage] => Array
      time: '1656016638523',                                                                               'open': 0.00322459,                                                            (
      highestBid: '4.48',                                                                                  'percentage': None,                                                            )
      lowestAsk: '4.49',                                                                                   'previousClose': 0.00322459,                                   
      rate: '4.46',                                                                                        'quoteVolume': None,                                                       [average] => Array
      previousRate: '4.49',                                                                                'symbol': 'AAVE/BTC',                                                          (
      m: 'DAI-PLN',                                                                                        'timestamp': 1656032226473,                                                    )
      h: '4.49',                                                                                           'vwap': None},                                                 
  l: '4.46',                                                                                                                                                                                       [baseVolume] => 1087.68146956
  v: '1087.68146956',                                                                                                                                                                                      [quoteVolume] => Array
  r24h: '4.46'                                                                                                                                                                                           (
}                                                                                                                                                                                          )
},                                                                                                                                                                           
                                                                                                                                                                                      [info] => Array
                                                                                                                                                                                        (
                                                                                                                                                                                            [market] => Array
                                                                                                                                                                                                (
                                                                                                                                                                                                    [code] => DAI-PLN
                                                                                                                                                                                                    [first] => Array
                                                                                                                                                                                                        (
                                                                                                                                                                                                            [currency] => DAI
                                                                                                                                                                                                            [minOffer] => 0.99
                                                                                                                                                                                                            [scale] => 8
                                                                                                                                                                                                        )
                                                                                                                                                                                                        
                                                                                                                                                                                                    [second] => Array
                                                                                                                                                                                                        (
                                                                                                                                                                                                            [currency] => PLN
                                                                                                                                                                                                            [minOffer] => 5
                                                                                                                                                                                                            [scale] => 2
                                                                                                                                                                                                        )
                                                                                                                                                                                                        
                                                                                                                                                                                                    [amountPrecision] => 8
                                                                                                                                                                                                    [pricePrecision] => 2
                                                                                                                                                                                                    [ratePrecision] => 2
                                                                                                                                                                                                )
                                                                                                                                                                                                        
                                                                                                                                                                                            [time] => 1656016638523
                                                                                                                                                                                            [highestBid] => 4.48
                                                                                                                                                                                            [lowestAsk] => 4.49
                                                                                                                                                                                            [rate] => 4.46
                                                                                                                                                                                            [previousRate] => 4.49
                                                                                                                                                                                            [m] => DAI-PLN
                                                                                                                                                                                            [h] => 4.49
                                                                                                                                                                                            [l] => 4.46
                                                                                                                                                                                            [v] => 1087.68146956
                                                                                                                                                                                            [r24h] => 4.46
                                                                                                                                                                                        )
                                                                                                                                                                                                        
                                                                                                                                                                                  )

samgermain avatar Jun 22 '22 00:06 samgermain

@samgermain can we keep both implementations and make this behavior optional to let the user choose the method of interest ?

For example:

  • https://github.com/ccxt/ccxt/blob/master/js/gemini.js#L463
  • https://github.com/ccxt/ccxt/blob/master/js/gemini.js#L485
  • https://github.com/ccxt/ccxt/blob/master/js/gemini.js#L522

kroitor avatar Jun 22 '22 08:06 kroitor

@samgermain can we keep both implementations and make this behavior optional to let the user choose the method of interest ?

For example:

* https://github.com/ccxt/ccxt/blob/master/js/gemini.js#L463

* https://github.com/ccxt/ccxt/blob/master/js/gemini.js#L485

* https://github.com/ccxt/ccxt/blob/master/js/gemini.js#L522

Sue, I don't like calling them V1 and V2 though, because this naming is used for the exchange api versions

samgermain avatar Jun 23 '22 04:06 samgermain

@kroitor This PR is done now

samgermain avatar Jun 24 '22 01:06 samgermain

@kroitor The build kept failing with

FAILED btcalpha (JavaScript): (explain @ run-tests.js:190)

	TESTING { exchange: 'btcalpha', symbol: 'all' } 

	

	58 symbols BTC/EUR, BTC/USDT, DOGE/BTC, ETH/BTC, LTC/BTC + more...

	SYMBOL: BTC/USDT

	Testing btcalpha loadMarkets ( )

	Testing btcalpha fetchCurrencies ( )

	Testing btcalpha fetchTicker ( BTC/USDT )

	[NotSupported] btcalpha fetchTicker() is not supported yet

	NotSupported: btcalpha fetchTicker() is not supported yet

	    at btcalpha.fetchTicker (/home/travis/build/ccxt/ccxt/js/base/Exchange.js:2119:19)

	    at Object.module.exports [as fetchTicker] (/home/travis/build/ccxt/ccxt/js/test/Exchange/test.fetchTicker.js:25:47)

	    at test (/home/travis/build/ccxt/ccxt/js/test/test.js:103:41)

	    at testSymbol (/home/travis/build/ccxt/ccxt/js/test/test.js:111:11)

	    at processTicksAndRejections (node:internal/process/task_queues:96:5)

	    at async testExchange (/home/travis/build/ccxt/ccxt/js/test/test.js:283:9)

	    at async tryAllProxies (/home/travis/build/ccxt/ccxt/js/test/test.js:390:13)

	    at async main (/home/travis/build/ccxt/ccxt/js/test/test.js:426:9) {

	  constructor: [class NotSupported extends ExchangeError]

	} NotSupported: btcalpha fetchTicker() is not supported yet

	    at btcalpha.fetchTicker (/home/travis/build/ccxt/ccxt/js/base/Exchange.js:2119:19)

	    at Object.module.exports [as fetchTicker] (/home/travis/build/ccxt/ccxt/js/test/Exchange/test.fetchTicker.js:25:47)

	    at test (/home/travis/build/ccxt/ccxt/js/test/test.js:103:41)

	    at testSymbol (/home/travis/build/ccxt/ccxt/js/test/test.js:111:11)

	    at processTicksAndRejections (node:internal/process/task_queues:96:5)

	    at async testExchange (/home/travis/build/ccxt/ccxt/js/test/test.js:283:9)

	    at async tryAllProxies (/home/travis/build/ccxt/ccxt/js/test/test.js:390:13)

	    at async main (/home/travis/build/ccxt/ccxt/js/test/test.js:426:9) (explain @ run-tests.js:193)


FAILED eqonex (JavaScript): (explain @ run-tests.js:190)

	TESTING { exchange: 'eqonex', symbol: 'all' } 

	

	21 symbols ETH/BTC + more...

	SYMBOL: ETH/BTC

	Testing eqonex loadMarkets ( )

	Testing eqonex fetchCurrencies ( )

	Testing eqonex fetchTicker ( ETH/BTC )

	[NotSupported] eqonex fetchTicker() is not supported yet

	NotSupported: eqonex fetchTicker() is not supported yet

	    at eqonex.fetchTicker (/home/travis/build/ccxt/ccxt/js/base/Exchange.js:2119:19)

	    at Object.module.exports [as fetchTicker] (/home/travis/build/ccxt/ccxt/js/test/Exchange/test.fetchTicker.js:25:47)

	    at test (/home/travis/build/ccxt/ccxt/js/test/test.js:103:41)

	    at testSymbol (/home/travis/build/ccxt/ccxt/js/test/test.js:111:11)

	    at processTicksAndRejections (node:internal/process/task_queues:96:5)

	    at async testExchange (/home/travis/build/ccxt/ccxt/js/test/test.js:283:9)

	    at async tryAllProxies (/home/travis/build/ccxt/ccxt/js/test/test.js:390:13)

	    at async main (/home/travis/build/ccxt/ccxt/js/test/test.js:426:9) {

	  constructor: [class NotSupported extends ExchangeError]

	} NotSupported: eqonex fetchTicker() is not supported yet

	    at eqonex.fetchTicker (/home/travis/build/ccxt/ccxt/js/base/Exchange.js:2119:19)

	    at Object.module.exports [as fetchTicker] (/home/travis/build/ccxt/ccxt/js/test/Exchange/test.fetchTicker.js:25:47)

	    at test (/home/travis/build/ccxt/ccxt/js/test/test.js:103:41)

	    at testSymbol (/home/travis/build/ccxt/ccxt/js/test/test.js:111:11)

	    at processTicksAndRejections (node:internal/process/task_queues:96:5)

	    at async testExchange (/home/travis/build/ccxt/ccxt/js/test/test.js:283:9)

	    at async tryAllProxies (/home/travis/build/ccxt/ccxt/js/test/test.js:390:13)

	    at async main (/home/travis/build/ccxt/ccxt/js/test/test.js:426:9) (explain @ run-tests.js:193)

WARN eqonex (Python 3 Async): (explain @ run-tests.js:191)

	[NotSupported] eqonex fetchTicker() is not supported yet

	eqonex using proxy ``

	EXCHANGE: eqonex

	SYMBOL: ETH/BTC

	CODE: USDC

	Testing fetch_ticker:ETH/BTC

	{'type': 'NotSupported', 'num_retries': 0, 'max_retries': 2} eqonex fetchTicker() is not supported yet

	eqonex using proxy `https://cors-anywhere.herokuapp.com/`

	EXCHANGE: eqonex

	SYMBOL: ETH/BTC

	CODE: USDC

	Testing fetch_ticker:ETH/BTC

	{'type': 'NotSupported', 'num_retries': 1, 'max_retries': 2} eqonex fetchTicker() is not supported yet

	[NotSupported] eqonex fetchTicker() is not supported yet (explain @ run-tests.js:193)

and I wasn't sure what to do for a solution except add btcalpha and eqonex as ignored exchanges to the fetchTicker test. I think that should be fine if they're not supported anyway.

samgermain avatar Jul 14 '22 20:07 samgermain

@kroitor @carlosmiei

samgermain avatar Jan 11 '23 06:01 samgermain

@kroitor @frosty00

samgermain avatar Jan 11 '23 06:01 samgermain

@samgermain can you please check out what's wrong with the build? I don't know why exchanges like coinbase, bitbns, etc fail here only. Do u think it can be related to ur changes inside Exchange.py/js/php?

carlosmiei avatar Jan 11 '23 15:01 carlosmiei

@carlosmiei I still need to fix btcalpha, only fixed bitbns so far

samgermain avatar Jan 24 '23 17:01 samgermain

@carlosmiei wait before merging this.

We might need to revert this commit https://github.com/ccxt/ccxt/pull/10088/commits/4c745165765fbba4be9682305ade8d97856ce093

I was pretty new at the time, but I think this commit was a mistake, I think that most of the methods that were marked false were done for a reason, but this commit changed them all to undefined (before this we just had true and false, and did not have undefined within has), I think that this would be the only spot that the changes to the extend method (from the current PR) would cause some problems, because the base exchange class has a number of methods set to true by default, but on a bunch of exchanges, these methods should be false because they can't be implemented on the exchange (right now they're undefined, which prevents users from thinking that the method is implemented, but isn't really the correct value)

samgermain avatar Jan 24 '23 17:01 samgermain

I removed fetchTickersV1andV2 for reasons discussed here https://discord.com/channels/690203284119617602/1069652282943229952/1069732744457879682

samgermain avatar Jan 31 '23 20:01 samgermain

@carlosmiei I rebased this PR again just so you know

samgermain avatar Jan 31 '23 20:01 samgermain