private void btnLoadData_Click(object sender, EventArgs e) { //string itemCode = ItemCodeSet.GetItemCode(ItemCode.선물_해외_WTI); string itemCode = ItemCodeSet.GetItemCode(ItemCode.지수_국내_코스피200); var list = PPContext.Instance.ClientContext.GetSourceData( itemCode , Lib.Base.Enums.TimeIntervalEnum.Day , null , tbDT_E.Text , 120); int round = ItemCodeUtil.GetItemCodeRoundNum(itemCode); List <S_CandleItemData> sourceDatas = new List <S_CandleItemData>(); foreach (var m in list) { S_CandleItemData sourceData = new S_CandleItemData(itemCode , (Single)Math.Round(m.OpenVal, round) , (Single)Math.Round(m.HighVal, round) , (Single)Math.Round(m.LowVal, round) , (Single)Math.Round(m.CloseVal, round) , m.Volume , m.DT ); sourceDatas.Add(sourceData); } chartCS1.LoadData(itemCode, sourceDatas); }
protected override void query_ReceiveData(string szTrCode) { PPContext.Instance.ClientContext.ClearSourceData(ItemCode, TimeInterval); Task.Factory.StartNew(() => { int blockCnt = Convert.ToInt32(query.GetBlockCount(outBlock1)); int round = ItemCodeUtil.GetItemCodeRoundNum(ItemCode); for (int idx = 0; idx < blockCnt; idx++) { string date = query.GetFieldData(outBlock1, "date", idx); string time = "000000"; string open = query.GetFieldData(outBlock1, "open", idx); string high = query.GetFieldData(outBlock1, "high", idx); string low = query.GetFieldData(outBlock1, "low", idx); string close = query.GetFieldData(outBlock1, "close", idx); //string jdiff_vol = query.GetFieldData(outBlock1, "jdiff_vol", idx); //string value = query.GetFieldData(outBlock1, "value", idx); if (date.Length == 0) { continue; } /* * OM.Lib.Entity.LitePurushaPrakriti data = new Lib.Entity.LitePurushaPrakriti(); * string format = "yyyyMMdd" + (time.Length > 0 ? "HHmmss" : ""); * var dt = DateTime.ParseExact(date + time, format, CultureInfo.InvariantCulture); * data.DT = dt; * data.Item = ItemCode; * data.OpenVal = Convert.ToSingle(open); * data.HighVal = Convert.ToSingle(high); * data.LowVal = Convert.ToSingle(low); * data.CloseVal = Convert.ToSingle(close); * data.Volume = 0; * data.Interval = (int)TimeInterval; * PPContext.Instance.ClientContext.SetSourceData( * ItemCode * , TimeInterval * , data); */ string format = "yyyyMMdd" + (time.Length > 0 ? "HHmmss" : ""); var dt = DateTime.ParseExact(date + time, format, CultureInfo.InvariantCulture); S_CandleItemData data = new S_CandleItemData(); data.DTime = dt; data.ItemCode = ItemCode; data.OpenPrice = (Single)Math.Round(Convert.ToDouble(open), round); data.HighPrice = (Single)Math.Round(Convert.ToDouble(high), round); data.LowPrice = (Single)Math.Round(Convert.ToDouble(low), round); data.ClosePrice = (Single)Math.Round(Convert.ToDouble(close), round); data.Volume = 0; PPContext.Instance.ClientContext.SetCandleSourceData(ItemCode, TimeInterval, data); OnApiLog($"date : {date} time : {time} opne : {open} high : {high} low : {low} close : {close} "); } OnApiLog("Api_WorldFutureDWM ::: query_ReceiveData"); }); }
private void btnLoadData_Click(object sender, EventArgs e) { string itemCode = ItemCodeSet.GetItemCode(ItemCode.물_해외_WTI); var list = PPContext.Instance.ClientContext.GetSourceData( itemCode , Lib.Base.Enums.TimeIntervalEnum.Day , null , tbDT_E.Text , 120); int round = ItemCodeUtil.GetItemCodeRoundNum(itemCode); List <S_CandleItemData> sourceDatas = new List <S_CandleItemData>(); List <S_CandleItemData> sourceDatas2 = new List <S_CandleItemData>(); List <T_MirrorItemData> transformedDatas = new List <T_MirrorItemData>(); foreach (var m in list) { S_CandleItemData sourceData = new S_CandleItemData( itemCode , (Single)Math.Round(m.OpenVal, round) , (Single)Math.Round(m.HighVal, round) , (Single)Math.Round(m.LowVal, round) , (Single)Math.Round(m.CloseVal, round) , m.Volume , m.DT ); sourceDatas.Add(sourceData); } chartCS1.LoadData(itemCode, sourceDatas); foreach (var m in sourceDatas) { T_MirrorItemData tData = new T_MirrorItemData(m, sourceDatas); tData.Transform(); transformedDatas.Add(tData); } foreach (var m in transformedDatas) { S_CandleItemData sourceData = new S_CandleItemData( itemCode , m.T_OpenPrice , m.T_HighPrice , m.T_LowPrice , m.T_ClosePrice , m.Volume , m.DTime ); sourceDatas2.Add(sourceData); } chartCS2.LoadData(itemCode, sourceDatas2); }
public static string Calculator(string itemCode, string strategyType, string position, double buyPrice, double currrentPrice) { string revenuePrice = "0"; int revenueTick = 0; try { if (strategyType == "1") { revenueTick = Config.RevenueConfig.LOW_LIMIT_TICKS; } else if (strategyType == "2") { revenueTick = Config.RevenueConfig.MIDDLE_LIMIT_TICKS; } else if (strategyType == "3") { revenueTick = Config.RevenueConfig.HIGH_LIMIT_TICKS; } int roundNum = ItemCodeUtil.GetItemCodeRoundNum(itemCode); //매도 if (position == "1") { //손실 if (buyPrice < currrentPrice) { revenuePrice = Math.Round(PriceTick.GetDownPriceOfTick(itemCode, buyPrice, revenueTick), roundNum).ToString(); } //수익 else { revenuePrice = Math.Round(PriceTick.GetDownPriceOfTick(itemCode, buyPrice, revenueTick), roundNum).ToString(); } } //매수 else if (position == "2") { //손실 if (buyPrice > currrentPrice) { revenuePrice = Math.Round(PriceTick.GetUpPriceOfTick(itemCode, buyPrice, revenueTick), roundNum).ToString(); } //수익 else { revenuePrice = Math.Round(PriceTick.GetUpPriceOfTick(itemCode, buyPrice, revenueTick), roundNum).ToString(); } } } catch (Exception) { } return(revenuePrice); }
protected override void query_ReceiveData(string szTrCode) { Task.Factory.StartNew(() => { try { int blockCnt = Convert.ToInt32(query.GetBlockCount(outBlock1)); int round = ItemCodeUtil.GetItemCodeRoundNum(ItemCode); for (int idx = 0; idx < blockCnt; idx++) { string date = query.GetFieldData(outBlock1, "date", idx); string time = query.GetFieldData(outBlock1, "time", idx); string open = query.GetFieldData(outBlock1, "open", idx); string high = query.GetFieldData(outBlock1, "high", idx); string low = query.GetFieldData(outBlock1, "low", idx); string close = query.GetFieldData(outBlock1, "price", idx); string volume = query.GetFieldData(outBlock1, "volume", idx); if (date.Length == 0) { continue; } //string format = "yyyyMMdd" + (time.Length > 0 ? "HHmmss" : ""); string format = "yyyyMMdd"; var dt = DateTime.ParseExact(date, format, CultureInfo.InvariantCulture); S_CandleItemData data = new S_CandleItemData(); data.DTime = dt; data.ItemCode = ItemCode; data.OpenPrice = (Single)Math.Round(Convert.ToDouble(open) * 100, round); data.HighPrice = (Single)Math.Round(Convert.ToDouble(high) * 100, round); data.LowPrice = (Single)Math.Round(Convert.ToDouble(low) * 100, round); data.ClosePrice = (Single)Math.Round(Convert.ToDouble(close) * 100, round); data.Volume = Convert.ToSingle(volume); PPContext.Instance.ClientContext.SetCandleSourceData(ItemCode, TimeInterval, data); OnApiLog($"date : {date} time : {time} opne : {open} high : {high} low : {low} close : {close} "); } OnApiLog("Api_WorldIndex ::: query_ReceiveData"); } catch (Exception ex) { OnApiLog("Error ::: " + ex.Message); } finally { manualEvent.Set(); } }); }
private void btnLoadData_Click(object sender, EventArgs e) { string itemCode = ItemCodeSet.GetItemCode(ItemCode.지수_국내_코스피200); var list = PPContext.Instance.ClientContext.GetSourceData( itemCode , Lib.Base.Enums.TimeIntervalEnum.Day , null , tbDT_E.Text , 120); int round = ItemCodeUtil.GetItemCodeRoundNum(itemCode); List <S_CandleItemData> sourceDatas = new List <S_CandleItemData>(); List <T_AtomItemData> transformedDatas = new List <T_AtomItemData>(); List <T_QuantumItemData> transformedDatas2 = new List <T_QuantumItemData>(); foreach (var m in list) { S_CandleItemData sourceData = new S_CandleItemData( itemCode , (Single)Math.Round(m.OpenVal, round) , (Single)Math.Round(m.HighVal, round) , (Single)Math.Round(m.LowVal, round) , (Single)Math.Round(m.CloseVal, round) , m.Volume , m.DT ); sourceDatas.Add(sourceData); } int itemsCnt = 7; for (int i = itemsCnt; i < sourceDatas.Count; i++) { T_AtomItemData transData = new T_AtomItemData(sourceDatas[i], sourceDatas.GetRange(i - itemsCnt, itemsCnt)); transData.Transform(); transformedDatas.Add(transData); } chartAT1.LoadData(itemCode, transformedDatas); itemsCnt = 7; for (int i = itemsCnt; i < sourceDatas.Count; i++) { T_QuantumItemData transData = new T_QuantumItemData(sourceDatas[i], sourceDatas.GetRange(i - itemsCnt, itemsCnt)); transData.Transform(); transformedDatas2.Add(transData); } chartQL1.LoadData(itemCode, transformedDatas2); }
protected override void query_ReceiveData(string szTrCode) { try { int blockCnt = Convert.ToInt32(query.GetBlockCount(outBlock1)); int round = ItemCodeUtil.GetItemCodeRoundNum(ItemCode); for (int idx = 0; idx < blockCnt; idx++) { string date = query.GetFieldData(outBlock1, "date", idx); string time = query.GetFieldData(outBlock1, "time", idx); string open = query.GetFieldData(outBlock1, "open", idx); string high = query.GetFieldData(outBlock1, "high", idx); string low = query.GetFieldData(outBlock1, "low", idx); string close = query.GetFieldData(outBlock1, "close", idx); string jdiff_vol = query.GetFieldData(outBlock1, "jdiff_vol", idx); string volume = query.GetFieldData(outBlock1, "value", idx); if (date.Length == 0) { continue; } string format = "yyyyMMdd" + (time.Length > 0 ? "HHmmss" : ""); var dt = DateTime.ParseExact(date + time, format, CultureInfo.InvariantCulture); S_CandleItemData data = new S_CandleItemData(); data.DTime = dt; data.ItemCode = ItemCode; data.OpenPrice = (Single)Math.Round(Convert.ToDouble(open), round); data.HighPrice = (Single)Math.Round(Convert.ToDouble(high), round); data.LowPrice = (Single)Math.Round(Convert.ToDouble(low), round); data.ClosePrice = (Single)Math.Round(Convert.ToDouble(close), round); data.Volume = Convert.ToSingle(volume); returnList.Add(data); } OnApiLog("Api_Jongmok ::: query_ReceiveData"); } catch (Exception ex) { OnApiLog("Error ::: " + ex.Message); } finally { manualEvent.Set(); } }
private void btnLoadData_Click(object sender, EventArgs e) { string itemCode = ItemCodeSet.GetItemCode(ItemCode.지수_국내_코스피200); var list = PPContext.Instance.ClientContext.GetSourceData( itemCode , Lib.Base.Enums.TimeIntervalEnum.Day , null , tbDT_E.Text , 120); int round = ItemCodeUtil.GetItemCodeRoundNum(itemCode); List <S_CandleItemData> sourceDatas = new List <S_CandleItemData>(); List <T_QuarkItemData> transformedDatas = new List <T_QuarkItemData>(); foreach (var m in list) { S_CandleItemData sourceData = new S_CandleItemData( itemCode , (Single)Math.Round(m.OpenVal, round) , (Single)Math.Round(m.HighVal, round) , (Single)Math.Round(m.LowVal, round) , (Single)Math.Round(m.CloseVal, round) , m.Volume , m.DT ); sourceDatas.Add(sourceData); } chartCS1.LoadData(itemCode, sourceDatas); DateTime?dtime = null; foreach (var m in sourceDatas.OrderByDescending(t => t.DTime)) { if (dtime != null && dtime.Value <= m.DTime) { continue; } T_QuarkItemData tData = new T_QuarkItemData(m, sourceDatas); tData.Transform(); transformedDatas.Add(tData); dtime = tData.DTimeS; } chartWX1.LoadData(itemCode, transformedDatas.OrderBy(t => t.DTime).ToList()); }
private void BindData(int cnt, ReverseCandleChart chart) { string itemCode = ItemCodeSet.GetItemCode(ItemCode.물_해외_WTI); int round = ItemCodeUtil.GetItemCodeRoundNum(itemCode); var list = PPContext.Instance.ClientContext.GetSourceData( itemCode , Lib.Base.Enums.TimeIntervalEnum.Day , null , tbDT_E.Text , cnt); List <S_CandleItemData> sourceDatas = new List <S_CandleItemData>(); List <S_CandleItemData> reverseDatas = new List <S_CandleItemData>(); foreach (var m in list) { S_CandleItemData sourceData = new S_CandleItemData( itemCode , (Single)Math.Round(m.OpenVal, round) , (Single)Math.Round(m.HighVal, round) , (Single)Math.Round(m.LowVal, round) , (Single)Math.Round(m.CloseVal, round) , m.Volume , m.DT ); sourceDatas.Add(sourceData); } for (int i = 0, j = sourceDatas.Count - 1; i < sourceDatas.Count; i++, j--) { S_CandleItemData reverseData = new S_CandleItemData( itemCode , sourceDatas[j].ClosePrice , sourceDatas[j].HighPrice , sourceDatas[j].LowPrice , sourceDatas[j].OpenPrice , 0 , sourceDatas[i].DTime ); reverseDatas.Add(reverseData); } chart.LoadData(itemCode, sourceDatas, reverseDatas); }
public void CalculateDirectionValue() { try { if (BalancePrice == 0) { return; } if (RangeValue == 0) { return; } //안정형 : 40 30 30 30 40 if (CharType == "안정형") { double p1Rate = 0.4; double p2Rate = 0.3; double p3Rate = 0.3; double p4Rate = 0.3; double p5Rate = 0.4; if (PositionType == "매도") { Direction1Value = BalancePrice + Math.Round(RangeValue * (p3Rate + p2Rate), ItemCodeUtil.GetItemCodeRoundNum(ItemCode)); Direction2Value = BalancePrice + Math.Round(RangeValue * (p3Rate), ItemCodeUtil.GetItemCodeRoundNum(ItemCode)); Direction3Value = BalancePrice; Direction4Value = BalancePrice - Math.Round(RangeValue * (p3Rate + p4Rate), ItemCodeUtil.GetItemCodeRoundNum(ItemCode)); Direction5Value = BalancePrice - Math.Round(RangeValue * (p3Rate + p4Rate + p5Rate), ItemCodeUtil.GetItemCodeRoundNum(ItemCode)); } else if (PositionType == "매수") { Direction1Value = BalancePrice + Math.Round(RangeValue * (p3Rate + p2Rate + p1Rate), ItemCodeUtil.GetItemCodeRoundNum(ItemCode)); Direction2Value = BalancePrice + Math.Round(RangeValue * (p3Rate + p2Rate), ItemCodeUtil.GetItemCodeRoundNum(ItemCode)); Direction3Value = BalancePrice; Direction4Value = BalancePrice - Math.Round(RangeValue * (p3Rate), ItemCodeUtil.GetItemCodeRoundNum(ItemCode)); Direction5Value = BalancePrice - Math.Round(RangeValue * (p3Rate + p4Rate), ItemCodeUtil.GetItemCodeRoundNum(ItemCode)); } } //공격형 : 30 30 40 30 30 else if (CharType == "공격형") { double p1Rate = 0.3; double p2Rate = 0.3; double p3Rate = 0.4; double p4Rate = 0.3; double p5Rate = 0.3; if (PositionType == "매도") { Direction1Value = BalancePrice + Math.Round(RangeValue * (p3Rate + p2Rate), ItemCodeUtil.GetItemCodeRoundNum(ItemCode)); Direction2Value = BalancePrice + Math.Round(RangeValue * (p3Rate), ItemCodeUtil.GetItemCodeRoundNum(ItemCode)); Direction3Value = BalancePrice; Direction4Value = BalancePrice - Math.Round(RangeValue * (p3Rate + p4Rate), ItemCodeUtil.GetItemCodeRoundNum(ItemCode)); Direction5Value = BalancePrice - Math.Round(RangeValue * (p3Rate + p4Rate + p5Rate), ItemCodeUtil.GetItemCodeRoundNum(ItemCode)); } else if (PositionType == "매수") { Direction1Value = BalancePrice + Math.Round(RangeValue * (p3Rate + p2Rate + p1Rate), ItemCodeUtil.GetItemCodeRoundNum(ItemCode)); Direction2Value = BalancePrice + Math.Round(RangeValue * (p3Rate + p2Rate), ItemCodeUtil.GetItemCodeRoundNum(ItemCode)); Direction3Value = BalancePrice; Direction4Value = BalancePrice - Math.Round(RangeValue * (p3Rate), ItemCodeUtil.GetItemCodeRoundNum(ItemCode)); Direction5Value = BalancePrice - Math.Round(RangeValue * (p3Rate + p4Rate), ItemCodeUtil.GetItemCodeRoundNum(ItemCode)); } } } catch (Exception) { } }
public List <S_CandleItemData> Query( string itemCode , string gubun = "D" //M : 15Min, H : Hour, D : Day, W : Week, M : Month ) { this.ItemCode = itemCode; int round = ItemCodeUtil.GetItemCodeRoundNum(ItemCode); Task.Factory.StartNew(() => { try { string symbol = "37427"; if (itemCode == "301") { symbol = "38016"; } string resolution = gubun; if (gubun == "H" || gubun == "1H") { resolution = "60"; } else if (gubun == "2H") { resolution = "120"; } else if (gubun == "4H") { resolution = "240"; } else if (gubun == "5H") { resolution = "300"; } else if (gubun == "M" || gubun == "1M") { resolution = "1"; } else if (gubun == "5M") { resolution = "5"; } else if (gubun == "15M") { resolution = "15"; } else if (gubun == "30M") { resolution = "30"; } Int32 from = (Int32)(DateTime.UtcNow.AddYears(-2).Subtract(new DateTime(1970, 1, 1))).TotalSeconds; Int32 to = (Int32)(DateTime.UtcNow.AddDays(10).Subtract(new DateTime(1970, 1, 1))).TotalSeconds; if (gubun == "M" || gubun == "1M") { from = (Int32)(DateTime.UtcNow.AddDays(-1).Subtract(new DateTime(1970, 1, 1))).TotalSeconds; to = (Int32)(DateTime.UtcNow.AddDays(10).Subtract(new DateTime(1970, 1, 1))).TotalSeconds; } else if (gubun == "5M") { from = (Int32)(DateTime.UtcNow.AddDays(-5).Subtract(new DateTime(1970, 1, 1))).TotalSeconds; to = (Int32)(DateTime.UtcNow.AddDays(10).Subtract(new DateTime(1970, 1, 1))).TotalSeconds; } else if (gubun == "15M") { from = (Int32)(DateTime.UtcNow.AddDays(-15).Subtract(new DateTime(1970, 1, 1))).TotalSeconds; to = (Int32)(DateTime.UtcNow.AddDays(10).Subtract(new DateTime(1970, 1, 1))).TotalSeconds; } else if (gubun == "30M") { from = (Int32)(DateTime.UtcNow.AddMonths(-1).Subtract(new DateTime(1970, 1, 1))).TotalSeconds; to = (Int32)(DateTime.UtcNow.AddDays(1).Subtract(new DateTime(1970, 1, 1))).TotalSeconds; } else if (gubun == "H" || gubun == "1H") { from = (Int32)(DateTime.UtcNow.AddMonths(-2).Subtract(new DateTime(1970, 1, 1))).TotalSeconds; to = (Int32)(DateTime.UtcNow.AddDays(10).Subtract(new DateTime(1970, 1, 1))).TotalSeconds; } else if (gubun == "2H") { from = (Int32)(DateTime.UtcNow.AddMonths(-4).Subtract(new DateTime(1970, 1, 1))).TotalSeconds; to = (Int32)(DateTime.UtcNow.AddDays(10).Subtract(new DateTime(1970, 1, 1))).TotalSeconds; } else if (gubun == "4H") { from = (Int32)(DateTime.UtcNow.AddMonths(-8).Subtract(new DateTime(1970, 1, 1))).TotalSeconds; to = (Int32)(DateTime.UtcNow.AddDays(10).Subtract(new DateTime(1970, 1, 1))).TotalSeconds; } else if (gubun == "5H") { from = (Int32)(DateTime.UtcNow.AddMonths(-10).Subtract(new DateTime(1970, 1, 1))).TotalSeconds; to = (Int32)(DateTime.UtcNow.AddDays(10).Subtract(new DateTime(1970, 1, 1))).TotalSeconds; } else if (gubun == "W") { from = (Int32)(DateTime.UtcNow.AddYears(-5).Subtract(new DateTime(1970, 1, 1))).TotalSeconds; to = (Int32)(DateTime.UtcNow.AddDays(10).Subtract(new DateTime(1970, 1, 1))).TotalSeconds; } else if (gubun == "M") { from = (Int32)(DateTime.UtcNow.AddYears(-10).Subtract(new DateTime(1970, 1, 1))).TotalSeconds; to = (Int32)(DateTime.UtcNow.AddDays(10).Subtract(new DateTime(1970, 1, 1))).TotalSeconds; } string urlPath = $"https://tvc4.forexpros.com/1cc1f0b6f392b9fad2b50b7aebef1f7c/1601866558/18/18/88/history?symbol={symbol}&resolution={resolution}&from={from}&to={to}"; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(urlPath); request.MaximumAutomaticRedirections = 4; request.MaximumResponseHeadersLength = 4; request.Credentials = CredentialCache.DefaultCredentials; HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Stream receiveStream = response.GetResponseStream(); StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8); string content = readStream.ReadToEnd(); var dyObj = JsonConverter.JsonToDynamicObject(content); int cnt = dyObj.t.Count; for (int i = 0; i < cnt; i++) { Int64 t = dyObj.t[i]; double o = dyObj.o[i]; double c = dyObj.c[i]; double h = dyObj.h[i]; double l = dyObj.l[i]; DateTime cTime = new DateTime(1970, 1, 1, 0, 0, 0, 0).AddSeconds(t); //Console.WriteLine($"DT : {cTime.ToLongDateString()} O : {Math.Round(o, 2)}, H : {Math.Round(h, 2)}, L : {Math.Round(l, 2)}, C : {Math.Round(c, 2)}"); S_CandleItemData data = new S_CandleItemData(); data.DTime = cTime; data.ItemCode = ItemCode; data.OpenPrice = (Single)Math.Round(o, round); data.HighPrice = (Single)Math.Round(h, round); data.LowPrice = (Single)Math.Round(l, round); data.ClosePrice = (Single)Math.Round(c, round); data.Volume = 0; returnList.Add(data); } } catch (Exception ex) { string err = ex.Message; } finally { manualEvent.Set(); } }); manualEvent.WaitOne(); return(returnList); }
private void btnLoadData_Click(object sender, EventArgs e) { string itemCode = ItemCodeSet.GetItemCode(ItemCode.지수_국내_코스피200); var list = PPContext.Instance.ClientContext.GetSourceData( itemCode , Lib.Base.Enums.TimeIntervalEnum.Day , null , tbDT_E.Text , 120); int round = ItemCodeUtil.GetItemCodeRoundNum(itemCode); List <S_CandleItemData> sourceDatas = new List <S_CandleItemData>(); List <T_VelocityItemData> transformedDatas1 = new List <T_VelocityItemData>(); List <T_VelocityItemData> transformedDatas2 = new List <T_VelocityItemData>(); List <T_VelocityItemData> transformedDatas3 = new List <T_VelocityItemData>(); foreach (var m in list) { S_CandleItemData sourceData = new S_CandleItemData( itemCode , (Single)Math.Round(m.OpenVal, round) , (Single)Math.Round(m.HighVal, round) , (Single)Math.Round(m.LowVal, round) , (Single)Math.Round(m.CloseVal, round) , m.Volume , m.DT ); sourceDatas.Add(sourceData); } int itemsCnt = 20; for (int i = itemsCnt; i < sourceDatas.Count; i++) { T_VelocityItemData transData = new T_VelocityItemData(sourceDatas[i], sourceDatas.GetRange(i - itemsCnt, itemsCnt)); transData.Transform(); transformedDatas1.Add(transData); } itemsCnt = 10; for (int i = itemsCnt; i < sourceDatas.Count; i++) { T_VelocityItemData transData = new T_VelocityItemData(sourceDatas[i], sourceDatas.GetRange(i - itemsCnt, itemsCnt)); transData.Transform(); transformedDatas2.Add(transData); } itemsCnt = 5; for (int i = itemsCnt; i < sourceDatas.Count; i++) { T_VelocityItemData transData = new T_VelocityItemData(sourceDatas[i], sourceDatas.GetRange(i - itemsCnt, itemsCnt)); transData.Transform(); transformedDatas3.Add(transData); } for (int i = 0; i < numericUpDown1.Value; i++) { transformedDatas1.Remove(transformedDatas1.Last()); transformedDatas2.Remove(transformedDatas2.Last()); transformedDatas3.Remove(transformedDatas3.Last()); } chartVL1.LoadData(itemCode, transformedDatas1); chartVL2.LoadData(itemCode, transformedDatas2); chartVL3.LoadData(itemCode, transformedDatas3); }
/// <summary> /// /// </summary> /// <returns></returns> public static string Calculator(string itemCode, string strategyType, string position, double buyPrice, double currrentPrice, double highPrice, double lowPrice) { string losscutPrice = "0"; int losscutTick = 0; try { int roundNum = ItemCodeUtil.GetItemCodeRoundNum(itemCode); //매도 if (position == "1") { //손실 if (buyPrice < currrentPrice) { if (strategyType == "1") { losscutTick = Config.LosscutConfig.LOSS_LOW_LIMIT_TICKS; } else if (strategyType == "2") { losscutTick = Config.LosscutConfig.LOSS_MIDDLE_LIMIT_TICKS; } else if (strategyType == "3") { losscutTick = Config.LosscutConfig.LOSS_HIGH_LIMIT_TICKS; } losscutPrice = Math.Round(PriceTick.GetUpPriceOfTick(itemCode, buyPrice, losscutTick), roundNum).ToString(); } //수익 else { if (strategyType == "1") { losscutTick = Config.LosscutConfig.REVENUE_LOW_LIMIT_TICKS; } else if (strategyType == "2") { losscutTick = Config.LosscutConfig.REVENUE_MIDDLE_LIMIT_TICKS; } else if (strategyType == "3") { losscutTick = Config.LosscutConfig.REVENUE_HIGH_LIMIT_TICKS; } losscutPrice = Math.Round(PriceTick.GetUpPriceOfTick(itemCode, lowPrice, losscutTick), roundNum).ToString(); } } //매수 else if (position == "2") { //손실 if (buyPrice > currrentPrice) { if (strategyType == "1") { losscutTick = Config.LosscutConfig.LOSS_LOW_LIMIT_TICKS; } else if (strategyType == "2") { losscutTick = Config.LosscutConfig.LOSS_MIDDLE_LIMIT_TICKS; } else if (strategyType == "3") { losscutTick = Config.LosscutConfig.LOSS_HIGH_LIMIT_TICKS; } losscutPrice = Math.Round(PriceTick.GetDownPriceOfTick(itemCode, buyPrice, losscutTick), roundNum).ToString(); } //수익 else { if (strategyType == "1") { losscutTick = Config.LosscutConfig.REVENUE_LOW_LIMIT_TICKS; } else if (strategyType == "2") { losscutTick = Config.LosscutConfig.REVENUE_MIDDLE_LIMIT_TICKS; } else if (strategyType == "3") { losscutTick = Config.LosscutConfig.REVENUE_HIGH_LIMIT_TICKS; } losscutPrice = Math.Round(PriceTick.GetDownPriceOfTick(itemCode, highPrice, losscutTick), roundNum).ToString(); } } } catch (Exception) { } return(losscutPrice); }
private void btnLoadData_Click(object sender, EventArgs e) { TimeIntervalEnum timeInterval = TimeIntervalEnum.Day; if (radioButton1.Checked) { timeInterval = TimeIntervalEnum.Hour_01; } if (radioButton2.Checked) { timeInterval = TimeIntervalEnum.Hour_02; } if (radioButton3.Checked) { timeInterval = TimeIntervalEnum.Hour_03; } if (radioButton4.Checked) { timeInterval = TimeIntervalEnum.Day; } string itemCode = ItemCodeSet.GetItemCode(ItemCode.지수_국내_코스피200); var list = PPContext.Instance.ClientContext.GetSourceData( itemCode , timeInterval , null , tbDT_E.Text , 300); int round = ItemCodeUtil.GetItemCodeRoundNum(itemCode); List <S_CandleItemData> sourceDatas = new List <S_CandleItemData>(); foreach (var m in list) { S_CandleItemData sourceData = new S_CandleItemData( itemCode , (Single)Math.Round(m.OpenVal, round) , (Single)Math.Round(m.HighVal, round) , (Single)Math.Round(m.LowVal, round) , (Single)Math.Round(m.CloseVal, round) , m.Volume , m.DT ); sourceDatas.Add(sourceData); } int itemsCnt = 7; List <T_AtomItemData> transformedDatas = new List <T_AtomItemData>(); for (int i = itemsCnt; i <= sourceDatas.Count; i++) { T_AtomItemData transData = new T_AtomItemData(sourceDatas[i - 1], sourceDatas.GetRange(i - itemsCnt, itemsCnt)); transData.Transform(); transformedDatas.Add(transData); } chartAT1.LoadData(itemCode, transformedDatas, timeInterval); List <S_CandleItemData> sourceDatas2 = new List <S_CandleItemData>(); itemsCnt = 7; for (int i = itemsCnt; i < sourceDatas.Count; i++) { S_CandleItemData transData = new S_CandleItemData(itemCode, sourceDatas.GetRange(i - itemsCnt, itemsCnt)); sourceDatas2.Add(transData); } itemsCnt = 7; List <T_AtomItemData> transformedDatas2 = new List <T_AtomItemData>(); for (int i = itemsCnt; i <= sourceDatas2.Count; i++) { T_AtomItemData transData = new T_AtomItemData(sourceDatas2[i - 1], sourceDatas2.GetRange(i - itemsCnt, itemsCnt)); transData.Transform(); transformedDatas2.Add(transData); } chartAT2.LoadData(itemCode, transformedDatas2, timeInterval); }
private void 진동주파수(S_CandleItemData item, DataPoint dataPoint) { try { Single headLen = 0f, bodyLen = 0f, legLen = 0f; //if (item.OpenPrice < item.ClosePrice) //{ // headLen = (Single)Math.Round(Math.Abs(item.HighPrice - item.ClosePrice), ItemCodeUtil.GetItemCodeRoundNum(ItemCode)); // bodyLen = (Single)Math.Round(Math.Abs(item.OpenPrice - item.ClosePrice), ItemCodeUtil.GetItemCodeRoundNum(ItemCode)); // legLen = (Single)Math.Round(Math.Abs(item.LowPrice - item.OpenPrice), ItemCodeUtil.GetItemCodeRoundNum(ItemCode)); //} //else if (item.OpenPrice > item.ClosePrice) //{ // headLen = (Single)Math.Round(Math.Abs(item.HighPrice - item.OpenPrice), ItemCodeUtil.GetItemCodeRoundNum(ItemCode)); // bodyLen = (Single)Math.Round(Math.Abs(item.OpenPrice - item.ClosePrice), ItemCodeUtil.GetItemCodeRoundNum(ItemCode)); // legLen = (Single)Math.Round(Math.Abs(item.LowPrice - item.ClosePrice), ItemCodeUtil.GetItemCodeRoundNum(ItemCode)); //} headLen = (Single)Math.Round(Math.Abs(item.HighPrice - item.OpenPrice), ItemCodeUtil.GetItemCodeRoundNum(ItemCode)); bodyLen = (Single)Math.Round(Math.Abs(item.HighPrice - item.LowPrice), ItemCodeUtil.GetItemCodeRoundNum(ItemCode)); legLen = (Single)Math.Round(Math.Abs(item.LowPrice - item.ClosePrice), ItemCodeUtil.GetItemCodeRoundNum(ItemCode)); //if (headLen == 0f || bodyLen == 0f || legLen == 0f) //{ // return; //} var rainbow = ChartUtil.GetRainbowType(headLen, bodyLen, legLen); Color[] colors = new Color[3] { Color.Black, Color.Black, Color.Black }; if (rainbow.head == RainbowTypeEnum._1_빨) { colors[0] = Color.Red; } if (rainbow.head == RainbowTypeEnum._2_주) { colors[0] = Color.Orange; } if (rainbow.head == RainbowTypeEnum._3_노) { colors[0] = Color.Yellow; } if (rainbow.head == RainbowTypeEnum._4_초) { colors[0] = Color.Green; } if (rainbow.head == RainbowTypeEnum._5_파) { colors[0] = Color.Blue; } if (rainbow.head == RainbowTypeEnum._6_남) { colors[0] = Color.DarkBlue; } if (rainbow.head == RainbowTypeEnum._7_보) { colors[0] = Color.Purple; } if (rainbow.head == RainbowTypeEnum._8_금) { colors[0] = Color.Gold; } if (rainbow.head == RainbowTypeEnum._9_흑) { colors[0] = Color.Black; } if (rainbow.body == RainbowTypeEnum._1_빨) { colors[1] = Color.Red; } if (rainbow.body == RainbowTypeEnum._2_주) { colors[1] = Color.Orange; } if (rainbow.body == RainbowTypeEnum._3_노) { colors[1] = Color.Yellow; } if (rainbow.body == RainbowTypeEnum._4_초) { colors[1] = Color.Green; } if (rainbow.body == RainbowTypeEnum._5_파) { colors[1] = Color.Blue; } if (rainbow.body == RainbowTypeEnum._6_남) { colors[1] = Color.DarkBlue; } if (rainbow.body == RainbowTypeEnum._7_보) { colors[1] = Color.Purple; } if (rainbow.body == RainbowTypeEnum._8_금) { colors[1] = Color.Gold; } if (rainbow.body == RainbowTypeEnum._9_흑) { colors[1] = Color.Black; } if (rainbow.leg == RainbowTypeEnum._1_빨) { colors[2] = Color.Red; } if (rainbow.leg == RainbowTypeEnum._2_주) { colors[2] = Color.Orange; } if (rainbow.leg == RainbowTypeEnum._3_노) { colors[2] = Color.Yellow; } if (rainbow.leg == RainbowTypeEnum._4_초) { colors[2] = Color.Green; } if (rainbow.leg == RainbowTypeEnum._5_파) { colors[2] = Color.Blue; } if (rainbow.leg == RainbowTypeEnum._6_남) { colors[2] = Color.DarkBlue; } if (rainbow.leg == RainbowTypeEnum._7_보) { colors[2] = Color.Purple; } if (rainbow.leg == RainbowTypeEnum._8_금) { colors[2] = Color.Gold; } if (rainbow.leg == RainbowTypeEnum._9_흑) { colors[2] = Color.Black; } if (colors[0] == colors[1] && colors[1] == colors[2]) { SetDataPointColor(dataPoint, colors[0], colors[1], colors[2], 3); } else { SetDataPointColor(dataPoint, Color.WhiteSmoke, Color.WhiteSmoke, Color.WhiteSmoke, 1); } } catch (Exception) { } }