최신 유지

This commit is contained in:
kyh
2024-09-11 10:54:52 +09:00
3 changed files with 98 additions and 12 deletions

View File

@@ -94,7 +94,6 @@
<EmbeddedResource Include="MainForm.resx">
<DependentUpon>MainForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\licenses.licx" />
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>

View File

@@ -91,6 +91,23 @@ namespace BitgetAPI
BitgetCandleStick_Coin = 22,
[Description("BitgetMCandle_FUTURE")]
BitgetCandleStick_Future = 23,
[Description("BitgetAccountList_FUTURE")]
BitgetAccountList_Future = 30,
[Description("BitgetOrder_FUTURE")]
BitgetOrder_Future = 31,
[Description("BitgetOrderCancel_FUTURE")]
BitgetCancelOrder_Future = 32,
[Description("BitgetPendingOrder_FUTURE")]
BitgetPendingOrder_Future = 33,
[Description("BitgetChangeLeverage_FUTURE")]
BitgetChangeLeverage_Future = 34,
[Description("BitgetChangeMarginMode_FUTURE")]
BitgetChangeMarginMode_Future = 35,
[Description("BitgetChangePositionMode_FUTURE")]
BitgetChangePositionMode_Future = 36,
[Description("BitgetOrderDetail_FUTURE")]
BitgetOrderDetail_Future = 37,
#endregion
}
@@ -98,9 +115,55 @@ namespace BitgetAPI
public enum BitgetWebSocketType
{
현황정보_전체종목 = 0,
캔들정보 = 1
캔들정보 = 1,
보유List = 2,
주문하기 = 3,
}
public enum Side
{
[Description("buy")]
buy = 0,
[Description("sell")]
sell =1
}
public enum FuturePositionMode
{
[Description("one_way_mode")]
one_way_mode = 0,
[Description("hedge_mode")]
hedge_mode = 1
}
public enum OrderType
{
[Description("limit")]
limit = 0,
[Description("market")]
market = 1,
}
#region 선물거래 관련
public enum FutureMarginMode
{
[Description("isolated")]
isolated = 0,
[Description("crossed")]
crossed = 1,
}
public enum FutureSide
{
BuyShort = 0,
BuyLong = 1,
SellShort = 0,
SellLong = 1,
}
#endregion
// 시가/고가/종가/저가
public enum CandlePriceType
{
@@ -150,8 +213,7 @@ namespace BitgetAPI
캔들 = 1,
거래량 = 2
}
#region 업비트 URL
public static string UpbitURL = "https://api.upbit.com/";
public static string UpbitURL_MarketInfo = "https://api.upbit.com/v1/market/all";
@@ -176,8 +238,16 @@ namespace BitgetAPI
public static string BitgetURL_MarketInfo_FUTURE = "https://api.bitget.com/api/v2/mix/market/tickers?productType=USDT-FUTURES";
public static string BitgetURL_MarketCandle_Coin = "https://api.bitget.com/api/v2/spot/market/candles?symbol={0}&granularity={1}in&startTime={2}&endTime={3}&limit={4}";
public static string BitgetURL_MarketCandle_Future = "https://api.bitget.com/api/v2/mix/market/candles?symbol={0}&granularity={1}&limit={2}&productType={3}";
public static string BitgetURL_MarketCandle_Future = "https://api.bitget.com/api/v2/mix/market/candles?symbol={0}&granularity={1}&limit={2}&productType={3}";
public static string BitgetURL_AccountList_Future = @"https://api.bitget.com/api/v2/mix/account/accounts?productType=USDT-FUTURES";
public static string BitgetURL_BuySellOrder_Future = @"https://api.bitget.com/api/v2/mix/order/place-order";
public static string BitgetURL_CancelOrder_Future = @"https://api.bitget.com/api/v2/mix/order/cancel-order";
public static string BitgetURL_PendingOrders_Future = @"https://api.bitget.com/api/v2/mix/order/orders-pending?productType=usdt-futures";
public static string BitgetURL_ChangeLeverage_Future = @"https://api.bitget.com/api/v2/mix/account/set-leverage";
public static string BitgetURL_ChangeMarginMode_Future = @"https://api.bitget.com/api/v2/mix/account/set-margin-mode";
public static string BitgetURL_ChangePositionMode_Future = @"https://api.bitget.com/api/v2/mix/account/set-position-mode";
public static string BitgetURL_OrderDetail_Future = @"https://api.bitget.com/api/v2/mix/order/detail";
#endregion
}

View File

@@ -23,6 +23,7 @@ using System.Runtime.InteropServices;
using DevExpress.XtraEditors.Filtering;
using DevExpress.XtraExport.Xls;
using DevExpress.Utils.Filtering.Internal;
using System.Collections.Specialized;
namespace BitgetAPI.WebService
{
@@ -40,7 +41,7 @@ namespace BitgetAPI.WebService
public static object SendWebServer(CommonProperty.ExchangeWebReqType exchangeWebReqType, string url = "",
MarketCandleDataList marketCandleDataList = null, CommonProperty.MCandleTimeType interval = MCandleTimeType.M1,
string postData = "", string subUri = "")
string postData = "", string subUri = "", NameValueCollection headers = null)
{
object returnJsonData = null;
@@ -56,6 +57,8 @@ namespace BitgetAPI.WebService
// 웹 전송 타입 지정
var webConType = CommonProperty.WebConnectionType.GET;
if(postData.Length > 0) webConType = CommonProperty.WebConnectionType.POST;
// 1. WebRequest 객체 형성 및 HttpWebRequest 로 형변환
// 2. 거래소에 따른 헤더 파일 처리(POST 일 경우만 지정함)
@@ -82,13 +85,13 @@ namespace BitgetAPI.WebService
break;
case CommonProperty.ExchangeWebReqType.BitgetCandleStick_Future:
wReq = (HttpWebRequest)WebRequest.Create(new Uri(CommonProperty.BitgetURL_MarketCandle_Future));
break;
#endregion
break;
#endregion
}
}
else wReq = (HttpWebRequest)WebRequest.Create(new Uri(url));
// GET, POST 구분
switch (webConType)
{
@@ -101,10 +104,16 @@ namespace BitgetAPI.WebService
stream.Write(rgbyData, 0, rgbyData.Length);
}
wReq.ContentType = "application/x-www-form-urlencoded";
wReq.ContentLength = rgbyData.Length;
//wReq.ContentLength = rgbyData.Length;
break;
}
if (headers != null)
{
wReq.Headers.Add(headers);
wReq.ContentType = "application/json";
}
using (var wRes = (HttpWebResponse)wReq.GetResponse())
{
var respPostStream = wRes.GetResponseStream();
@@ -144,7 +153,6 @@ namespace BitgetAPI.WebService
return commonProperty.marketInfoList;
}
break;
case CommonProperty.ExchangeWebReqType.BitgetCandleStick_Coin:
{
@@ -251,6 +259,15 @@ namespace BitgetAPI.WebService
}
}
break;
case ExchangeWebReqType.BitgetAccountList_Future:
{
var datalist = JsonConvert.DeserializeObject<Dictionary<string, object>>(resResult);
return JsonConvert.DeserializeObject<List<Dictionary<string, object>>>(datalist["data"]?.ToString());
}
case ExchangeWebReqType.BitgetOrder_Future:
{
return JsonConvert.DeserializeObject<Dictionary<string, object>>(resResult);
}
#endregion
}
}