private List <Security> ParseSecurities(XDocument doc) { if (doc == null) { return(null); } List <Security> securities = new List <Security>(); IEnumerable <XElement> quotes = doc.Root.Descendants("finance"); foreach (var quote in quotes) { var symbol = GetAttributeData(quote, "symbol"); var exchange = GetAttributeData(quote, "exchange"); var last = GetDecimal(quote, "last"); var change = GetDecimal(quote, "change"); var percentChange = GetDecimal(quote, "perc_change"); var company = GetAttributeData(quote, "company"); //if (exchange.ToUpper() == "MUTF") //handle mutual fund if (exchange.ToUpper() == "NASDAQ") //handle mutual fund { var mf = new MutualFund(); mf.Symbol = symbol; mf.Last = last; mf.Change = change; mf.PercentChange = percentChange; mf.RetrievalDateTime = DateTime.Now; mf.Company = company; securities.Add(mf); } } return(securities); }
public async Task <ActionResult <MutualFund> > PostMutualFund(MutualFund mutualFund) { _context.MutualFunds.Add(mutualFund); await _context.SaveChangesAsync(); return(CreatedAtAction(nameof(GetMutualFund), new { schemeCode = mutualFund.SchemeCode }, mutualFund)); }
public async Task <MutualFund> GetItemAsync(string id) { MutualFund fund = FundList.FirstOrDefault(Fund => Fund.Id == id); MutualFund returnFund = CopyFund(fund); return(await Task.FromResult(returnFund)); }
public void Add(MutualFund mutualFund) { try { string clientName = DataBase.DBService.ExecuteCommandScalar(string.Format(SELECT_ID, mutualFund.Id)); DataBase.DBService.BeginTransaction(); DataBase.DBService.ExecuteCommandString(string.Format(INSERT_MutualFund, mutualFund.Pid, mutualFund.InvesterName, mutualFund.SchemeName, mutualFund.FolioNo, mutualFund.Nav, mutualFund.Units, mutualFund.EquityRatio, mutualFund.GoldRatio, mutualFund.DebtRatio, mutualFund.SIP, mutualFund.FreeUnit, mutualFund.RedumptionAmount, mutualFund.GoalID, mutualFund.CreatedOn.ToString("yyyy-MM-dd hh:mm:ss"), mutualFund.CreatedBy, mutualFund.UpdatedOn.ToString("yyyy-MM-dd hh:mm:ss"), mutualFund.UpdatedBy, mutualFund.FirstHolder, mutualFund.SecondHolder, mutualFund.Nominee, mutualFund.InvestmentReturnRate, mutualFund.CurrentValue), true); Activity.ActivitiesService.Add(ActivityType.CreateMutualFund, EntryStatus.Success, Source.Server, mutualFund.UpdatedByUserName, "MutualFund", mutualFund.MachineName); DataBase.DBService.CommitTransaction(); } catch (Exception ex) { DataBase.DBService.RollbackTransaction(); StackTrace st = new StackTrace(); StackFrame sf = st.GetFrame(0); MethodBase currentMethodName = sf.GetMethod(); LogDebug(currentMethodName.Name, ex); throw ex; } }
private static MutualFund CopyFund(MutualFund fund) { return(new MutualFund(fund.Ticker) { FundName = fund.FundName, Id = fund.Id }); }
private MutualFund convertToMutualFund(DataRow dr) { MutualFund mutualFund = new MutualFund(); mutualFund.Id = dr.Field <int>("ID"); mutualFund.Pid = dr.Field <int>("PID"); mutualFund.InvesterName = dr.Field <string>("InvesterName"); mutualFund.SchemeName = dr.Field <string>("SchemeName"); mutualFund.FolioNo = dr.Field <string>("FolioNo"); mutualFund.Nav = float.Parse(dr["NAV"].ToString()); mutualFund.Units = double.Parse(dr["units"].ToString()); mutualFund.EquityRatio = float.Parse(dr["EquityRatio"].ToString()); mutualFund.GoldRatio = float.Parse(dr["GoldRatio"].ToString()); mutualFund.DebtRatio = float.Parse(dr["DebtRatio"].ToString()); mutualFund.SIP = double.Parse(dr["SIP"].ToString()); mutualFund.FreeUnit = dr.Field <int>("FreeUnits"); mutualFund.RedumptionAmount = double.Parse(dr["RedumptionAmount"].ToString()); mutualFund.GoalID = dr.Field <int>("GoalId"); mutualFund.UpdatedBy = dr.Field <int>("UpdatedBy"); mutualFund.UpdatedOn = dr.Field <DateTime>("UpdatedOn"); mutualFund.UpdatedByUserName = dr.Field <string>("UpdatedByUserName"); mutualFund.FirstHolder = dr.Field <string>("FirstHolder"); mutualFund.SecondHolder = dr.Field <string>("SecondHolder"); mutualFund.Nominee = dr.Field <string>("Nominee"); mutualFund.InvestmentReturnRate = float.Parse(dr["InvestmentReturnRate"].ToString()); mutualFund.CurrentValue = double.Parse(dr["TotalValue"].ToString()); return(mutualFund); }
public async Task <IActionResult> PutMutualFund(string schemeCode, MutualFund mutualFund) { if (schemeCode != mutualFund.SchemeCode) { return(BadRequest()); } _context.Entry(mutualFund).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MutualFundExists(schemeCode)) { return(NotFound()); } else { throw; } } return(NoContent()); }
private void HandleLimitOrderUpdateResponse(LimitOrderUpdateResponseMessage message) { var orderWasExecuted = false; var completedLimitOrders = new List <LimitOrder>(); foreach (var sec in message.SecuritiesToCheck) { //Get all limit orders for the security being iterated var matches = LimitOrderList.Where(s => s.Ticker == sec.Ticker); foreach (var match in matches) { var securityType = match.SecurityType; var isActive = match.IsLimitOrderActive(sec.LastPrice); if (isActive && match.TradeType == "Sell" && securityType is Stock) { var securityToTrade = new Stock("", sec.Ticker, sec.Description, sec.LastPrice, sec.Yield); var newTrade = new Trade(match.TradeType, securityToTrade, match.Ticker, match.Shares, "Limit", match.Limit, match.OrderDuration); SellPosition(newTrade); completedLimitOrders.Add(match); orderWasExecuted = true; } else if (isActive && match.TradeType == "Buy" && securityType is Stock) { var securityToTrade = new Stock("", sec.Ticker, sec.Description, sec.LastPrice, sec.Yield); var newTrade = new Trade(match.TradeType, securityToTrade, match.Ticker, match.Shares, "Limit", match.Limit, match.OrderDuration); AddPosition(newTrade); completedLimitOrders.Add(match); orderWasExecuted = true; } else if (isActive && match.TradeType == "Sell" && securityType is MutualFund) { var securityToTrade = new MutualFund("", sec.Ticker, sec.Description, sec.LastPrice, sec.Yield); var newTrade = new Trade(match.TradeType, securityToTrade, match.Ticker, match.Shares, "Limit", match.Limit, match.OrderDuration); SellPosition(newTrade); completedLimitOrders.Add(match); orderWasExecuted = true; } else if (isActive && match.TradeType == "Buy" && securityType is MutualFund) { var securityToTrade = new MutualFund("", sec.Ticker, sec.Description, sec.LastPrice, sec.Yield); var newTrade = new Trade(match.TradeType, securityToTrade, match.Ticker, match.Shares, "Limit", match.Limit, match.OrderDuration); AddPosition(newTrade); completedLimitOrders.Add(match); orderWasExecuted = true; } } } foreach (var order in completedLimitOrders) { LimitOrderList.Remove(order); } if (orderWasExecuted) { Messenger.Default.Send <LimitOrderMessage>(new LimitOrderMessage(_limitOrderList, false)); } }
public Asset(int assetId, string assetCode, MutualFund mutualFund) { defaultValues(); AssetId = assetId; AssetCode = assetCode; MutualFund = mutualFund; }
public void ShouldBeAbleToUpdateInstrumentCurrentPrice() { Instrument instrument = new MutualFund(new Symbol("SUN"), new Price(1000), "Sun MF", "SUNMF", "SUN Magma", "Growth"); var four = new Price(4); instrument.UpdateCurrentPrice(four); Assert.AreEqual(four, instrument.CurrentPrice); }
public IList <MutualFund> GetAll(int plannerId) { try { Logger.LogInfo("Get: Mutual fund process start"); IList <MutualFund> lstMutualFundOption = new List <MutualFund>(); DataTable dtAppConfig = DataBase.DBService.ExecuteCommand(string.Format(SELECT_ALL, plannerId)); foreach (DataRow dr in dtAppConfig.Rows) { MutualFund mf = convertToMutualFund(dr); lstMutualFundOption.Add(mf); } Logger.LogInfo("Get: Mutual fund process completed."); return(lstMutualFundOption); } catch (Exception ex) { StackTrace st = new StackTrace(); StackFrame sf = st.GetFrame(0); MethodBase currentMethodName = sf.GetMethod(); LogDebug(currentMethodName.Name, ex); return(null); } }
static void Main(string[] args) { var mutualFund = new MutualFund(1234567); mutualFund.Buy("AAPL", 10); Console.ReadKey(); }
public UnitTest1() { MockFund = new MutualFund("vfiax") { Id = "0", FundName = "Vanguard", }; }
/// <summary> /// This Will calculate the networth of the Client based on the number of stocks and mutual Funds he has. /// </summary> /// <param name="pd"></param> /// <returns></returns> /// public async Task <NetWorth> calculateNetWorthAsync(PortFolioDetails portFolioDetails) { Stock stock = new Stock(); MutualFund mutualfund = new MutualFund(); NetWorth networth = new NetWorth(); _log4net.Info("Calculating the networth in the repository method of user with id = " + portFolioDetails.PortFolioId); try { using (var httpClient = new HttpClient()) { var fetchStock = configuration["GetStockDetails"]; var fetchMutualFund = configuration["GetMutualFundDetails"]; if (portFolioDetails.StockList != null && portFolioDetails.StockList.Any() == true) { foreach (StockDetails stockDetails in portFolioDetails.StockList) { if (stockDetails.StockName != null) { using (var response = await httpClient.GetAsync(fetchStock + stockDetails.StockName)) { _log4net.Info("Fetching the details of stock " + stockDetails.StockName + "from the stock api"); string apiResponse = await response.Content.ReadAsStringAsync(); stock = JsonConvert.DeserializeObject <Stock>(apiResponse); _log4net.Info("Th stock details are " + JsonConvert.SerializeObject(stock)); } networth.Networth += stockDetails.StockCount * stock.StockValue; } } } if (portFolioDetails.MutualFundList != null && portFolioDetails.MutualFundList.Any() == true) { foreach (MutualFundDetails mutualFundDetails in portFolioDetails.MutualFundList) { if (mutualFundDetails.MutualFundName != null) { using (var response = await httpClient.GetAsync(fetchMutualFund + mutualFundDetails.MutualFundName)) { _log4net.Info("Fetching the details of mutual Fund " + mutualFundDetails.MutualFundName + "from the MutualFundNAV api"); string apiResponse = await response.Content.ReadAsStringAsync(); mutualfund = JsonConvert.DeserializeObject <MutualFund>(apiResponse); _log4net.Info("The mutual Fund Details are" + JsonConvert.SerializeObject(mutualfund)); } networth.Networth += mutualFundDetails.MutualFundUnits * mutualfund.MutualFundValue; } } } } networth.Networth = Math.Round(networth.Networth, 2); } catch (Exception ex) { _log4net.Error("Exception occured while calculating the networth of user" + portFolioDetails.PortFolioId + ":" + ex.Message); } return(networth); }
private async void OnItemTapped(object sender, ItemTappedEventArgs args) { if (args is null) { throw new ArgumentNullException(nameof(args)); } MutualFund fund = args.Item as MutualFund; await Navigation.PushAsync(new ItemDetailPage(new ItemDetailViewModel(fund))); }
public void ShouldPersistMutualFund() { var fourThousand = new Price(4000); Instrument instrument = new MutualFund(new Symbol("SUN"), fourThousand, "Sun MF", "SUNMF", "SUN Magma", "Growth"); repository.Save(instrument); var lookedUpObject = repository.Lookup<Instrument>(instrument.Id); Assert.AreEqual(new Price(4000), lookedUpObject.CurrentPrice); }
public void ShouldDeleteMutualFund() { var fourThousand = new Price(4000); Instrument instrument = new MutualFund(new Symbol("SUN"), fourThousand, "Sun MF", "SUNMF", "SUN Magma", "Growth"); repository.Delete(instrument); var lookedUpObject = repository.Lookup<Instrument>(instrument.Id); Assert.IsNull(lookedUpObject); }
public ItemDetailPage() { MutualFund holderFund = new MutualFund("MockFund") { FundName = "Holder Fund", Id = "0" }; InitializeComponent(); BindingContext = ViewModel = new ItemDetailViewModel(holderFund); }
public async Task <string> AddItemAsync(MutualFund fund) { lock (this) { fund.Id = nextFundId.ToString(); FundList.Add(fund); nextFundId++; } return(await Task.FromResult(fund.Id)); }
public bool Update(EditMutualFundVm editMutualFundVm, MutualFund mutualFund) { if (editMutualFundVm.Id == mutualFund.Id) { mutualFund.Symbol = editMutualFundVm.Symbol; mutualFund.Title = editMutualFundVm.Title; return MutualRepository.UpdateMutualFund(mutualFund).OperationSuccessStatus; } return false; }
public bool Update(EditMutualFundVm editMutualFundVm, MutualFund mutualFund) { if (editMutualFundVm.Id == mutualFund.Id) { mutualFund.Symbol = editMutualFundVm.Symbol; mutualFund.Title = editMutualFundVm.Title; return(MutualRepository.UpdateMutualFund(mutualFund).OperationSuccessStatus); } return(false); }
private List <Security> ParseSecurities(XDocument doc) { if (doc == null) { return(null); } List <Security> securities = new List <Security>(); IEnumerable <XElement> quotes = doc.Root.Descendants("finance"); foreach (var quote in quotes) { var symbol = GetAttributeData(quote, "symbol"); var exchange = GetAttributeData(quote, "exchange"); var last = GetDecimal(quote, "last"); var change = GetDecimal(quote, "change"); var percentChange = GetDecimal(quote, "perc_change"); var company = GetAttributeData(quote, "company"); if (exchange.ToUpper() == "MUTF") //Handle mutual fund { var mf = new MutualFund(); mf.Symbol = symbol; mf.Last = last; mf.Change = change; mf.PercentChange = percentChange; mf.RetrievalDateTime = DateTime.Now; mf.Company = company; securities.Add(mf); } else //Handle stock { var stock = new Stock(); stock.Symbol = symbol; stock.Last = last; stock.Change = change; stock.PercentChange = percentChange; stock.RetrievalDateTime = DateTime.Now; stock.Company = company; stock.Exchange = new Exchange { Title = exchange }; stock.DayHigh = GetDecimal(quote, "high"); stock.DayLow = GetDecimal(quote, "low"); stock.Volume = GetDecimal(quote, "volume"); stock.AverageVolume = GetDecimal(quote, "avg_volume"); stock.MarketCap = GetDecimal(quote, "market_cap"); stock.Open = GetDecimal(quote, "open"); securities.Add(stock); } } return(securities); }
/// <summary> /// Calculates the networth based on the details provided in the portfolio object /// </summary> /// <param name="portFolio"></param> /// <returns></returns> public async Task <NetWorth> calculateNetWorth(PortFolioDetails portFolio) { try { NetWorth _networth = new NetWorth(); Stock stock = new Stock(); MutualFund mutualFund = new MutualFund(); double networth = 0; using (var httpClient = new HttpClient()) { var fetchStock = configuration["GetStockDetails"]; var fetchMutualFund = configuration["GetMutualFundDetails"]; if (portFolio.StockList != null || portFolio.MutualFundList.Any() != false) { foreach (StockDetails stockDetails in portFolio.StockList) { using (var response = await httpClient.GetAsync(fetchStock + stockDetails.StockName)) { _log4net.Info("Fetching the details of stock " + stockDetails.StockName + " from the stock api"); string apiResponse = await response.Content.ReadAsStringAsync(); stock = JsonConvert.DeserializeObject <Stock>(apiResponse); } networth += stockDetails.StockCount * stock.StockValue; } } if (portFolio.MutualFundList != null || portFolio.MutualFundList.Any() != false) { foreach (MutualFundDetails mutualFundDetails in portFolio.MutualFundList) { using (var response = await httpClient.GetAsync(fetchMutualFund + mutualFundDetails.MutualFundName)) { _log4net.Info("Fetching the details of stock " + mutualFundDetails.MutualFundName + " from the stock api"); string apiResponse = await response.Content.ReadAsStringAsync(); mutualFund = JsonConvert.DeserializeObject <MutualFund>(apiResponse); } networth += mutualFundDetails.MutualFundUnits * mutualFund.MutualFundValue; } } } networth = Math.Round(networth, 2); _networth.Networth = networth; return(_networth); } catch (Exception ex) { _log4net.Error("An exception occured while selling the assets:" + ex.Message); return(null); } }
public MockFunds() { MockFund1 = new MutualFund("vfiax") { Id = "0", FundName = "Vanguard", }; MockFund2 = new MutualFund("fcntx") { Id = "1", FundName = "Fidelity", }; }
public void TestListTransactionsByInstrumentId() { var hundredRuppees = new Price(100); var relianceMutuals = new Symbol("RELTICK"); Instrument instrument = new MutualFund(relianceMutuals, hundredRuppees, "Test Fund", "SUNMF", "SUN Magma", "Growth"); repository.Save(instrument); Transaction buyTransaction = new BuyTransaction(DateTime.Now, instrument, 10, new Price(1000), 100, 100); repository.Save(buyTransaction); IList<Transaction> translist=repository.ListTransactionsByInstrumentId<Transaction>(instrument.Id); Assert.AreEqual(1,repository.ListTransactionsByInstrumentId<Transaction>(instrument.Id).Count); }
public void ShouldCreateCashDividendTransactionForMutualFund() { var firstOfJan2008 = new DateTime(2008, 1, 1); var selectedMutualFund = new MutualFund(null, null, null, "SUNMF", "SUN Magma", "Growth"); DividendTransaction expectedTransaction = new CashDividendTransaction(selectedMutualFund, new Price(100), firstOfJan2008); CashDividendTransaction actualTransaction = selectedMutualFund.CreateCashDividendTransaction(new Price(100), firstOfJan2008); Assert.AreEqual(expectedTransaction.UnitPrice, actualTransaction.UnitPrice); Assert.AreEqual(expectedTransaction.Instrument, actualTransaction.Instrument); Assert.AreEqual(expectedTransaction.Date, actualTransaction.Date); }
public void TestListAllSymbols() { var hundredRuppees = new Price(100); var relianceMutuals = new Symbol("RELTICK"); Instrument instrument = new MutualFund(relianceMutuals, hundredRuppees, "Test Fund", "SUNMF", "SUN Magma", "Growth"); repository.Save(instrument); IList<Symbol> list = repository.ListAllSymbols<Symbol>(); Assert.AreEqual(1,list.Count); Assert.AreEqual("RELTICK",list[0].Value); }
public int Create(AddMutualFundVm addMutualFundVm) { var mutualFund = new MutualFund() { Title = addMutualFundVm.Title, Symbol = addMutualFundVm.Symbol, }; DbOperationStatus opStatus = MutualRepository.InsertMutualFund(mutualFund); if (opStatus.OperationSuccessStatus) { return opStatus.AffectedIndices.First(); } return -1; }
public IList <MutualFund> getListFund() { return(MutualFund.List(iSabayaContext)); //List<MutualFund> listFunds = new List<MutualFund>(); //IList<MutualFund> Funds = new List<MutualFund>(); //if (IsFillterSellingAgent) //{ // foreach (PersonOrgRelation employer in this.User.Person.FindCurrentEmployments(iSabaya.Context)) // { // if (employer.Organization == iSabayaContext.SystemOwnerOrg) // { // Funds = ComplicatedListFunds(); // break; // } // else // { // Funds = FundSellingAgent.ListFunds(iSabaya.Context, employer.Organization); // } // } //} //else //{ // Funds = ComplicatedListFunds(); //} //if (TransactionTypeCode != "") //{ // if (Funds.Count > 0) // { // foreach (MutualFund item in Funds) // { // if (item.GetTransactionType(TransactionType.FindByCode(iSabaya.Context, TransactionTypeCode), DateTime.Now) != null) // listFunds.Add(item); // } // } //} //else //{ // if (Funds.Count > 0) // { // listFunds = new List<MutualFund>(Funds); // } //} //if (listFunds.Count > 0) //{ // listFunds.Sort((x, y) => string.Compare(x.Code, y.Code)); //} //return listFunds; }
public void ShouldCreateUnitDividendTransactionForMutualFund() { var firstOfJan2008 = new DateTime(2008, 1, 1); var selectedMutualFund = new MutualFund(null, null, null, "SUNMF", "SUN Magma", "Growth"); var expectedTransaction = new UnitDividendTransaction(selectedMutualFund, 100, firstOfJan2008); UnitDividendTransaction actualTransaction = selectedMutualFund.CreateUnitDividendTransaction(100, firstOfJan2008); Assert.AreEqual(expectedTransaction.Quantity, actualTransaction.Quantity); Assert.AreEqual(expectedTransaction.Instrument, actualTransaction.Instrument); Assert.AreEqual(expectedTransaction.Date, actualTransaction.Date); }
public void ShouldIncludeUnitDividendWhileGettingCurrentMarketValueOfInstrument() { Instrument instrument = new MutualFund(new Symbol("RILMF"), new Price(100.00), "Reliance Mutual Fund", "SUNMF", "SUN Magma", "Growth"); Transaction transaction1 = new BuyTransaction(new DateTime(2009, 09, 09), instrument, 10, new Price(100.00), 10, 10); Transaction transaction2 = new SellTransaction(new DateTime(2009, 09, 10), instrument, 5, new Price(200.00), 10, 10); Transaction transaction3 = new UnitDividendTransaction(instrument, 5, new DateTime(2009, 09, 10)); List<Transaction> listTransaction = new List<Transaction>(); listTransaction.Add(transaction1); listTransaction.Add(transaction2); Assert.AreEqual(500.00, instrument.CurrentMarketValue(listTransaction).Value); listTransaction.Add(transaction3); Assert.AreEqual(1000.00, instrument.CurrentMarketValue(listTransaction).Value); }
public int Create(AddMutualFundVm addMutualFundVm) { var mutualFund = new MutualFund() { Title = addMutualFundVm.Title, Symbol = addMutualFundVm.Symbol, }; DbOperationStatus opStatus = MutualRepository.InsertMutualFund(mutualFund); if (opStatus.OperationSuccessStatus) { return(opStatus.AffectedIndices.First()); } return(-1); }
/*ใช้ในหน้าสรุปซื้อขาย เรียกจาก ObjectDatasource*/ public static IList <VOTransactionSelect_GridTransaction> List( imSabayaContext context, int fundId, int accountId, DateTime date, int transactionTypeId, int sellingAgentId, int orgUnitId ) { ICriteria crit = context.PersistencySession.CreateCriteria(typeof(MFTransaction)); crit.Add(Expression.Eq("Fund", (Fund)MutualFund.Find(context, fundId))) //.Add(Expression.Eq("RollbackStatus", (byte)0)) .CreateAlias("CurrentState", "currentState") .CreateAlias("CurrentState.State", "state") .Add(Expression.Eq("state.Code", "Released")); if (accountId != 0) { crit.Add(Expression.Eq("Portfolio", MFAccount.Find(context, accountId))); } if (transactionTypeId != 0) { crit.Add(Expression.Eq("Type", InvestmentTransactionType.Find(context, transactionTypeId))); } if (date != DateTime.MinValue) { DateTime minOfToday = date.Date; DateTime maxOfToday = date.Date.AddDays(1).Date.AddMilliseconds(-1); crit.Add(Expression.Between("TransactionTS", minOfToday, maxOfToday)); } if (sellingAgentId != 0) { crit.Add(Expression.Eq("SellingAgent", Organization.Find(context, sellingAgentId))); } IList <MFTransaction> list = crit.List <MFTransaction>(); IList <VOTransactionSelect_GridTransaction> vos = new List <VOTransactionSelect_GridTransaction>(); foreach (MFTransaction tran in list) { vos.Add(new VOTransactionSelect_GridTransaction(context, tran)); } return(vos); }
private async void OnItemSelected(object sender, SelectedItemChangedEventArgs args) { if (sender is null || args is null) { throw new ArgumentNullException(nameof(sender), nameof(args)); } MutualFund fund = args.SelectedItem as MutualFund; if (fund is null) { return; } await Navigation.PushAsync(new ItemDetailPage(new ItemDetailViewModel(fund))); // Manually deselect item. ItemsListView.SelectedItem = null; }
public Result Delete(MutualFund mf) { var result = new Result(); try { MutualFundService mutualFundService = new MutualFundService(); mutualFundService.Delete(mf); result.IsSuccess = true; } catch (Exception exception) { result.IsSuccess = false; result.ExceptionInfo = exception; } return(result); }
public void ShouldUpdateQuantityOnAdditionOfUnitDividend() { Portfolio d = new Portfolio(); TransactionCollection ts = new TransactionCollection(); var selectedMutualFund = new MutualFund(null, null, null, "SUNMF", "SUN Magma", "Growth"); ts.Add(new BuyTransaction(new DateTime(1999, 3, 20), selectedMutualFund, 10, new Price(1200), 1000, 0)); ts.Add(new SellTransaction(new DateTime(1999, 5, 20), selectedMutualFund, 5, new Price(1300), 0, 1000)); ts.Add(new UnitDividendTransaction(selectedMutualFund, 2, new DateTime(1999, 5, 20))); int actualQty = 0; foreach (Transaction transaction in ts.TransactionList) { actualQty += transaction.EffectiveTransactionQuantity(); } Assert.AreEqual(7, actualQty); }
public void TestLookupAfterSave() { var hundredRuppees = new Price(100); var relianceMutuals = new Symbol("RELTICK"); Instrument instrument = new MutualFund(relianceMutuals, hundredRuppees, "Test Fund", "SUNMF", "SUN Magma", "Growth"); repository.Save(instrument); var actual = repository.Lookup<Instrument>(instrument.Id); Assert.AreEqual(typeof(MutualFund), actual.GetType()); Instrument expectedMutualFund = new MutualFund(relianceMutuals, hundredRuppees, "Test Fund", "SUNMF", "SUN Magma", "Growth") {Id = actual.Id}; Assert.AreEqual(expectedMutualFund, actual); Assert.AreNotEqual(0, instrument.Id); Assert.True(instrument.Id > 0); }
private Security CreateNewSecurity(YahooAPIResult yahooResult) { var determinedType = DetermineIfStockOrFund(yahooResult); if (determinedType == "Stock") { yahooResult.MarketCap = yahooResult.MarketCap.Substring(0, yahooResult.MarketCap.Length - 1); var newStock = new Stock(yahooResult); return(newStock); } if (determinedType == "Mutual Fund") { var newFund = new MutualFund(yahooResult); return(newFund); } return(new Security("", "N/A", "Unknown Ticker", 0, 0.00)); }
// public PostCompareOverlapViewModelV2 ViewModel { get; set; } public PostCompareUnitTest() { MockFundOne = new MutualFund("vfiax") { Id = "0", FundName = "Vanguard", // Ticker = "vfiax", }; MockFundTwo = new MutualFund("fcntx") { Id = "1", FundName = "Fidelity", // Ticker = "fcntx" }; Comparer = new ListBasedCompare(MockFundOne.AssetList, MockFundTwo.AssetList); // ViewModel = new PostCompareOverlapViewModelV2(MockFundOne, MockFundTwo); }
internal bool Update(MutualFund mutualFund) { try { FinancialPlanner.Common.JSONSerialization jsonSerialization = new FinancialPlanner.Common.JSONSerialization(); string apiurl = Program.WebServiceUrl + "/" + UPDATE_MUTUALFUND_API; RestAPIExecutor restApiExecutor = new RestAPIExecutor(); var restResult = restApiExecutor.Execute <MutualFund>(apiurl, mutualFund, "POST"); return(true); } catch (Exception ex) { StackTrace st = new StackTrace(); StackFrame sf = st.GetFrame(0); MethodBase currentMethodName = sf.GetMethod(); LogDebug(currentMethodName.Name, ex); return(false); } }
//private List<PortFolioDetails> _portFolioDetails; /// <summary> /// This Will calculate the networth of the Client using the number of stoks and mutual funds he has. /// </summary> /// <param name="pd"></param> /// <returns></returns> /// public async Task <NetWorth> calculateNetWorthAsync(PortFolioDetails portFolioDetails) { //PortFolioDetails simp = _portFolioDetails.FirstOrDefault(exec => exec.PortFolioId == id); Stock st = new Stock(); MutualFund mf = new MutualFund(); //double networth = 0; NetWorth networth = new NetWorth(); PortFolioDetails pd = portFolioDetails; _log4net.Info("Calculating the networth in the repository method"); using (var httpClient = new HttpClient()) { if (pd.StockList != null) { foreach (StockDetails x in pd.StockList) { using (var response = await httpClient.GetAsync("http://localhost:58451/api/Stock/" + x.StockName)) { string apiResponse = await response.Content.ReadAsStringAsync(); st = JsonConvert.DeserializeObject <Stock>(apiResponse); } networth.Networth += x.StockCount * st.StockValue; } } if (pd.MutualFundList != null) { foreach (MutualFundDetails x in pd.MutualFundList) { using (var response = await httpClient.GetAsync("https://localhost:55953/api/MutualFundNAV/" + x.MutualFundName)) { string apiResponse = await response.Content.ReadAsStringAsync(); mf = JsonConvert.DeserializeObject <MutualFund>(apiResponse); } networth.Networth += x.MutualFundUnits * mf.MValue; } } } networth.Networth = Math.Round(networth.Networth, 2); return(networth); }
public async Task <NetWorth> calculateNetWorth(PortFolioDetails pd) { NetWorth _networth = new NetWorth(); Stock st = new Stock(); MutualFund mf = new MutualFund(); double networth = 0; using (var httpClient = new HttpClient()) { if (pd.StockList != null) { foreach (StockDetails x in pd.StockList) { using (var response = await httpClient.GetAsync("http://localhost:58451/api/Stock/" + x.StockName)) { string apiResponse = await response.Content.ReadAsStringAsync(); st = JsonConvert.DeserializeObject <Stock>(apiResponse); } networth += x.StockCount * st.StockValue; } } if (pd.MutualFundList != null) { foreach (MutualFundDetails x in pd.MutualFundList) { using (var response = await httpClient.GetAsync("https://localhost:44394/api/MutualFund/" + x.MutualFundName)) { string apiResponse = await response.Content.ReadAsStringAsync(); mf = JsonConvert.DeserializeObject <MutualFund>(apiResponse); } networth += x.MutualFundUnits * mf.MValue; } } } networth = Math.Round(networth, 2); _networth.Networth = networth; return(_networth); }
public void TestLookupBySymbol() { var hundredRuppees = new Price(100); var relianceMutuals = new Symbol("RELTICK"); Instrument instrument = new MutualFund(relianceMutuals, hundredRuppees, "Test Fund", "SUNMF", "SUN Magma", "Growth"); repository.Save(instrument); var symbol = new Symbol("RELTICK"); Instrument resultInstrument = repository.LookupBySymbol<Instrument>(symbol); Assert.AreEqual(instrument, resultInstrument); }
public void ShouldIncludeUnitDividendSoldInRealizedProfit() { Portfolio d = new Portfolio(); TransactionCollection ts = new TransactionCollection(); var selectedMutualFund = new MutualFund(null, null, null, "SUNMF", "SUN Magma", "Growth"); int buyUnitPrice = 1200; int buyBrokerage = 100; int sellBrokerage = 100; int buyQuantity = 10; int sellQuantity = 10; ts.Add(new BuyTransaction(new DateTime(1999, 3, 20), selectedMutualFund, buyQuantity, new Price(buyUnitPrice), buyBrokerage, 0)); int sellUnitPrice = 1300; ts.Add(new SellTransaction(new DateTime(1999, 5, 20), selectedMutualFund, 5, new Price(sellUnitPrice), 0, sellBrokerage)); int unitReceived = 2; ts.Add(new UnitDividendTransaction(selectedMutualFund, unitReceived, new DateTime(1999, 5, 20))); ts.Add(new SellTransaction(new DateTime(1999, 5, 20), selectedMutualFund, 7, new Price(sellUnitPrice), 0, sellBrokerage)); Assert.AreEqual((sellUnitPrice - buyUnitPrice) * sellQuantity - buyBrokerage - sellBrokerage + sellUnitPrice * unitReceived - sellBrokerage, d.CalculateRealizedProfits(ts)); }
public void TestSave() { var hundredRuppees = new Price(100); var relianceMutuals = new Symbol("RELTICK"); Instrument instrument = new MutualFund(relianceMutuals, hundredRuppees, "Test Fund", "SUNMF", "SUN Magma", "Growth"); Assert.AreEqual(0, instrument.Id); repository.Save(instrument); Assert.AreNotEqual(0, instrument.Id); Assert.IsNotNull(instrument.Id); }