File tree Expand file tree Collapse file tree 3 files changed +25
-42
lines changed
src/ExchangeSharp/API/Exchanges Expand file tree Collapse file tree 3 files changed +25
-42
lines changed Original file line number Diff line number Diff line change @@ -74,28 +74,6 @@ protected BinanceGroupCommon()
7474 RateLimit = new RateGate ( 40 , TimeSpan . FromSeconds ( 10 ) ) ;
7575 }
7676
77- protected virtual string [ ] NonThreeLetterQuoteCurrencies => new [ ] { "USDT" , "USDC" , "EURI" } ;
78-
79- public override Task < string > ExchangeMarketSymbolToGlobalMarketSymbolAsync (
80- string marketSymbol
81- )
82- {
83- foreach ( var quoteCurrency in NonThreeLetterQuoteCurrencies )
84- {
85- if ( marketSymbol . EndsWith ( quoteCurrency ) )
86- {
87- return ExchangeMarketSymbolToGlobalMarketSymbolWithSeparatorAsync (
88- marketSymbol . Substring ( 0 , marketSymbol . Length - quoteCurrency . Length ) +
89- GlobalMarketSymbolSeparator +
90- quoteCurrency ) ;
91- }
92- }
93-
94- return ExchangeMarketSymbolToGlobalMarketSymbolWithSeparatorAsync (
95- marketSymbol . Substring ( 0 , marketSymbol . Length - 3 ) + GlobalMarketSymbolSeparator +
96- marketSymbol . Substring ( marketSymbol . Length - 3 ) ) ;
97- }
98-
9977 /// <summary>
10078 /// Get the details of all trades
10179 /// </summary>
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ The above copyright notice and this permission notice shall be included in all c
1212
1313using System ;
1414using System . Collections . Generic ;
15+ using System . IO ;
1516using System . Linq ;
1617using System . Net ;
1718using 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 (
Original file line number Diff line number Diff line change @@ -26,24 +26,7 @@ private ExchangeMEXCAPI()
2626 RateLimit = new RateGate ( 20 , TimeSpan . FromSeconds ( 2 ) ) ;
2727 WebSocketOrderBookType = WebSocketOrderBookType . FullBookFirstThenDeltas ;
2828 }
29-
30- public override Task < string > ExchangeMarketSymbolToGlobalMarketSymbolAsync ( string marketSymbol )
31- {
32- var quoteLength = 3 ;
33- if ( marketSymbol . EndsWith ( "USDT" ) ||
34- marketSymbol . EndsWith ( "USDC" ) ||
35- marketSymbol . EndsWith ( "TUSD" ) )
36- {
37- quoteLength = 4 ;
38- }
39-
40- var baseSymbol = marketSymbol . Substring ( marketSymbol . Length - quoteLength ) ;
41-
42- return ExchangeMarketSymbolToGlobalMarketSymbolWithSeparatorAsync (
43- marketSymbol . Replace ( baseSymbol , "" )
44- + GlobalMarketSymbolSeparator
45- + baseSymbol ) ;
46- }
29+
4730
4831 protected override async Task < IEnumerable < string > > OnGetMarketSymbolsAsync ( )
4932 {
You can’t perform that action at this time.
0 commit comments