diff --git a/BitgetApi/IndicatorConditionSetup/IndicatorProcess.cs b/BitgetApi/IndicatorConditionSetup/IndicatorProcess.cs index 409edde..0a78afd 100644 --- a/BitgetApi/IndicatorConditionSetup/IndicatorProcess.cs +++ b/BitgetApi/IndicatorConditionSetup/IndicatorProcess.cs @@ -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 FutureOrder(string symbol, FutureMarginMode marginMode, double size, double price, FutureSide futureSide, OrderType orderType, string leverage, string id = "") + public Dictionary 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)}, diff --git a/BitgetApi/WebService/WebConnection.cs b/BitgetApi/WebService/WebConnection.cs index e1b8633..38600af 100644 --- a/BitgetApi/WebService/WebConnection.cs +++ b/BitgetApi/WebService/WebConnection.cs @@ -268,6 +268,22 @@ namespace BitgetAPI.WebService { return JsonConvert.DeserializeObject>(resResult); } + case ExchangeWebReqType.BitgetCancelOrder_Future: + { + return JsonConvert.DeserializeObject>(resResult); + } + case ExchangeWebReqType.BitgetChangeLeverage_Future: + { + return JsonConvert.DeserializeObject>(resResult); + } + case ExchangeWebReqType.BitgetChangeMarginMode_Future: + { + return JsonConvert.DeserializeObject>(resResult); + } + case ExchangeWebReqType.BitgetChangePositionMode_Future: + { + return JsonConvert.DeserializeObject>(resResult); + } #endregion } }