public ServiceResult <PortfolioValueResponse> GetValue(Guid stockId, DateRange dateRange, ValueFrequency frequency) { if (_Portfolio == null) { return(ServiceResult <PortfolioValueResponse> .NotFound()); } var holding = _Portfolio.Holdings[stockId]; if (holding == null) { return(ServiceResult <PortfolioValueResponse> .NotFound()); } var response = new PortfolioValueResponse(); var dates = GetDates(dateRange, frequency); foreach (var date in dates) { var value = new ClosingPrice() { Date = date, Price = holding.Value(date) }; response.Values.Add(value); } return(ServiceResult <PortfolioValueResponse> .Ok(response)); }
/// <summary> /// Serves as the default hash function. /// </summary> /// <returns></returns> public override int GetHashCode() { var hashCode = 378868840; hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Name); hashCode = hashCode * -1521134295 + ClosingPrice.GetHashCode(); hashCode = hashCode * -1521134295 + DateTime.GetHashCode(); hashCode = hashCode * -1521134295 + Volumen.GetHashCode(); hashCode = hashCode * -1521134295 + PreviousDayClosingPrice.GetHashCode(); hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(StockExchange); return(hashCode); }
public override int GetHashCode() { var hashCode = 1319828343; hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Name); hashCode = hashCode * -1521134295 + ClosingPrice.GetHashCode(); hashCode = hashCode * -1521134295 + QtyInBuyingPacket.GetHashCode(); hashCode = hashCode * -1521134295 + EqualityComparer <ITechnicalAnalysis> .Default.GetHashCode(TechnicalAnalysis); hashCode = hashCode * -1521134295 + EqualityComparer <IFinancialAnalysis> .Default.GetHashCode(FinancialAnalysis); return(hashCode); }
public ServiceResult <PortfolioValueResponse> GetValue(DateRange dateRange, ValueFrequency frequency) { if (_Portfolio == null) { return(ServiceResult <PortfolioValueResponse> .NotFound()); } var response = new PortfolioValueResponse(); var dates = GetDates(dateRange, frequency); var holdings = _Portfolio.Holdings.All(dateRange); var closingBalances = _Portfolio.CashAccount.EffectiveBalances(dateRange); var closingBalanceEnumerator = closingBalances.GetEnumerator(); closingBalanceEnumerator.MoveNext(); foreach (var date in dates) { var amount = 0.00m; // Add holding values foreach (var holding in holdings) { amount += holding.Value(date); } // Add cash account balances if (date > closingBalanceEnumerator.Current.EffectivePeriod.ToDate) { closingBalanceEnumerator.MoveNext(); } amount += closingBalanceEnumerator.Current.Balance; var value = new ClosingPrice() { Date = date, Price = amount }; response.Values.Add(value); } return(ServiceResult <PortfolioValueResponse> .Ok(response)); }
public string EditQuery() { roundParams(); int iTradeClosed = 0; if (TradeClosed == false) { iTradeClosed = 0; ClosingPrice = 0; Comission = 0; Taxes = 0; Profit = 0; } else { iTradeClosed = 1; } int iTradeType = 0; int iInstrumentType = 0; switch (InstrumentType.ToString()) { case "Валюта": iInstrumentType = 0; break; case "Акция": iInstrumentType = 1; break; case "Фьючерс": iInstrumentType = 2; break; } switch (TradeType.ToString()) { case "Long": iTradeType = 0; break; case "Short": iTradeType = 1; break; } //UPDATE `tradesassistant`.`trades` SET `trade_type`='0', `trade_sum`='2120.00' WHERE `id`='6'; string query = "UPDATE `" + Schema + "`.`" + Table + "` SET " + "`instrument_name`='" + InstrumentName + "', " + "`instrument_class`='" + iInstrumentType.ToString() + "', " + "`instrument_ticker`='" + Ticker + "', " + "`trade_type`='" + iTradeType.ToString() + "', " + "`opening_price`='" + OpeningPrice.ToString().Replace(",", ".") + "', " + "`trade_volume`='" + TradeSize.ToString() + "', " + "`trade_sum`='" + TradeSum.ToString().Replace(",", ".") + "', " + "`trade_closed`='" + iTradeClosed.ToString() + "', " + "`closing_price`='" + ClosingPrice.ToString().Replace(",", ".") + "', " + "`comissions`='" + Comission.ToString().Replace(",", ".") + "', " + "`taxes`='" + Taxes.ToString().Replace(",", ".") + "', " + "`profit`='" + Profit.ToString().Replace(",", ".") + "' " + "WHERE `id`='" + TradeId + "';"; return(query); }
//метод формирования строки удаления записи public string AddQuery() { roundParams(); int iTradeClosed = 0; if (TradeClosed == false) { iTradeClosed = 0; } else { iTradeClosed = 1; } int iTradeType = 0; int iInstrumentType = 0; switch (InstrumentType.ToString()) { case "Валюта": iInstrumentType = 0; break; case "Акция": iInstrumentType = 1; break; case "Фьючерс": iInstrumentType = 2; break; } switch (TradeType.ToString()) { case "Long": iTradeType = 0; break; case "Short": iTradeType = 1; break; } string query = "INSERT INTO `" + Schema + "`.`" + Table + "` " + "(`instrument_name`, " + "`instrument_class`, " + "`instrument_ticker`, " + "`trade_type`, " + "`opening_price`, " + "`trade_volume`, " + "`trade_sum`, " + "`trade_closed`, " + "`closing_price`, " + "`comissions`, " + "`taxes`, " + "`profit`) " + "VALUES ('" + InstrumentName + "', '" + iInstrumentType.ToString() + "', '" + Ticker + "', '" + iTradeType.ToString() + "', '" + OpeningPrice.ToString().Replace(",", ".") + "', '" + TradeSize.ToString() + "', '" + TradeSum.ToString().Replace(",", ".") + "', '" + iTradeClosed.ToString() + "', '" + ClosingPrice.ToString().Replace(",", ".") + "', '" + Comission.ToString().Replace(",", ".") + "', '" + Taxes.ToString().Replace(",", ".") + "', '" + Profit.ToString().Replace(",", ".") + "');"; return(query); }
public override string ToString() { return($"{TranDate.ToDateString()} {StockId} {ClosingPrice.ToNumberString(6)}"); }