Ejemplo n.º 1
0
        public void Add(PortfolioPosition position, Enum enumeration, ScalarDate scalar)
        {
            KeyValuePair <PortfolioPosition, Enum> key = new KeyValuePair <PortfolioPosition, Enum>(position, enumeration);

            if (_dates.ContainsKey(key))
            {
                _dates[key] = scalar;
            }
            else
            {
                _dates.Add(key, scalar);
            }
        }
        public ScalarDate GetScalarDate(PortfolioPosition position, ScalarAttribute attribute)
        {
            var markets = _markets.Where(z => z.GetIMapping().FindAI(attribute));

            foreach (var x in markets)
            {
                ScalarDate scalarDate = x.GetScalarDate(position, attribute);
                if (scalarDate != null)
                {
                    return(scalarDate);
                }
            }
            return(null);
        }
Ejemplo n.º 3
0
        public void TestScalarHas()
        {
            Dictionary <DateTime, DateTime> dateTimes = new Dictionary <DateTime, DateTime>()
            {
                { DateTime.Now, DateTime.Now },
                { DateTime.Now.AddDays(-1), DateTime.Now.AddDays(-1) },
                { DateTime.Now.AddDays(1), DateTime.Now.AddDays(1) },
                { DateTime.Now.AddDays(2), DateTime.Now.AddDays(2) },
            };

            ScalarDate date = new ScalarDate(dateTimes);

            Assert.IsFalse(date.HasValue(DateTime.Now.AddDays(-2)));
            Assert.IsTrue(date.HasValue(DateTime.Now));
            Assert.IsTrue(date.HasValue(DateTime.Now.AddDays(3)));
        }
        public ScalarDate GetScalarDate(PortfolioPosition position,
                                        ScalarAttribute attribute)
        {
            if (!_mapping.FindAI(attribute))
            {
                return(null);
            }

            KeyValuePair <PortfolioPosition, Enum> key =
                new KeyValuePair <PortfolioPosition, Enum>(position, attribute);

            if (_cache.ContainsKey(key))
            {
                return((ScalarDate)_cache[key]);
            }
            ScalarDate scalarDate = null;

            string fif_id = _mapping.GetAI(attribute);
            string query  = string.Format(
                @"SELECT fi.ident as ident, fd.dat_from as dat_from, fd.val as val
                        from fin_instrument fi join
	                        ffd t on t.fi_id = fi.fi_id join
	                        data_source ds on t.ds_id = ds.ds_id join
	                        fisd_date fd on fd.fisd_id = t.fisd_id 
	                        where fi.ident = '{0}'
		                        and t.fif_id = {1}
		                        and ds.ident = '{2}'"        ,
                position.Ident,
                fif_id,
                _providerParams[SCALAR]);
            var result = _dbLink.GetConnection().Query <fisddate>(query);

            if (result != null && result.Count() != 0)
            {
                Dictionary <DateTime, DateTime> dict = new Dictionary <DateTime, DateTime>();
                foreach (var x in result)
                {
                    dict.Add(x.dat_from, x.val);
                }
                scalarDate = new ScalarDate(dict);
            }


            _cache.Add(key, scalarDate);
            return(scalarDate);
        }