Performance enhancements for market tick creation

This commit is contained in:
djbadders 2019-02-26 22:49:07 +00:00
parent 56a29b6745
commit 46bd84549b
3 changed files with 15 additions and 4 deletions

View File

@ -167,6 +167,7 @@ namespace Core.MarketAnalyzer
log.DoLogInfo("Binance - Checking first seen dates for " + markets.Count + " markets. This may take a while...");
int marketsChecked = 0;
foreach (string key in markets.Keys)
{
// Save market info

View File

@ -8,6 +8,8 @@ using Core.Helper;
using Core.Main.DataObjects.PTMagicData;
using Newtonsoft.Json;
using Core.ProfitTrailer;
using System.Threading;
using System.Threading.Tasks;
namespace Core.MarketAnalyzer
{
@ -232,7 +234,10 @@ namespace Core.MarketAnalyzer
// Get Ticks for all markets
log.DoLogDebug("Bittrex - Getting ticks for '" + markets.Count + "' markets");
Dictionary<string, List<MarketTick>> marketTicks = new Dictionary<string, List<MarketTick>>();
foreach (string key in markets.Keys)
Parallel.ForEach( markets.Keys,
new ParallelOptions { MaxDegreeOfParallelism = 5 },
(key) =>
{
marketTicks.Add(key, Bittrex.GetMarketTicks(key, systemConfiguration, log));
@ -240,7 +245,7 @@ namespace Core.MarketAnalyzer
{
log.DoLogInfo("Bittrex - No worries, I am still alive... " + marketTicks.Count + "/" + markets.Count + " markets done...");
}
}
});
log.DoLogInfo("Bittrex - Ticks completed.");

View File

@ -8,6 +8,8 @@ using Core.Helper;
using Core.Main.DataObjects.PTMagicData;
using Newtonsoft.Json;
using Core.ProfitTrailer;
using System.Threading;
using System.Threading.Tasks;
namespace Core.MarketAnalyzer
{
@ -266,7 +268,10 @@ namespace Core.MarketAnalyzer
// Get Ticks for all markets
log.DoLogDebug("Poloniex - Getting ticks for '" + markets.Count + "' markets");
Dictionary<string, List<MarketTick>> marketTicks = new Dictionary<string, List<MarketTick>>();
foreach (string key in markets.Keys)
Parallel.ForEach( markets.Keys,
new ParallelOptions { MaxDegreeOfParallelism = 5 },
(key) =>
{
marketTicks.Add(key, Poloniex.GetMarketTicks(key, systemConfiguration, log));
@ -274,7 +279,7 @@ namespace Core.MarketAnalyzer
{
log.DoLogInfo("Poloniex - No worries, I am still alive... " + marketTicks.Count + "/" + markets.Count + " markets done...");
}
}
});
log.DoLogInfo("Poloniex - Ticks completed.");