コード例 #1
0
        private static cSecurity getCurrSecurity(Security security, IPortfolioBL cCurrPort)
        {                                                                                        // Retrieves an instance of a security based on its datarow info
            cSecurity cCurrSec = new cSecurity(cCurrPort, security.strName, security.strSymbol); //111An

            cCurrSec.Properties.PortSecurityId = security.idSecurity;

            //cCurrSec.Properties.HebName = security.HebName;

            //cCurrSec.FAC = Convert.ToDouble(security.FAC);

            if (cCurrSec.FAC <= 0D)
            {
                cCurrSec.FAC = 1D;
            }

            cCurrSec.AvgYield = security.AvgYield;
            cCurrSec.StdYield = security.StdYield;

            cCurrSec.AvgYieldNIS = security.AvgYieldNIS;
            cCurrSec.StdYieldNIS = security.StdYieldNIS;

            cCurrSec.ValueUSA = security.dValueUSA;
            cCurrSec.ValueNIS = security.dValueNIS;

            cCurrSec.WeightUSA = security.WeightUSA;
            cCurrSec.WeightNIS = security.WeightNIS;

            //cCurrSec.Properties.ISIN = security.strISIN;

            cCurrSec.DateRange = new cDateRange(security.dtPriceStart, security.dtPriceEnd);

            //lock (lockObject)
            //{
            cCurrSec.Properties.Sector = cColHandler.getCatItemByID(enumCatType.Sector, security.idSector,
                                                                    cColHandler.Sectors);

            cCurrSec.Properties.Market     = cColHandler.getCatItemByID(enumCatType.StockMarket, security.idMarket, cColHandler.Markets);
            cCurrSec.Properties.MarketName = getSecMarketName(security.idMarket);

            cCurrSec.Properties.SecurityType = cColHandler.getCatItemByID(enumCatType.SecurityType,
                                                                          security.idSecurityType, cColHandler.SecTypes);
            //}
            var priceRepository = Resolver.Resolve <IRepository>();

            try
            {
                priceRepository.Execute(session =>
                {
                    // cCurrSec.PriceTable = AutoMapper.Mapper.Map<List<Models.dbo.Price>>(session.Query<TFI.Entities.dbo.Price>().Where(x => x.Securities.idSecurity == security.idSecurity).OrderByDescending(x => x.dDate).ToList());
                });
            }
            catch (Exception ex)
            {
                //m_objErrorHandler.LogInfo(ex);
            }
            Resolver.Release(priceRepository);
            return(cCurrSec);
        }//getCurrSecurity
コード例 #2
0
        }//getCurrSecurity

        private cSecurity getCurrBMSecurity_with_EntitySec(Entities.dbo.Security drSec, IPortfolioBL cCurrPort)
        { // Retrieves an instance of a security based on its datarow info
            ICollectionsHandler cColHandler = cCurrPort.ColHandler;

            cSecurity cCurrSec = new cSecurity(cCurrPort, drSec.strName, drSec.strSymbol);  //111An

            cCurrSec.Properties.PortSecurityId = drSec.idSecurity;

            cCurrSec.Properties.HebName = drSec.strHebName;
            cCurrSec.FAC = 1D;

            ////if (drSec["FAC"] != DBNull.Value) cCurrSec.FAC = Convert.ToDouble(drSec["FAC"]);
            ////else cCurrSec.FAC = 1D;
            ////if (cCurrSec.FAC <= 0D) cCurrSec.FAC = 1D;

            if (drSec.AvgYield.HasValue)
            {
                cCurrSec.AvgYield = Convert.ToDouble(drSec.AvgYield);
            }
            if (drSec.StdYield.HasValue)
            {
                cCurrSec.StdYield = Convert.ToDouble(drSec.StdYield);
            }

            if (drSec.AvgYieldNIS.HasValue)
            {
                cCurrSec.AvgYieldNIS = Convert.ToDouble(drSec.AvgYieldNIS);
            }
            if (drSec.StdYieldNIS.HasValue)
            {
                cCurrSec.StdYieldNIS = Convert.ToDouble(drSec.StdYieldNIS);
            }

            if (drSec.MonetaryAvg.HasValue)
            {
                cCurrSec.ValueUSA = Convert.ToDouble(drSec.MonetaryAvg);
            }
            if (drSec.MonetaryAvgNIS.HasValue)
            {
                cCurrSec.ValueNIS = Convert.ToDouble(drSec.MonetaryAvgNIS);
            }

            if (drSec.WeightUSA.HasValue)
            {
                cCurrSec.WeightUSA = Convert.ToDouble(drSec.WeightUSA);
            }
            if (drSec.WeightNIS.HasValue)
            {
                cCurrSec.WeightNIS = Convert.ToDouble(drSec.WeightNIS);
            }

            //cCurrSec.Properties.ISIN = drSec.strISIN;

            ////if ((drSec["dtPriceStart"] != DBNull.Value) && (drSec["dtPriceEnd"] != DBNull.Value))
            ////    cCurrSec.DateRange = new cDateRange(Convert.ToDateTime(drSec["dtPriceStart"]), Convert.ToDateTime(drSec["dtPriceEnd"]));
            cCurrSec.DateRange = new cDateRange(DateTime.Today.AddYears(-cProperties.DatesInterval), DateTime.Today.AddDays(-1));

            if (drSec.idSector.HasValue)
            {
                cCurrSec.Properties.Sector = cColHandler.getCatItemByID(enumCatType.Sector, Convert.ToInt32(drSec.idSector),
                                                                        cColHandler.Sectors);
            }
            if (drSec.idMarket.HasValue)
            { // Exchange values
                cCurrSec.Properties.Market     = cColHandler.getCatItemByID(enumCatType.StockMarket, drSec.idMarket.Value, cColHandler.Markets);
                cCurrSec.Properties.MarketName = getSecMarketName(drSec.idMarket.Value);
            }
            if (drSec.idSecurityType.HasValue)
            {
                cCurrSec.Properties.SecurityType = cColHandler.getCatItemByID(enumCatType.SecurityType,
                                                                              drSec.idSecurityType.Value, cColHandler.SecTypes);
            }

            //if (drSec["idCurrency"] != DBNull.Value) cCurrSec.IdCurrency = drSec["IdCurrency"].ToString();
            cCurrSec.IdCurrency = cProperties.CurrencyId;

            try
            { // Only exists in portfolio securities
              // For Benchmark we assign 'true'
              //if (drSec["isActiveSecurity"] != DBNull.Value) cCurrSec.setSecurityActivity(Convert.ToBoolean(drSec["isActiveSecurity"]));
              //else cCurrSec.setSecurityActivity(true);



                // LR: at this point security already has .PriceTable filled in, so commenting the line, because it crashes here
                //cCurrSec.PriceTable = drSec.Prices.ToList();

                //////foreach (var p in cCurrSec.PriceTable)
                //////{
                //////    p.dAdjPrice = p.fClose;
                //////}

                cCurrSec.setSecurityActivity(true);
            }
            catch (Exception ex)
            {
            }

            return(cCurrSec);
        }//getCurrSecurity
コード例 #3
0
        }//getSecDatarowPosition

        #endregion Static methods

        #region Load Benchmarks from SQL Srv

        private cSecurity getCurrBMSecurity(BMsecurity drSec, IPortfolioBL cCurrPort)
        { // Retrieves an instance of a security based on its datarow info
            ICollectionsHandler cColHandler = cCurrPort.ColHandler;

            cSecurity cCurrSec = new cSecurity(cCurrPort, drSec.strName, drSec.strSymbol);  //111An

            cCurrSec.Properties.PortSecurityId = drSec.idSecurity;

            cCurrSec.Properties.HebName = drSec.strHebName;
            cCurrSec.FAC = 1D;

            cCurrSec.AvgYield = Convert.ToDouble(drSec.AvgYield);
            cCurrSec.StdYield = Convert.ToDouble(drSec.StdYield);

            cCurrSec.AvgYieldNIS = Convert.ToDouble(drSec.AvgYieldNIS);
            cCurrSec.StdYieldNIS = Convert.ToDouble(drSec.StdYieldNIS);

            //////cCurrSec.ValueUSA = Convert.ToDouble(drSec.dValueUSA);        // THEY ARE NULLS for BM sec
            //////cCurrSec.ValueNIS = Convert.ToDouble(drSec.dValueNIS);

            //////cCurrSec.WeightUSA = Convert.ToDouble(drSec.WeightUSA);
            //////cCurrSec.WeightNIS = Convert.ToDouble(drSec.WeightNIS);

            cCurrSec.DateRange = new cDateRange(DateTime.Today.AddYears(-cProperties.DatesInterval), DateTime.Today.AddDays(-1));
            lock (lockObject)
            {
                cCurrSec.Properties.Sector = cColHandler.getCatItemByID(enumCatType.Sector, Convert.ToInt32(drSec.idSector),
                                                                        cColHandler.Sectors);
                // Exchange values
                cCurrSec.Properties.Market     = cColHandler.getCatItemByID(enumCatType.StockMarket, drSec.idMarket, cColHandler.Markets);
                cCurrSec.Properties.MarketName = getSecMarketName(drSec.idMarket);

                cCurrSec.Properties.SecurityType = cColHandler.getCatItemByID(enumCatType.SecurityType,
                                                                              drSec.idSecurityType, cColHandler.SecTypes);
            }
            //if (drSec["idCurrency"] != DBNull.Value) cCurrSec.IdCurrency = drSec["IdCurrency"].ToString();
            cCurrSec.IdCurrency = drSec.idCurrency; // WHY WAS IT HERE????? cProperties.CurrencyId;

            try
            { // Only exists in portfolio securities
              // For Benchmark we assign 'true'
              //if (drSec["isActiveSecurity"] != DBNull.Value) cCurrSec.setSecurityActivity(Convert.ToBoolean(drSec["isActiveSecurity"]));
              //else cCurrSec.setSecurityActivity(true);


                // LR: at this point security already has .PriceTable filled in, so commenting the line, because it crashes here
                //cCurrSec.PriceTable = drSec.Prices.ToList();

                //////foreach (var p in cCurrSec.PriceTable)
                //////{
                //////    p.dAdjPrice = p.fClose;
                //////}

                cCurrSec.setSecurityActivity(true);
            }
            catch (Exception ex)
            {
            }

            //// Made separate entity for tbl_IndexPrices
            //var priceRepository = Resolver.Resolve<IRepository>();
            //List<Entities.dbo.BMPrice> laura;
            //try
            //{
            //    priceRepository.Execute(session =>
            //    {
            //        ////cCurrSec.PriceTable = AutoMapper.Mapper.Map<List<Entities.dbo.Price>>(session.Query<Entities.dbo.BMPrice>().Where(x => x.idSecurity == "'" + drSec.idSecurity + "'").OrderByDescending(x => x.dDate).ToList());
            //        laura = session.Query<Entities.dbo.BMPrice>().Where(x => x.idSecurity == "'" + drSec.idSecurity + "'").OrderByDescending(x => x.dDate).ToList();
            //    });
            //}
            //catch (Exception ex)
            //{
            //    m_objErrorHandler.LogInfo(ex);
            //}
            //Resolver.Release(priceRepository);

            return(cCurrSec);
        }//getCurrSecurity
コード例 #4
0
        }//getCatItemByID

        #endregion Load from DB


        #region Static methods

        private cSecurity getCurrSecurity(Security security, IPortfolioBL cCurrPort)
        { // Retrieves an instance of a security based on its datarow info
            ICollectionsHandler cColHandler = cCurrPort.ColHandler;

            cSecurity cCurrSec = new cSecurity(cCurrPort, security.strName, security.strSymbol);//111An

            cCurrSec.Properties.PortSecurityId = security.idSecurity;

            cCurrSec.Properties.HebName = security.strHebName;

            //cCurrSec.FAC = Convert.ToDouble(security.FAC);

            if (cCurrSec.FAC <= 0D)
            {
                cCurrSec.FAC = 1D;
            }

            cCurrSec.AvgYield = security.AvgYield;       //* 52;
            cCurrSec.StdYield = security.StdYield;       // * Math.Sqrt(52);

            cCurrSec.AvgYieldNIS = security.AvgYieldNIS; // * 52;
            cCurrSec.StdYieldNIS = security.StdYieldNIS; // * Math.Sqrt(52);

            cCurrSec.ValueUSA = security.dValueUSA;
            cCurrSec.ValueNIS = security.dValueNIS;

            cCurrSec.WeightUSA = security.WeightUSA;
            cCurrSec.WeightNIS = security.WeightNIS;

            //cCurrSec.Properties.ISIN = security.strISIN;
            cCurrSec.IdCurrency = security.idCurrency;
            cCurrSec.DateRange  = new cDateRange(security.dtPriceStart, security.dtPriceEnd);
            cCurrSec.setSecurityActivity(true);

            lock (lockObject)
            {
                cCurrSec.Properties.Sector = cColHandler.getCatItemByID(enumCatType.Sector, security.idSector,
                                                                        cColHandler.Sectors);

                cCurrSec.Properties.Market     = cColHandler.getCatItemByID(enumCatType.StockMarket, security.idMarket, cColHandler.Markets);
                cCurrSec.Properties.MarketName = getSecMarketName(security.idMarket);

                cCurrSec.Properties.SecurityType = cColHandler.getCatItemByID(enumCatType.SecurityType,
                                                                              security.idSecurityType, cColHandler.SecTypes);
            }


            //var priceRepository = Resolver.Resolve<IRepository>();
            //try
            //{
            //    priceRepository.Execute(session =>
            //    {
            //        cCurrSec.PriceTable = session.Query<Entities.dbo.Price>().Where(x => x.idSecurity == security.idSecurity).ToList(); //.OrderByDescending(x => x.dDate)
            //    });
            //}
            //catch (Exception ex)
            //{
            //    m_objErrorHandler.LogInfo(ex);
            //}
            //Resolver.Release(priceRepository);


            //List<Models.dbo.Price> BMprices = getFullPrices();
            //cCurrSec.PriceTable = AutoMapper.Mapper.Map<List<Price>, List<Entities.dbo.Price>>(BMprices.Where(x => x.idSecurity == cCurrSec.Properties.PortSecurityId).OrderByDescending(x => x.dDate).ToList());


            return(cCurrSec);
        }//getCurrSecurity