private TradingDayInfo GetTradingDayInfo(IEnumerable <ScheduleSettings> scheduleSettings, BrokerSettingsContract brokerSettings, DateTime currentDateTime) { var compiledSchedule = CompileSchedule(scheduleSettings, currentDateTime); var currentInterval = compiledSchedule .Where(x => IsBetween(currentDateTime, x.Start, x.End)) .OrderByDescending(x => x.Schedule.Rank) .FirstOrDefault(); var isEnabled = currentInterval.Enabled(); var lastTradingDay = GetPreviousTradingDay(compiledSchedule, currentInterval, currentDateTime); var nextTradingDay = GetNextTradingDay(compiledSchedule, currentInterval, currentDateTime, lastTradingDay); var isBusinessDay = !brokerSettings.Weekends.Contains(currentDateTime.DayOfWeek) && !brokerSettings.Holidays.Select(x => x.Date).Contains(currentDateTime.Date); var result = new TradingDayInfo { IsTradingEnabled = isEnabled, LastTradingDay = lastTradingDay, NextTradingDayStart = nextTradingDay, IsBusinessDay = isBusinessDay }; return(result); }
public void Update(BrokerSettingsContract brokerSettings) { _lockSlim.EnterWriteLock(); try { _brokerSettings = brokerSettings; } finally { _lockSlim.ExitWriteLock(); } }
public static void SetDividendFactorFields(this Asset asset, MarketSettings marketSettings, BrokerSettingsContract brokerSettings, Product product) { var dividendShort = product.DividendsShort ?? marketSettings.DividendsShort ?? brokerSettings.DividendsShortPercent; var dividendLong = product.DividendsLong ?? marketSettings.DividendsLong ?? brokerSettings.DividendsLongPercent; var dividend871M = product.Dividends871M ?? marketSettings.Dividends871M ?? brokerSettings.Dividends871MPercent; asset.DividendsFactor.Percent = dividendLong; asset.DividendsFactor.ShortPercent = dividendShort; asset.DividendsFactor.Us871Percent = dividend871M; asset.Underlying.MarketDetails.DividendsFactor.Percent = dividendLong; asset.Underlying.MarketDetails.DividendsFactor.ShortPercent = dividendShort; asset.Underlying.MarketDetails.DividendsFactor.Us871Percent = dividend871M; asset.Underlying.DividendsFactor.Percent = dividendLong; asset.Underlying.DividendsFactor.ShortPercent = dividendShort; asset.Underlying.DividendsFactor.Us871Percent = dividend871M; }
private static bool IsScheduleDataChanged(BrokerSettingsContract oldSettings, BrokerSettingsContract newSettings, string brokerId) { var brokerConditionGuard = newSettings.BrokerId.Equals(brokerId, StringComparison.InvariantCultureIgnoreCase); if (!brokerConditionGuard) { return(false); } var isSameSchedule = oldSettings.Open == newSettings.Open && oldSettings.Close == newSettings.Close && oldSettings.Timezone == newSettings.Timezone && oldSettings.Holidays.SequenceEqual(newSettings.Holidays) && oldSettings.Weekends.SequenceEqual(newSettings.Weekends) && oldSettings.PlatformSchedule.HalfWorkingDays.SequenceEqual(newSettings.PlatformSchedule.HalfWorkingDays); return(!isSameSchedule); }