구름떼 검색기 수정 중!!
This commit is contained in:
@@ -21,6 +21,7 @@ using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using static BitgetAPI.CommonProperty;
|
||||
using static DevExpress.Utils.Html.ViewInfo.DxHtmlOrderedListInfoCore;
|
||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement.TextBox;
|
||||
|
||||
namespace BitgetAPI
|
||||
@@ -30,16 +31,18 @@ namespace BitgetAPI
|
||||
CommonProperty commonProperty = CommonProperty.Instance;
|
||||
|
||||
#region 폼 내 사용되는 스레드
|
||||
// 트리 현황판 업데이트 스레드
|
||||
// 트리 현황판 업데이트 스레드 (단순 폼 업데이트)
|
||||
Thread treeListMarketInfoListUpdateTimer = null;
|
||||
// 현황판 웹소켓 스레드
|
||||
// 웹소켓 스레드 (선택된 종목 개수 만큼 가져오기)
|
||||
List<Thread> th_MarketStatusList = null;
|
||||
// WebSocket 내 스레드 관리
|
||||
List<Thread> webSocketThreadList = new List<Thread>();
|
||||
// 종목별 캔들 데이터 스레드
|
||||
// 종목별 캔들 데이터 스레드 (사용 안함)
|
||||
Thread th_MarketCandeData = null;
|
||||
// 신호검색 스레드 함수
|
||||
// 신호검색 스레드 함수
|
||||
Thread th_SignalInfo = null;
|
||||
// 현황판 웹서비스 Ticker 스레드 (한번에 전체 종목 종가 받음)
|
||||
Thread th_MarketInfoList = null;
|
||||
|
||||
// 신호검색 리스트 작성
|
||||
// 신호 Long 상승 (구매)
|
||||
@@ -77,50 +80,7 @@ namespace BitgetAPI
|
||||
treeList_MarketInfo.Columns["quoteVolume"].SortOrder = SortOrder.Descending;
|
||||
treeList_MarketInfo.EndSort();
|
||||
|
||||
// Json String 만들기
|
||||
// 종목별 Ticker 구독하기
|
||||
th_MarketStatusList = new List<Thread>();
|
||||
var dic = new Dictionary<string, object>();
|
||||
dic.Add("op", "subscribe");
|
||||
|
||||
var argsList = new List<Dictionary<string, object>>();
|
||||
|
||||
var count = 0;
|
||||
|
||||
foreach (var marketInfo in commonProperty.marketInfoList)
|
||||
{
|
||||
var args = new Dictionary<string, object>();
|
||||
args.Add("instType", "USDT-FUTURES");
|
||||
args.Add("channel", "ticker");
|
||||
args.Add("instId", marketInfo.MarketName);
|
||||
argsList.Add(args);
|
||||
|
||||
count++;
|
||||
|
||||
if (count % 30 == 0 || count == commonProperty.marketInfoList.Count - 1)
|
||||
{
|
||||
dic.Add("args", argsList);
|
||||
|
||||
var th_MarketStatus = new Thread(() => ThreadEventAsync(BitgetWebSocketType.현황정보_전체종목, dic));
|
||||
th_MarketStatus.Start();
|
||||
|
||||
th_MarketStatusList.Add(th_MarketStatus);
|
||||
//break;
|
||||
|
||||
dic = new Dictionary<string, object>();
|
||||
dic.Add("op", "subscribe");
|
||||
argsList = new List<Dictionary<string, object>>();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 현황판 웹소켓
|
||||
commonProperty.webSocketCandles = new List<WebSocketTickerInfo>();
|
||||
treeList_MarketInfo.DataSource = commonProperty.webSocketCandles;
|
||||
|
||||
// 트리 현황판 업데이트
|
||||
treeListMarketInfoListUpdateTimer = new Thread(new ThreadStart(TreeListMarketInfoListUpdate));
|
||||
treeListMarketInfoListUpdateTimer.Start();
|
||||
|
||||
// 신호 Long 상승 (구매)
|
||||
signals_LU = new List<SignalInfoData>();
|
||||
@@ -135,14 +95,30 @@ namespace BitgetAPI
|
||||
treeList_LongUp.DataSource = signals_LU;
|
||||
treeList_ShortDown.DataSource = signals_SD;
|
||||
|
||||
// 신호검색 스레드
|
||||
//th_SignalInfo = new Thread(new ThreadStart(Signalnfo));
|
||||
//th_SignalInfo.Start();
|
||||
|
||||
// API Key 가져오기 및 등록
|
||||
|
||||
}
|
||||
|
||||
// 웹서비스를 통해 현황판 및 마켓 Ticker 업데이트
|
||||
private void getMarketInfoList_WebService(ExchangeWebReqType exchangeWebReqType)
|
||||
{
|
||||
while(true)
|
||||
{
|
||||
Thread.Sleep(500);
|
||||
// 마켓 모든 종목 캔들 정보 Web Service로 가져오기
|
||||
commonProperty.marketInfoList = (List<MarketInfo>)BitgetAPI.WebService.WebConnection.SendWebServer(exchangeWebReqType);
|
||||
|
||||
// 현황판에 최신 정보 업데이트 하기
|
||||
Invoke(new MethodInvoker(delegate ()
|
||||
{
|
||||
var scrollPoint = treeList_MarketInfo.TopVisibleNodeIndex;
|
||||
treeList_MarketInfo.DataSource = commonProperty.marketInfoList;
|
||||
treeList_MarketInfo.RefreshDataSource();
|
||||
treeList_MarketInfo.TopVisibleNodeIndex = scrollPoint;
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
// 웹소켓 생성 관련 함수 스레드 => Thread
|
||||
private async void ThreadEventAsync(BitgetWebSocketType bitgetWebSocketType, Dictionary<string, object> dic)
|
||||
{
|
||||
@@ -200,11 +176,14 @@ namespace BitgetAPI
|
||||
선행스팬2 : (과거 k일간의 최고가 + 과거 k일간의 최저가) /2한 값을 ℓ일 후에 기입
|
||||
*/
|
||||
|
||||
var checkedMarkets = checkedComboBoxEdit_MarketInfoList.Properties.Items.GetCheckedValues();
|
||||
var intervalList = checkedComboBoxEdit_TimeInterval.Properties.Items.GetCheckedValues();
|
||||
|
||||
while (true)
|
||||
{
|
||||
//if (!xtraTabPage_Searcher.PageEnabled) continue;
|
||||
|
||||
Thread.Sleep(200);
|
||||
//Thread.Sleep(200);
|
||||
var nowTime = DateTime.Now;
|
||||
|
||||
// 특정 시간 이후 삭제
|
||||
@@ -229,17 +208,36 @@ namespace BitgetAPI
|
||||
}
|
||||
|
||||
}
|
||||
foreach (var item in signals_LD.ToList())
|
||||
if (item.SignalStart + timeSpanEdit_SesstionTime.TimeSpan < nowTime) { signals_LD.Remove(item); }
|
||||
foreach (var item in signals_SU.ToList())
|
||||
if (item.SignalStart + timeSpanEdit_SesstionTime.TimeSpan < nowTime) signals_SU.Remove(item);
|
||||
foreach (var item in signals_SD.ToList())
|
||||
{
|
||||
// 시간 지나면 삭제
|
||||
if (item.SignalStart + timeSpanEdit_SesstionTime.TimeSpan < nowTime)
|
||||
{
|
||||
signals_SD.Remove(item);
|
||||
continue;
|
||||
|
||||
}
|
||||
var findedMarket = commonProperty.candleDataLists.Find(i => i.ConGoodsData.MarketName == item.MarketName);
|
||||
var lastCandleData = findedMarket.candleDataList[item.MCandleTimeType].OrderBy(i => i.Argument).ToList().Last();
|
||||
|
||||
if (lastCandleData.IchimokData != null)
|
||||
{
|
||||
item.Price = lastCandleData.Close;
|
||||
if (lastCandleData.Open == 0) { }
|
||||
item.Rate = (lastCandleData.Close / lastCandleData.Open) * 100 - 100;
|
||||
item.IndicatorPrice = lastCandleData.IchimokData.하한선;
|
||||
item.IndicatorRate = (lastCandleData.Close / item.IndicatorPrice) * 100 - 100;
|
||||
}
|
||||
}
|
||||
foreach (var item in signals_LD.ToList())
|
||||
if (item.SignalStart + timeSpanEdit_SesstionTime.TimeSpan < nowTime) signals_SU.Remove(item);
|
||||
foreach (var item in signals_SU.ToList())
|
||||
if (item.SignalStart + timeSpanEdit_SesstionTime.TimeSpan < nowTime) signals_SD.Remove(item);
|
||||
|
||||
var intervalList = checkedComboBoxEdit_TimeInterval.Properties.Items.GetCheckedValues();
|
||||
|
||||
|
||||
// 체크된 마켓 정보
|
||||
foreach (string market in checkedComboBoxEdit_MarketInfoList.Properties.Items.GetCheckedValues())
|
||||
foreach (string market in checkedMarkets)
|
||||
{
|
||||
var findedMarket = commonProperty.candleDataLists.Find(i => i.ConGoodsData.MarketName == market);
|
||||
|
||||
@@ -314,6 +312,7 @@ namespace BitgetAPI
|
||||
signalInfoData.Price = price;
|
||||
signalInfoData.IndicatorPrice = indicatorPrice;
|
||||
signalInfoData.IndicatorRate = indicatorRate;
|
||||
signalInfoData.MCandleTimeType = interval;
|
||||
|
||||
signals_SD.Add(signalInfoData);
|
||||
}
|
||||
@@ -327,18 +326,24 @@ namespace BitgetAPI
|
||||
|
||||
|
||||
// 종목별 캔들데이터 가져오기 (초기 설정) => Thread
|
||||
private void getMarketCandleData_WebService(ExchangeWebReqType exchangeWebReqType)
|
||||
private void getMarketCandleData_WebService(ExchangeWebReqType exchangeWebReqType, List<object> marketList)
|
||||
{
|
||||
// 프로그레스 바
|
||||
progressBarControl_data.Properties.Minimum = 0;
|
||||
progressBarControl_data.Properties.Maximum = commonProperty.candleDataLists.Count;
|
||||
progressBarControl_data.Properties.Step = 1;
|
||||
progressBarControl_data.EditValue = 0;
|
||||
var progressCnt = 0;
|
||||
// WebServicee 초기 캔들 데이터 가져오기 : 종목, 개수
|
||||
foreach (var marketCandleDataList in commonProperty.candleDataLists)
|
||||
Invoke(new MethodInvoker(delegate ()
|
||||
{
|
||||
var marketName = marketCandleDataList.ConGoodsData.MarketName;
|
||||
progressBarControl_data.Properties.Minimum = 0;
|
||||
progressBarControl_data.Properties.Maximum = marketList.Count;
|
||||
progressBarControl_data.Properties.Step = 1;
|
||||
progressBarControl_data.EditValue = 0;
|
||||
}));
|
||||
|
||||
var progressCnt = 0;
|
||||
|
||||
// WebServicee 초기 캔들 데이터 가져오기 : 종목, 개수
|
||||
foreach (var marketName in marketList)
|
||||
{
|
||||
var marketCandleDataList = commonProperty.candleDataLists.Find(i => i.ConGoodsData.MarketName.Equals(marketName));
|
||||
if (marketCandleDataList == null) continue;
|
||||
|
||||
// 캔들 데이터 가져오기
|
||||
foreach (var interval in Enum.GetValues(typeof(CommonProperty.MCandleTimeType)))
|
||||
@@ -392,17 +397,13 @@ namespace BitgetAPI
|
||||
progressBarControl_data.EditValue = progressCnt;
|
||||
progressBarControl_data.PerformStep();
|
||||
progressBarControl_data.Update();
|
||||
|
||||
//xtraTabPage_Searcher.PageEnabled = true;
|
||||
//xtraTabControl_Main.SelectedTabPage = xtraTabPage_Searcher;
|
||||
}));
|
||||
}
|
||||
|
||||
Invoke(new MethodInvoker(delegate ()
|
||||
{
|
||||
xtraTabPage_Searcher.PageEnabled = true;
|
||||
xtraTabControl_Main.SelectedTabPage = xtraTabPage_Searcher;
|
||||
}));
|
||||
// 웹서비스 호출 완료 되면 시작
|
||||
// 신호검색 스레드
|
||||
th_SignalInfo = new Thread(new ThreadStart(Signalnfo));
|
||||
th_SignalInfo.Start();
|
||||
}
|
||||
|
||||
// 거래소 콤보박스 클릭 시 이벤트 처리
|
||||
@@ -420,7 +421,6 @@ namespace BitgetAPI
|
||||
commonProperty.selectedBitgetProductType = CommonProperty.BitgetProductType.FUTURE;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 코인 타입 콤보박스 클릭 시 이벤트 처리
|
||||
@@ -446,7 +446,8 @@ namespace BitgetAPI
|
||||
}
|
||||
|
||||
// 마켓 정보 가져오기
|
||||
var marketInfos = (List<MarketInfo>)BitgetAPI.WebService.WebConnection.SendWebServer(exchangeWebReqType);
|
||||
var marketInfos = commonProperty.marketInfoList = (List<MarketInfo>)BitgetAPI.WebService.WebConnection.SendWebServer(exchangeWebReqType);
|
||||
commonProperty.marketInfoList = marketInfos;
|
||||
|
||||
labelControl_MarketCount.Text = marketInfos.Count().ToString();
|
||||
treeList_MarketInfo.DataSource = marketInfos;
|
||||
@@ -469,8 +470,8 @@ namespace BitgetAPI
|
||||
}
|
||||
|
||||
// 조건 설정 : 체크콤보박스 마켓 정보 추가하기
|
||||
foreach (var item in commonProperty.candleDataLists)
|
||||
checkedComboBoxEdit_MarketInfoList.Properties.Items.Add(item.ConGoodsData.MarketName);
|
||||
foreach (var item in marketInfos.OrderByDescending(i => i.quoteVolume))
|
||||
checkedComboBoxEdit_MarketInfoList.Properties.Items.Add(item.MarketName);
|
||||
// 조건 설정 : 체크콤보박스 시간별 정보 추가하기
|
||||
// 캔들 데이터 가져오기
|
||||
foreach (var interval in Enum.GetValues(typeof(CommonProperty.MCandleTimeType)))
|
||||
@@ -479,6 +480,10 @@ namespace BitgetAPI
|
||||
checkedComboBoxEdit_TimeInterval.Properties.Items.Add(description);
|
||||
}
|
||||
|
||||
// 마켓정보(WebService Ticker) => 0.5초당 1번으로 업데이트 하기 (현황판)
|
||||
th_MarketInfoList = new Thread(() => getMarketInfoList_WebService(exchangeWebReqType));
|
||||
th_MarketInfoList.Start();
|
||||
|
||||
#region 캔들 웹소켓 : 종목 50, 캔들 1 개만 해도 뒤지려고 함 !! (일딴 패스)
|
||||
/*
|
||||
// 시간별 분봉 웹소켓
|
||||
@@ -490,11 +495,6 @@ namespace BitgetAPI
|
||||
break;
|
||||
}*/
|
||||
#endregion
|
||||
|
||||
// WebServicee 초기 캔들 데이터 가져오기 : 종목, 개수
|
||||
// 종목별 캔들 데이터 가져오기 (WebService)
|
||||
//th_MarketCandeData = new Thread(() => getMarketCandleData_WebService(exchangeWebReqType));
|
||||
//th_MarketCandeData.Start();
|
||||
}
|
||||
|
||||
// 폼 닫기 시 처리 이벤트
|
||||
@@ -512,6 +512,12 @@ namespace BitgetAPI
|
||||
}
|
||||
}
|
||||
|
||||
if (th_MarketInfoList != null)
|
||||
{
|
||||
th_MarketInfoList.Abort();
|
||||
th_MarketInfoList = null;
|
||||
}
|
||||
|
||||
if (treeListMarketInfoListUpdateTimer != null)
|
||||
{
|
||||
treeListMarketInfoListUpdateTimer.Abort();
|
||||
@@ -540,5 +546,73 @@ namespace BitgetAPI
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 검색기 > 종목 재 정렬
|
||||
private void simpleButton_MarketOrderRefresh_Click(object sender, EventArgs e)
|
||||
{
|
||||
checkedComboBoxEdit_MarketInfoList.Properties.Items.Clear();
|
||||
|
||||
// 조건 설정 : 체크콤보박스 마켓 정보 추가하기
|
||||
foreach (var item in commonProperty.marketInfoList.OrderByDescending(i=>i.quoteVolume))
|
||||
checkedComboBoxEdit_MarketInfoList.Properties.Items.Add(item.MarketName);
|
||||
|
||||
}
|
||||
|
||||
// 신호 검색 시작
|
||||
private void simpleButton_SignalStart_Click(object sender, EventArgs e)
|
||||
{
|
||||
var count = 0;
|
||||
|
||||
var marketList = checkedComboBoxEdit_MarketInfoList.Properties.Items.GetCheckedValues();
|
||||
if (marketList.Count <=0 ) return;
|
||||
|
||||
if (marketList.Count > 50)
|
||||
{
|
||||
for(var i = 50; i < marketList.Count; i++)
|
||||
{
|
||||
checkedComboBoxEdit_MarketInfoList.Properties.Items[i].CheckState = CheckState.Unchecked;
|
||||
}
|
||||
|
||||
marketList = checkedComboBoxEdit_MarketInfoList.Properties.Items.GetCheckedValues();
|
||||
}
|
||||
|
||||
th_MarketStatusList = new List<Thread>();
|
||||
var dic = new Dictionary<string, object>();
|
||||
dic.Add("op", "subscribe");
|
||||
|
||||
var argsList = new List<Dictionary<string, object>>();
|
||||
|
||||
// Json String 만들기
|
||||
// 종목별 Ticker 구독하기
|
||||
// WebSocket으로 데이터 가져오기
|
||||
foreach (var marketName in marketList)
|
||||
{
|
||||
var args = new Dictionary<string, object>();
|
||||
args.Add("instType", "USDT-FUTURES");
|
||||
args.Add("channel", "ticker");
|
||||
args.Add("instId", marketName);
|
||||
argsList.Add(args);
|
||||
|
||||
count++;
|
||||
}
|
||||
|
||||
dic.Add("args", argsList);
|
||||
|
||||
// 웹소켓으로 캔들 쌓기
|
||||
var th_MarketStatus = new Thread(() => ThreadEventAsync(BitgetWebSocketType.현황정보_전체종목, dic));
|
||||
th_MarketStatus.Start();
|
||||
th_MarketStatusList.Add(th_MarketStatus);
|
||||
|
||||
// WebServicee 초기 캔들 데이터 가져오기 : 종목, 개수
|
||||
// 종목별 캔들 데이터 가져오기 (WebService)
|
||||
// 선택된 타입에 따라서 종목 정보 가져오기
|
||||
var exchangeWebReqType = ExchangeWebReqType.BitgetMarket_Future;
|
||||
th_MarketCandeData = new Thread(() => getMarketCandleData_WebService(exchangeWebReqType, marketList));
|
||||
th_MarketCandeData.Start();
|
||||
|
||||
// 트리 현황판 업데이트
|
||||
treeListMarketInfoListUpdateTimer = new Thread(new ThreadStart(TreeListMarketInfoListUpdate));
|
||||
treeListMarketInfoListUpdateTimer.Start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user