1. Hunter 일반 비교 관련 로직 재 수정

This commit is contained in:
kyh
2022-11-03 10:05:07 +09:00
parent 76ee46cece
commit b97e241973
5 changed files with 93 additions and 35 deletions

View File

@@ -152,6 +152,8 @@ namespace Million_Buyer
int.TryParse(tb_CycleCount.Text, out cycleCount);
double.TryParse(tb_CycleMoneyValue.Text, out cycleBuyMoney);
bt_BuyStart_Click(null, null);
if (!RealTimeMode)
{
if (cycleCount == 0 || cycleBuyMoney == 0)
@@ -319,6 +321,7 @@ namespace Million_Buyer
InsertLog("Buyer 구동 중..");
var cnt = 0;
var boolFlag = false;
sw.Start();
#endregion
while (ThreadFlag)
@@ -729,7 +732,7 @@ namespace Million_Buyer
/// Text Area 에 Log 입력
/// </summary>
/// <param name="log"></param>
private void InsertLog(string log)
private bool InsertLog(string log)
{
this.BeginInvoke(new Action(delegate ()
{
@@ -739,6 +742,7 @@ namespace Million_Buyer
}
lb_log.Items.Insert(0, log);
}));
return true;
}
/// <summary>
/// Thread 가 살아 있는지 확인
@@ -775,7 +779,7 @@ namespace Million_Buyer
if (price == 0)
ordType = UpbitOrderType.price;
var returnData = CommonProperty.UpbitApi.TryOrder(coinFullName, side, volume, price, ordType);
var returnData = CommonProperty.UpbitApi.TryOrder(coinFullName, side, volume, price, InsertLog, ordType);
InsertLog("------------------------------------");
InsertLog("Buy Return Data : " + JsonConvert.SerializeObject(returnData));
InsertLog("------------------------------------");
@@ -802,11 +806,16 @@ namespace Million_Buyer
OrderCancel(coinFullName, uuid);
var orderData = CommonProperty.UpbitApi.GetOrderInformation(uuid);
var returnData = CommonProperty.UpbitApi.TryOrder(coinFullName, side, orderData.ExecutedVolume, price, ordType);
// 못삿을 경우
if (orderData.ExecutedVolume != 0)
{
var returnData = CommonProperty.UpbitApi.TryOrder(coinFullName, side, orderData.ExecutedVolume, price, InsertLog, ordType);
InsertLog("------------------------------------");
InsertLog("Sell Return Data : " + JsonConvert.SerializeObject(returnData));
InsertLog("------------------------------------");
}
return orderData.ExecutedVolume;
}

View File

@@ -1,6 +1,7 @@
using Million.Data;
using Million.DbManagement;
using Million.IndicatorConditionSetup;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -602,29 +603,25 @@ namespace Million.Manager
{
var dic = parent.CalculateFlag;
var overlapData = GetOverlapValueData(setUp, parent, key);
if (overlapData == 0) continue;
var valDic = ResultLogicManager.GetIndicateValue(dic, totalIndicators, parent);
var subVal = GetConditionValue(subScript.regularExpressionString, valDic, dic);
if (subVal == 0) continue;
//Sub 조건 만족 여부
if (subScript.DicExcuteScript(dic))
{
subFlag = true;
}
else
{
if (subFlag)
{
subFlag = false;
var str = "";
if (recentlyDataFlag)
{
if (!subManagement[coinFullName])
{
str = "Buyer(Realtime) Mode\r\n";
str += coinFullName + " 최초 돌파 Sub조건 초기화 됨\r\n";
str += JsonConvert.SerializeObject(parent);
LogManager.WriteLog(str, coinFullName);
}
subManagement[coinFullName] = true;
}
else
@@ -632,7 +629,14 @@ namespace Million.Manager
firstFlag = false;
}
}
}
var overlapData = GetOverlapValueData(setUp, parent, key);
if (overlapData == 0) continue;
var valDic = ResultLogicManager.GetIndicateValue(dic, totalIndicators, parent);
var subVal = GetConditionValue(subScript.regularExpressionString, valDic, dic);
if (subVal == 0) continue;
//sub 조건이 만족할 경우
if (subFlag)
@@ -846,7 +850,29 @@ namespace Million.Manager
if (value == 0 || overlapData == 0) continue;
if (CompareSettingValueOfTranspierce(setUp.IndicatorOver, overlapData, value))
var compareFlag = false;
//헌터 일경우
if (setUp.CandlePriceType == CandlePriceType.종가)
{
if (!recentlyDataFlag)
{
var highFlag = CompareSettingValueOfTranspierce(setUp.IndicatorOver, overlapData, item.HighValue);
var lowFlag = CompareSettingValueOfTranspierce(setUp.IndicatorOver, overlapData, item.LowValue);
if (highFlag || lowFlag) compareFlag = true;
}
else
{
compareFlag = CompareSettingValueOfTranspierce(setUp.IndicatorOver, overlapData, value);
}
}
else
{
compareFlag = CompareSettingValueOfTranspierce(setUp.IndicatorOver, overlapData, value);
}
if (compareFlag)
{
var childList = new List<CandleData>();
if (item.CandleTimeType == (int)MCandleTimeType.M1)
@@ -896,6 +922,9 @@ namespace Million.Manager
var lowVal = child.LowValue;
var highVal = child.HighValue;
if (lowVal == 0 || highVal == 0)
continue;
var lowFlag = CompareSettingValueOfSimpleComparison(setUp.IndicatorOver, overlapData, lowVal);
var highFlag = CompareSettingValueOfSimpleComparison(setUp.IndicatorOver, overlapData, highVal);
@@ -925,6 +954,9 @@ namespace Million.Manager
else
{
var childValue = GetValue(item, setUp);
if (childValue == 0)
continue;
var flag = CompareSettingValueOfSimpleComparison(setUp.IndicatorOver, overlapData, childValue);
if (child.IndicatorDic.ContainsKey(key))
@@ -1122,6 +1154,7 @@ namespace Million.Manager
private static double GetValue(CandleData data, IndicatorCoditionSetup setUp)
{
double value = 0;
if (setUp.CandlePriceType == CommonProperty.CandlePriceType.시가)
{
value = data.StartValue;

View File

@@ -42,7 +42,7 @@ namespace Million.Manager
if (!System.IO.File.Exists(filePath))
{
System.IO.File.Create(filePath);
System.IO.File.Create(filePath).Close();
}
System.IO.File.AppendAllText(filePath, defaultMesage);

View File

@@ -323,6 +323,7 @@ namespace Million.Manager
candle.LowValue = low;
candle.RecentlyDataFlag = true;
candle.EndValue = list[list.Count - 1].TradePrice;
var date = basicDateTime.AddHours(1);
date.AddMinutes(-1 * callM);
date.AddSeconds(-1 * callS);

View File

@@ -10,6 +10,8 @@ using Million.Data.Upbit.Order;
using Million.Data.Upbit;
using Million.Data.Upbit.OrderBook;
using System.Threading;
using Million.Manager;
using Newtonsoft.Json;
namespace Million.WebMangement.Upbit
{
@@ -217,7 +219,7 @@ namespace Million.WebMangement.Upbit
/// <param name="price">가격</param>
/// <param name="ord_type">Limit = 지정가 주문, price = 시장가 주문(매수), market = 시장가 주문(매도)</param>
/// <returns></returns>
public Order TryOrder(string coinFullName, UpbitOrderSide side, double volume, double price, UpbitOrderType ord_type = UpbitOrderType.limit)
public Order TryOrder(string coinFullName, UpbitOrderSide side, double volume, double price, Func<string, bool> insertLog, UpbitOrderType ord_type = UpbitOrderType.limit)
{
string url = UpbitURL_Orders;
var namevalCollection = new NameValueCollection {
@@ -234,6 +236,8 @@ namespace Million.WebMangement.Upbit
Order returnData;
var cnt = 0;
while (true)
{
returnData = WebServiceFunctions.TryOrder(resResult);
@@ -241,11 +245,22 @@ namespace Million.WebMangement.Upbit
break;
else
{
resResult = process.CallAPI(url, HttpMethod.Post, namevalCollection);
Thread.Sleep(1000);
resResult = process.CallAPI(url, HttpMethod.Post, namevalCollection);
}
if (cnt == 10)
{
insertLog("Try Order Count 넘어감 -> CNT : " + cnt);
var logStr = coinFullName + " 주문 에러!! 주문 returnData : " + JsonConvert.SerializeObject(returnData) + "\r\n"
+ "resResult : " + resResult;
LogManager.WriteLog(logStr, coinFullName);
break;
}
cnt++;
}
return returnData;
}