Esempio n. 1
0
 internal StockExchange(StockExchange se)
 {
     if (se == null)
     {
         throw new ArgumentNullException("se", "Original StockExchange is null.");
     }
     else
     {
         if (se != null)
         {
             mID      = se.ID;
             mCountry = se.Country;
             mSuffix  = se.Suffix;
             mName    = se.Name;
             TradingTimeInfo tt = se.TradingTime;
             mTradingTime = new TradingTimeInfo(tt.DelayMinutes, tt.TradingDays, tt.Holidays, tt.LocalOpeningTime, tt.TradingSpan, tt.UtcOffsetStandardTime, tt.DaylightSavingTimes);
         }
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Loads a list of default stock exchanges from market.xml
        /// </summary>
        /// <returns></returns>
        /// <remarks></remarks>
        public static StockExchange[] GetDefaultStockExchanges()
        {
            List <StockExchange> lst = new List <StockExchange>();

            XParseDocument xmlDoc = MyHelper.ParseXmlDocument(Properties.Resources.market);

            XParseElement[] exchanges = XPath.GetElements("//Resources/StockExchanges/StockExchange", xmlDoc);

            foreach (XParseElement exchangeNode in exchanges)
            {
                string seID     = MyHelper.GetXmlAttributeValue(exchangeNode, "ID");
                string seSuffix = MyHelper.GetXmlAttributeValue(exchangeNode, "Suffix");
                string seName   = MyHelper.GetXmlAttributeValue(exchangeNode, "Name");

                CountryInfo seCountry = null;
                string      ctrID     = MyHelper.GetXmlAttributeValue(exchangeNode, "Country");
                foreach (CountryInfo ctr in DefaultCountries)
                {
                    if (ctr.ID.ToString() == ctrID)
                    {
                        seCountry = ctr;
                        break;
                    }
                }

                //TradingTimeInfo
                int      seDelayMinutes     = Convert.ToInt32(MyHelper.GetXmlAttributeValue(exchangeNode, "DelayMinutes"));
                int      seRelativeToUTC    = Convert.ToInt32(MyHelper.GetXmlAttributeValue(exchangeNode, "UtcOffsetStandardTime"));
                DateTime seOpeningTimeLocal = Convert.ToDateTime(MyHelper.GetXmlAttributeValue(exchangeNode, "OpeningTimeLocal"));
                DateTime seClosingTimeLocal = Convert.ToDateTime(MyHelper.GetXmlAttributeValue(exchangeNode, "ClosingTimeLocal"));
                TimeSpan seTradingSpan      = seClosingTimeLocal - seOpeningTimeLocal;

                List <DayOfWeek> seTradingDaysList = new List <DayOfWeek>();
                string           trdDays           = MyHelper.GetXmlAttributeValue(exchangeNode, "TradingDays");
                foreach (string day in trdDays.Split(','))
                {
                    switch (day)
                    {
                    case "Mo":
                        seTradingDaysList.Add(DayOfWeek.Monday);
                        break;

                    case "Tu":
                        seTradingDaysList.Add(DayOfWeek.Tuesday);
                        break;

                    case "We":
                        seTradingDaysList.Add(DayOfWeek.Wednesday);
                        break;

                    case "Th":
                        seTradingDaysList.Add(DayOfWeek.Thursday);
                        break;

                    case "Fr":
                        seTradingDaysList.Add(DayOfWeek.Friday);
                        break;

                    case "Sa":
                        seTradingDaysList.Add(DayOfWeek.Saturday);
                        break;

                    case "Su":
                        seTradingDaysList.Add(DayOfWeek.Sunday);
                        break;
                    }
                }

                DaylightSavingTime[] seDaylightSavingTimes = null;
                if (seCountry != null)
                {
                    seDaylightSavingTimes = seCountry.DaylightSavingTimes;
                }

                TradingTimeInfo seTradingTimeInfo = new TradingTimeInfo(seDelayMinutes, seTradingDaysList.ToArray(), null, seOpeningTimeLocal, seTradingSpan, seRelativeToUTC, seDaylightSavingTimes);

                StockExchange se = new StockExchange(seID, seSuffix, seName, seCountry, seTradingTimeInfo);
                string        s  = MyHelper.GetXmlAttributeValue(exchangeNode, "Tags");
                if (s != string.Empty)
                {
                    se.Tags.AddRange(s.Split(','));
                }
                lst.Add(se);
            }

            return(lst.ToArray());
        }