private void FillDictionaries(ITradeSharpDictionary dict) { // прочитать локальную копию настроек группа - лот dictionaryGroupLot = LotByGroupDictionary.LoadFromFile(lotDicPath); if (dict != null) { try { long lotByGroupHashCode; tickers = dict.GetTickers(out lotByGroupHashCode).ToDictionary(t => t.Title, t => t); if (tickers.Count > 0) { // контракты прочитаны, проверить словарь группа - лот if (lotByGroupHashCode == 0) { dictionaryGroupLot.Clear(); } else { if (dictionaryGroupLot.calculatedHashCode != lotByGroupHashCode) { var newDictionaryGroupLot = dict.GetLotByGroup(); if (newDictionaryGroupLot != null) { dictionaryGroupLot = newDictionaryGroupLot; dictionaryGroupLot.SaveInFile(lotDicPath); } } } ConnectionWasEstablished = true; return; } else { Logger.ErrorFormat("DalSpot: тикеры не получены"); } } catch (Exception ex) { Logger.Error("Ошибка в DalSpot ctor (доступ к БД)", ex); } } InitializeDefault(); }
public void LotByGroupDictionarySaveLoad() { var path = ExecutablePath.ExecPath + "\\lotdic.txt"; lotDictionary.SaveInFile(path); var dic2 = LotByGroupDictionary.LoadFromFile(path); Assert.Greater(dic2.dictionary.Count, 0, "dic is loaded and not empty"); Assert.AreNotEqual(0, dic2.GetHashCodeForDic(), "loaded dic has not 0 hash"); Assert.AreEqual(lotDictionary.GetHashCodeForDic(), dic2.GetHashCodeForDic(), "same dics has same hashes"); var firstKey = dic2.dictionary.Keys.First(); var firstPair = dic2.dictionary[firstKey].Keys.First(); dic2.dictionary[firstKey][firstPair] = new VolumeStep(5000, 1000); Assert.AreNotEqual(0, dic2.GetHashCodeForDic(), "loaded&modified dic has not 0 hash"); Assert.AreNotEqual(lotDictionary.GetHashCodeForDic(), dic2.GetHashCodeForDic(), "modified dics has different hashes"); }
public void Setup() { lotDictionary = new LotByGroupDictionary { dictionary = new Dictionary <string, Dictionary <string, VolumeStep> > { { "Demo", new Dictionary <string, VolumeStep> { { "EURUSD", new VolumeStep(10000, 10000) }, { "GBPUSD", new VolumeStep(10000, 5000) } } }, { "Nano", new Dictionary <string, VolumeStep> { { "EURUSD", new VolumeStep(100, 100) }, { "GBPUSD", new VolumeStep(100, 100) }, { "USDJPY", new VolumeStep(100, 100) } } } } }; }
public void Setup() { lotDictionary = new LotByGroupDictionary { dictionary = new Dictionary <string, Dictionary <string, Cortege2 <int, int> > > { { "Demo", new Dictionary <string, Cortege2 <int, int> > { { "EURUSD", new Cortege2 <int, int>(10000, 10000) }, { "GBPUSD", new Cortege2 <int, int>(10000, 5000) } } }, { "Nano", new Dictionary <string, Cortege2 <int, int> > { { "EURUSD", new Cortege2 <int, int>(100, 100) }, { "GBPUSD", new Cortege2 <int, int>(100, 100) }, { "USDJPY", new Cortege2 <int, int>(100, 100) } } } } }; }