//
        public ActionResult SavePortfolioType(PortfolioType aObj)
        {
            var aData = _aManager.SavePortfolioType(aObj);

            return(Json(new { success = aData.Status, aData }, JsonRequestBehavior.AllowGet));
            // return null;
        }
        public ResponseModel SavePortfolioType(PortfolioType aObj)
        {
            try
            {
                if (isAlreadyExist(aObj))
                {
                    return(_aModel.Respons(false, "This Type aleady exists"));
                }
                aObj.LastUpdateDate = DateTime.Now;
                if (aObj.PortfolioTypeId != 0)
                {
                    _aRepository.Update(aObj);
                }
                else
                {
                    _aRepository.Insert(aObj);
                }

                _aRepository.Save();
                return(_aModel.Respons(true, "Data Successfully Saved"));
            }
            catch (Exception ex)
            {
                return(_aModel.Respons(false, "Sorry! There is some ERROR. " + ex));
            }
        }
Beispiel #3
0
        public double YieldOnPortfolio = 0; //%
        #endregion

        #region 过程
        public Portfolio(string code, string name, PortfolioType type, PortfolioCategoryI categoryI, PortfolioCategoryII categoryII)
        {
            this.Code       = code;
            this.Name       = name;
            this.Type       = type;
            this.CategoryI  = categoryI;
            this.CategoryII = categoryII;
        }
        bool isAlreadyExist(PortfolioType aObj)
        {
            // var isAlreadyExist = _aRepository.SelectAll().Any(a => a.Type == aObj.Type && a.PortfolioTypeId != aObj.PortfolioTypeId);
            var isAlreadyExist = _aRepository.SelectAllValidation().Any(a => a.Type == aObj.Type && a.PortfolioTypeId != aObj.PortfolioTypeId);

            if (isAlreadyExist)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
 public PortfolioFile(PortfolioType type, DateTime dt, string folderPath)
 {
     if (!System.IO.Directory.Exists(folderPath))
     {
         throw new DirectoryNotFoundException();
     }
     Type = type;
     if (type == PortfolioType.LoanPortfolio)
     {
         Name = "loan portfolio " + dt.ToString("yyyyMMdd") + ".xlsx";
     }
     else
     {
         Name = "FTP - Deposits " + dt.ToString("yyyyMMdd") + ".xlsx";
     }
     DTime = dt;
     string folderName = Path.Combine(folderPath, folder);
     path = System.IO.Path.Combine(folderName, Name);
 }
Beispiel #6
0
        public sealed override void OnConfigure()
        {
            BreakPoint.TrySetStrategy(this);
            base.OnConfigure();
            AddInterceptor(performance.Equity);
            AddInterceptor(performance);
            do
            {
                // Count all the unique symbols used by dependencies and
                // get a list of all the strategies.
                strategies = new List <Strategy>();
                portfolios = new List <Portfolio>();
                Dictionary <string, List <Model> > symbolMap = new Dictionary <string, List <Model> >();
                for (int i = 0; i < Chain.Dependencies.Count; i++)
                {
                    Chain chain = Chain.Dependencies[i];
                    if (chain.Model is Strategy || chain.Model is Portfolio)
                    {
                        Model        model = (Model)chain.Model;
                        List <Model> tempModels;
                        if (symbolMap.TryGetValue(model.SymbolDefault, out tempModels))
                        {
                            tempModels.Add(model);
                        }
                        else
                        {
                            tempModels = new List <Model>();
                            tempModels.Add(model);
                            symbolMap[model.SymbolDefault] = tempModels;
                        }
                        if (model is Strategy)
                        {
                            strategies.Add((Strategy)model);
                        }
                        else if (model is Portfolio)
                        {
                            portfolios.Add((Portfolio)model);
                        }
                    }
                }
                if (symbolMap.Count == 1)
                {
                    portfolioType = PortfolioType.SingleSymbol;
                }
                else if (symbolMap.Count == (strategies.Count + portfolios.Count))
                {
                    portfolioType = PortfolioType.MultiSymbol;
                }
                else
                {
                    // Remove all dependencies which have more than one obect.
                    for (int i = Chain.Dependencies.Count - 1; i >= 0; i--)
                    {
                        Chain chain = Chain.Dependencies[i];
                        Chain.Dependencies.RemoveAt(i);
                    }
                    // There is a mixture of multi symbols and multi strategies per symbol.
                    // Insert additional Portfolios for each symbol.
                    foreach (var kvp in symbolMap)
                    {
                        string       symbol         = kvp.Key;
                        List <Model> tempStrategies = kvp.Value;
                        if (tempStrategies.Count > 1)
                        {
                            Portfolio portfolio = new Portfolio();
                            portfolio.Name            = "AutoGen-Portfolio-" + symbol;
                            portfolio.SymbolDefault   = symbol;
                            portfolio.IntervalDefault = IntervalDefault;
                            portfolio.Performance.Equity.EnableDailyStats   = Performance.Equity.EnableDailyStats;
                            portfolio.Performance.Equity.EnableWeeklyStats  = Performance.Equity.EnableWeeklyStats;
                            portfolio.Performance.Equity.EnableMonthlyStats = Performance.Equity.EnableMonthlyStats;
                            portfolio.Performance.Equity.EnableYearlyStats  = Performance.Equity.EnableYearlyStats;

                            foreach (var strategy in tempStrategies)
                            {
                                portfolio.Chain.Dependencies.Add(strategy.Chain);
                            }
                            Chain.Dependencies.Add(portfolio.Chain);
                        }
                        else
                        {
                            Model model = tempStrategies[0];
                            Chain.Dependencies.Add(model.Chain);
                        }
                    }
                }
            } while(portfolioType == PortfolioType.None);

            if (debug)
            {
                log.Debug("Configuring Portfolio " + Name + " for sub strategies/portfolios..");
            }

            // Create strategy watchers
            foreach (var strategy in strategies)
            {
                SetupWatcher(strategy);
            }

            foreach (var portfolio in portfolios)
            {
                SetupWatcher(portfolio);
            }
        }