푸시ㅜ푸ㅡ쉬

This commit is contained in:
kyh
2025-06-18 15:35:54 +09:00
parent 044e72664a
commit d684edc831
2 changed files with 51 additions and 33 deletions

View File

@@ -375,16 +375,16 @@ namespace BitgetAPI.IndicatorConditionSetup
{
if(!FirstFlag[market + strInterval + "Long"])
{
if(sMABandConditionSetup.Calculate(candleDatas_5_TempList, SMABandType.LongSell, true))
if(sMABandConditionSetup.Calculate(candleDatas_5_TempList, SMABandType.LongSell, market, true))
{
FirstFlag[market + strInterval + "Long"] = true;
}
}
if (sMABandConditionSetup.Calculate(candleDatas_5_TempList, SMABandType.LongBuy, true) &&
!sMABandConditionSetup.Calculate(candleDatas_5_TempList, SMABandType.LongSell, true) &&
FirstFlag[market + strInterval + "Long"] &&
저고점["전저가"] > 저고점["전전저가"]
if (sMABandConditionSetup.Calculate(candleDatas_5_TempList, SMABandType.LongBuy, market, true) &&
!sMABandConditionSetup.Calculate(candleDatas_5_TempList, SMABandType.LongSell, market, true) &&
FirstFlag[market + strInterval + "Long"]
//&& 저고점["전저가"] > 저고점["전전저가"]
)
{
BuyLongStep[market] = 0;
@@ -459,14 +459,14 @@ namespace BitgetAPI.IndicatorConditionSetup
var flag = (bool)buyItem["Flag"];
if (interval < MCandleTimeType.H1)
{
var buyTime = ((DateTime)buyItem["BuyDate"]).AddMinutes(5);
var buyTime = ((DateTime)buyItem["BuyDate"]).AddMinutes(1);
var buyTwoTime = buyTime.AddMinutes(5);
if (nowTime < buyTime)
continue;
else if (nowTime < buyTwoTime)
{
if (!(sMABandConditionSetup.Calculate(candleDatas_5_TempList, SMABandType.LongBuy, true) &&
!sMABandConditionSetup.Calculate(candleDatas_5_TempList, SMABandType.LongSell, true)))
if (!(sMABandConditionSetup.Calculate(candleDatas_5_TempList, SMABandType.LongBuy, market, true) &&
!sMABandConditionSetup.Calculate(candleDatas_5_TempList, SMABandType.LongSell, market, true)))
{
buyItem["Flag"] = true;
}
@@ -489,7 +489,7 @@ namespace BitgetAPI.IndicatorConditionSetup
sellFlag= true;
}
if (sMABandConditionSetup.Calculate(candleDatas_5_TempList, SMABandType.LongSell) || sellFlag)
if (sMABandConditionSetup.Calculate(candleDatas_5_TempList, SMABandType.LongSell, market, true) || sellFlag)
{
double.TryParse(buyItem["Price"].ToString(), out var buyPrice);
var resultRate = ((price - buyPrice) / buyPrice) * 100;
@@ -580,17 +580,18 @@ namespace BitgetAPI.IndicatorConditionSetup
{
if (!FirstFlag[market + strInterval + "Short"])
{
if (sMABandConditionSetup.Calculate(candleDatas_5_TempList, SMABandType.ShortSell, true))
if (sMABandConditionSetup.Calculate(candleDatas_5_TempList, SMABandType.ShortSell, market, true))
{
FirstFlag[market + strInterval + "Short"] = true;
}
}
if (sMABandConditionSetup.Calculate(candleDatas_5_TempList, SMABandType.ShortBuy, true) &&
!sMABandConditionSetup.Calculate(candleDatas_5_TempList, SMABandType.ShortSell, true) &&
FirstFlag[market + strInterval + "Short"] &&
저고점["전고가"] < 저고점["전전고가"])
if (sMABandConditionSetup.Calculate(candleDatas_5_TempList, SMABandType.ShortBuy, market, true) &&
!sMABandConditionSetup.Calculate(candleDatas_5_TempList, SMABandType.ShortSell, market, true) &&
FirstFlag[market + strInterval + "Short"]
//&& 저고점["전고가"] < 저고점["전전고가"])
)
{
BuyShortStep[market] = 0;
// 없으면 생성
@@ -663,15 +664,15 @@ namespace BitgetAPI.IndicatorConditionSetup
var flag = (bool)buyItem["Flag"];
if (interval < MCandleTimeType.H1)
{
var buyTime = ((DateTime)buyItem["BuyDate"]).AddMinutes(5);
var buyTime = ((DateTime)buyItem["BuyDate"]).AddMinutes(1);
var buyTwoTime = buyTime.AddMinutes(5);
if (nowTime < buyTime)
continue;
else if (nowTime < buyTwoTime)
{
if (!(sMABandConditionSetup.Calculate(candleDatas_5_TempList, SMABandType.ShortBuy, true) &&
!sMABandConditionSetup.Calculate(candleDatas_5_TempList, SMABandType.ShortSell, true)))
if (!(sMABandConditionSetup.Calculate(candleDatas_5_TempList, SMABandType.ShortBuy, market, true) &&
!sMABandConditionSetup.Calculate(candleDatas_5_TempList, SMABandType.ShortSell, market, true)))
{
buyItem["Flag"] = true;
}
@@ -696,7 +697,7 @@ namespace BitgetAPI.IndicatorConditionSetup
sellFlag = true;
}
if (sMABandConditionSetup.Calculate(candleDatas_5_TempList, SMABandType.ShortSell) || sellFlag)
if (sMABandConditionSetup.Calculate(candleDatas_5_TempList, SMABandType.ShortSell, market, true) || sellFlag)
{
BuyShortStep[market] = 0;
double.TryParse(buyItem["Price"].ToString(), out var buyPrice);
@@ -897,13 +898,13 @@ namespace BitgetAPI.IndicatorConditionSetup
{"ACCESS-TIMESTAMP",timestamp}
};
return (Dictionary<string, object>)WebConnection.SendWebServer(ExchangeWebReqType.BitgetPendingOrder_Future, BitgetURL_PendingOrders_Future, null, MCandleTimeType.M1, "", "", nvc);
return (Dictionary<string, object>)WebConnection.SendWebServer(ExchangeWebReqType.BitgetPendingOrder_Future, BitgetURL_PendingOrders_Future, null, MCandleTimeType.M5, "", "", nvc);
}
public long GetTimeStamp()
{
var result = (Dictionary<string, object>)WebConnection.SendWebServer(ExchangeWebReqType.BitgetGetTimeStamp, BitgetURL_GetTimestamp, null, MCandleTimeType.M1, "", "", null);
var result = (Dictionary<string, object>)WebConnection.SendWebServer(ExchangeWebReqType.BitgetGetTimeStamp, BitgetURL_GetTimestamp, null, MCandleTimeType.M5, "", "", null);
if (result == null)
{
return 0;
@@ -929,7 +930,7 @@ namespace BitgetAPI.IndicatorConditionSetup
{"ACCESS-TIMESTAMP",timestamp}
};
return (List<Dictionary<string, object>>)WebConnection.SendWebServer(ExchangeWebReqType.BitgetAccountList_Future, BitgetURL_AccountList_Future, null, MCandleTimeType.M1, "", "", nvc);
return (List<Dictionary<string, object>>)WebConnection.SendWebServer(ExchangeWebReqType.BitgetAccountList_Future, BitgetURL_AccountList_Future, null, MCandleTimeType.M5, "", "", nvc);
}
public Dictionary<string, object> CancelFutureOrder(string symbol, string orderId)
@@ -947,7 +948,7 @@ namespace BitgetAPI.IndicatorConditionSetup
{"ACCESS-TIMESTAMP", timestamp}
};
return (Dictionary<string, object>)WebConnection.SendWebServer(ExchangeWebReqType.BitgetCancelOrder_Future, BitgetURL_CancelOrder_Future, null, MCandleTimeType.M1, postStr, "", nvc);
return (Dictionary<string, object>)WebConnection.SendWebServer(ExchangeWebReqType.BitgetCancelOrder_Future, BitgetURL_CancelOrder_Future, null, MCandleTimeType.M5, postStr, "", nvc);
}
public Dictionary<string, object> ChangeFuturePositionMode(FuturePositionMode mode)
@@ -966,7 +967,7 @@ namespace BitgetAPI.IndicatorConditionSetup
{"ACCESS-TIMESTAMP", timestamp}
};
return (Dictionary<string, object>)WebConnection.SendWebServer(ExchangeWebReqType.BitgetChangePositionMode_Future, BitgetURL_ChangePositionMode_Future, null, MCandleTimeType.M1, postStr, "", nvc);
return (Dictionary<string, object>)WebConnection.SendWebServer(ExchangeWebReqType.BitgetChangePositionMode_Future, BitgetURL_ChangePositionMode_Future, null, MCandleTimeType.M5, postStr, "", nvc);
}
public Dictionary<string, object> GetFutureOrderDetail(string symbol, string orderId)
@@ -984,7 +985,7 @@ namespace BitgetAPI.IndicatorConditionSetup
{"ACCESS-TIMESTAMP",timestamp}
};
return (Dictionary<string, object>)WebConnection.SendWebServer(ExchangeWebReqType.BitgetOrderDetail_Future, BitgetURL_OrderDetail_Future + "?symbol=" + symbol.ToString() + "&orderId=" + orderId.ToString() + "&productType=USDT-FUTURES", null, MCandleTimeType.M1, "", "", orderDetailnvc);
return (Dictionary<string, object>)WebConnection.SendWebServer(ExchangeWebReqType.BitgetOrderDetail_Future, BitgetURL_OrderDetail_Future + "?symbol=" + symbol.ToString() + "&orderId=" + orderId.ToString() + "&productType=USDT-FUTURES", null, MCandleTimeType.M5, "", "", orderDetailnvc);
}
@@ -1037,7 +1038,7 @@ namespace BitgetAPI.IndicatorConditionSetup
{"ACCESS-PASSPHRASE", YHKIM_PassphraseKey },
{"ACCESS-TIMESTAMP", timestamp}
};
var result = (Dictionary<string, object>)WebConnection.SendWebServer(ExchangeWebReqType.BitgetChangeMarginMode_Future, BitgetURL_ChangeMarginMode_Future, null, MCandleTimeType.M1, changeMarginModeStr, "", nvcMargin);
var result = (Dictionary<string, object>)WebConnection.SendWebServer(ExchangeWebReqType.BitgetChangeMarginMode_Future, BitgetURL_ChangeMarginMode_Future, null, MCandleTimeType.M5, changeMarginModeStr, "", nvcMargin);
if (result == null || result["msg"]?.ToString() != "success")
{
return null;
@@ -1051,7 +1052,7 @@ namespace BitgetAPI.IndicatorConditionSetup
{"ACCESS-PASSPHRASE", YHKIM_PassphraseKey },
{"ACCESS-TIMESTAMP", timestamp}
};
result = (Dictionary<string, object>)WebConnection.SendWebServer(ExchangeWebReqType.BitgetChangeLeverage_Future, BitgetURL_ChangeLeverage_Future, null, MCandleTimeType.M1, leverageStr, "", nvcLeverage);
result = (Dictionary<string, object>)WebConnection.SendWebServer(ExchangeWebReqType.BitgetChangeLeverage_Future, BitgetURL_ChangeLeverage_Future, null, MCandleTimeType.M5, leverageStr, "", nvcLeverage);
if (result == null || result["msg"]?.ToString() != "success")
{
return null;
@@ -1076,7 +1077,7 @@ namespace BitgetAPI.IndicatorConditionSetup
{"ACCESS-PASSPHRASE", YHKIM_PassphraseKey },
{"ACCESS-TIMESTAMP", timestamp}
};
return (Dictionary<string, object>)WebConnection.SendWebServer(ExchangeWebReqType.BitgetOrder_Future, BitgetURL_BuySellOrder_Future, null, MCandleTimeType.M1, postStr, "", nvc);
return (Dictionary<string, object>)WebConnection.SendWebServer(ExchangeWebReqType.BitgetOrder_Future, BitgetURL_BuySellOrder_Future, null, MCandleTimeType.M5, postStr, "", nvc);
}
public string GenerateSignString(string timestamp, string method, string requestPath, string queryString, string body, string secretKey)

View File

@@ -29,14 +29,28 @@ namespace BitgetApi.IndicatorConditionSetup
public class SMABandConditionSetup
{
private readonly int rangeLookback = 12;
private readonly double rangeThresholdPercent = 0.7;
private double rangeThresholdPercent = 0.7;
/// <summary>
/// false 는 구매 전, true는 판매 후
/// </summary>
private bool firstCloudFlag = true;
public bool Calculate(List<CandleData> candles, SMABandType type, bool flag = false)
public static double CalculateSMA(List<double> data, int index, int period = 72)
{
var result = 0.0;
for(var i = 0; i <period; i++)
result += data[index - i];
return result / period;
}
public bool Calculate(List<CandleData> candles, SMABandType type, string market,bool flag = false)
{
if (market.Contains("BTC"))
{
rangeThresholdPercent = 0.3;
}
var close = candles.Select(t => t.Close).ToList();
var high = candles.Select(t => t.High).ToList();
@@ -57,6 +71,9 @@ namespace BitgetApi.IndicatorConditionSetup
if (close.Count < 100 || high.Count < 100 || low.Count < 100 || open.Count < 100)
return false;
double sma72 = CalculateSMA(close, i);
double prevSma72 = CalculateSMA(close, i - 1);
// SMA4 관련
double sma4 = Sma4(close, i);
double prevSma4 = Sma4(close, i - 1);
@@ -106,14 +123,14 @@ namespace BitgetApi.IndicatorConditionSetup
bool redCandle = open[i] > close[i];
// 진입/청산 조건
bool rawNewLong = sma4 > cloudBottomNow && IsSideways(high, low, i, true) && isSma4AboveCloud && (sma4 == sma4High && prevSma4 <= prevSma4High && prev2Sma4 <= prev2Sma4High) && (sma4 >= prevSma4 && prevSma4 >= prev2Sma4 && prev2Sma4 >= prev3Sma4);
bool rawNewLong = sma4 == sma4High && prevSma4<sma4High && sma4Middle> sma72 && sma4 > cloudTopNow && ichmok.SenkouSpanA > ichmok.SenkouSpanB; // sma4 > cloudBottomNow && IsSideways(high, low, i, true) && isSma4AboveCloud && (sma4 == sma4High && prevSma4 <= prevSma4High && prev2Sma4 <= prev2Sma4High) && (sma4 >= prevSma4 && prevSma4 >= prev2Sma4 && prev2Sma4 >= prev3Sma4);
bool rawLongSell = (sma4 <= prevSma4 && prevSma4 <= prev2Sma4 && sma4 < sma4Middle);
bool rawLongSell = (sma4Middle < sma72 && prevSma4Middle > prevSma72) || (sma4 < cloudBottomNow);// (sma4 <= prevSma4 && prevSma4 <= prev2Sma4 && sma4 < sma4Middle);
//cloudFlag &&
bool rawNewShort = sma4 < cloudTopNow && IsSideways(high, low, i, false) && isSma4BelowCloud && (sma4 == sma4Low && prevSma4 >= prevSma4Low && prev2Sma4 >= prev2Sma4Low) && (sma4 <= prevSma4 && prevSma4 <= prev2Sma4 && prev2Sma4 <= prev3Sma4);
bool rawNewShort = sma4High < sma72 && prevSma4High > prevSma72;//sma4 < cloudTopNow && 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);
bool rawShortSell = (sma4Middle > sma72 && prevSma4Middle < prevSma72) || (sma4 > cloudTopNow);//(sma4 >= prevSma4 && prevSma4 >= prev2Sma4 && sma4 > sma4Middle);
// === 시그널 계산 ===
if (type == SMABandType.LongBuy)