Repository: ccxt/ccxt
Pull request: Bitmex :: protect convertValue
- protect code against inexistent markets
- fixes https://github.com/ccxt/ccxt/issues/14823#event-7294155471


Problem statement:
TypeError: can only concatenate str (not "NoneType") to str
S: Ubuntu 18.04 LTS within WSL of Windows 10
Programming Language version: 3.8.10
CCXT version: 1.92.88
Exchange: Bitmex
Method: fetch_positions

>>>print(exchange.fetch_positions())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/iquantdev/venv/lib/python3.8/site-packages/ccxt/bitmex.py", line 1940, in fetch_positions
    return self.parse_positions(response, symbols)
  File "/iquantdev/venv/lib/python3.8/site-packages/ccxt/base/exchange.py", line 2508, in parse_positions
    position = self.extend(self.parse_position(positions[i], None), params)
  File "/iquantdev/venv/lib/python3.8/site-packages/ccxt/bitmex.py", line 2068, in parse_position
    'maintenanceMargin': self.convert_value(maintenanceMargin, market),
  File "/iquantdev/venv/lib/python3.8/site-packages/ccxt/bitmex.py", line 2087, in convert_value
    currency = self.currency(market['quote'])
  File "/iquantdev/venv/lib/python3.8/site-packages/ccxt/base/exchange.py", line 2962, in currency
    raise ExchangeError(self.id + ' does not have currency code ' + code)
TypeError: can only concatenate str (not "NoneType") to str

 Thanks very much for your efforts!

Hints from issue discussion:
Hi @ViktorKov, thanks for reporting it, can you please share with us a verbose log? (you just need to set `exchange.verbose=True`before calling fetch_positions)
Hi Carlos, 

Here you are the verbose:


>>> exchange.verbose=True
>>> print(exchange.fetch_positions())

fetch Request: bitmex GET https://testnet.bitmex.com/api/v1/position RequestHeaders: {'Content-Type': 'application/json', 'api-key': '4fDlD4UxANM_0-z_N69sx_7i', 'api-expires': '1661804766', 'api-signature': 'aa60bdc21d30659344db5c7d53a6b69f97b0f6a870aaefa6c8825a7ecd8b
121a', 'User-Agent': 'python-requests/2.26.0', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} RequestBody: None

fetch Response: bitmex GET https://testnet.bitmex.com/api/v1/position 200 ResponseHeaders: {'Date': 'Mon, 29 Aug 2022 20:25:59 GMT', 'Content-Type': 'application/json; charset=utf-8', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Set-Cookie': 'AWSALBTG=
p23xLuivH8mZiuwDR31wldCoNbaH/NdExvgYI/eMbbkOHjHa9zwoX9LWaPq6NQdVN4CPmiFW82CQObC/hn8EJdjRBVgTVBYOzaMnCxeYR6O/npBh56s5sXpuKejOZJ7EX/45UnoIKJn2MkE+esKkNLANqybJkvetTELrrc5GJbGz; Expires=Mon, 05 Sep 2022 20:25:59 GMT; Path=/, AWSALBTGCORS=p23xLuivH8mZiuwDR31wldCoNbaH/NdExv
gYI/eMbbkOHjHa9zwoX9LWaPq6NQdVN4CPmiFW82CQObC/hn8EJdjRBVgTVBYOzaMnCxeYR6O/npBh56s5sXpuKejOZJ7EX/45UnoIKJn2MkE+esKkNLANqybJkvetTELrrc5GJbGz; Expires=Mon, 05 Sep 2022 20:25:59 GMT; Path=/; SameSite=None; Secure, __cf_bm=YRJBT5C1Qf1rbNUIKt4KMVNHjUjEN_1hOb._8JrkmNk-166180
4759-0-AdSNkscOSioVWfDJMCGI5gCsdh40nYJz8YaHiV750NFwdxx4s375e7bD4a25lvVQc8EbnPrB32Fx3HJEkMXn6is=; path=/; expires=Mon, 29-Aug-22 20:55:59 GMT; domain=.bitmex.com; HttpOnly; Secure; SameSite=None', 'X-User-ID': '397420', 'X-RateLimit-Limit': '120', 'X-RateLimit-Remainin
g': '119', 'X-RateLimit-Reset': '1661804760', 'X-Powered-By': 'Profit', 'ETag': 'W/"29b6-mOlHgNJYaVpmMhjt/d0QWV9XebU"', 'CF-Cache-Status': 'DYNAMIC', 'Expect-CT': 'max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"', 'Server': 'clo
udflare', 'CF-RAY': '742804e39b0e844f-YVR', 'Content-Encoding': 'gzip', 'alt-svc': 'h3=":443"; ma=86400, h3-29=":443"; ma=86400'} ResponseBody: [{"account":397420,"symbol":"XBTUSD","currency":"XBt","underlying":"XBT","quoteCurrency":"USD","commission":0.00075,"initMar
ginReq":0.01,"maintMarginReq":0.0035,"riskLimit":20000000000,"leverage":100,"crossMargin":true,"deleveragePercentile":0.4,"rebalancedPnl":-3927,"prevRealisedPnl":828,"prevUnrealisedPnl":0,"prevClosePrice":20089.38,"openingTimestamp":"2022-08-29T20:00:00.000Z","opening
Qty":200,"openingCost":-993296,"openingComm":905,"openOrderBuyQty":0,"openOrderBuyCost":0,"openOrderBuyPremium":0,"openOrderSellQty":0,"openOrderSellCost":0,"openOrderSellPremium":0,"execBuyQty":0,"execBuyCost":0,"execSellQty":0,"execSellCost":0,"execQty":0,"execCost"
:0,"execComm":400,"currentTimestamp":"2022-08-29T20:25:55.823Z","currentQty":200,"currentCost":-993296,"currentComm":1305,"realisedCost":0,"unrealisedCost":-993296,"grossOpenCost":0,"grossOpenPremium":0,"grossExecCost":0,"isOpen":true,"markPrice":20156.88,"markValue":
-992218,"riskValue":992218,"homeNotional":0.00992218,"foreignNotional":-200,"posState":"","posCost":-993296,"posCost2":-988808,"posCross":4488,"posInit":9933,"posComm":756,"posLoss":4488,"posMargin":10689,"posMaint":4332,"posAllowance":0,"taxableMargin":0,"initMargin"
:0,"maintMargin":11767,"sessionMargin":0,"targetExcessMargin":0,"varMargin":0,"realisedGrossPnl":0,"realisedTax":0,"realisedPnl":-1305,"unrealisedGrossPnl":1078,"longBankrupt":0,"shortBankrupt":0,"taxBase":0,"indicativeTaxRate":null,"indicativeTax":0,"unrealisedTax":0
,"unrealisedPnl":1078,"unrealisedPnlPcnt":0.0011,"unrealisedRoePcnt":0.1085,"simpleQty":null,"simpleCost":null,"simpleValue":null,"simplePnl":null,"simplePnlPcnt":null,"avgCostPrice":20135,"avgEntryPrice":20135,"breakEvenPrice":20242,"marginCallPrice":18061.5,"liquida
tionPrice":18061.5,"bankruptPrice":18003.5,"timestamp":"2022-08-29T20:25:55.823Z","lastPrice":20156.88,"lastValue":-992218},{"account":397420,"symbol":"XBTH23","currency":"XBt","underlying":"XBT","quoteCurrency":"USD","commission":0.00075,"initMarginReq":0.01,"maintMa
rginReq":0.0035,"riskLimit":7500000000,"leverage":100,"crossMargin":true,"deleveragePercentile":1,"rebalancedPnl":-331,"prevRealisedPnl":38406,"prevUnrealisedPnl":0,"prevClosePrice":22206.18,"openingTimestamp":"2022-08-29T20:00:00.000Z","openingQty":-100,"openingCost"
:442360,"openingComm":0,"openOrderBuyQty":0,"openOrderBuyCost":0,"openOrderBuyPremium":0,"openOrderSellQty":0,"openOrderSellCost":0,"openOrderSellPremium":0,"execBuyQty":0,"execBuyCost":0,"execSellQty":0,"execSellCost":0,"execQty":0,"execCost":0,"execComm":0,"currentT
imestamp":"2022-08-29T20:25:55.823Z","currentQty":-100,"currentCost":442360,"currentComm":0,"realisedCost":0,"unrealisedCost":442360,"grossOpenCost":0,"grossOpenPremium":0,"grossExecCost":0,"isOpen":true,"markPrice":22278.52,"markValue":448863,"riskValue":448863,"home
Notional":-0.00448863,"foreignNotional":100,"posState":"","posCost":442360,"posCost2":442360,"posCross":0,"posInit":4424,"posComm":336,"posLoss":0,"posMargin":4760,"posMaint":1885,"posAllowance":0,"taxableMargin":0,"initMargin":0,"maintMargin":11263,"sessionMargin":0,
"targetExcessMargin":0,"varMargin":0,"realisedGrossPnl":0,"realisedTax":0,"realisedPnl":0,"unrealisedGrossPnl":6503,"longBankrupt":0,"shortBankrupt":0,"taxBase":0,"indicativeTaxRate":null,"indicativeTax":0,"unrealisedTax":0,"unrealisedPnl":6503,"unrealisedPnlPcnt":0.0
147,"unrealisedRoePcnt":1.4701,"simpleQty":null,"simpleCost":null,"simpleValue":null,"simplePnl":null,"simplePnlPcnt":null,"avgCostPrice":22606,"avgEntryPrice":22606,"breakEvenPrice":22589,"marginCallPrice":30138,"liquidationPrice":30138,"bankruptPrice":30279.5,"times
tamp":"2022-08-29T20:25:55.823Z","lastPrice":22278.52,"lastValue":448863},{"account":397420,"symbol":"XBTZ22","currency":"XBt","underlying":"XBT","quoteCurrency":"USD","commission":0.00075,"initMarginReq":0.01,"maintMarginReq":0.0035,"riskLimit":7500000000,"leverage":
100,"crossMargin":true,"deleveragePercentile":null,"rebalancedPnl":0,"prevRealisedPnl":92,"prevUnrealisedPnl":0,"prevClosePrice":20891.17,"openingTimestamp":"2022-08-29T20:00:00.000Z","openingQty":0,"openingCost":0,"openingComm":0,"openOrderBuyQty":0,"openOrderBuyCost
":0,"openOrderBuyPremium":0,"openOrderSellQty":0,"openOrderSellCost":0,"openOrderSellPremium":0,"execBuyQty":0,"execBuyCost":0,"execSellQty":0,"execSellCost":0,"execQty":0,"execCost":0,"execComm":0,"currentTimestamp":"2022-08-29T20:00:00.042Z","currentQty":0,"currentC
ost":0,"currentComm":0,"realisedCost":0,"unrealisedCost":0,"grossOpenCost":0,"grossOpenPremium":0,"grossExecCost":0,"isOpen":false,"markPrice":null,"markValue":0,"riskValue":0,"homeNotional":0,"foreignNotional":0,"posState":"","posCost":0,"posCost2":0,"posCross":0,"po
sInit":0,"posComm":0,"posLoss":0,"posMargin":0,"posMaint":0,"posAllowance":0,"taxableMargin":0,"initMargin":0,"maintMargin":0,"sessionMargin":0,"targetExcessMargin":0,"varMargin":0,"realisedGrossPnl":0,"realisedTax":0,"realisedPnl":0,"unrealisedGrossPnl":0,"longBankru
pt":0,"shortBankrupt":0,"taxBase":0,"indicativeTaxRate":null,"indicativeTax":0,"unrealisedTax":0,"unrealisedPnl":0,"unrealisedPnlPcnt":0,"unrealisedRoePcnt":0,"simpleQty":null,"simpleCost":null,"simpleValue":null,"simplePnl":null,"simplePnlPcnt":null,"avgCostPrice":nu
ll,"avgEntryPrice":null,"breakEvenPrice":null,"marginCallPrice":null,"liquidationPrice":null,"bankruptPrice":null,"timestamp":"2022-08-29T20:00:00.042Z","lastPrice":null,"lastValue":0},{"account":397420,"symbol":"XBTU22","currency":"XBt","underlying":"XBT","quoteCurre
ncy":"USD","commission":0.00075,"initMarginReq":0.01,"maintMarginReq":0.0035,"riskLimit":7500000000,"leverage":100,"crossMargin":true,"deleveragePercentile":null,"rebalancedPnl":0,"prevRealisedPnl":41585,"prevUnrealisedPnl":0,"prevClosePrice":20899.87,"openingTimestam
p":"2022-08-29T20:00:00.000Z","openingQty":0,"openingCost":0,"openingComm":0,"openOrderBuyQty":0,"openOrderBuyCost":0,"openOrderBuyPremium":0,"openOrderSellQty":0,"openOrderSellCost":0,"openOrderSellPremium":0,"execBuyQty":0,"execBuyCost":0,"execSellQty":0,"execSellCo
st":0,"execQty":0,"execCost":0,"execComm":0,"currentTimestamp":"2022-08-29T20:00:00.042Z","currentQty":0,"currentCost":0,"currentComm":0,"realisedCost":0,"unrealisedCost":0,"grossOpenCost":0,"grossOpenPremium":0,"grossExecCost":0,"isOpen":false,"markPrice":null,"markV
alue":0,"riskValue":0,"homeNotional":0,"foreignNotional":0,"posState":"","posCost":0,"posCost2":0,"posCross":0,"posInit":0,"posComm":0,"posLoss":0,"posMargin":0,"posMaint":0,"posAllowance":0,"taxableMargin":0,"initMargin":0,"maintMargin":0,"sessionMargin":0,"targetExc
essMargin":0,"varMargin":0,"realisedGrossPnl":0,"realisedTax":0,"realisedPnl":0,"unrealisedGrossPnl":0,"longBankrupt":0,"shortBankrupt":0,"taxBase":0,"indicativeTaxRate":null,"indicativeTax":0,"unrealisedTax":0,"unrealisedPnl":0,"unrealisedPnlPcnt":0,"unrealisedRoePcn
t":0,"simpleQty":null,"simpleCost":null,"simpleValue":null,"simplePnl":null,"simplePnlPcnt":null,"avgCostPrice":null,"avgEntryPrice":null,"breakEvenPrice":null,"marginCallPrice":null,"liquidationPrice":null,"bankruptPrice":null,"timestamp":"2022-08-29T20:00:00.042Z","
lastPrice":null,"lastValue":0},{"account":397420,"symbol":"XBTQ22","currency":"XBt","underlying":"XBT","quoteCurrency":"USD","commission":0.00075,"initMarginReq":0.01,"maintMarginReq":0.0035,"riskLimit":7500000000,"leverage":100,"crossMargin":true,"deleveragePercentil
e":null,"rebalancedPnl":0,"prevRealisedPnl":-147716,"prevUnrealisedPnl":0,"prevClosePrice":21525.81,"openingTimestamp":"2022-08-21T13:00:00.000Z","openingQty":0,"openingCost":0,"openingComm":0,"openOrderBuyQty":0,"openOrderBuyCost":0,"openOrderBuyPremium":0,"openOrder
SellQty":0,"openOrderSellCost":0,"openOrderSellPremium":0,"execBuyQty":0,"execBuyCost":0,"execSellQty":0,"execSellCost":0,"execQty":0,"execCost":0,"execComm":0,"currentTimestamp":"2022-08-21T13:00:00.044Z","currentQty":0,"currentCost":0,"currentComm":0,"realisedCost":
0,"unrealisedCost":0,"grossOpenCost":0,"grossOpenPremium":0,"grossExecCost":0,"isOpen":false,"markPrice":null,"markValue":0,"riskValue":0,"homeNotional":0,"foreignNotional":0,"posState":"","posCost":0,"posCost2":0,"posCross":0,"posInit":0,"posComm":0,"posLoss":0,"posM
argin":0,"posMaint":0,"posAllowance":0,"taxableMargin":0,"initMargin":0,"maintMargin":0,"sessionMargin":0,"targetExcessMargin":0,"varMargin":0,"realisedGrossPnl":0,"realisedTax":0,"realisedPnl":0,"unrealisedGrossPnl":0,"longBankrupt":0,"shortBankrupt":0,"taxBase":0,"i
ndicativeTaxRate":null,"indicativeTax":0,"unrealisedTax":0,"unrealisedPnl":0,"unrealisedPnlPcnt":0,"unrealisedRoePcnt":0,"simpleQty":null,"simpleCost":null,"simpleValue":null,"simplePnl":null,"simplePnlPcnt":null,"avgCostPrice":null,"avgEntryPrice":null,"breakEvenPric
e":null,"marginCallPrice":null,"liquidationPrice":null,"bankruptPrice":null,"timestamp":"2022-08-21T13:00:00.044Z","lastPrice":null,"lastValue":0},{"account":397420,"symbol":"XBTV22","currency":"XBt","underlying":"XBT","quoteCurrency":"USD","commission":0.00075,"initM
arginReq":0.01,"maintMarginReq":0.0035,"riskLimit":7500000000,"leverage":100,"crossMargin":true,"deleveragePercentile":1,"rebalancedPnl":-358,"prevRealisedPnl":0,"prevUnrealisedPnl":0,"prevClosePrice":20089.36,"openingTimestamp":"2022-08-29T20:00:00.000Z","openingQty"
:-100,"openingCost":478457,"openingComm":0,"openOrderBuyQty":0,"openOrderBuyCost":0,"openOrderBuyPremium":0,"openOrderSellQty":0,"openOrderSellCost":0,"openOrderSellPremium":0,"execBuyQty":0,"execBuyCost":0,"execSellQty":0,"execSellCost":0,"execQty":0,"execCost":0,"ex
ecComm":0,"currentTimestamp":"2022-08-29T20:25:55.823Z","currentQty":-100,"currentCost":478457,"currentComm":0,"realisedCost":0,"unrealisedCost":478457,"grossOpenCost":0,"grossOpenPremium":0,"grossExecCost":0,"isOpen":true,"markPrice":20154.97,"markValue":496156,"risk
Value":496156,"homeNotional":-0.00496156,"foreignNotional":100,"posState":"","posCost":478457,"posCost2":478457,"posCross":0,"posInit":4785,"posComm":363,"posLoss":0,"posMargin":5148,"posMaint":2038,"posAllowance":0,"taxableMargin":0,"initMargin":0,"maintMargin":22847
,"sessionMargin":0,"targetExcessMargin":0,"varMargin":0,"realisedGrossPnl":0,"realisedTax":0,"realisedPnl":0,"unrealisedGrossPnl":17699,"longBankrupt":0,"shortBankrupt":0,"taxBase":0,"indicativeTaxRate":null,"indicativeTax":0,"unrealisedTax":0,"unrealisedPnl":17699,"u
nrealisedPnlPcnt":0.037,"unrealisedRoePcnt":3.6992,"simpleQty":null,"simpleCost":null,"simpleValue":null,"simplePnl":null,"simplePnlPcnt":null,"avgCostPrice":20900.5,"avgEntryPrice":20900.5,"breakEvenPrice":20884.5,"marginCallPrice":27198.5,"liquidationPrice":27198.5,
"bankruptPrice":27323,"timestamp":"2022-08-29T20:25:55.823Z","lastPrice":20154.97,"lastValue":496156}]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/iquantdev/venv/lib/python3.8/site-packages/ccxt/bitmex.py", line 1940, in fetch_positions
    return self.parse_positions(response, symbols)
  File "/iquantdev/venv/lib/python3.8/site-packages/ccxt/base/exchange.py", line 2508, in parse_positions
    position = self.extend(self.parse_position(positions[i], None), params)
  File "/iquantdev/venv/lib/python3.8/site-packages/ccxt/bitmex.py", line 2068, in parse_position
    'maintenanceMargin': self.convert_value(maintenanceMargin, market),
  File "/iquantdev/venv/lib/python3.8/site-packages/ccxt/bitmex.py", line 2087, in convert_value
    currency = self.currency(market['quote'])
  File "/iquantdev/venv/lib/python3.8/site-packages/ccxt/base/exchange.py", line 2962, in currency
    raise ExchangeError(self.id + ' does not have currency code ' + code)
TypeError: can only concatenate str (not "NoneType") to str
>>>

@ViktorKov thanks for the log, you have there a position in a market that we can't find anymore, can you find the XBTQ22 contract on the bitmex's website? 
Hi Carlos,

I have no XBTQ22 trade position on testnet.bitmex.com.
I have the next positions right now:

Symbol  Size       Value      Entry Price    Mark Price Liq. Price
Margin             Unrealised PNL (ROE %) Realised PNL   Close
Position
XBTUSD  200 USD     0.0101 XBT 20135.00   19785.67   18065.0
0.0001 XBT (Cross)  -0.0001 XBT (-176.54%)  0.0000 XBT     19785.5
XBTV22  -100 USD    0.0050 XBT 20900.50   19784.67   25947.0
0.0003 XBT (Cross)  0.0002 XBT (564.00%)    0.0000 XBT     19784.5
XBTH23  -100 USD    0.0045 XBT 22606.00   21861.26   28609.0
0.0001 XBT (Cross)  0.0001 XBT (340.67%)    0.0000 XBT     21861.0


According to my order history, the last day was 08.16 when my bot placed a
BUY order for XBTQ22.

Symbol
Size
Order Price
Filled
Stop Price
Fill Price
Type
Status
Time
XBTU22 -100 USD *Market* -100 USD 24435.0 Market Filled 61ebde2 Aug 16,
2022, 1:09:50 PM
XBTZ22 100 USD 25260.5 100 USD 25260.5 Limit Filled 0fa13b2 Aug 16, 2022,
12:59:43 PM
XBTQ22 100 *Market* 100 37500 Market Filled fb61c51 Aug 16, 2022, 11:37:15
AM
XBTH23 100 USD *Market* 100 USD 26808.5 Market Filled e627705 Aug 16, 2022,
11:37:10 AM
XBTUSD -700 USD *Market* -700 USD 24213.0 Market Filled 972c512 Aug 16,
2022, 11:34:23 AM
XBTUSD 100 USD 24196.0 100 USD 24196.0 Limit Filled 619c2fb Aug 15, 2022,
6:05:10 PM
XBTU22 -100 USD 24641.5 -100 USD 24641.5 Limit Filled 5bb33cc Aug 15, 2022,
6:05:08 PM

Notice what is strange in that history :  XBTQ22 size is 100 without USD !?

Anyway, I used CCXT library for 5 months and my bot executed fetchPositions
24*60 times daily with no issue.
Last Friday (08.26) realized that fetchPositions is failing to give back my
active trades.
I upgraded for the latest ccxt package version, but the problem persists.

Thanks for your help.

Viktor


On Tue, Aug 30, 2022 at 6:26 AM Carlos Gonçalves ***@***.***>
wrote:

> @ViktorKov <https://github.com/ViktorKov> thanks for the log, you have
> there a position in a market that we can't find anymore, can you find the
> XBTQ22 contract on the bitmex's website?
>
> —
> Reply to this email directly, view it on GitHub
> <https://github.com/ccxt/ccxt/issues/14823#issuecomment-1231597003>, or
> unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AP2RJFE5QRK5Y4XKK3S2TVLV3X4YTANCNFSM577CBAPA>
> .
> You are receiving this because you were mentioned.Message ID:
> ***@***.***>
>

@ViktorKov we will investigate, thank you!
Great, thanks!

On Wed., Aug. 31, 2022, 2:10 a.m. Igor Kroitor, ***@***.***>
wrote:

> @ViktorKov <https://github.com/ViktorKov> we will investigate, thank you!
>
> —
> Reply to this email directly, view it on GitHub
> <https://github.com/ccxt/ccxt/issues/14823#issuecomment-1232609537>, or
> unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AP2RJFEIAQNYYUNCTGNBK43V34HRFANCNFSM577CBAPA>
> .
> You are receiving this because you were mentioned.Message ID:
> ***@***.***>
>

Commit message: protect code against inexistent markets

Patch to review:
diff --git a/js/bitmex.js b/js/bitmex.js
index 0cd9d9ef168bb..c4897d470f4a0 100644
--- a/js/bitmex.js
+++ b/js/bitmex.js
@@ -2202,12 +2202,17 @@ module.exports = class bitmex extends Exchange {
         } else if (market['quote'] === 'USDT') {
             resultValue = Precise.stringMul (value, '0.000001');
         } else {
-            const currency = this.currency (market['quote']);
+            let currency = undefined;
+            const quote = market['quote'];
+            if (quote !== undefined) {
+                currency = this.currency (market['quote']);
+            }
             if (currency !== undefined) {
                 resultValue = Precise.stringMul (value, this.numberToString (currency['precision']));
+                return parseFloat (resultValue);
             }
         }
-        return parseFloat (resultValue);
+        return undefined;
     }
 
     isFiat (currency) {


Code review comments:
diff_hunk: @@ -2202,12 +2202,17 @@ module.exports = class bitmex extends Exchange {
         } else if (market['quote'] === 'USDT') {
             resultValue = Precise.stringMul (value, '0.000001');
         } else {
-            const currency = this.currency (market['quote']);
+            let currency = undefined;
+            const quote = market['quote'];
+            if (quote !== undefined) {
+                currency = this.currency (market['quote']);
+            }
             if (currency !== undefined) {
                 resultValue = Precise.stringMul (value, this.numberToString (currency['precision']));
+                return parseFloat (resultValue);
             }
         }
-        return parseFloat (resultValue);
+        return undefined;
path: js/bitmex.js
text: @user1:
@author Changing this line introduces another bug – we're now returning undefined in all other if-else cases (not using the resultValue in those cases), which seems wrong to me. Lmk your thoughts.

@author:
@user1 yes my bad, I was trying to avoid `parseFloat(undefined)` that would return `nan` without an extra check but ended up messing it, it should be ok now, thanks!