public void AddMacd(MacdDto macd, string symbol) { string tableName = MacdTablePrefix + symbol; string sqlRemove = "DELETE FROM fx." + tableName + " WHERE PriceDate = '" + macd.PriceDate + "';"; string sqlInsert = "INSERT INTO fx." + tableName + "(AssetId, PriceDate, MA13, EMA13, MA26, EMA26, MACDLine, SignalLine, Histogram, HistogramAvg, " + "HistogramExtremum, DeltaHistogram, DeltaHistogramPositive, DeltaHistogramNegative, DeltaHistogramZero, " + "HistogramDirection2D, HistogramDirection3D, HistogramDirectionChanged, HistogramToOX, " + "HistogramRow, OxCrossing, MacdPeak, LastMACDPeak, MACDPeakSlope, MACDTrough, LastMACDTrough, MACDTroughSlope) " + "VALUES (" + macd.AssetId + ", '" + macd.PriceDate + "'" + ", " + macd.Ma13.ToDbString() + ", " + macd.Ema13.ToDbString() + ", " + macd.Ma26.ToDbString() + ", " + macd.Ema26.ToDbString() + ", " + macd.MacdLine.ToDbString() + ", " + macd.SignalLine.ToDbString() + ", " + macd.Histogram.ToDbString() + ", " + macd.HistogramAvg.ToDbString() + ", " + macd.HistogramExtremum.ToDbString() + ", " + macd.DeltaHistogram.ToDbString() + ", " + macd.DeltaHistogramPositive + ", " + macd.DeltaHistogramNegative + ", " + macd.DeltaHistogramZero + ", " + macd.HistogramDirection2D + ", " + macd.HistogramDirection3D + ", " + macd.HistogramDirectionChanged + ", " + macd.HistogramToOx + ", " + macd.HistogramRow + ", " + macd.OxCrossing.ToDbString() + ", " + macd.MacdPeak + ", " + macd.LastMacdPeak.ToDbString() + ", " + macd.MacdPeakSlope.ToDbString() + ", " + macd.MacdTrough + ", " + macd.LastMacdTrough.ToDbString() + ", " + macd.MacdTroughSlope.ToDbString() +");"; using (var context = new EFDbContext()) { context.Database.ExecuteSqlCommand(sqlRemove); context.Database.ExecuteSqlCommand(sqlInsert); context.SaveChanges(); } }
public void UpdateMacd(MacdDto macd, string symbol) { string tableName = MacdTablePrefix + symbol; string sqlUpdate = "UPDATE fx." + tableName + " SET " + "MA13 = " + macd.Ma13.ToDbString() + ", EMA13 = " + macd.Ema13.ToDbString() + ", MA26 = " + macd.Ma26.ToDbString() + ", EMA26 = " + macd.Ema26.ToDbString() + ", MACDLine = " + macd.MacdLine.ToDbString() + ", SignalLine = " + macd.SignalLine.ToDbString() + ", Histogram = " + macd.Histogram.ToDbString() + ", HistogramAvg = " + macd.HistogramAvg.ToDbString() + ", HistogramExtremum = " + macd.HistogramExtremum.ToDbString() + ", DeltaHistogram = " + macd.DeltaHistogram.ToDbString() + ", DeltaHistogramPositive = " + macd.DeltaHistogramPositive + ", DeltaHistogramNegative = " + macd.DeltaHistogramNegative + ", DeltaHistogramZero = " + macd.DeltaHistogramZero + ", HistogramDirection2D = " + macd.HistogramDirection2D + ", HistogramDirection3D = " + macd.HistogramDirection3D + ", HistogramDirectionChanged = " + macd.HistogramDirectionChanged + ", HistogramToOX = " + macd.HistogramToOx + ", HistogramRow = " + macd.HistogramRow + ", OxCrossing = " + macd.OxCrossing.ToDbString() + ", MacdPeak = " + macd.MacdPeak + ", LastMACDPeak = " + macd.LastMacdPeak.ToDbString() + ", MACDPeakSlope = " + macd.MacdPeakSlope.ToDbString() + ", MACDTrough = " + macd.MacdTrough + ", LastMACDTrough = " + macd.LastMacdTrough.ToDbString() + ", MACDTroughSlope = " + macd.MacdTroughSlope.ToDbString() + " WHERE PriceDate = '" + macd.PriceDate + "';"; using (var context = new EFDbContext()) { context.Database.ExecuteSqlCommand(sqlUpdate); context.SaveChanges(); } }
public MacdDto ToDto() { var dto = new MacdDto { Id = this.Id, AssetId = this.AssetId, PriceDate = this.Date, Ma13 = this.Ma13, Ema13 = this.Ema13, Ma26 = this.Ma26, Ema26 = this.Ema26, MacdLine = this.MacdLine, SignalLine = this.SignalLine, Histogram = this.Histogram, HistogramAvg = this.HistogramAvg, HistogramExtremum = this.HistogramExtremum, DeltaHistogram = this.DeltaHistogram, DeltaHistogramPositive = this.DeltaHistogramPositive, DeltaHistogramNegative = this.DeltaHistogramNegative, DeltaHistogramZero = this.DeltaHistogramZero, HistogramDirection2D = this.HistogramDirection2D, HistogramDirection3D = this.HistogramDirection3D, HistogramDirectionChanged = this.HistogramDirectionChanged, HistogramToOx = this.HistogramToOx, HistogramRow = this.HistogramRow, OxCrossing = this.OxCrossing, MacdPeak = this.MacdPeak, LastMacdPeak = this.LastMacdPeak, MacdPeakSlope = this.MacdPeakSlope, MacdTrough = this.MacdTrough, LastMacdTrough = this.LastMacdTrough, MacdTroughSlope = this.MacdTroughSlope, TimeframeId = 1 }; return dto; }
public static Macd FromDto(MacdDto dto) { var macd = new Macd(); macd.Id = dto.Id; macd.AssetId = dto.AssetId; macd.Date = dto.PriceDate; macd.Ma13 = dto.Ma13; macd.Ema13 = dto.Ema13; macd.Ma26 = dto.Ma26; macd.Ema26 = dto.Ema26; macd.MacdLine = dto.MacdLine; macd.SignalLine = dto.SignalLine; macd.Histogram = dto.Histogram; macd.HistogramAvg = dto.HistogramAvg; macd.HistogramExtremum = dto.HistogramExtremum; macd.DeltaHistogram = dto.DeltaHistogram; macd.DeltaHistogramPositive = dto.DeltaHistogramPositive; macd.DeltaHistogramNegative = dto.DeltaHistogramNegative; macd.DeltaHistogramZero = dto.DeltaHistogramZero; macd.HistogramDirection2D = dto.HistogramDirection2D; macd.HistogramDirection3D = dto.HistogramDirection3D; macd.HistogramDirectionChanged = dto.HistogramDirectionChanged; macd.HistogramToOx = dto.HistogramToOx; macd.HistogramRow = dto.HistogramRow; macd.OxCrossing = dto.OxCrossing; macd.MacdPeak = dto.MacdPeak; macd.LastMacdPeak = dto.LastMacdPeak; macd.MacdPeakSlope = dto.MacdPeakSlope; macd.MacdTrough = dto.MacdTrough; macd.LastMacdTrough = dto.LastMacdTrough; macd.MacdTroughSlope = dto.MacdTroughSlope; return macd; }