public Domain.Stock GetStock(int itemNo) { IDbConnection conn = _connectionFactory.GetNewSqlConnectionWithLoginDetails(new SqlConnection(connection), String.Empty, String.Empty); var sqlStr = "select AXCategory, " + "AXSubCategory, " + "AXClass, " + "Pattern, " + "OrdCodeDescrip, " + "OrdCode, " + "Size, " + "Colour, " + "Variation, " + "Page, " + "SequenceNo, " + "ItemNo, " + "CashPrice, " + "QtyAvail" + " from stoStock " + "where ItemNO = @ItemNo"; DynamicParameters param = new DynamicParameters(); param.Add("@ItemNo", itemNo, dbType: DbType.Int32, direction: ParameterDirection.Input); Domain.Stock stock = conn.Query <Domain.Stock>(sqlStr, param, commandType: CommandType.Text).SingleOrDefault(); return(stock); }
public void AddQuotesToStock(IEnumerable <Candle> historicalQuotes, Domain.Stock stock) { var mvAvgs10Info = this.GetMovingAveragesByPeriod(historicalQuotes, 10); var macdsInfo = this.GetMACD(historicalQuotes); var stochasticsInfo = this.GetStochastics(historicalQuotes); var mvgAvgs = mvAvgs10Info.MovingAverages.Skip(macdsInfo.StartIndex - mvAvgs10Info.StartIndex).ToArray(); var macds = macdsInfo.Macds; var stochastics = stochasticsInfo.StochasticsSlowsK.Skip(macdsInfo.StartIndex - stochasticsInfo.StartIndex).ToArray(); var quotes = historicalQuotes.Skip(macdsInfo.StartIndex).Take(macdsInfo.EndIndex); int idx = 0; foreach (var q in quotes) { var mvAvg10 = mvgAvgs[idx]; var stoch = stochastics[idx]; var macd = macds[idx]; var quote = new Quote() { DayHigh = q.High, DayLow = q.Low, DateTime = q.DateTime, Open = q.Open, Close = q.Close, Volume = q.Volume, MovingAverage10 = Convert.ToDecimal(mvAvg10), Macd8179 = Convert.ToDecimal(macd), StochasticsSlowK1450 = Convert.ToDecimal(stoch) }; stock.Quotes.Add(quote); idx++; } }
public static Stock ToEF(this Domain.Stock s) { if (s == null) { return(null); } return(new Stock { Symbol = s.Symbol, Name = s.Name, Currency = s.Currency }); }
public async Task AddStock(DTO.Stock stockDto) { var stock = new Domain.Stock() { Symbol = stockDto.Symbol, Company = stockDto.Company, ExchangeId = stockDto.ExchangeId }; _financeSecurityContext.Stocks.Add(stock); await _financeSecurityContext.SaveChangesAsync(); }
public async Task <bool> Insert(Domain.Stock stock) { if (await context.Stocks.FindAsync(stock.Symbol) != null) { return(false); } await context.Stocks.AddAsync(stock.ToEF()); await context.SaveChangesAsync(); return(true); }
public bool Insert(Domain.Stock stock) { using (FhQuotesContext ctx = new FhQuotesContext()) { if (ctx.Stocks.Find(stock.Symbol) == null) { ctx.Stocks.Add(stock.ToEF()); ctx.SaveChanges(); return(true); } return(false); } }