public void Summary(string itemCode, QuantumLineChart c) { var data2 = c.ChartData[c.ChartData.Count - 2]; var data1 = c.ChartData[c.ChartData.Count - 1]; Lib.Base.Enums.UpDownEnum upDown1 = Lib.Base.Enums.UpDownEnum.None; if (data2.T_QuantumAvg < data2.T_MassAvg && data1.T_QuantumAvg < data1.T_MassAvg) { upDown1 = UpDownEnum.StrongUp; } else if (data2.T_QuantumAvg < data2.T_MassAvg && data1.T_QuantumAvg >= data1.T_MassAvg) { upDown1 = UpDownEnum.WeakUp; } CandleSummary.Instance.UpdateSummaryTrend(itemCode, c.TimeInterval, "매수", upDown1); Lib.Base.Enums.UpDownEnum upDown2 = Lib.Base.Enums.UpDownEnum.None; if (data2.T_QuantumAvg > data2.T_MassAvg && data1.T_QuantumAvg > data1.T_MassAvg) { upDown1 = UpDownEnum.StrongDown; } else if (data2.T_QuantumAvg < data2.T_MassAvg && data1.T_QuantumAvg <= data1.T_MassAvg) { upDown1 = UpDownEnum.WeakDown; } CandleSummary.Instance.UpdateSummaryTrend(itemCode, c.TimeInterval, "매도", upDown2); int tick2 = PriceTick.GetTickDiff(itemCode, data2.MassPrice, data2.QuantumPrice); int tick1 = PriceTick.GetTickDiff(itemCode, data1.MassPrice, data1.QuantumPrice); CandleSummary.Instance.UpdateSummaryTrendOfStrength(itemCode, c.TimeInterval, "매수", tick2); CandleSummary.Instance.UpdateSummaryTrendOfStrength(itemCode, c.TimeInterval, "매도", tick2); }
private void calculateRevenueLosscutTick(string price) { this.Invoke(new MethodInvoker(() => { try { if (rule.RevenuePrice > 0) { double p = Convert.ToDouble(price); int tick = PriceTick.GetTickDiff(rule.ItemCode, rule.BuyPrice, p); if (rule.Position == "1" && rule.BuyPrice > p) { lblRevenueTick.Text = "+" + tick.ToString(); lblRevenueTick.ForeColor = Color.Red; } else if (rule.Position == "2" && rule.BuyPrice < p) { lblRevenueTick.Text = "+" + tick.ToString(); lblRevenueTick.ForeColor = Color.Red; } else { lblRevenueTick.Text = "-" + tick.ToString(); lblRevenueTick.ForeColor = Color.Blue; } } } catch (Exception) { } })); }
private void calculateRevenueTick(string price) { this.Invoke(new MethodInvoker(() => { try { tbRevenuePrice.Text = Cals.RevenueCalculater.Calculator(rule); if (rule.RevenuePrice > 0) { double p = Convert.ToDouble(price); int tick = PriceTick.GetTickDiff(rule.ItemCode, rule.RevenuePrice, p); tbRevenuePriceTick.Text = tick.ToString(); } } catch (Exception) { } })); }
private void calculateLosscutTick(string price) { this.Invoke(new MethodInvoker(() => { try { if (IsAutoLosscutCal) { tbLosscutPrice.Text = Cals.LosscutCalculater.Calculator(rule); } if (rule.LosscutPrice > 0) { double p = Convert.ToDouble(price); int tick = PriceTick.GetTickDiff(rule.ItemCode, rule.LosscutPrice, p); tbLosscutPriceTick.Text = tick.ToString(); } } catch (Exception) { } })); }
public void SummaryPrice(double cPrice) { if (ChartData != null && ChartData.Count == 1) { this.Invoke(new Action(() => { double hPrice = Convert.ToDouble(lblH.Text); double lPrice = Convert.ToDouble(lblL.Text); double qhPrice = Convert.ToDouble(lblMH.Text); double qlPrice = Convert.ToDouble(lblML.Text); int hTick = PriceTick.GetTickDiff(ItemCode, hPrice, cPrice); int lTick = PriceTick.GetTickDiff(ItemCode, lPrice, cPrice); int qhTick = PriceTick.GetTickDiff(ItemCode, qhPrice, cPrice); int qlTick = PriceTick.GetTickDiff(ItemCode, qlPrice, cPrice); lblH.Text = $"{Math.Round(hPrice, RoundLength).ToString()}"; lblH.Visible = true; lblL.Text = $"{Math.Round(lPrice, RoundLength).ToString()}"; lblL.Visible = true; lblMH.Text = $"{Math.Round(qhPrice, RoundLength).ToString()}"; lblMH.Visible = true; lblML.Text = $"{Math.Round(qlPrice, RoundLength).ToString()}"; lblML.Visible = true; lblHTick.Text = $"{(hPrice > cPrice ? "+" : "-")}{hTick}"; lblHTick.Visible = true; lblLTick.Text = $"{(lPrice > cPrice ? "+" : "-")}{lTick}"; lblLTick.Visible = true; lblMHTick.Text = $"{(qhPrice > cPrice ? "+" : "-")}{qhTick}"; lblMHTick.Visible = true; lblMLTick.Text = $"{(qlPrice > cPrice ? "+" : "-")}{qlTick}"; lblMLTick.Visible = true; SetPriceLineAnnotation(cPrice); })); } }
private void btnCal_Click(object sender, EventArgs e) { double buyRate = Convert.ToDouble(tbBuyRate.Text); double revenueRate = Convert.ToDouble(tbRevenueRate.Text); double lossRate = Convert.ToDouble(tbLossRate.Text); string itemCode = tbItem.Text; string position = tbTimeType.Text; double basePrice = Convert.ToDouble(tbBasePrice.Text); double baseRevenueRate = 1.0; if (position == "매수") { tbBuyPrice.Text = PriceTick.GetDownPriceOfRate(itemCode, basePrice, buyRate).ToString(); tbBuyTick.Text = PriceTick.GetTickDiff(itemCode, basePrice, Convert.ToDouble(tbBuyPrice.Text)).ToString(); double hPrice = PriceTick.GetUpPriceOfRate(itemCode, basePrice, baseRevenueRate); tbRevenuePrice.Text = PriceTick.GetDownPriceOfRate(itemCode, hPrice, revenueRate).ToString(); tbRevenueTick.Text = PriceTick.GetTickDiff(itemCode, hPrice, Convert.ToDouble(tbRevenuePrice.Text)).ToString(); tbLossPrice.Text = PriceTick.GetDownPriceOfRate(itemCode, basePrice, lossRate).ToString(); tbLossTick.Text = PriceTick.GetTickDiff(itemCode, basePrice, Convert.ToDouble(tbLossPrice.Text)).ToString(); } if (position == "매도") { tbBuyPrice.Text = PriceTick.GetUpPriceOfRate(itemCode, basePrice, buyRate).ToString(); tbBuyTick.Text = PriceTick.GetTickDiff(itemCode, basePrice, Convert.ToDouble(tbBuyPrice.Text)).ToString(); double lPrice = PriceTick.GetDownPriceOfRate(itemCode, basePrice, baseRevenueRate); tbRevenuePrice.Text = PriceTick.GetUpPriceOfRate(itemCode, lPrice, revenueRate).ToString(); tbRevenueTick.Text = PriceTick.GetTickDiff(itemCode, lPrice, Convert.ToDouble(tbRevenuePrice.Text)).ToString(); tbLossPrice.Text = PriceTick.GetUpPriceOfRate(itemCode, basePrice, lossRate).ToString(); tbLossTick.Text = PriceTick.GetTickDiff(itemCode, basePrice, Convert.ToDouble(tbLossPrice.Text)).ToString(); } }
public void GetSise(CurrentPrice price = null) { try { if (candle != null && price != null) { var nextTime = candle.DTime.AddMinutes(EnumUtil.GetIntervalValueToMinutes(ruleInfo.TimeType)); if (price.DTime < nextTime) { return; } } PurushaPrakriti pp = new PurushaPrakriti(); pp.Item = ruleInfo.Item; pp.Interval = (int)EnumUtil.GetTimeIntervalValue(ruleInfo.TimeType); pp.DisplayCount = 5; try { Entities entities = (Entities)pp.Collect(new Query("USP_PP_SIMPLE_LST")); List <PurushaPrakriti> list = entities.Cast <PurushaPrakriti>().ToList(); List <int> ticks = new List <int>(); foreach (var k in list.GetRange(1, 4)) { int tick = PriceTick.GetTickDiff(ItemCode , Convert.ToDouble(k.OpenVal) , Convert.ToDouble(k.CloseVal)); ticks.Add(tick); } int avgTick = Convert.ToInt32(ticks.Average()); if (avgTick < limitTicks) { avgTick = limitTicks; } var m = list[1]; if (candle != null) { if (candle.HighPrice > m.HighVal && candle.LowPrice < m.LowVal) { return; } int tick = PriceTick.GetTickDiff(ItemCode , Convert.ToDouble(candle.OpenPrice) , Convert.ToDouble(candle.ClosePrice)); if (tick < avgTick) { return; } } candle = new S_CandleItemData(ItemCode, m.OpenVal, m.HighVal, m.LowVal, m.CloseVal, m.Volume, m.DT); if (!ruleInfo.IsBuyDone) { InitRule(); } else { ruleInfo.IsCanRevenue = true; } } catch (Exception ex) { string err = ex.Message; } } catch (Exception) { } }
public override void View() { pnlScroll.Visible = IsAutoScrollX; if (ChartData == null) { return; } if (ChartDataSub == null) { return; } if (IsShowCandle) { chart.Series[3].Enabled = chart.Series[4].Enabled = false; } int bDistance = -1; T_QuantumItemData bItem = null; for (int i = 0; i < ChartData.Count; i++) { var item = ChartData[i]; int idx = chart.Series[0].Points.AddXY(item.DTime, item.HighPrice, item.LowPrice, item.OpenPrice, item.ClosePrice); item = ChartDataSub[i]; if (IsShowCandle) { chart.Series[1].Points.AddXY(item.DTime, item.T_MassAvg); chart.Series[2].Points.AddXY(item.DTime, item.T_QuantumAvg); } else { chart.Series[1].Points.AddXY(item.DTime, item.T_OpenAvg); chart.Series[2].Points.AddXY(item.DTime, item.T_CloseAvg); chart.Series[3].Points.AddXY(item.DTime, item.T_VikalaAvg); chart.Series[4].Points.AddXY(item.DTime, item.T_QuantumAvg); } int d = PriceTick.GetTickDiff(ItemCode, item.MassPrice, item.TotalCenterPrice); chart.Series[5].Points.AddXY(item.DTime, d); if (bDistance != -1) { if (d > bDistance) { chart.Series[5].Points[idx].Color = Color.DarkRed; } else { chart.Series[5].Points[idx].Color = Color.DarkBlue; } } if (d == 0 && bItem != null) { var p = chart.Series[5].Points[idx]; bool isSignal = false; if (item.T_MassAvg < item.T_QuantumAvg) { if (item.T_QuantumAvg < item.LowPrice) { isSignal = true; } if (item.T_MassAvg > item.HighPrice) { isSignal = true; } } if (item.T_MassAvg > item.T_QuantumAvg) { if (item.T_QuantumAvg > item.HighPrice) { isSignal = true; } if (item.T_MassAvg < item.LowPrice) { isSignal = true; } } if (isSignal) { p.Label = "↑"; } } bDistance = d; var dataPoint = chart.Series[0].Points[idx]; bItem = item; } //maxPrice = ChartData.Max(m => m.HighPrice); //minPrice = ChartData.Min(m => m.LowPrice); //double maxPrice2 = ChartData.Max(m => m.T_QuantumHighAvg); //double minPrice2 = ChartData.Min(m => m.T_QuantumLowAvg); //if (maxPrice < maxPrice2) maxPrice = maxPrice2; //if (minPrice > minPrice2) minPrice = minPrice2; //maxPrice2 = ChartData.Max(m => m.T_CloseAvg); //minPrice2 = ChartData.Min(m => m.T_CloseAvg); //if (maxPrice < maxPrice2) maxPrice = maxPrice2; //if (minPrice > minPrice2) minPrice = minPrice2; //maxPrice2 = ChartData.Max(m => m.T_QuantumAvg); //minPrice2 = ChartData.Min(m => m.T_QuantumAvg); //if (maxPrice < maxPrice2) maxPrice = maxPrice2; //if (minPrice > minPrice2) minPrice = minPrice2; //maxPrice = maxPrice + SpaceMaxMin; //minPrice = minPrice - SpaceMaxMin; //chart.ChartAreas[0].AxisY2.Maximum = maxPrice; //chart.ChartAreas[0].AxisY2.Minimum = minPrice; //chart.ChartAreas[0].AxisY.Maximum = 10000; //chart.ChartAreas[0].AxisY.Minimum = 0; SetTrackBar(); SetScrollBar(); DisplayView(); IsLoaded = true; base.View(); }
public override void View() { pnlScroll.Visible = IsAutoScrollX; if (ChartData == null) { return; } if (ChartDataSub == null) { return; } int bDistance = -1; for (int i = 0; i < ChartData.Count; i++) { var item = ChartData[i]; int idx = chart.Series[0].Points.AddXY(item.DTime, item.HighPrice, item.LowPrice, item.OpenPrice, item.ClosePrice); var itemAvg = ChartDataSub[i]; chart.Series[1].Points.AddXY(item.DTime, item.T_QuantumHighAvg + itemAvg.HeadLength + itemAvg.LegLength); chart.Series[2].Points.AddXY(item.DTime, item.T_QuantumLowAvg - itemAvg.HeadLength - itemAvg.LegLength); chart.Series[3].Points.AddXY(item.DTime, ((item.T_QuantumHighAvg + itemAvg.HeadLength + itemAvg.LegLength) + (item.T_QuantumLowAvg - itemAvg.HeadLength - itemAvg.LegLength)) / 2.0 ); int d = PriceTick.GetTickDiff(ItemCode, itemAvg.MassPrice, itemAvg.TotalCenterPrice); chart.Series[4].Points.AddXY(item.DTime, d); if (bDistance != -1) { if (d > bDistance) { chart.Series[4].Points[idx].Color = Color.DarkRed; } else { chart.Series[4].Points[idx].Color = Color.DarkBlue; } } if (d == 0) { if (itemAvg.T_HighAvg < itemAvg.LowPrice || itemAvg.T_LowAvg > item.HighPrice) { chart.Series[4].Points[idx].Label = "↑"; } } bDistance = d; { var dataPoint = chart.Series[0].Points[idx]; if (item.PlusMinusType == PlusMinusTypeEnum.양 && item.YinAndYang == PlusMinusTypeEnum.양) { SetDataPointColor(dataPoint, Color.Red, Color.Red, Color.Red, 2); } else if (item.PlusMinusType == PlusMinusTypeEnum.음 && item.YinAndYang == PlusMinusTypeEnum.양) { SetDataPointColor(dataPoint, Color.Blue, Color.Blue, Color.Blue, 2); } else if (item.PlusMinusType == PlusMinusTypeEnum.양) { SetDataPointColor(dataPoint, Color.Red, Color.Red, Color.White, 2); } else if (item.PlusMinusType == PlusMinusTypeEnum.음) { SetDataPointColor(dataPoint, Color.Blue, Color.Blue, Color.White, 2); } else { SetDataPointColor(dataPoint, Color.Black, Color.Black, Color.White, 2); } } } //maxPrice = ChartData.Max(m => m.HighPrice); //minPrice = ChartData.Min(m => m.LowPrice); //double maxPrice2 = ChartData.Max(m => m.T_QuantumHighAvg); //double minPrice2 = ChartData.Min(m => m.T_QuantumLowAvg); //if (maxPrice < maxPrice2) maxPrice = maxPrice2; //if (minPrice > minPrice2) minPrice = minPrice2; //maxPrice2 = ChartData.Max(m => m.T_CloseAvg); //minPrice2 = ChartData.Min(m => m.T_CloseAvg); //if (maxPrice < maxPrice2) maxPrice = maxPrice2; //if (minPrice > minPrice2) minPrice = minPrice2; //maxPrice2 = ChartData.Max(m => m.T_QuantumAvg); //minPrice2 = ChartData.Min(m => m.T_QuantumAvg); //if (maxPrice < maxPrice2) maxPrice = maxPrice2; //if (minPrice > minPrice2) minPrice = minPrice2; //maxPrice = maxPrice + SpaceMaxMin; //minPrice = minPrice - SpaceMaxMin; //chart.ChartAreas[0].AxisY2.Maximum = maxPrice; //chart.ChartAreas[0].AxisY2.Minimum = minPrice; //chart.ChartAreas[0].AxisY.Maximum = 10000; //chart.ChartAreas[0].AxisY.Minimum = 0; SetTrackBar(); SetScrollBar(); DisplayView(); IsLoaded = true; base.View(); }
public override void View() { pnlScroll.Visible = IsAutoScrollX; if (ChartData == null) { return; } double maxPrice = 0.0; double minPrice = 0.0; int bDistance = -1; foreach (var item in ChartData) { int idx = chart.Series[0].Points.AddXY(item.DTime, item.HighPrice, item.LowPrice, item.OpenPrice, item.ClosePrice); chart.Series[1].Points.AddXY(item.DTime, item.T_MassAvg); chart.Series[2].Points.AddXY(item.DTime, item.T_QuantumAvg); chart.Series[3].Points.AddXY(item.DTime, item.T_QuantumHighAvg); chart.Series[4].Points.AddXY(item.DTime, item.T_QuantumLowAvg); //double d = Math.Round(Math.Abs(item.MassPrice - item.QuantumPrice), RoundLength); int d = PriceTick.GetTickDiff(ItemCode, item.MassPrice, item.QuantumPrice); chart.Series[5].Points.AddXY(item.DTime, d); if (bDistance != -1) { if (d > bDistance) { chart.Series[5].Points[idx].Color = Color.DarkRed; } else { chart.Series[5].Points[idx].Color = Color.DarkBlue; } } bDistance = d; var dataPoint = chart.Series[0].Points[idx]; } chart.Series[3].Enabled = chart.Series[4].Enabled = false; maxPrice = ChartData.Max(m => m.HighPrice); minPrice = ChartData.Min(m => m.LowPrice); double maxPrice2 = ChartData.Max(m => m.T_QuantumHighAvg); double minPrice2 = ChartData.Min(m => m.T_QuantumLowAvg); if (maxPrice < maxPrice2) { maxPrice = maxPrice2; } if (minPrice > minPrice2) { minPrice = minPrice2; } maxPrice2 = ChartData.Max(m => m.T_CloseAvg); minPrice2 = ChartData.Min(m => m.T_CloseAvg); if (maxPrice < maxPrice2) { maxPrice = maxPrice2; } if (minPrice > minPrice2) { minPrice = minPrice2; } maxPrice2 = ChartData.Max(m => m.T_QuantumAvg); minPrice2 = ChartData.Min(m => m.T_QuantumAvg); if (maxPrice < maxPrice2) { maxPrice = maxPrice2; } if (minPrice > minPrice2) { minPrice = minPrice2; } maxPrice = maxPrice + SpaceMaxMin; minPrice = minPrice - SpaceMaxMin; chart.ChartAreas[0].AxisY2.Maximum = maxPrice; chart.ChartAreas[0].AxisY2.Minimum = minPrice; chart.ChartAreas[0].AxisY.Maximum = 10000; chart.ChartAreas[0].AxisY.Minimum = 0; SetTrackBar(); SetScrollBar(); DisplayView(); IsLoaded = true; base.View(); }
public void Bind(A_HLOC hloc, int type = 0) { lblTime.Text = hloc.DTime.ToString("yyyy-MM-dd HH:mm"); Dictionary <string, float> abc = new Dictionary <string, float>(); abc.Add("시가", hloc.OpenPrice); abc.Add("고가", hloc.HighPrice); abc.Add("저가", hloc.LowPrice); abc.Add("종가", hloc.ClosePrice); abc.Add("중앙가", hloc.CenterPrice); abc.Add("중심가", hloc.MiddlePrice); abc.Add("양중앙가", hloc.QuantumCenterPrice); abc.Add("양중심가", hloc.QuantumMiddlePrice); abc.Add("양고가", hloc.QuantumHighPrice); abc.Add("양저가", hloc.QuantumLowPrice); abc.Add("양종가", hloc.QuantumPrice); abc.Add("질량가", hloc.MassPrice); double h1 = abc["양고가"] > abc["고가"] ? abc["양고가"] : abc["고가"]; double l1 = abc["양저가"] < abc["저가"] ? abc["양저가"] : abc["저가"]; lblMaxMin.Text = Math.Round(Math.Abs(h1 - l1), hloc.RoundLength).ToString() + " / " + PriceTick.GetTickDiff(hloc.ItemCode, h1, l1).ToString(); double h2 = abc["고가"]; double l2 = abc["저가"]; lblHighLow.Text = Math.Round(Math.Abs(h2 - l2), hloc.RoundLength).ToString() + " / " + PriceTick.GetTickDiff(hloc.ItemCode, h2, l2).ToString(); lblMiddle.Text = Math.Round(Math.Abs(abc["양중심가"] - abc["중심가"]), hloc.RoundLength).ToString() + " / " + PriceTick.GetTickDiff(hloc.ItemCode, abc["양중심가"], abc["중심가"]).ToString(); lblCenter.Text = Math.Round(Math.Abs(abc["양중앙가"] - abc["중앙가"]), hloc.RoundLength).ToString() + " / " + PriceTick.GetTickDiff(hloc.ItemCode, abc["양중앙가"], abc["중앙가"]).ToString(); lblMassClose.Text = Math.Round(Math.Abs(abc["질량가"] - abc["종가"]), hloc.RoundLength).ToString() + " / " + PriceTick.GetTickDiff(hloc.ItemCode, abc["질량가"], abc["종가"]).ToString(); lblMassQClose.Text = Math.Round(Math.Abs(abc["질량가"] - abc["양종가"]), hloc.RoundLength).ToString() + " / " + PriceTick.GetTickDiff(hloc.ItemCode, abc["질량가"], abc["양종가"]).ToString(); int idx = 0; foreach (var m in abc.OrderByDescending(t => t.Value)) { textBoxes[idx].ForeColor = labels[idx].ForeColor = SystemColors.ControlText; labels[idx].Text = m.Key; if (type == 0) { if (m.Key == "양종가" || m.Key == "양중앙가" || m.Key == "양중심가") { if (hloc.ClosePrice < hloc.QuantumPrice) { textBoxes[idx].ForeColor = labels[idx].ForeColor = Color.Red; } else if (hloc.ClosePrice > hloc.QuantumPrice) { textBoxes[idx].ForeColor = labels[idx].ForeColor = Color.Blue; } } } else if (type == 1) { string h = abc["양고가"] > abc["고가"] ? "양고가" : "고가"; string l = abc["양저가"] < abc["저가"] ? "양저가" : "저가"; if (m.Key == h || m.Key == l) { if (hloc.ClosePrice < hloc.QuantumPrice) { textBoxes[idx].ForeColor = labels[idx].ForeColor = Color.Red; } else if (hloc.ClosePrice > hloc.QuantumPrice) { textBoxes[idx].ForeColor = labels[idx].ForeColor = Color.Blue; } } } else if (type == 2) { if (m.Key == "양중앙가" || m.Key == "중앙가") { if (hloc.ClosePrice < hloc.QuantumPrice) { textBoxes[idx].ForeColor = labels[idx].ForeColor = Color.Red; } else if (hloc.ClosePrice > hloc.QuantumPrice) { textBoxes[idx].ForeColor = labels[idx].ForeColor = Color.Blue; } } } textBoxes[idx].Text = m.Value.ToString(); idx++; } }