삿는데 다음봉 되보니 아닐경우에 대한 예외처리 추가(원본가 오면 팔아버림)
This commit is contained in:
@@ -4,6 +4,7 @@ using BitgetApi.IndicatorConditionSetup;
|
||||
using BitgetApi.IndicatorData;
|
||||
using BitgetAPI.Data;
|
||||
using BitgetAPI.WebService;
|
||||
using DevExpress.XtraGrid.Views.Base;
|
||||
using Newtonsoft.Json;
|
||||
using Serilog;
|
||||
using Serilog.Debugging;
|
||||
@@ -394,7 +395,8 @@ namespace BitgetAPI.IndicatorConditionSetup
|
||||
{
|
||||
{ "MarketName", market },
|
||||
{ "BuyDate", nowTime },
|
||||
{ "Price", price },
|
||||
{ "Price", price },
|
||||
{ "Flag", false },
|
||||
{ "MCandleTimeType", (int)interval },
|
||||
{ "CandleTime", candleData_30.Argument },
|
||||
{ "Candle", candleData_30 }
|
||||
@@ -441,12 +443,21 @@ namespace BitgetAPI.IndicatorConditionSetup
|
||||
{
|
||||
|
||||
var buyItem = UpBuyList[market];
|
||||
//var flag = (bool)buyItem["Flag"];
|
||||
var flag = (bool)buyItem["Flag"];
|
||||
if (interval < MCandleTimeType.H1)
|
||||
{
|
||||
var buyTime = ((DateTime)buyItem["BuyDate"]).AddMinutes(5);
|
||||
var buyTime = ((DateTime)buyItem["BuyDate"]).AddMinutes(30);
|
||||
var buyTwoTime = buyTime.AddMinutes(30);
|
||||
if (nowTime < buyTime)
|
||||
continue;
|
||||
else if (nowTime < buyTwoTime)
|
||||
{
|
||||
if (sMABandConditionSetup.Calculate(candleDatas_30_TempList, SMABandType.LongBuy, true) &&
|
||||
!sMABandConditionSetup.Calculate(candleDatas_30_TempList, SMABandType.LongSell, true))
|
||||
{
|
||||
buyItem["Flag"] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
//임시로 처리
|
||||
else
|
||||
@@ -456,7 +467,16 @@ namespace BitgetAPI.IndicatorConditionSetup
|
||||
continue;
|
||||
}
|
||||
|
||||
if (sMABandConditionSetup.Calculate(candleDatas_30_TempList, SMABandType.LongSell))
|
||||
var sellFlag = false;
|
||||
|
||||
if (flag)
|
||||
{
|
||||
var buyPrice = (double)buyItem["Price"];
|
||||
if(candleData_30.Close > buyPrice)
|
||||
sellFlag= true;
|
||||
}
|
||||
|
||||
if (sMABandConditionSetup.Calculate(candleDatas_30_TempList, SMABandType.LongSell) || sellFlag)
|
||||
{
|
||||
double.TryParse(buyItem["Price"].ToString(), out var buyPrice);
|
||||
var resultRate = ((price - buyPrice) / buyPrice) * 100;
|
||||
@@ -465,7 +485,7 @@ namespace BitgetAPI.IndicatorConditionSetup
|
||||
{
|
||||
{ "MarketName", market },
|
||||
{ "BuyDate", buyItem["BuyDate"]},
|
||||
{ "Type", "상향"},
|
||||
{ "Type", "상향"},
|
||||
{ "BuyPrice", buyPrice },
|
||||
{ "MCandleTimeType", (int)interval },
|
||||
{ "BuyCandle", buyItem["Candle"] },
|
||||
@@ -568,7 +588,8 @@ namespace BitgetAPI.IndicatorConditionSetup
|
||||
{
|
||||
{ "MarketName", market },
|
||||
{ "BuyDate", nowTime },
|
||||
{ "Price", price },
|
||||
{ "Price", price },
|
||||
{ "Flag", false },
|
||||
{ "MCandleTimeType", (int)interval },
|
||||
{ "CandleTime", candleData_30.Argument },
|
||||
{ "Candle", candleData_30 }
|
||||
@@ -615,22 +636,43 @@ namespace BitgetAPI.IndicatorConditionSetup
|
||||
else
|
||||
{
|
||||
var buyItem = DownBuyList[market];
|
||||
//var flag = (bool)buyItem["Flag"];
|
||||
var flag = (bool)buyItem["Flag"];
|
||||
if (interval < MCandleTimeType.H1)
|
||||
{
|
||||
var buyTime = ((DateTime)buyItem["BuyDate"]).AddMinutes(5);
|
||||
var buyTime = ((DateTime)buyItem["BuyDate"]).AddMinutes(30);
|
||||
var buyTwoTime = buyTime.AddMinutes(30);
|
||||
|
||||
if (nowTime < buyTime)
|
||||
continue;
|
||||
else if (nowTime < buyTwoTime)
|
||||
{
|
||||
if (sMABandConditionSetup.Calculate(candleDatas_30_TempList, SMABandType.ShortBuy, true) &&
|
||||
!sMABandConditionSetup.Calculate(candleDatas_30_TempList, SMABandType.ShortSell, true))
|
||||
{
|
||||
buyItem["Flag"] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
//임시로 처리
|
||||
else
|
||||
{
|
||||
var buyTime = ((DateTime)buyItem["BuyDate"]).AddHours((int)interval / 60);
|
||||
|
||||
if (nowTime < buyTime)
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
if (sMABandConditionSetup.Calculate(candleDatas_30_TempList, SMABandType.ShortSell))
|
||||
|
||||
var sellFlag = false;
|
||||
|
||||
if (flag)
|
||||
{
|
||||
var buyPrice = (double)buyItem["Price"];
|
||||
if (candleData_30.Close > buyPrice)
|
||||
sellFlag = true;
|
||||
}
|
||||
|
||||
if (sMABandConditionSetup.Calculate(candleDatas_30_TempList, SMABandType.ShortSell) || sellFlag)
|
||||
{
|
||||
BuyShortStep[market] = 0;
|
||||
double.TryParse(buyItem["Price"].ToString(), out var buyPrice);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using BitgetAPI.Data;
|
||||
using BitgetAPI.Data.IndicatorData;
|
||||
using DevExpress.Utils.Extensions;
|
||||
using DevExpress.XtraBars.Ribbon.Gallery;
|
||||
using DevExpress.XtraBars.ViewInfo;
|
||||
using System;
|
||||
@@ -34,7 +35,7 @@ namespace BitgetApi.IndicatorConditionSetup
|
||||
/// </summary>
|
||||
private bool firstCloudFlag = true;
|
||||
|
||||
public bool Calculate(List<CandleData> candles, SMABandType type)
|
||||
public bool Calculate(List<CandleData> candles, SMABandType type, bool flag = false)
|
||||
{
|
||||
var close = candles.Select(t => t.Close).ToList();
|
||||
|
||||
@@ -44,6 +45,14 @@ namespace BitgetApi.IndicatorConditionSetup
|
||||
|
||||
var open = candles.Select(t => t.Open).ToList();
|
||||
|
||||
if (flag)
|
||||
{
|
||||
close.RemoveAt(close.Count - 1);
|
||||
high.RemoveAt(high.Count - 1);
|
||||
low.RemoveAt(low.Count - 1);
|
||||
open.RemoveAt(open.Count - 1);
|
||||
}
|
||||
|
||||
int i = close.Count - 1;
|
||||
if (close.Count < 100 || high.Count < 100 || low.Count < 100 || open.Count < 100)
|
||||
return false;
|
||||
@@ -79,18 +88,18 @@ namespace BitgetApi.IndicatorConditionSetup
|
||||
|
||||
bool isSma4BelowCloud = low[i] < cloudBottomNow;
|
||||
bool isSma4AboveCloud = high[i] > cloudTopNow;
|
||||
bool cloudFlag = false;
|
||||
//bool cloudFlag = false;
|
||||
|
||||
if (!firstCloudFlag)
|
||||
{
|
||||
if(isSma4BelowCloud)
|
||||
cloudFlag = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!isSma4BelowCloud)
|
||||
firstCloudFlag = false;
|
||||
}
|
||||
//if (!firstCloudFlag)
|
||||
//{
|
||||
// if(isSma4BelowCloud)
|
||||
// cloudFlag = true;
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// if (!isSma4BelowCloud)
|
||||
// firstCloudFlag = false;
|
||||
//}
|
||||
|
||||
|
||||
bool greenCandle = open[i] < close[i];
|
||||
@@ -101,8 +110,8 @@ namespace BitgetApi.IndicatorConditionSetup
|
||||
|
||||
bool rawLongSell = (sma4 <= prevSma4 && prevSma4 <= prev2Sma4 && sma4 < sma4High);
|
||||
|
||||
|
||||
bool rawNewShort = cloudFlag && IsSideways(high, low, i, false) && isSma4BelowCloud && (sma4 == sma4Low && prevSma4 >= prevSma4Low && prev2Sma4 >= prev2Sma4Low) && (sma4 <= prevSma4 && prevSma4 <= prev2Sma4 && prev2Sma4 <= prev3Sma4);
|
||||
//cloudFlag &&
|
||||
bool rawNewShort = IsSideways(high, low, i, false) && isSma4BelowCloud && (sma4 == sma4Low && prevSma4 >= prevSma4Low && prev2Sma4 >= prev2Sma4Low) && (sma4 <= prevSma4 && prevSma4 <= prev2Sma4 && prev2Sma4 <= prev3Sma4);
|
||||
|
||||
bool rawShortSell = (sma4 >= prevSma4 && prevSma4 >= prev2Sma4 && sma4 > sma4Middle);
|
||||
|
||||
@@ -122,8 +131,8 @@ namespace BitgetApi.IndicatorConditionSetup
|
||||
}
|
||||
else if (type == SMABandType.ShortSell)
|
||||
{
|
||||
if (rawShortSell)
|
||||
firstCloudFlag = true;
|
||||
//if (rawShortSell)
|
||||
// firstCloudFlag = true;
|
||||
return rawShortSell;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user