고가 저가 처리 완료
This commit is contained in:
@@ -284,7 +284,7 @@ namespace BitgetAPI.IndicatorConditionSetup
|
||||
//파는 시점 볼랜저 전전봉 12 - 24 값이 전봉 12 - 24보다 클경우 팜
|
||||
//var sellFlag = 전봉Bol12 - 전봉Bol24 < Bol12 - Bol24 || 현재봉4 > 낮은값_74_24;
|
||||
//var sellFlag = 현재봉4 > 낮은값_74_24 || 전전봉Bol12 - 전전봉Bol24 < 전봉Bol12 - 전봉Bol24;
|
||||
var sellFlag = 현재봉4 > 낮은값_74_24 || 현재봉12 < 현재봉4; ;
|
||||
var sellFlag = 현재봉4 > 낮은값_74_24 || 현재봉12 < 현재봉4 || 전전봉Bol12 - 전전봉Bol24 < 전봉Bol12 - 전봉Bol24;
|
||||
//파는 시점 볼랜저 전전봉 12 - 24 값이 전봉 12 - 24보다 클경우 팜
|
||||
//var buyFlag = candleData_전봉.movingAverageDataList[12].BolangerValue > candleData_전봉.movingAverageDataList[24].BolangerValue && 전전봉Bol12 - 전전봉Bol24 > 전봉Bol12 - 전봉Bol24;
|
||||
|
||||
|
||||
@@ -174,17 +174,18 @@ namespace BitgetAPI
|
||||
{
|
||||
var flag = true;
|
||||
|
||||
//속도 개선을 위하여 미리 선언
|
||||
while (webConnection.Is_th_webSocketThread)
|
||||
{
|
||||
webConnection.CalculateDataList(type);
|
||||
webConnection.CalculateDataList(type, indicatorProcess.intervalList);
|
||||
if (flag)
|
||||
{
|
||||
th_SignalInfo = new Thread(new ThreadStart(Signalnfo));
|
||||
th_SignalInfo.Start();
|
||||
}
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 신호검색 Thread 함수
|
||||
private void Signalnfo()
|
||||
@@ -201,13 +202,7 @@ namespace BitgetAPI
|
||||
*/
|
||||
|
||||
|
||||
var checkedMarkets = checkedComboBoxEdit_MarketInfoList.Properties.Items.GetCheckedValues();
|
||||
var intervalList = checkedComboBoxEdit_TimeInterval.Properties.Items.GetCheckedValues();
|
||||
|
||||
indicatorProcess = new IndicatorProcess();
|
||||
indicatorProcess.Is_th_SignalInfo = true;
|
||||
indicatorProcess.checkedMarkets = checkedMarkets;
|
||||
indicatorProcess.intervalList = intervalList;
|
||||
indicatorProcess.signals_LU = signals_LU;
|
||||
indicatorProcess.signals_SD = signals_SD;
|
||||
indicatorProcess.signals_LD = signals_LD;
|
||||
@@ -246,6 +241,9 @@ namespace BitgetAPI
|
||||
// 캔들 데이터 가져오기
|
||||
foreach (var interval in Enum.GetValues(typeof(CommonProperty.MCandleTimeType)))
|
||||
{
|
||||
var strInterval = Utils.Convertor.GetEnumDescription((Enum)interval);
|
||||
if (!indicatorProcess.intervalList.Contains(strInterval)) continue;
|
||||
|
||||
// Description
|
||||
var description = Utils.Convertor.GetEnumDescription((Enum)interval);
|
||||
// 1M, 3M Names....
|
||||
@@ -524,6 +522,11 @@ namespace BitgetAPI
|
||||
|
||||
// 웹소켓으로 캔들 쌓기
|
||||
// WebSocket 생성
|
||||
indicatorProcess = new IndicatorProcess();
|
||||
var checkedMarkets = checkedComboBoxEdit_MarketInfoList.Properties.Items.GetCheckedValues();
|
||||
var intervalList = checkedComboBoxEdit_TimeInterval.Properties.Items.GetCheckedValues();
|
||||
indicatorProcess.checkedMarkets = checkedMarkets;
|
||||
indicatorProcess.intervalList = intervalList;
|
||||
|
||||
commonProperty.webConnection = webConnection;
|
||||
webConnection.Is_th_webSocketThread = true;
|
||||
|
||||
@@ -19,6 +19,7 @@ using static BitgetAPI.CommonProperty;
|
||||
using DateTime = System.DateTime;
|
||||
using DevExpress.Xpo.Logger;
|
||||
using DevExpress.XtraTreeList.Filtering.Provider;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace BitgetAPI.WebService
|
||||
{
|
||||
@@ -736,7 +737,7 @@ namespace BitgetAPI.WebService
|
||||
}
|
||||
}
|
||||
|
||||
public void CalculateDataList(BitgetWebSocketType bitgetWebSocketType)
|
||||
public void CalculateDataList(BitgetWebSocketType bitgetWebSocketType, List<object> intervalList)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -766,7 +767,7 @@ namespace BitgetAPI.WebService
|
||||
|
||||
var dataList = cloneList.Where(t => t.ContainsKey("data")).Select(t => t["data"]);
|
||||
var list = JsonConvert.DeserializeObject<List<List<WebSocketTickerInfo>>>(JsonConvert.SerializeObject(dataList));
|
||||
|
||||
var stringList = list.Select(t => t[0].instId).Distinct().ToList();
|
||||
list = list.OrderBy(t => t[0].ts).ToList();
|
||||
|
||||
|
||||
@@ -774,37 +775,102 @@ namespace BitgetAPI.WebService
|
||||
{
|
||||
case CommonProperty.BitgetWebSocketType.현황정보_전체종목:
|
||||
{
|
||||
foreach (var datalist in list)
|
||||
{
|
||||
var candleInfo = datalist;
|
||||
var tickerList = candleInfo[0];
|
||||
var minList = new Dictionary<string, List<CandleData>>();
|
||||
|
||||
foreach (var item in stringList)
|
||||
{
|
||||
var temp = list.Where(t => item == t[0].instId);
|
||||
if (temp.Count() > 0)
|
||||
{
|
||||
minList.Add(item, new List<CandleData>());
|
||||
foreach (var t in temp)
|
||||
{
|
||||
var tickerList = t[0];
|
||||
DateTime dt = new DateTime(1970, 01, 01);
|
||||
tickerList.reciveTime = dt.AddMilliseconds(Convert.ToDouble(tickerList.ts)).ToLocalTime();
|
||||
|
||||
// 웹소켓 티커 리스트에 추가 (사용 안함)
|
||||
/*
|
||||
var searchIndex = commonProperty.webSocketCandles.IndexOf(i => i.instId == tickerList.instId);
|
||||
if (searchIndex < 0)
|
||||
commonProperty.webSocketCandles.Add(tickerList);
|
||||
else
|
||||
{
|
||||
commonProperty.webSocketCandles[searchIndex] = tickerList;
|
||||
}
|
||||
*/
|
||||
|
||||
var timeList = temp.Select(t => t[0].reciveTime.Minute);
|
||||
foreach (var min in timeList)
|
||||
{
|
||||
var minDataList = temp.Where(t => t[0].reciveTime.Minute == min);
|
||||
var candleData = new CandleData();
|
||||
|
||||
candleData.Argument = minDataList.Last()[0].reciveTime;
|
||||
candleData.Close = minDataList.Last()[0].lastPr;
|
||||
candleData.Open = minDataList.First()[0].lastPr;
|
||||
candleData.Low = minDataList.Min(t => t[0].lastPr);
|
||||
candleData.High = minDataList.Max(t => t[0].lastPr);
|
||||
|
||||
minList[item].Add(candleData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//minList = new Dictionary<string, List<CandleData>>();
|
||||
|
||||
//List<WebSocketTickerInfo> tempList = new List<WebSocketTickerInfo>();
|
||||
//foreach (var datalist in list)
|
||||
//{
|
||||
// var tickerList = datalist[0];
|
||||
// DateTime dt = new DateTime(1970, 01, 01);
|
||||
// tickerList.reciveTime = dt.AddMilliseconds(Convert.ToDouble(tickerList.ts)).ToLocalTime();
|
||||
// tempList.Add(tickerList);
|
||||
|
||||
// if (minList.ContainsKey(tickerList.instId))
|
||||
// {
|
||||
// if (!minList[tickerList.instId].Any(m => m.Argument.Minute == tickerList.reciveTime.Minute))
|
||||
// {
|
||||
// var candleData = new CandleData();
|
||||
// candleData.Argument = tickerList.reciveTime;
|
||||
// candleData.Close = tickerList.lastPr;
|
||||
// candleData.Open = tickerList.lastPr;
|
||||
// candleData.Low = tickerList.lastPr;
|
||||
// candleData.High = tickerList.lastPr;
|
||||
|
||||
// minList[tickerList.instId].Add(candleData);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// var tempItem = minList[tickerList.instId].First(t => t.Argument.Minute == tickerList.reciveTime.Minute);
|
||||
// tempItem.Argument = tickerList.reciveTime;
|
||||
// tempItem.Close = tickerList.lastPr;
|
||||
// tempItem.Low = tempItem.Low > tickerList.lastPr ? tickerList.lastPr : tempItem.Low;
|
||||
// tempItem.High = tempItem.High < tickerList.lastPr ? tickerList.lastPr : tempItem.High;
|
||||
// }
|
||||
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// minList.Add(tickerList.instId, new List<CandleData>());
|
||||
// var candleData = new CandleData();
|
||||
// candleData.Argument = tickerList.reciveTime;
|
||||
// candleData.Close = tickerList.lastPr;
|
||||
// candleData.Open = tickerList.lastPr;
|
||||
// candleData.Low = tickerList.lastPr;
|
||||
// candleData.High = tickerList.lastPr;
|
||||
|
||||
// minList[tickerList.instId].Add(candleData);
|
||||
// }
|
||||
//}
|
||||
|
||||
foreach (var item in minList.Keys)
|
||||
{
|
||||
var temp = minList[item];
|
||||
|
||||
foreach (var candleData in temp)
|
||||
{
|
||||
|
||||
// 캔들 리스트에서 해당 데이터 찾기
|
||||
var searchIndex_c = commonProperty.candleDataLists.IndexOf(i => i.ConGoodsData.MarketName == tickerList.instId);
|
||||
var searchIndex_c = commonProperty.candleDataLists.IndexOf(i => i.ConGoodsData.MarketName == item);
|
||||
|
||||
// 캔들 리스트에 업데이트 (전체 시간별)
|
||||
foreach (CommonProperty.MCandleTimeType interval in Enum.GetValues(typeof(CommonProperty.MCandleTimeType)))
|
||||
{
|
||||
var candleDataList = commonProperty.candleDataLists[searchIndex_c].candleDataList[interval];
|
||||
var strInterval = Utils.Convertor.GetEnumDescription((Enum)interval);
|
||||
if (!intervalList.Contains(strInterval)) continue;
|
||||
|
||||
// 캔들 리스트에 추가
|
||||
var candleData = new CandleData();
|
||||
candleData.Argument = tickerList.reciveTime;
|
||||
candleData.Close = tickerList.lastPr;
|
||||
var candleDataList = commonProperty.candleDataLists[searchIndex_c].candleDataList[interval];
|
||||
|
||||
// 캔들 리스트가 없으면 추가
|
||||
if (candleDataList.Count == 0)
|
||||
@@ -867,20 +933,14 @@ namespace BitgetAPI.WebService
|
||||
lastCandleData.Argument = candleData.Argument;
|
||||
// 종가 수정
|
||||
lastCandleData.Close = candleData.Close;
|
||||
// 저가 등록
|
||||
if (lastCandleData.Low == 0 || lastCandleData.Low > candleData.Close) lastCandleData.Low = candleData.Close;
|
||||
// 고가 등록
|
||||
if (lastCandleData.High == 0 || lastCandleData.High < candleData.Close) lastCandleData.High = candleData.Close;
|
||||
lastCandleData.Low = lastCandleData.Low > candleData.Low ? candleData.Low : lastCandleData.Low;
|
||||
lastCandleData.High = lastCandleData.High < candleData.High ? candleData.High : lastCandleData.High;
|
||||
|
||||
lastCandleData.WebSocketUpdate = true;
|
||||
}
|
||||
// 없는 경우 추가
|
||||
else
|
||||
{
|
||||
if (candleData.Open == 0) { }
|
||||
// 1분 이상 Ticker가 없는 겨우는 Open 가만 가격이 등록됨
|
||||
candleData.Open = candleData.Close;
|
||||
|
||||
candleData.WebSocketUpdate = true;
|
||||
|
||||
// 새 데이터 등록
|
||||
@@ -894,9 +954,8 @@ namespace BitgetAPI.WebService
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user