public double calcStockGrade(Stock s, double investedMoney, List <double> ARList, List <double> earnLossList, History history, int roundNum, Comission comm) { double earningProbability = 1.0 / s.getEarningsCount(); List <double> earnings = s.getEarnings(); double sum = 0; List <HistoryRecord> investmentsRecords = history.getInvestmentsHistory(); double currTotalMoney = investmentsRecords[investmentsRecords.Count - 1]._currMoney; foreach (double earning in earnings) { earnLossList.Add(earning); double earnMoney = (1 + earning) * investedMoney; double commissionPercent = comm.takeCommision(investedMoney, earning).Item2; double commissionMoney = comm.takeCommision(investedMoney, earning).Item1; double endInvestmentMoney = earnMoney - commissionMoney; double endMoney = currTotalMoney - investedMoney + endInvestmentMoney; InvestmentData investmentData = new InvestmentData(s._id, investedMoney, earning, earnMoney, commissionMoney, commissionPercent, endInvestmentMoney); history.addRecord(new HistoryRecord(investmentData, currTotalMoney, endMoney, roundNum)); double expectedAdoptionRate = _predictor.predict(endMoney, roundNum + 1, history); sum += expectedAdoptionRate * earningProbability; // sum += (currTotalMoney - investedMoney + investedMoney * (1 + earning)) * expectedAdoptionRate * earningProbability; } return(sum); }
public InvestmentDataProvider() { for (int i = 0; i < 10; i++) { InvestmentData temp = new InvestmentData(); temp.userName = "******" + i; temp.invId = i; temp.invName = "Investment" + i; Random random = new Random(); temp.numShares = random.Next(1, 10); temp.costBasisPerShare = random.Next(10, 100); temp.currentPrice = random.Next(10, 100); temp.currentValue = temp.numShares * temp.currentPrice; int term = random.Next(0, 1); if (term == 0) { temp.term = "short"; } else { temp.term = "long"; } temp.totalGainLoss = temp.currentValue - (temp.numShares * temp.costBasisPerShare); investmentData.Add(temp); } }
public static InvestmentData GetInvestmentDataFromDataSource(int recordId) { DataRow ukAllData = MyExcel.GetDetails("i", recordId); InvestmentData data = new InvestmentData() { id = int.Parse(ukAllData[5].ToString()), ProjectName = ukAllData[2].ToString(), Otrasl = ukAllData[7].ToString(), Region = ukAllData[9].ToString(), Description = ukAllData[42].ToString(), InvestmentVolume = ukAllData[13].ToString(), Stage = ukAllData[14].ToString(), Round = ukAllData[53].ToString(), DealType = ukAllData[18].ToString(), InvestorName = ukAllData[55].ToString(), InvestorType = ukAllData[57].ToString(), Sindicated = ukAllData[16].ToString(), FollowOn = ukAllData[15].ToString(), }; return(data); }
override public InvestmentData Invest(double money, History hist, int roundNum) { checkIfInitilized(); InvestmentData result = makeInvestment(money, roundNum, getRandomStock(), _isTrain); return(result); }
public IEnumerable <object> UserStocks(string userId) { if (string.IsNullOrEmpty(userId)) { throw new Exception("User not Specified"); } if (_isUnitTest) { return(_stocks); } int.TryParse(userId, out var clientId); return(InvestmentData.GetUserStocks(clientId)); }
public void PlaceInvestment(long InvestmentAmount, long ReturnAmount, int DaysDuration, SchemeInfo.RiskTypes Risk) { TheRunGameManager.Instance.GameData.Data.Profile.SubtractMoney(InvestmentAmount); InvestmentData Data = new InvestmentData(); Data.FinishTime = DateTime.Now + TimeSpan.FromDays(DaysDuration); Data.InvestmentAmount = InvestmentAmount; Data.ReturnAmount = ReturnAmount; Data.Risk = Risk; TheRunGameManager.Instance.GameData.Data.Profile.Investments.Add(Data); TheRunGameManager.Instance.GameData.Save(); }
public ActionResult Investment(int id) { //var tableName = "i"; //DataRow row = MyExcel.GetDetails(tableName, id); //var fundsTmp = MyExcel.GetDetailsList("fi", $"[Номер инвестиции]='{id}'"); //var fundsIds = String.Join(", ", fundsTmp.Select(x => $"'{x["Funds.Id"]}'").ToArray()); //fundsIds = fundsIds != "" ? fundsIds : "NULL"; //var funds = MyExcel.GetDetailsList("f_2", $"[Id] In ({fundsIds})"); //ViewBag.funds = funds; InvestmentData data = MyExcel.GetInvestmentDataFromDataSource(id); return(View(data)); }
public IInvestment UserStocksByStock(string userId, string investmentId) { if (string.IsNullOrEmpty(userId)) { throw new Exception("User not Specified"); } if (string.IsNullOrEmpty(investmentId)) { throw new Exception("Stock not Specified"); } int.TryParse(userId, out var clientId); int.TryParse(investmentId, out var investmentNumber); if (_isUnitTest) { return(_stocks.Find(stock => stock.Id.Equals(investmentId))); } return(InvestmentData.GetUserStocks(clientId, investmentNumber)); }
/// <summary> /// Displays the item information and item data information /// for the given investment itemSummary. /// </summary> /// <param name="itemSummary">an itemSummary whose containerType is 'stocks'</param> public void displayInvestmentDataForItem(ItemSummary itemSummary) { System.Console.WriteLine(""); String containerType = itemSummary.contentServiceInfo.containerInfo.containerName; if (!containerType.Equals(ContainerTypes.INVESTMENT)) { throw new Exception("DisplayInvestmentDataForItem called with invalid container type" + containerType); } DisplayItemInfo displayItemInfo = new DisplayItemInfo(); displayItemInfo.displayItemSummaryInfo(itemSummary); // Get ItemData ItemData1 itemData = itemSummary.itemData; if (itemData == null) { System.Console.WriteLine("\tItemData is null"); } else { // InvestmentData object[] accounts = itemData.accounts; if (accounts == null || accounts.Length == 0) { System.Console.WriteLine("\tNo accounts"); } else { System.Console.WriteLine("\n\t\t**InvestmentData**"); for (int i = 0; i < accounts.Length; i++) { InvestmentData investment = (InvestmentData)accounts[i]; System.Console.WriteLine("\t\tAccount Name: " + investment.accountName); System.Console.WriteLine("\t\tAccount Number: " + investment.accountNumber); System.Console.WriteLine("\t\tAccount Holder: " + investment.accountHolder); System.Console.WriteLine("\t\tAccount Type: " + investment.acctType); System.Console.WriteLine("\t\tCash: " + investment.cash); System.Console.WriteLine("\t\tTotal Balance: " + investment.totalBalance.amount); System.Console.WriteLine("\t\tTotal Vested Balance: " + investment.totalVestedBalance.amount); System.Console.WriteLine("\t\tTotal Unvested Balance: " + investment.totalUnvestedBalance.amount); System.Console.WriteLine("\t\tMargin Balance: " + investment.marginBalance.amount); System.Console.WriteLine("\t\tlastUpdated: " + UtcToDateTime(investment.lastUpdated.Value)); // HoldingData object[] holdings = investment.holdings; if (holdings == null || holdings.Length == 0) { System.Console.WriteLine("\t\tNo investment holdings."); } else { System.Console.WriteLine("\t\t\t**HoldingData**"); for (int j = 0; j < holdings.Length; j++) { HoldingData holding = (HoldingData)holdings[j]; System.Console.WriteLine("\t\t\tHoldingData Symbol: " + holding.symbol); System.Console.WriteLine("\t\t\tHoldingData Quantity: " + holding.quantity); System.Console.WriteLine("\t\t\tHoldingData Value: " + holding.value.amount); System.Console.WriteLine("\t\t\tHoldingData Description: " + holding.description); System.Console.WriteLine("\t\t\tHoldingData Price: " + holding.price.amount); System.Console.WriteLine("\t\t\tHoldingData Link: " + holding.link); System.Console.WriteLine("\t\t\tHoldingData HoldingType: " + holding.holdingType); System.Console.WriteLine("\t\t\tHoldingData HoldingTypeId: " + holding.holdingTypeId); System.Console.WriteLine("\t\t\tHoldingData Percentage Allocaton: " + holding.percentAllocation); System.Console.WriteLine("\t\t\tHoldingData Percantage Change: " + holding.percentageChange); System.Console.WriteLine("\t\t\tHoldingData Employee Contribution: " + holding.employeeContribution); System.Console.WriteLine("\t\t\tHoldingData Employeer Contribution: " + holding.employerContribution); System.Console.WriteLine("\t\t\tHoldingData Cusip Number: " + holding.cusipNumber); System.Console.WriteLine("\t\t\tHoldingData Daily Change: " + holding.dailyChange); System.Console.WriteLine("\t\t\tHoldingData Cost Basis: " + holding.costBasis.amount + "\n"); // TaxLots object[] taxLots = holding.taxLots; if (taxLots == null || taxLots.Length == 0) { System.Console.WriteLine("\t\t\tNo holdings taxLots"); } else { System.Console.WriteLine("\t\t\t\t**TaxLot**"); for (int u = 0; u < taxLots.Length; u++) { TaxLot taxLot = (TaxLot)taxLots[u]; System.Console.WriteLine("\t\t\t\tTaxLot Symbol: " + taxLot.symbol); System.Console.WriteLine("\t\t\t\tTaxLot Description: " + taxLot.description); System.Console.WriteLine("\t\t\t\tTaxLot Quantity: " + taxLot.quantity); System.Console.WriteLine("\t\t\t\tTaxLot Amount: " + taxLot.amount.amount); System.Console.WriteLine("\t\t\t\tTaxLot Price: " + taxLot.price.amount); System.Console.WriteLine("\t\t\t\tTaxLot Link: " + taxLot.link); System.Console.WriteLine("\t\t\t\tTaxLot Cusip Number: " + taxLot.cusipNumber + "\n"); } } // End TaxLot } } // End HoldingData // InvestmentTransactionData object[] investTransactions = investment.investmentTransactions; if (investTransactions == null || investTransactions.Length == 0) { System.Console.WriteLine("\t\tNo investment tranactions"); } else { System.Console.WriteLine("\t\t\t**InvestmentTransactionsData**"); for (int j = 0; j < investTransactions.Length; j++) { InvestmentTransactionsData trans = (InvestmentTransactionsData)investTransactions[j]; System.Console.WriteLine("\t\t\tTranaction.symbol: " + trans.symbol); System.Console.WriteLine("\t\t\tTranaction.amount: " + trans.amount.amount); System.Console.WriteLine("\t\t\tTranaction.price : " + trans.price.amount); System.Console.WriteLine("\t\t\tTranaction.quantity : " + trans.quantity); System.Console.WriteLine("\t\t\tTranaction.transDate : " + trans.transDate.date); System.Console.WriteLine("\t\t\tTransaction.description: " + trans.description); System.Console.WriteLine("\t\t\tTranaction.link : " + trans.link); System.Console.WriteLine("\t\t\tTranaction.transactionType : " + trans.transactionType); System.Console.WriteLine("\t\t\tTranaction.confirmantionNumber : " + trans.confirmationNumber + "\n"); } } // End InvestmentTransactionData } } // End InvestmentData } /* * // Get AccountHistory * object[] acctHistories = itemData.accountHistory; * if(acctHistories == null || acctHistories.Length == 0) * { * System.Console.WriteLine("\tNo Account History"); * } * else * { * System.Console.WriteLine("\n\t**Account History**"); * for(int i = 0; i < acctHistories.Length; i++) * { * AccountHistory acctHistory = (AccountHistory)acctHistories[i]; * * System.Console.WriteLine("\tAccount ID: {0}", acctHistory.accountId ); * * // Get History * object[] histories = acctHistory.history; * if(histories == null || histories.Length == 0) * { * System.Console.WriteLine("\t\tNo History"); * } * else * { * System.Console.WriteLine("\t\t**History**"); * for(int j = 0; j < histories.Length; j++) * { * InvestmentData investment = (InvestmentData) histories[j]; * System.Console.WriteLine("\t\taccountName: "+ investment.accountName ); * System.Console.WriteLine("\t\taccountNumber: "+ investment.accountNumber ); * System.Console.WriteLine("\t\taccountHolder: "+ investment.accountHolder ); * System.Console.WriteLine("\t\tacctType: "+ investment.acctType ); * System.Console.WriteLine("\t\tcash: "+ investment.cash ); * System.Console.WriteLine("\t\ttotalBalance: "+ investment.totalBalance.amount ); * System.Console.WriteLine("\t\ttotalVestedBalance: "+ investment.totalVestedBalance.amount ); * System.Console.WriteLine("\t\ttotalUnvestedBalance: "+ investment.totalUnvestedBalance.amount ); * System.Console.WriteLine("\t\tmarginBalance: "+ investment.marginBalance.amount ); * System.Console.WriteLine("\t\tlastUpdated: " + UtcToDateTime(investment.lastUpdated.Value) + "\n"); * } * } * } * } * // AccountHistory*/ }