Пример #1
0
 public ClientHolding(FundInvestorBO investor)
 {
     Investor     = investor;
     Units        = 0;
     AverageCost  = 0;
     RealisedPnL  = 0;
     Transactions = new List <TransferAgencyBO>();
     openLots     = new Queue <TaxLotsOpen>();
 }
        public override async Task ExecuteAsync(object parameter)
        {
            try
            {
                if (_investorActionVM.TradeAmount <= _investorActionVM.TargetFundMinimumInvestment)
                {
                    throw new ArgumentException($"The Subscription amount must be greater than the Funds minimum investment: {_investorActionVM.TargetFundMinimumInvestment} {_investorActionVM.TargetFundBaseCurrency}.");
                }
                //For now settledate = trade date TODO soon it will be td + fund subscription date
                TransferAgencyBO newInvestorAction = new TransferAgencyBO
                {
                    TransactionDate       = _investorActionVM.TradeDate,
                    TransactionSettleDate = _investorActionVM.TradeDate,
                    IssueType             = _investorActionVM.TAType,
                    Units       = decimal.Zero,
                    NAVPrice    = decimal.Zero,
                    TradeAmount = _investorActionVM.TradeAmount,
                    Currency    = _investorActionVM.Currency,
                    Fees        = _investorActionVM.Fee,
                    FundId      = _investorActionVM.FundId,
                    IsNavFinal  = false
                };
                FundInvestorBO fundInvestor = _investorService.GetFundInvestor(_investorActionVM.FundId, _investorActionVM.SelectedInvestor.InvestorId);
                if (fundInvestor == null)
                {
                    //this means the investor is new to the fund.
                    fundInvestor = new FundInvestorBO
                    {
                        InceptionDate = _investorActionVM.TradeDate,
                        FundId        = _investorActionVM.FundId,
                        InvestorId    = _investorActionVM.SelectedInvestor.InvestorId,
                    };
                    fundInvestor.HighWaterMark     = (_investorActionVM.TargetFundWaterMark && _investorActionVM.isNavFinal) ? _investorActionVM.Price : (decimal?)null;
                    newInvestorAction.FundInvestor = fundInvestor;
                }
                else
                {
                    newInvestorAction.FundInvestorId = fundInvestor.FundInvestorId;
                }

                await _investorService.CreateInvestorAction(newInvestorAction);

                _investorActionVM.CloseAction();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }
Пример #3
0
        public override async Task ExecuteAsync(object parameter)
        {
            try
            {
                if (_investorActionVM.Units < decimal.One)
                {
                    throw new InvalidOperationException("The redemption units must be greater than or equal 1");
                }

                TransferAgencyBO newInvestorAction = new TransferAgencyBO
                {
                    TransactionDate       = _investorActionVM.TradeDate,
                    TransactionSettleDate = _investorActionVM.TradeDate,
                    IssueType             = _investorActionVM.TAType,
                    Units       = _investorActionVM.Units * -1,
                    NAVPrice    = decimal.Zero,
                    TradeAmount = decimal.Zero,
                    Currency    = _investorActionVM.Currency,
                    Fees        = _investorActionVM.Fee,
                    FundId      = _investorActionVM.FundId,
                    IsNavFinal  = false
                };
                FundInvestorBO fundInvestor = _investorService.GetFundInvestor(_investorActionVM.FundId, _investorActionVM.SelectedInvestor.InvestorId);
                if (fundInvestor == null)
                {
                    throw new InvalidOperationException($"{_investorActionVM.SelectedInvestor.FullName} does not have any shares to redeem");
                }
                else
                {
                    newInvestorAction.FundInvestorId = fundInvestor.FundInvestorId;
                }
                await _investorService.CreateInvestorAction(newInvestorAction);

                _investorActionVM.CloseAction();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }
        public override async Task ExecuteAsync(object parameter)
        {
            try
            {
                if (_fundInitialiseVM.dgSeedingInvestors.Count == 0)
                {
                    throw new ArgumentException("Your fund must have initial investors.");
                }
                if (_fundInitialiseVM.dgSeedingInvestors.Count != _fundInitialiseVM.dgSeedingInvestors.ToHashSet().Count)
                {
                    throw new ArgumentException("You must net an investors seed capital.");
                }

                Fund updateFund = _fundInitialiseVM.TargetFund;
                updateFund.IsInitialised = true;

                string             cashSymbol = $"{updateFund.BaseCurrency}c";
                SecuritiesDIM      security   = _staticReferences.GetSecurityInfo(cashSymbol);
                TransactionTypeDIM tradeType  = _staticReferences.GetTransactionType("Deposit");
                CustodiansDIM      custodian  = _staticReferences.GetCustodian(_fundInitialiseVM.Custodian);

                List <TransferAgencyBO>     subscriptions    = new List <TransferAgencyBO>();
                List <TransactionsBO>       transactions     = new List <TransactionsBO>();
                List <FundInvestorBO>       fundInvestors    = new List <FundInvestorBO>();
                List <InvestorHoldingsFACT> investorHoldings = new List <InvestorHoldingsFACT>();

                foreach (SeedingInvestor seedInvestor in _fundInitialiseVM.dgSeedingInvestors)
                {
                    if (seedInvestor.SeedAmount >= updateFund.MinimumInvestment)
                    {
                        FundInvestorBO fundInvestor = new FundInvestorBO
                        {
                            InceptionDate = updateFund.LaunchDate,
                            FundId        = updateFund.FundId,
                            InvestorId    = seedInvestor.InvestorId
                        };
                        // The highwatermark is only applicable if the fund has a highwatermark...
                        fundInvestor.HighWaterMark = (updateFund.HasHighWaterMark) ? _fundInitialiseVM.NavPrice : (decimal?)null;
                        fundInvestors.Add(fundInvestor);

                        InvestorHoldingsFACT investor = new InvestorHoldingsFACT
                        {
                            ManagementFeesAccrued  = decimal.Zero,
                            PerformanceFeesAccrued = decimal.Zero,
                            FundId       = updateFund.FundId,
                            HoldingDate  = updateFund.LaunchDate,
                            InvestorId   = seedInvestor.InvestorId,
                            AverageCost  = _fundInitialiseVM.NavPrice,
                            Units        = seedInvestor.SeedAmount / _fundInitialiseVM.NavPrice,
                            NetValuation = seedInvestor.SeedAmount,
                        };
                        investor.HighWaterMark = (updateFund.HasHighWaterMark) ? _fundInitialiseVM.NavPrice : (decimal?)null;
                        investorHoldings.Add(investor);
                        // hwm
                        TransferAgencyBO newSubscription = new TransferAgencyBO
                        {
                            TradeAmount           = seedInvestor.SeedAmount,
                            NAVPrice              = _fundInitialiseVM.NavPrice,
                            TransactionDate       = updateFund.LaunchDate,
                            TransactionSettleDate = updateFund.LaunchDate,
                            Currency              = updateFund.BaseCurrency,
                            FundId       = updateFund.FundId,
                            Fees         = 0,
                            IssueType    = "Subscription",
                            Units        = seedInvestor.SeedAmount / _fundInitialiseVM.NavPrice,
                            IsNavFinal   = true,
                            FundInvestor = fundInvestor
                        };
                        subscriptions.Add(newSubscription);
                        TransactionsBO newTransaction = new TransactionsBO
                        {
                            SecurityId        = security.SecurityId,
                            Quantity          = seedInvestor.SeedAmount,
                            Price             = decimal.One,
                            TradeAmount       = seedInvestor.SeedAmount,
                            TradeDate         = updateFund.LaunchDate,
                            SettleDate        = updateFund.LaunchDate,
                            CreatedDate       = DateTime.Now,
                            LastModified      = DateTime.Now,
                            Fees              = decimal.Zero,
                            isActive          = true,
                            isLocked          = true,
                            isCashTransaction = false,
                            FundId            = updateFund.FundId,
                            TransactionTypeId = tradeType.TransactionTypeId,
                            CurrencyId        = security.CurrencyId,
                            Comment           = "Initial Subscription",
                            CustodianId       = custodian.CustodianId
                        };
                        transactions.Add(newTransaction);
                    }
                    else
                    {
                        throw new ArgumentException("The seed amount must be greater than the Funds minimum investment");
                    }
                }

                int PeriodId = _staticReferences.GetPeriod(updateFund.LaunchDate, updateFund.FundId).PeriodId;
                NAVPriceStoreFACT initialNav = new NAVPriceStoreFACT
                {
                    FinalisedDate     = updateFund.LaunchDate,
                    NAVPrice          = _fundInitialiseVM.NavPrice,
                    FundId            = updateFund.FundId,
                    NetAssetValue     = subscriptions.Sum(ni => ni.TradeAmount),
                    SharesOutstanding = subscriptions.Sum(ni => ni.Units),
                    Currency          = updateFund.BaseCurrency,
                    NAVPeriodId       = PeriodId
                };
                await _investorService.InitialiseFundAction(updateFund, subscriptions, transactions, initialNav, fundInvestors, investorHoldings);

                _fundInitialiseVM.CloseAction();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }