static void _cel_InstrumentSubscribed(string symbol, CQGInstrument cqgInstrument) { MonthCharYearModel variable = new MonthCharYearModel(); variable.MonthChar = "def"; variable.Year = "def"; foreach (var monthCharYearModel in monthCharYearlList) { if (monthCharYearModel.Symbol == symbol) return; } CQGInstrumentProperties props = cqgInstrument.Properties; var properties = props[eInstrumentProperty.ipMonthChar]; if (props != null && Cel.IsValid(properties.Value)) variable.MonthChar = properties.Value.ToString(); properties = props[eInstrumentProperty.ipYear]; if (props != null && Cel.IsValid(properties.Value)) variable.Year = properties.Value.ToString(); variable.Symbol = symbol; monthCharYearlList.Add(variable); Cel.RemoveInstrument(cqgInstrument); }
static void _cel_InstrumentSubscribed(string symbol, CQGInstrument cqgInstrument) { //Check expired date DateTime d = cqgInstrument.ExpirationDate; Console.WriteLine("Symbol: '" + symbol + "' will be expired:" + d.ToShortDateString()); if ((d - DateTime.Now).TotalHours < (Settings.Default.DaysToExpiration * 24)) { if (!Settings.Default.EmailedSymbols.Contains(symbol)) { OnSendReport("Symbol: '" + symbol + "' will expired soon", "Hello. \n The symbol: '" + symbol + "' will be expired on less then " + Settings.Default.DaysToExpiration + " days. \nExpiration date: " + d.ToShortDateString() + "\n\nGood luck"); Settings.Default.EmailedSymbols += symbol; } } //Month MonthCharYearModel variable = new MonthCharYearModel(); variable.MonthChar = "def"; variable.Year = "def"; foreach (var monthCharYearModel in monthCharYearlList) { if (monthCharYearModel.Symbol == symbol) return; } CQGInstrumentProperties props = cqgInstrument.Properties; var properties = props[eInstrumentProperty.ipMonthChar]; if (props != null && Cel.IsValid(properties.Value)) variable.MonthChar = properties.Value.ToString(); properties = props[eInstrumentProperty.ipYear]; if (props != null && Cel.IsValid(properties.Value)) variable.Year = properties.Value.ToString(); variable.Symbol = symbol; monthCharYearlList.Add(variable); Cel.RemoveInstrument(cqgInstrument); }