Skip to content

Commit 4d2a821

Browse files
committed
BitMEX: Override ExchangeMarketSymbolToGlobalMarketSymbolAsync
Adds an ExchangeMarketSymbolToGlobalMarketSymbolAsync override to convert local ISO 4217-style symbols (e.g., XBT) to global market symbols (e.g., BTC).
1 parent 3b1425f commit 4d2a821

1 file changed

Lines changed: 24 additions & 2 deletions

File tree

src/ExchangeSharp/API/Exchanges/BitMEX/ExchangeBitMEXAPI.cs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ The above copyright notice and this permission notice shall be included in all c
1212

1313
using System;
1414
using System.Collections.Generic;
15+
using System.IO;
1516
using System.Linq;
1617
using System.Net;
1718
using System.Text;
@@ -52,11 +53,32 @@ private ExchangeBitMEXAPI()
5253
RateLimit = new RateGate(300, TimeSpan.FromMinutes(5));
5354
}
5455

55-
public override Task<string> ExchangeMarketSymbolToGlobalMarketSymbolAsync(
56+
public override async Task<string> ExchangeMarketSymbolToGlobalMarketSymbolAsync(
5657
string marketSymbol
5758
)
5859
{
59-
throw new NotImplementedException();
60+
ExchangeMarket marketSymbolMetadata = await GetExchangeMarketFromCacheAsync(
61+
marketSymbol
62+
);
63+
if (marketSymbolMetadata == null)
64+
{
65+
throw new InvalidDataException(
66+
$"No market symbol metadata returned or unable to find symbol metadata for {marketSymbol}"
67+
);
68+
}
69+
70+
if (marketSymbolMetadata.BaseCurrency == "XBT")
71+
{
72+
marketSymbolMetadata.BaseCurrency = "BTC";
73+
}
74+
75+
if (marketSymbolMetadata.QuoteCurrency == "XBT")
76+
{
77+
marketSymbolMetadata.QuoteCurrency = "BTC";
78+
}
79+
80+
return await ExchangeMarketSymbolToGlobalMarketSymbolWithSeparatorAsync(
81+
marketSymbolMetadata.BaseCurrency + GlobalMarketSymbolSeparator + marketSymbolMetadata.QuoteCurrency);
6082
}
6183

6284
public override Task<string> GlobalMarketSymbolToExchangeMarketSymbolAsync(

0 commit comments

Comments
 (0)