Ejemplo n.º 1
0
        void LoadAlreadyRegisteredEvent()
        {
            // Load data from global_event table
            string query = String.Format(
                "select * from global_event where EventDate > '{0}'",
                _dtStart.AddYears(-2));
            DataRowCollection rows = DBUtil.SelectFromDB(query, Config_DB.kDatabase);

            foreach (DataRow row in rows)
            {
                string country = Convert.ToString(row["Country"]);
                string eventType = Convert.ToString(row["EventType"]);
                DateTime eventDate = Convert.ToDateTime(row["EventDate"]);
                string eventDesc = Convert.ToString(row["Event"]);
                eventDesc = eventDesc.Substring(eventDesc.IndexOf("]"));

                string key = GlobalEventKey.CreateKey(country, eventType, eventDate);

                GlobalEventDatum datum = new GlobalEventDatum();
                datum.Key = key;
                datum.Country = country;
                datum.EventType = eventType;
                datum.EventDate = eventDate;
                datum.Event = eventDesc;

                _registeredEvents.Add(key, datum);
            }
        }
Ejemplo n.º 2
0
        void Load_Rate()
        {
            List<Tuple<DateTime, string>> events = new List<Tuple<DateTime, string>>();
            List<Tuple<DateTime, double>> marketData = MarketDataUtil.GetMarketData(
                _datum.RateCode, _dtStart, _dtEnd);

            string eventType = EventType.TargetRate.ToString();
            for (int i = 0; i < marketData.Count - 1; ++i)
            {
                Tuple<DateTime, double> prev = marketData[i];
                Tuple<DateTime, double> cur = marketData[i + 1];
                if (!DoubleUtil.IsSameDouble(prev.Item2, cur.Item2, 2))
                {
                    string upDown = "up";
                    if (prev.Item2 > cur.Item2)
                    {
                        upDown = "down";
                    }

                    string desc = String.Format("[{4}] {0}, {1}, {2:n2} -> {3:n2} {5}", cur.Item1.ToString("yyyy-MM-dd"),
                        _datum.CountryCode, prev.Item2, cur.Item2, eventType, upDown);

                    string key =
                        GlobalEventKey.CreateKey(_datum.CountryCode, eventType, cur.Item1);

                    if (_registeredEvents.ContainsKey(key))
                    {
                        //pass
                        continue;
                    }

                    GlobalEventDatum datum = new GlobalEventDatum();
                    datum.Key = key;
                    datum.Country = _datum.CountryCode;
                    datum.EventType = eventType;
                    datum.EventDate = cur.Item1;
                    datum.Event = desc;

                    _newEvents.Add(key, datum);
                }
            }
        }