Skip to content
This repository has been archived by the owner on Feb 15, 2022. It is now read-only.

TypeError: format.replace is not a function #240

Closed
nedievas opened this issue Jun 7, 2017 · 7 comments
Closed

TypeError: format.replace is not a function #240

nedievas opened this issue Jun 7, 2017 · 7 comments
Labels

Comments

@nedievas
Copy link
Contributor

nedievas commented Jun 7, 2017

I'm getting this after latest pull

2017-06-07 20:10:05  2710.70 BTC-USD   +0.0%        1   ---       -0.1845   0.1000           0.00038 BTC  107.24 USD    +8.3%   -6.2%/home/rebootfin/zenbot/node_modules/numbro/numbro.js:183
            escapedFormat = format.replace(/\{[^\{\}]*\}/g, '');
                                   ^

TypeError: format.replace is not a function
    at formatNumbro (/home/rebootfin/zenbot/node_modules/numbro/numbro.js:183:36)
    at Object.format (/home/rebootfin/zenbot/node_modules/numbro/numbro.js:1144:20)
    at /home/rebootfin/zenbot/lib/engine.js:432:82
    at /home/rebootfin/zenbot/lib/engine.js:341:11
    at /home/rebootfin/zenbot/extensions/exchanges/bitfinex/exchange.js:82:9
    at Request._callback (/home/rebootfin/zenbot/extensions/exchanges/bitfinex/node_modules/bitfinex-api-node/rest.js:95:16)
    at Request.self.callback (/home/rebootfin/zenbot/extensions/exchanges/bitfinex/node_modules/request/request.js:188:22)
    at emitTwo (events.js:106:13)
    at Request.emit (events.js:191:7)
    at Request.<anonymous> (/home/rebootfin/zenbot/extensions/exchanges/bitfinex/node_modules/request/request.js:1171:10)
rebootfin@zenbot:~/zenbot$

code part:

    getQuote: function (opts, cb) {
      var client = publicClient()
      var pair = joinProduct(opts.product_id)
      client.ticker(pair, function (err, body) {
        if (err) return cb(err)
        cb(null, {bid: body.bid, ask: body.ask}) //line 82
      })
    },

@DeviaVir DeviaVir added the bug label Jun 7, 2017
@nedievas
Copy link
Contributor Author

nedievas commented Jun 8, 2017

What's the solution?

@tuxitor
Copy link
Contributor

tuxitor commented Jun 8, 2017

I have the same problem with the bitstamp implementation

@tuxitor
Copy link
Contributor

tuxitor commented Jun 8, 2017

With some debugging I found the problem.
In lib/engine.js:
line 398
price = n(mid_price).subtract(n(mid_price).multiply(so.markup_pct / 100)).format(s.product.increment, Math.floor)
line 432
price = n(mid_price).add(n(mid_price).multiply(so.markup_pct / 100)).format(s.product.increment, Math.ceil)

In both lines the "format(s.product.increment, Math.ceil)" expects a number as a string
In both extensions/exchanges/bitfinex/products.json
and extensions/exchanges/bitfinex/products.json
are used numeric values for increment and other parameters,
but in extensions/exchanges/gdax/products.json
are used string values.

The question is, should it be fixed in products.json or should engine.js accept both forms?

@nedievas
Copy link
Contributor Author

nedievas commented Jun 8, 2017

I think it's easier to apply String() to products.json as I see all other exchanges have string values in there.

@nedievas
Copy link
Contributor Author

nedievas commented Jun 8, 2017

I'm proud to announce it solved! Thanks to @EigilB

@raresabr
Copy link

It is not solved 😢 . It happens again. I tried this {{ new Date() | moment( 'ddd [at] h:mm' )}}
Any solution?

@zbralex
Copy link

zbralex commented Jun 19, 2020

Import MatMomentDateModule.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants