임시로 사고 파는거까지 처리 함 (주석넣음)

This commit is contained in:
kyh
2024-10-16 15:34:16 +09:00
parent e1608e285d
commit 7c8afe1418
2 changed files with 34 additions and 11 deletions

View File

@@ -82,6 +82,13 @@ namespace BitgetAPI.IndicatorConditionSetup
signals_LD.Clear();
signals_SU.Clear();
//ChangeFuturePositionMode(FuturePositionMode.hedge_mode);
//FutureOrder("XRPUSDT", FutureMarginMode.isolated, 10, (double)0.531, FutureSide.BuyShort, OrderType.limit, 10);
// 추후 공통화 및 소스정리 필요
while (true)
{
@@ -1074,7 +1081,7 @@ namespace BitgetAPI.IndicatorConditionSetup
}
public Dictionary<string, object> FutureOrder(string symbol, FutureMarginMode marginMode, double size, double price, FutureSide futureSide, OrderType orderType, string leverage, string id = "")
public Dictionary<string, object> FutureOrder(string symbol, FutureMarginMode marginMode, double size, double price, FutureSide futureSide, OrderType orderType, double leverage, string id = "")
{
var side = "";
var tradeSide = "";
@@ -1102,7 +1109,7 @@ namespace BitgetAPI.IndicatorConditionSetup
tradeSide = "close";
}
if (orderType == OrderType.limit)
if (orderType == OrderType.market)
price = 0;
var timeSpan = DateTime.Now;
@@ -1114,11 +1121,11 @@ namespace BitgetAPI.IndicatorConditionSetup
if (futureSide == FutureSide.BuyShort || futureSide == FutureSide.BuyLong)
{
//change margin mode 이후 leverage 처리 해야 함
var changeMarginModeStr = string.Format("{\"symbol\": \"{0}\", \"productType\": \"usdt-futures\", \"marginCoin\": \"USDT\", \"marginMode\": \"{1}\"}",
symbol, Utils.Convertor.GetEnumDescription((Enum)marginMode));
var changeMarginModeStr = "{\"symbol\": \"" + symbol + "\", \"productType\": \"usdt-futures\", \"marginCoin\": \"USDT\", \"marginMode\": \"" + Utils.Convertor.GetEnumDescription((Enum)marginMode) + "\"}";
var nvcMargin = new NameValueCollection {
{"ACC ESS-KEY", YHKIM_AccessKey},
{"ACCESS-SIGN", GenerateSignString(timestamp, "POST", "/api/v2/mix/account/set-margin-mode", "", null, YHKIM_SecreteKey)},
{"ACCESS-KEY", YHKIM_AccessKey},
{"ACCESS-SIGN", GenerateSignString(timestamp, "POST", "/api/v2/mix/account/set-margin-mode", "", changeMarginModeStr, YHKIM_SecreteKey)},
{"ACCESS-PASSPHRASE", YHKIM_PassphraseKey },
{"ACCESS-TIMESTAMP", timestamp}
};
@@ -1128,11 +1135,11 @@ namespace BitgetAPI.IndicatorConditionSetup
return null;
}
var leverageStr = string.Format("{\"symbol\": \"{0}\", \"productType\": \"usdt-futures\", \"marginCoin\": \"USDT\", \"leverage\": \"{1}\", \"holdSide\": \"{3}\"}",
symbol, leverage, futureSide == FutureSide.BuyShort ? "short" : "long");
var leverageStr = "{\"symbol\": \"" + symbol + "\", \"productType\": \"usdt-futures\", \"marginCoin\": \"USDT\", \"leverage\": \"" + leverage.ToString() + "\", \"holdSide\": \"" + (futureSide == FutureSide.BuyShort ? "short" : "long") + "\"}";
timestamp = (((DateTimeOffset)timeSpan).ToUnixTimeSeconds() * 1000).ToString();
var nvcLeverage = new NameValueCollection {
{"ACCESS-KEY", YHKIM_AccessKey},
{"ACCESS-SIGN", GenerateSignString(timestamp, "POST", "/api/v2/mix/account/set-leverage", "", null, YHKIM_SecreteKey)},
{"ACCESS-SIGN", GenerateSignString(timestamp, "POST", "/api/v2/mix/account/set-leverage", "", leverageStr, YHKIM_SecreteKey)},
{"ACCESS-PASSPHRASE", YHKIM_PassphraseKey },
{"ACCESS-TIMESTAMP", timestamp}
};
@@ -1146,7 +1153,7 @@ namespace BitgetAPI.IndicatorConditionSetup
{
// sell은 ClientOID 가 필요
var orderDetailStr = "/api/v2/mix/order/detail";
timestamp = (((DateTimeOffset)timeSpan).ToUnixTimeSeconds() * 1000).ToString();
var orderDetailnvc = new NameValueCollection {
{"ACCESS-KEY", YHKIM_AccessKey},
{"ACCESS-SIGN", GenerateSignString(timestamp, "GET", orderDetailStr, "symbol="+symbol.ToString()+"&orderId="+id.ToString()+"&productType=usdt-future", null, YHKIM_SecreteKey) },
@@ -1163,7 +1170,7 @@ namespace BitgetAPI.IndicatorConditionSetup
var postStr = "{\"symbol\": \"" + symbol + "\", \"productType\": \"usdt-futures\", \"marginMode\": \"" + Utils.Convertor.GetEnumDescription((Enum)marginMode) + "\", \"marginCoin\": \"USDT\", \"size\": \""
+ size.ToString() + "\", \"price\": \"" + price.ToString() + "\", \"side\": \"" + side + "\", " + "\"tradeSide\": \"" + tradeSide + "\", \"orderType\": \"" + Utils.Convertor.GetEnumDescription((Enum)orderType)
+ "\", \"force\": \"gtc\", \"clientOid\": \"" + id + "\" }";
timestamp = (((DateTimeOffset)timeSpan).ToUnixTimeSeconds() * 1000).ToString();
var nvc = new NameValueCollection {
{"ACCESS-KEY", YHKIM_AccessKey},
{"ACCESS-SIGN", GenerateSignString(timestamp, "POST", reqStr, "", postStr, YHKIM_SecreteKey)},