public override async Task ExecuteAsync(object parameter) { try { // cash symbol would be something like EURc name = EUR CASH TransactionTypeDIM tradeType = _transactionService.GetTradeType(_editCashTradeWindowVM.CashType); CustodiansDIM custodian = _transactionService.GetCustodian(_editCashTradeWindowVM.Custodian); _transaction.Comment = _editCashTradeWindowVM.Notes; _transaction.TradeAmount = _editCashTradeWindowVM.CashAmount; _transaction.LastModified = _editCashTradeWindowVM.LastModifiedDate; _transaction.TransactionTypeId = tradeType.TransactionTypeId; _transaction.TransactionType = tradeType; _transaction.CustodianId = custodian.CustodianId; _transaction.Custodian = custodian; _transaction.TradeDate = _editCashTradeWindowVM.TradeDate; _transaction.SettleDate = _editCashTradeWindowVM.SettleDate; await _transactionService.UpdateTransaction(_transaction); _editCashTradeWindowVM.CloseAction(); } catch (Exception e) { MessageBox.Show(e.Message); } }
public override async Task ExecuteAsync(object parameter) { try { TransactionTypeDIM tradeType = _transactionService.GetTradeType(_addTradeWindowVM.TradeType); CustodiansDIM custodian = _transactionService.GetCustodian(_addTradeWindowVM.Custodian); TransactionsBO newTrade = new TransactionsBO { SecurityId = _addTradeWindowVM.SelectedSecurity.SecurityId, Quantity = _addTradeWindowVM.Quantity, Price = _addTradeWindowVM.Price, TradeAmount = _addTradeWindowVM.TradeAmount, TradeDate = _addTradeWindowVM.TradeDate, SettleDate = _addTradeWindowVM.SettleDate, CreatedDate = _addTradeWindowVM.CreatedDate, LastModified = _addTradeWindowVM.LastModifiedDate, Fees = _addTradeWindowVM.Commission, isActive = _addTradeWindowVM.isActive, isLocked = _addTradeWindowVM.isLocked, isCashTransaction = false, FundId = _addTradeWindowVM.FundId, TransactionTypeId = tradeType.TransactionTypeId, CurrencyId = _addTradeWindowVM.SelectedSecurity.CurrencyId, Comment = "", CustodianId = custodian.CustodianId }; await _transactionService.CreateTransaction(newTrade); _addTradeWindowVM.CloseAction(); } catch (Exception e) { MessageBox.Show(e.Message); } }
public override async Task ExecuteAsync(object parameter) { try { // cash symbol would be something like EURc name = EUR CASH SecuritiesDIM security = _transactionService.GetSecurityInfo(_addCashTradeWindowVM.Symbol); TransactionTypeDIM tradeType = _transactionService.GetTradeType(_addCashTradeWindowVM.CashType); CustodiansDIM custodian = _transactionService.GetCustodian(_addCashTradeWindowVM.Custodian); TransactionsBO newCashTrade = new TransactionsBO { SecurityId = security.SecurityId, Quantity = _addCashTradeWindowVM.Quantity, Price = _addCashTradeWindowVM.Price, TradeAmount = _addCashTradeWindowVM.CashAmount, TradeDate = _addCashTradeWindowVM.TradeDate, SettleDate = _addCashTradeWindowVM.SettleDate, CreatedDate = _addCashTradeWindowVM.CreatedDate, LastModified = _addCashTradeWindowVM.LastModifiedDate, Fees = _addCashTradeWindowVM.Fees, isActive = _addCashTradeWindowVM.isActive, isLocked = _addCashTradeWindowVM.isLocked, isCashTransaction = true, FundId = _addCashTradeWindowVM.FundId, TransactionTypeId = tradeType.TransactionTypeId, CurrencyId = security.CurrencyId, Comment = _addCashTradeWindowVM.Notes, CustodianId = custodian.CustodianId }; await _transactionService.CreateTransaction(newCashTrade); _addCashTradeWindowVM.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); } }
public static void SeedPortfolio(PortfolioAceDbContext context) { CurrenciesDIM[] SeedCurrencies = new CurrenciesDIM[] { new CurrenciesDIM { CurrencyId = 1, Name = "PoundSterling", Symbol = "GBP" }, new CurrenciesDIM { CurrencyId = 2, Name = "Euro", Symbol = "EUR" }, new CurrenciesDIM { CurrencyId = 3, Name = "UnitedStatesDollar", Symbol = "USD" }, new CurrenciesDIM { CurrencyId = 4, Name = "JapaneseYen", Symbol = "JPY" }, new CurrenciesDIM { CurrencyId = 5, Name = "IndianRupee", Symbol = "INR" }, new CurrenciesDIM { CurrencyId = 6, Name = "SwissFranc", Symbol = "CHF" }, new CurrenciesDIM { CurrencyId = 7, Name = "CanadianDollar", Symbol = "CAD" }, new CurrenciesDIM { CurrencyId = 8, Name = "AustralianDollar", Symbol = "AUD" } }; TransactionTypeDIM[] SeedTransactionTypes = new TransactionTypeDIM[] { new TransactionTypeDIM { TransactionTypeId = 1, TypeName = "Trade", TypeClass = "SecurityTrade", Direction = "None" }, new TransactionTypeDIM { TransactionTypeId = 2, TypeName = "Dividends", TypeClass = "SecurityTrade", Direction = "None" }, new TransactionTypeDIM { TransactionTypeId = 3, TypeName = "Income", TypeClass = "CashTrade", Direction = "Inflow" }, new TransactionTypeDIM { TransactionTypeId = 4, TypeName = "Expense", TypeClass = "CashTrade", Direction = "Outflow" }, new TransactionTypeDIM { TransactionTypeId = 5, TypeName = "Deposit", TypeClass = "CashTrade", Direction = "Inflow" }, new TransactionTypeDIM { TransactionTypeId = 6, TypeName = "Withdrawal", TypeClass = "CashTrade", Direction = "Outflow" }, new TransactionTypeDIM { TransactionTypeId = 7, TypeName = "Interest", TypeClass = "CashTrade", Direction = "None" }, new TransactionTypeDIM { TransactionTypeId = 8, TypeName = "ManagementFee", TypeClass = "CashTrade", Direction = "Outflow" }, new TransactionTypeDIM { TransactionTypeId = 9, TypeName = "PerformanceFee", TypeClass = "CashTrade", Direction = "Outflow" }, new TransactionTypeDIM { TransactionTypeId = 10, TypeName = "Miscellaneous", TypeClass = "CashTrade", Direction = "None" }, new TransactionTypeDIM { TransactionTypeId = 11, TypeName = "FXBuy", TypeClass = "CashTrade", Direction = "Inflow" }, new TransactionTypeDIM { TransactionTypeId = 12, TypeName = "FXSell", TypeClass = "CashTrade", Direction = "Outflow" }, new TransactionTypeDIM { TransactionTypeId = 13, TypeName = "FXTrade", TypeClass = "FXTrade", Direction = "None" }, new TransactionTypeDIM { TransactionTypeId = 14, TypeName = "FXTradeCollapse", TypeClass = "FXTrade", Direction = "None" } }; AssetClassDIM[] SeedAssetClasses = new AssetClassDIM[] { new AssetClassDIM { AssetClassId = 1, Name = "Equity" }, new AssetClassDIM { AssetClassId = 2, Name = "Cryptocurrency" }, new AssetClassDIM { AssetClassId = 3, Name = "FX" }, new AssetClassDIM { AssetClassId = 4, Name = "Cash" }, new AssetClassDIM { AssetClassId = 5, Name = "InterestRate" }, new AssetClassDIM { AssetClassId = 6, Name = "FXForward" }, }; SecuritiesDIM[] seedSecurities = new SecuritiesDIM[] { new SecuritiesDIM { SecurityId = 1, SecurityName = "CASH GBP", Symbol = "GBPc", AssetClassId = 4, CurrencyId = 1 }, new SecuritiesDIM { SecurityId = 2, SecurityName = "CASH EURO", Symbol = "EURc", AssetClassId = 4, CurrencyId = 2 }, new SecuritiesDIM { SecurityId = 3, SecurityName = "CASH USD", Symbol = "USDc", AssetClassId = 4, CurrencyId = 3 }, new SecuritiesDIM { SecurityId = 4, SecurityName = "CASH JPY", Symbol = "JPYc", AssetClassId = 4, CurrencyId = 4 }, new SecuritiesDIM { SecurityId = 5, SecurityName = "CASH INR", Symbol = "INRc", AssetClassId = 4, CurrencyId = 5 }, new SecuritiesDIM { SecurityId = 6, SecurityName = "CASH CHF", Symbol = "CHFc", AssetClassId = 4, CurrencyId = 6 }, new SecuritiesDIM { SecurityId = 7, SecurityName = "CASH CAD", Symbol = "CADc", AssetClassId = 4, CurrencyId = 7 }, new SecuritiesDIM { SecurityId = 8, SecurityName = "CASH AUD", Symbol = "AUDc", AssetClassId = 4, CurrencyId = 8 }, new SecuritiesDIM { SecurityId = 9, SecurityName = "BOE Base Rate", Symbol = "GBP_IRBASE", AssetClassId = 5, CurrencyId = 1 }, new SecuritiesDIM { SecurityId = 10, SecurityName = "ECB Main Refinancing Rate", Symbol = "EUR_IRBASE", AssetClassId = 5, CurrencyId = 2 }, new SecuritiesDIM { SecurityId = 11, SecurityName = "Federal Funds Rate", Symbol = "USD_IRBASE", AssetClassId = 5, CurrencyId = 3 }, new SecuritiesDIM { SecurityId = 12, SecurityName = "BOJ Mutan Rate", Symbol = "JPY_IRBASE", AssetClassId = 5, CurrencyId = 4 }, new SecuritiesDIM { SecurityId = 13, SecurityName = "BOI Repurchase Rate", Symbol = "INR_IRBASE", AssetClassId = 5, CurrencyId = 5 }, new SecuritiesDIM { SecurityId = 14, SecurityName = "SNB Policy Rate", Symbol = "CHF_IRBASE", AssetClassId = 5, CurrencyId = 6 }, new SecuritiesDIM { SecurityId = 15, SecurityName = "BOC Policy Rate", Symbol = "CAD_IRBASE", AssetClassId = 5, CurrencyId = 7 }, new SecuritiesDIM { SecurityId = 16, SecurityName = "RBA Cash Rate Target", Symbol = "AUD_IRBASE", AssetClassId = 5, CurrencyId = 8 }, new SecuritiesDIM { SecurityId = 17, SecurityName = "Apple", Symbol = "AAPL", AssetClassId = 1, CurrencyId = 3 }, new SecuritiesDIM { SecurityId = 18, SecurityName = "Microsoft Corporation", Symbol = "MSFT", AssetClassId = 1, CurrencyId = 3 }, new SecuritiesDIM { SecurityId = 19, SecurityName = "Advanced Micro Devices", Symbol = "AMD", AssetClassId = 1, CurrencyId = 3 }, new SecuritiesDIM { SecurityId = 20, SecurityName = "Bitcoin", Symbol = "BTC", AssetClassId = 2, CurrencyId = 3 }, new SecuritiesDIM { SecurityId = 21, SecurityName = "FX FWD USD/GBP 03/12/20", Symbol = "USDGBP031220", AssetClassId = 6, CurrencyId = 3 } }; NavFrequencyDIM[] SeedNavFrequencies = new NavFrequencyDIM[] { new NavFrequencyDIM { NavFrequencyId = 1, Frequency = "Daily" }, new NavFrequencyDIM { NavFrequencyId = 2, Frequency = "Monthly" } }; IssueTypesDIM[] SeedIssueTypes = new IssueTypesDIM[] { new IssueTypesDIM { IssueTypeID = 1, TypeName = "Subscription" }, new IssueTypesDIM { IssueTypeID = 2, TypeName = "Redemption" } }; CustodiansDIM[] SeedCustodians = new CustodiansDIM[] { new CustodiansDIM { CustodianId = 1, Name = "Default", Symbol = "Default" } }; context.Currencies.AddRange(SeedCurrencies); context.TransactionTypes.AddRange(SeedTransactionTypes); context.AssetClasses.AddRange(SeedAssetClasses); context.Securities.AddRange(seedSecurities); context.NavFrequencies.AddRange(SeedNavFrequencies); context.IssueTypes.AddRange(SeedIssueTypes); context.Custodians.AddRange(SeedCustodians); context.SaveChanges(); }