diff --git a/BitgetApi/IndicatorConditionSetup/IndicatorProcess.cs b/BitgetApi/IndicatorConditionSetup/IndicatorProcess.cs index 9064f1b..7cf4976 100644 --- a/BitgetApi/IndicatorConditionSetup/IndicatorProcess.cs +++ b/BitgetApi/IndicatorConditionSetup/IndicatorProcess.cs @@ -2,6 +2,7 @@ using BitgetAPI.Data; using BitgetAPI.IndicatorConditionSetup; using BitgetAPI.WebService; +using DevExpress.Internal.WinApi.Windows.UI.Notifications; using DevExpress.Utils.IoC; using DevExpress.XtraPrinting.Native; using Newtonsoft.Json; @@ -92,9 +93,9 @@ namespace BitgetAPI.IndicatorConditionSetup //시작시 한번만 하면됨(양방향) ChangeFuturePositionMode(FuturePositionMode.hedge_mode); - GetFutureAccountList(); + //GetFutureAccountList(); //order 로직 - //var orderData = FutureOrder("XRPUSDT", FutureMarginMode.isolated, 10, (double)0.541, FutureSide.BuyShort, OrderType.limit, 10); + //var orderDatas = FutureOrder("XRPUSDT", FutureMarginMode.isolated, 10, (double)0.549, FutureSide.BuyShort, OrderType.limit, 10); //var orderDic = JsonConvert.DeserializeObject>(JsonConvert.SerializeObject(orderData["data"])); //var orderValue = new Dictionary(); @@ -1115,7 +1116,7 @@ namespace BitgetAPI.IndicatorConditionSetup } catch (Exception e) { - + Console.WriteLine(e.Message); } } } @@ -1124,7 +1125,7 @@ namespace BitgetAPI.IndicatorConditionSetup } catch (Exception e) { - + Console.WriteLine(e.Message); } } } @@ -1218,7 +1219,7 @@ namespace BitgetAPI.IndicatorConditionSetup {"ACCESS-TIMESTAMP",timestamp} }; - return (Dictionary)WebConnection.SendWebServer(ExchangeWebReqType.BitgetOrderDetail_Future, BitgetURL_OrderDetail_Future + "?symbol=" + symbol.ToString() + "&orderId=" + id.ToString() + "&productType=USDT-FUTURES", null, MCandleTimeType.M1, "", "", orderDetailnvc); + return (Dictionary)WebConnection.SendWebServer(ExchangeWebReqType.BitgetOrderDetail_Future, BitgetURL_OrderDetail_Future + "?symbol=" + symbol.ToString() + "&orderId=" + orderId.ToString() + "&productType=USDT-FUTURES", null, MCandleTimeType.M1, "", "", orderDetailnvc); } @@ -1245,7 +1246,7 @@ namespace BitgetAPI.IndicatorConditionSetup side = "sell"; tradeSide = "close"; } - else if (futureSide == FutureSide.SellShort) + else if (futureSide == FutureSide.SellLong) { side = "buy"; tradeSide = "close"; @@ -1272,7 +1273,7 @@ namespace BitgetAPI.IndicatorConditionSetup {"ACCESS-TIMESTAMP", timestamp} }; var result = (Dictionary)WebConnection.SendWebServer(ExchangeWebReqType.BitgetChangeMarginMode_Future, BitgetURL_ChangeMarginMode_Future, null, MCandleTimeType.M1, changeMarginModeStr, "", nvcMargin); - if (result["msg"]?.ToString() != "success") + if (result == null || result["msg"]?.ToString() != "success") { return null; } @@ -1286,11 +1287,18 @@ namespace BitgetAPI.IndicatorConditionSetup {"ACCESS-TIMESTAMP", timestamp} }; result = (Dictionary)WebConnection.SendWebServer(ExchangeWebReqType.BitgetChangeLeverage_Future, BitgetURL_ChangeLeverage_Future, null, MCandleTimeType.M1, leverageStr, "", nvcLeverage); - if (result["msg"]?.ToString() != "success") + if (result == null ||result["msg"]?.ToString() != "success") { return null; } - } + } + else { + var result = CancelFutureOrder(symbol, id); + if (result == null || result["msg"]?.ToString() != "success") + { + Console.WriteLine("Sell에서 Cancel관련 Error"); + } + } 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) diff --git a/BitgetApi/WebService/WebConnection.cs b/BitgetApi/WebService/WebConnection.cs index 01dc50a..a3dd696 100644 --- a/BitgetApi/WebService/WebConnection.cs +++ b/BitgetApi/WebService/WebConnection.cs @@ -304,7 +304,7 @@ namespace BitgetAPI.WebService using (var reader = new StreamReader(Response.GetResponseStream())) { var sRespBodyData = reader.ReadToEnd(); - + Console.WriteLine(sRespBodyData); //return (JObject.Parse(sRespBodyData)); } }