Skip to content

Commit 0d1c82a

Browse files
authored
Kraken: speedup symbol lookup in trade stream (#473)
* Kraken: speedup symbol lookup in trade stream - Kraken uses special symbols (ADA/CAD rather than ADACAD) - a recent bugfix fa2534e now sets the WS name as an alternate name - this ExchangeMarket is looked up for each symbol name to pull out the alternate name - while it attempts to use caching, it is not actually able to use the cache, bc once it hits the await MakeJsonRequestAsync() in OnGetMarketSymbolsMetadataAsync(), the next select statement progresses so OnGetMarketSymbolsMetadataAsync() is called for every symbol - by priming the cache first, this allows the cache to populate first before the select statement, thus hitting OnGetMarketSymbolsMetadataAsync() once * change to PopulateLookupTables() for priming
1 parent 7b6e897 commit 0d1c82a

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

ExchangeSharp/API/Exchanges/Kraken/ExchangeKrakenAPI.cs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -859,16 +859,17 @@ protected override async Task<IWebSocket> OnGetTradesWebSocketAsync(Func<KeyValu
859859
}
860860
}, connectCallback: async (_socket) =>
861861
{
862-
//{
863-
// "event": "subscribe",
864-
// "pair": [
865-
// "XBT/USD","XBT/EUR"
866-
// ],
867-
// "subscription": {
868-
// "name": "ticker"
869-
// }
870-
//}
871-
Task<string>[] marketSymbolsArray = marketSymbols.Select(async (m) =>
862+
//{
863+
// "event": "subscribe",
864+
// "pair": [
865+
// "XBT/USD","XBT/EUR"
866+
// ],
867+
// "subscription": {
868+
// "name": "ticker"
869+
// }
870+
//}
871+
await PopulateLookupTables(); // prime cache
872+
Task<string>[] marketSymbolsArray = marketSymbols.Select(async (m) =>
872873
{
873874
ExchangeMarket market = await GetExchangeMarketFromCacheAsync(m);
874875
if (market == null)

0 commit comments

Comments
 (0)