public DateTime addBusinessDaysToDate(DateTime date, int daysToAdd, MarketName marketName, AssetClass assetClass) { date = date.AddDays(1 * Math.Sign(daysToAdd)); //so as to not count the current day int bdCount = 0; DateTime priorDate = DateTime.MinValue; List <DateTime> holidays = marketHolidaysInYear(marketName, assetClass, date.Year); while (bdCount < Math.Abs(daysToAdd)) { if ((holidays.Contains(date) == false) && (isWeekend(date) == false)) { bdCount++; } priorDate = date; date = date.AddDays(1 * Math.Sign(daysToAdd)); if (date.Year != priorDate.Year) { holidays = marketHolidaysInYear(marketName, assetClass, date.Year); } } return(priorDate); }
public bool isHoliday(DateTime date, MarketName marketName, AssetClass assetClass) { bool isHoliday = false; List <DateTime> holidayList = marketHolidaysInYear(marketName, assetClass, date.Year); isHoliday = holidayList.Contains(date.Date); return(isHoliday); }
public bool isValidBusinessDay(DateTime date, MarketName marketName, AssetClass assetClass) { bool isValidDay = true; bool isHol = isHoliday(date, marketName, assetClass); if ((date.DayOfWeek == DayOfWeek.Saturday) || (date.DayOfWeek == DayOfWeek.Sunday) || (isHol == true)) { isValidDay = false; } return(isValidDay); }
public ExchangeTicker GetExchangeTicker() { string[] pairs = MarketName.Split('-'); ExchangeTicker ticker = new ExchangeTicker() { exchange = Name, market = pairs[1], symbol = pairs[0], last = Last, ask = Ask, bid = Bid, volume = BaseVolume, high = High, low = Low }; return(ticker); }
public List <DateTime> marketHolidaysInYear(MarketName marketName, AssetClass assetClass, int year) { switch (marketName) { case MarketName.US: switch (assetClass) { case AssetClass.EQUITY: return(yearlyEquityMarketHolidays_US(year)); case AssetClass.BOND: return(yearlyBondMarketHolidays_US(year)); default: return(yearlyEquityMarketHolidays_US(year)); } default: return(yearlyEquityMarketHolidays_US(year)); } }
public override string ToString() { return(EventId.ToString() + "," + MarketId.ToString() + "," + (MeetingDate > DateTime.MinValue ? MeetingDate.ToString("yyyy-MM-dd") : @"\N") + "," + DayOfWeek.ToString() + "," + CountryCode.ToString() + "," + Track.ToString() + "," + (RaceTime > DateTime.MinValue ? RaceTime.ToString("yyyy-MM-dd HH:mm:ss") : @"\N") + "," + (OffTime > DateTime.MinValue ? OffTime.ToString("yyyy-MM-dd HH:mm:ss") : @"\N") + "," + MarketName.ToString() + "," + Entries.ToString() + "," + Runners.ToString() + "," + SelectionId.ToString() + "," + SelectionName.ToString() + "," + (Bsp > 1 ? Bsp.ToString() : @"\N") + "," + (NonRunner ? "1" : "0") + "," + (RemovalTime > DateTime.MinValue ? RemovalTime.ToString("yyyy-MM-dd HH:mm:ss") : @"\N") + "," + (NonRunner ? ReductionFactor.ToString() : @"\N") ); }
public void _validateTimeParameters() { if (Instrument.MasterInstrument.InstrumentType == InstrumentType.Future) { string codePrefix = Instrument.MasterInstrument.Name; //get first two letters of code (i.e. CLM5 returns CL) char monthCode = this.futureTickerMonthCode(Instrument.Expiry.Month); int mnth = this.futuresCodeToMonthNumber(monthCode); int yr = Instrument.Expiry.Year; AssetClass assetCls = this.getInstrumentAssetClass(codePrefix); MarketName mktName = this.getInstrumentMarketName(codePrefix); DateTime anchorDate = new DateTime(yr, mnth, 1); DateTime lastTrdDate = this.futuresLastTradingDate(anchorDate, codePrefix, mktName, assetCls); DateTime dateToRoll = this.addBusinessDaysToDate(lastTrdDate, -1 * _numBizDaysToRollBeforeExpiry, mktName, assetCls); Print(String.Format("{0} Last trading date for {1} futures contract is {2:MMMM d yyyy}.", this._StratName, codePrefix, lastTrdDate)); Print(String.Format("{0} Contract should be rolled forward on or before {1:MMMM d yyyy}.", this._StratName, dateToRoll)); Print(String.Empty); if (DateTime.Now.Date >= dateToRoll) { string dataMsg = String.Format("{0} Contract is either unsupported or within {1} days of expiration. Roll to next contract.", this._StratName, _numBizDaysToRollBeforeExpiry); Print(dataMsg); DrawTextFixed("dataMsg", dataMsg, TextPosition.BottomRight, Color.Navy, new Font("Arial", 12), Color.LightGray, Color.LightGreen, 6); } int daysLoaded = Bars.BarsData.DaysBack; if (daysLoaded < 3) { string dataMsg = String.Format("{0} Chart loads {1} days of data. Needs {2} days of history to calculate ATR factors.", this._StratName, daysLoaded, 3); Print(dataMsg); DrawTextFixed("dataMsg", dataMsg, TextPosition.BottomRight, Color.Navy, new Font("Arial", 12), Color.LightGray, Color.LightGreen, 6); } } if (_session1StartTime.Second != 0) { Print(String.Format("{0} Session1 start time must be a round number of minutes (seconds must equal zero).", this._StratName)); } if (_firstSessionStartTime.Seconds != 0) { Print(String.Format("{0} Session1 end time must be a round number of minutes (seconds must equal zero).", this._StratName)); } if (_secondSessionStartTime.Seconds != 0) { Print(String.Format("{0} Session2 start time must be a round number of minutes (seconds must equal zero).", this._StratName)); } if (_secondSessionEndTime.Seconds != 0) { Print(String.Format("{0} Session2 end time must be a round number of minutes (seconds must equal zero).", this._StratName)); } // if (_endOfNewEntriesTime.Seconds != 0) // Print(String.Format("{0} Last new entry time must be a round number of minutes (seconds must equal zero).",this._StratName)); if (_firstSessionEndTime.CompareTo(_firstSessionStartTime) != 1) { Print(String.Format("{0} Session1 start time must be strictly less than Session1 end time.", this._StratName)); } if (_secondSessionEndTime.CompareTo(_secondSessionStartTime) != 1) { Print(String.Format("{0} Session2 start time must be strictly less than Session2 end time.", this._StratName)); } if (_secondSessionStartTime.CompareTo(_firstSessionEndTime) == -1) { Print(String.Format("{0} Session2 start time must be greater than or equal to Session1 end time.", this._StratName)); } // if (_endOfNewEntriesTime.CompareTo(_secondSessionEndTime) == 1) // Print(String.Format("{0} Last new entry time must be less than or equal to Session2 end time.",this._StratName)); }
/// <summary> /// Gets the configuration for the market name provided. /// </summary> public static IMarketConfiguration GetMarketConfiguration(MarketName marketName) { return GlobalSettings.Markets.AvailableMarkets.FirstOrDefault(c => c.Name == marketName).GetConfiguration(); }
/// <summary> /// Gets the configuration for the market name provided. /// </summary> public static IMarketConfiguration GetMarketConfiguration(MarketName marketName) { return(GlobalSettings.Markets.AvailableMarkets.Where(c => c.Name == marketName).FirstOrDefault().GetConfiguration()); }
public DateTime futuresLastTradingDate(DateTime anchorDate, string cntPrefix, MarketName mktNm, AssetClass asstCls) { switch (cntPrefix) { case "YM": case "NQ": case "ES": case "TF": return(this.nextContractExpirationDate(anchorDate, true, 3, DayOfWeek.Wednesday)); case "CL": DateTime settleDate; if (anchorDate.Month != 1) { settleDate = new DateTime(anchorDate.Year, anchorDate.Month - 1, 25); //subtract 1 from month because CL trades 1 month ahead (i.e. Aug contract expires Jul 25) } else { settleDate = new DateTime(anchorDate.Year - 1, 12, 25); } bool isValid = isValidBusinessDay(settleDate, mktNm, asstCls); if (!isValid) { DateTime prevBD = this.previousBusinessDate(settleDate, mktNm, asstCls); settleDate = prevBD; } return(this.addBusinessDaysToDate(settleDate, -3, mktNm, asstCls)); default: string dataMsg = String.Format("{1} is not a supported futures contract. Cannot determine contract expiration. ", cntPrefix); Print(dataMsg); DrawTextFixed("dataMsg", dataMsg, TextPosition.Center, Color.Navy, new Font("Arial", 12), Color.LightGray, Color.LightGreen, 6); return(DateTime.Today); } }
public DateTime previousBusinessDate(DateTime date, MarketName marketName, AssetClass assetClass) { return(addBusinessDaysToDate(date, -1, marketName, assetClass)); }
public override int GetHashCode() { return(MarketName != null?MarketName.GetHashCode() : 0); }
public static bool SetDirectDeposit(int customerID, BankAccount account, MarketName CurrentMarket) { try { var context = Exigo.WebService(); var request = new SetAccountDirectDepositRequest{ CustomerID = customerID, NameOnAccount = account.NameOnAccount, BankName = account.BankName, DepositAccountType = DepositAccountType.Checking, BankAddress = account.BillingAddress.Address1, BankCity = account.BillingAddress.City, BankState = account.BillingAddress.State, BankCountry = account.BillingAddress.Country, BankZip = account.BillingAddress.Zip }; if (CurrentMarket == MarketName.UnitedStates) { request.BankRoutingNumber = account.RoutingNumber; request.BankAccountNumber = account.AccountNumber; } // We are seperating out swiftCode/Iban so in order to keep everything else the same we are simply pulling back the account routing number, and account number and setting them to their proper fields. else { request.SwiftCode = account.RoutingNumber; request.Iban = account.AccountNumber; } var result = context.SetAccountDirectDeposit(request); Exigo.WebService().UpdateCustomer(new UpdateCustomerRequest { CustomerID = customerID, PayableType = PayableType.DirectDeposit }); } catch { return false; } return true; }