@@ -155,36 +155,46 @@ protected async Task<decimal> ClampOrderQuantity(string marketSymbol, decimal ou
155
155
return market == null ? outputQuantity : CryptoUtility . ClampDecimal ( market . MinTradeSize , market . MaxTradeSize , market . QuantityStepSize , outputQuantity ) ;
156
156
}
157
157
158
- /// <summary>
159
- /// Convert an exchange symbol into a global symbol, which will be the same for all exchanges.
160
- /// Global symbols are always uppercase and separate the currency pair with a hyphen (-).
161
- /// Global symbols list the base currency first (i.e. BTC) and conversion currency
162
- /// second (i.e. ETH). Example BTC-ETH, read as x BTC is worth y ETH.
163
- /// BTC is always first, then ETH, etc. Fiat pair is always first in global symbol too.
164
- /// </summary>
165
- /// <param name="marketSymbol">Exchange market symbol</param>
166
- /// <param name="separator">Separator</param>
167
- /// <returns>Global symbol</returns>
168
- protected async Task < string > ExchangeMarketSymbolToGlobalMarketSymbolWithSeparatorAsync ( string marketSymbol , char separator = GlobalMarketSymbolSeparator )
169
- {
170
- if ( string . IsNullOrEmpty ( marketSymbol ) )
171
- {
172
- throw new ArgumentException ( "Symbol must be non null and non empty" ) ;
173
- }
174
- string [ ] pieces = marketSymbol . Split ( separator ) ;
175
- if ( MarketSymbolIsReversed )
176
- {
177
- return ( await ExchangeCurrencyToGlobalCurrencyAsync ( pieces [ 0 ] ) ) . ToUpperInvariant ( ) + GlobalMarketSymbolSeparator + ( await ExchangeCurrencyToGlobalCurrencyAsync ( pieces [ 1 ] ) ) . ToUpperInvariant ( ) ;
178
- }
179
- return ( await ExchangeCurrencyToGlobalCurrencyAsync ( pieces [ 1 ] ) ) . ToUpperInvariant ( ) + GlobalMarketSymbolSeparator + ( await ExchangeCurrencyToGlobalCurrencyAsync ( pieces [ 0 ] ) ) . ToUpperInvariant ( ) ;
180
- }
158
+ /// <summary>
159
+ /// Convert an exchange symbol into a global symbol, which will be the same for all exchanges.
160
+ /// Global symbols are always uppercase and separate the currency pair with a hyphen (-).
161
+ /// Global symbols list the base currency first (i.e. BTC) and quote/conversion currency
162
+ /// second (i.e. USD). Global symbols are of the form BASE-QUOTE. BASE-QUOTE is read as
163
+ /// 1 BASE is worth y QUOTE.
164
+ ///
165
+ /// Examples:
166
+ /// On 1/25/2020,
167
+ /// - BTC-USD: $8,371; 1 BTC (base) is worth $8,371 USD (quote)
168
+ /// - ETH-BTC: 0.01934; 1 ETH is worth 0.01934 BTC
169
+ /// - EUR-USD: 1.2; 1 EUR worth 1.2 USD
170
+ ///
171
+ /// A value greater than 1 means one unit of base currency is more valuable than one unit of
172
+ /// quote currency.
173
+ ///
174
+ /// </summary>
175
+ /// <param name="marketSymbol">Exchange market symbol</param>
176
+ /// <param name="separator">Separator</param>
177
+ /// <returns>Global symbol</returns>
178
+ protected async Task < string > ExchangeMarketSymbolToGlobalMarketSymbolWithSeparatorAsync ( string marketSymbol , char separator = GlobalMarketSymbolSeparator )
179
+ {
180
+ if ( string . IsNullOrEmpty ( marketSymbol ) )
181
+ {
182
+ throw new ArgumentException ( "Symbol must be non null and non empty" ) ;
183
+ }
184
+ string [ ] pieces = marketSymbol . Split ( separator ) ;
185
+ if ( MarketSymbolIsReversed == false ) //if reversed then put quote currency first
186
+ {
187
+ return ( await ExchangeCurrencyToGlobalCurrencyAsync ( pieces [ 0 ] ) ) . ToUpperInvariant ( ) + GlobalMarketSymbolSeparator + ( await ExchangeCurrencyToGlobalCurrencyAsync ( pieces [ 1 ] ) ) . ToUpperInvariant ( ) ;
188
+ }
189
+ return ( await ExchangeCurrencyToGlobalCurrencyAsync ( pieces [ 1 ] ) ) . ToUpperInvariant ( ) + GlobalMarketSymbolSeparator + ( await ExchangeCurrencyToGlobalCurrencyAsync ( pieces [ 0 ] ) ) . ToUpperInvariant ( ) ;
190
+ }
181
191
182
- /// <summary>
183
- /// Split a market symbol into currencies. For weird exchanges like Bitthumb, they can override and hard-code the other pair
184
- /// </summary>
185
- /// <param name="marketSymbol">Market symbol</param>
186
- /// <returns>Base and quote currency</returns>
187
- protected virtual ( string baseCurrency , string quoteCurrency ) OnSplitMarketSymbolToCurrencies ( string marketSymbol )
192
+ /// <summary>
193
+ /// Split a market symbol into currencies. For weird exchanges like Bitthumb, they can override and hard-code the other pair
194
+ /// </summary>
195
+ /// <param name="marketSymbol">Market symbol</param>
196
+ /// <returns>Base and quote currency</returns>
197
+ protected virtual ( string baseCurrency , string quoteCurrency ) OnSplitMarketSymbolToCurrencies ( string marketSymbol )
188
198
{
189
199
var pieces = marketSymbol . Split ( MarketSymbolSeparator [ 0 ] ) ;
190
200
if ( pieces . Length < 2 )
@@ -348,32 +358,32 @@ public static IExchangeAPI[] GetExchangeAPIs()
348
358
}
349
359
}
350
360
351
- /// <summary>
352
- /// Convert an exchange currency to a global currency. For example, on Binance,
353
- /// BCH (Bitcoin Cash) is BCC but in most other exchanges it is BCH, hence
354
- /// the global symbol is BCH.
355
- /// </summary>
356
- /// <param name="currency">Exchange currency</param>
357
- /// <returns>Global currency</returns>
358
- public Task < string > ExchangeCurrencyToGlobalCurrencyAsync ( string currency )
359
- {
360
- currency = ( currency ?? string . Empty ) ;
361
- foreach ( KeyValuePair < string , string > kv in ExchangeGlobalCurrencyReplacements [ GetType ( ) ] )
362
- {
363
- currency = currency . Replace ( kv . Key , kv . Value ) ;
364
- }
365
- return Task . FromResult ( currency . ToUpperInvariant ( ) ) ;
366
- }
361
+ /// <summary>
362
+ /// Convert an exchange currency to a global currency. For example, on Binance,
363
+ /// BCH (Bitcoin Cash) is BCC but in most other exchanges it is BCH, hence
364
+ /// the global symbol is BCH.
365
+ /// </summary>
366
+ /// <param name="currency">Exchange currency</param>
367
+ /// <returns>Global currency</returns>
368
+ public Task < string > ExchangeCurrencyToGlobalCurrencyAsync ( string currency )
369
+ {
370
+ currency = ( currency ?? string . Empty ) ;
371
+ foreach ( KeyValuePair < string , string > kv in ExchangeGlobalCurrencyReplacements [ GetType ( ) ] )
372
+ {
373
+ currency = currency . Replace ( kv . Key , kv . Value ) ;
374
+ }
375
+ return Task . FromResult ( currency . ToUpperInvariant ( ) ) ;
376
+ }
367
377
368
- /// <summary>
369
- /// Convert a global currency to exchange currency. For example, on Binance,
370
- /// BCH (Bitcoin Cash) is BCC but in most other exchanges it is BCH, hence
371
- /// the global symbol BCH would convert to BCC for Binance, but stay BCH
372
- /// for most other exchanges.
373
- /// </summary>
374
- /// <param name="currency">Global currency</param>
375
- /// <returns>Exchange currency</returns>
376
- public string GlobalCurrencyToExchangeCurrency ( string currency )
378
+ /// <summary>
379
+ /// Convert a global currency to exchange currency. For example, on Binance,
380
+ /// BCH (Bitcoin Cash) is BCC but in most other exchanges it is BCH, hence
381
+ /// the global symbol BCH would convert to BCC for Binance, but stay BCH
382
+ /// for most other exchanges.
383
+ /// </summary>
384
+ /// <param name="currency">Global currency</param>
385
+ /// <returns>Exchange currency</returns>
386
+ public string GlobalCurrencyToExchangeCurrency ( string currency )
377
387
{
378
388
currency = ( currency ?? string . Empty ) ;
379
389
foreach ( KeyValuePair < string , string > kv in ExchangeGlobalCurrencyReplacements [ GetType ( ) ] )
@@ -404,16 +414,25 @@ public virtual string NormalizeMarketSymbol(string? marketSymbol)
404
414
return marketSymbol . ToLowerInvariant ( ) ;
405
415
}
406
416
407
- /// <summary>
408
- /// Convert an exchange symbol into a global symbol, which will be the same for all exchanges.
409
- /// Global symbols are always uppercase and separate the currency pair with a hyphen (-).
410
- /// Global symbols list the base currency first (i.e. BTC) and conversion currency
411
- /// second (i.e. ETH). Example BTC-ETH, read as x BTC is worth y ETH.
412
- /// BTC is always first, then ETH, etc. Fiat pair is always first in global symbol too.
413
- /// </summary>
414
- /// <param name="marketSymbol">Exchange symbol</param>
415
- /// <returns>Global symbol</returns>
416
- public virtual async Task < string > ExchangeMarketSymbolToGlobalMarketSymbolAsync ( string marketSymbol )
417
+ /// <summary>
418
+ /// Convert an exchange symbol into a global symbol, which will be the same for all exchanges.
419
+ /// Global symbols are always uppercase and separate the currency pair with a hyphen (-).
420
+ /// Global symbols list the base currency first (i.e. BTC) and quote/conversion currency
421
+ /// second (i.e. USD). Global symbols are of the form BASE-QUOTE. BASE-QUOTE is read as
422
+ /// 1 BASE is worth y QUOTE.
423
+ ///
424
+ /// Examples:
425
+ /// On 1/25/2020,
426
+ /// - BTC-USD: $8,371; 1 BTC (base) is worth $8,371 USD (quote)
427
+ /// - ETH-BTC: 0.01934; 1 ETH is worth 0.01934 BTC
428
+ /// - EUR-USD: 1.2; 1 EUR worth 1.2 USD
429
+ ///
430
+ /// A value greater than 1 means one unit of base currency is more valuable than one unit of
431
+ /// quote currency.
432
+ /// </summary>
433
+ /// <param name="marketSymbol">Exchange symbol</param>
434
+ /// <returns>Global symbol</returns>
435
+ public virtual async Task < string > ExchangeMarketSymbolToGlobalMarketSymbolAsync ( string marketSymbol )
417
436
{
418
437
string modifiedMarketSymbol = marketSymbol ;
419
438
char separator ;
@@ -490,7 +509,7 @@ public virtual Task<string> GlobalMarketSymbolToExchangeMarketSymbolAsync(string
490
509
{
491
510
throw new ArgumentException ( $ "Market symbol { marketSymbol } is missing the global symbol separator '{ GlobalMarketSymbolSeparator } '") ;
492
511
}
493
- if ( MarketSymbolIsReversed )
512
+ if ( MarketSymbolIsReversed == false )
494
513
{
495
514
marketSymbol = GlobalCurrencyToExchangeCurrency ( marketSymbol . Substring ( 0 , pos ) ) + MarketSymbolSeparator + GlobalCurrencyToExchangeCurrency ( marketSymbol . Substring ( pos + 1 ) ) ;
496
515
}
0 commit comments