날아간거 복구
This commit is contained in:
@@ -1,13 +1,16 @@
|
||||
using BitgetApi.Data;
|
||||
using BitgetAPI.Data;
|
||||
using BitgetAPI.IndicatorConditionSetup;
|
||||
using BitgetAPI.WebService;
|
||||
using DevExpress.Utils.IoC;
|
||||
using DevExpress.XtraPrinting.Native;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
@@ -20,6 +23,11 @@ namespace BitgetAPI.IndicatorConditionSetup
|
||||
{
|
||||
CommonProperty commonProperty = CommonProperty.Instance;
|
||||
|
||||
//영호 Key
|
||||
private string YHKIM_AccessKey = "bg_f93aa530288b6ec9d62095994c51972a";
|
||||
private string YHKIM_SecreteKey = "2fce18bcd12ca23a7920c48295a58da031443ea383af8114ed599c1b14ac678e";
|
||||
private string YHKIM_PassphraseKey = "dudgh0505";
|
||||
|
||||
// 스레드 시작/종료 플래그
|
||||
public bool Is_th_SignalInfo;
|
||||
public Dictionary<string, Dictionary<string, object>> 전저점 = new Dictionary<string, Dictionary<string, object>>();
|
||||
@@ -561,13 +569,13 @@ namespace BitgetAPI.IndicatorConditionSetup
|
||||
{
|
||||
if (UpList.ContainsKey(market + strInterval))
|
||||
{
|
||||
if(UpList[market + strInterval])
|
||||
if (UpList[market + strInterval])
|
||||
UpList[market + strInterval] = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
UpList.Add(market + strInterval, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((
|
||||
@@ -721,7 +729,7 @@ namespace BitgetAPI.IndicatorConditionSetup
|
||||
};
|
||||
|
||||
UpResultList.Add(result);
|
||||
UpBuyList.Remove(market + interval);
|
||||
UpBuyList.Remove(market + interval);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -823,13 +831,13 @@ namespace BitgetAPI.IndicatorConditionSetup
|
||||
|
||||
if (DownList.ContainsKey(market + strInterval))
|
||||
{
|
||||
if(DownList[market + strInterval])
|
||||
if (DownList[market + strInterval])
|
||||
DownList[market + strInterval] = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
DownList.Add(market + strInterval, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((
|
||||
@@ -880,8 +888,8 @@ namespace BitgetAPI.IndicatorConditionSetup
|
||||
&& 전전봉4 < 높은값_48_24_전전봉
|
||||
&& 전봉4 < 낮은값_48_24_전봉
|
||||
&& 전봉12 > 낮은값_48_24_전봉
|
||||
&& 전봉24 < 전전봉24
|
||||
&& 전봉12 < 전전봉12
|
||||
&& 전봉24 < 전전봉24
|
||||
&& 전봉12 < 전전봉12
|
||||
&& 전봉4 < 전전봉4
|
||||
&& 낮은값_48_24_전봉 < candleData_전봉.IchimokData.상한선
|
||||
&& candleData_전봉.Close < candleData_전봉.IchimokData.상한선
|
||||
@@ -968,7 +976,7 @@ namespace BitgetAPI.IndicatorConditionSetup
|
||||
{ "SellPrice", price },
|
||||
{ "SellCandle", candleData },
|
||||
{ "Rate", resultRate }
|
||||
};
|
||||
};
|
||||
|
||||
DownResultList.Add(result);
|
||||
DownBuyList.Remove(market + interval);
|
||||
@@ -992,6 +1000,192 @@ namespace BitgetAPI.IndicatorConditionSetup
|
||||
}
|
||||
|
||||
|
||||
public Dictionary<string, object> GetPendingOrders()
|
||||
{
|
||||
var timeSpan = DateTime.Now;
|
||||
|
||||
var timestamp = (((DateTimeOffset)timeSpan).ToUnixTimeSeconds() * 1000).ToString();
|
||||
|
||||
var reqStr = "/api/v2/mix/order/orders-pending";
|
||||
|
||||
var nvc = new NameValueCollection {
|
||||
{"ACCESS-KEY", YHKIM_AccessKey},
|
||||
{"ACCESS-SIGN", GenerateSignString(timestamp, "GET", reqStr, "productType=USDT-FUTURES", null, YHKIM_SecreteKey) },
|
||||
{"ACCESS-PASSPHRASE", YHKIM_PassphraseKey },
|
||||
{"ACCESS-TIMESTAMP",timestamp}
|
||||
};
|
||||
|
||||
return (Dictionary<string, object>)WebConnection.SendWebServer(ExchangeWebReqType.BitgetPendingOrder_Future, BitgetURL_PendingOrders_Future, null, MCandleTimeType.M1, "", "", nvc);
|
||||
}
|
||||
|
||||
public List<Dictionary<string, object>> GetFutureAccountList()
|
||||
{
|
||||
var timeSpan = DateTime.Now;
|
||||
|
||||
var timestamp = (((DateTimeOffset)timeSpan).ToUnixTimeSeconds() * 1000).ToString();
|
||||
|
||||
var reqStr = "/api/v2/mix/account/accounts";
|
||||
|
||||
var nvc = new NameValueCollection {
|
||||
{"ACCESS-KEY", YHKIM_AccessKey},
|
||||
{"ACCESS-SIGN", GenerateSignString(timestamp, "GET", reqStr, "productType=USDT-FUTURES", null, YHKIM_SecreteKey) },
|
||||
{"ACCESS-PASSPHRASE", YHKIM_PassphraseKey },
|
||||
{"ACCESS-TIMESTAMP",timestamp}
|
||||
};
|
||||
|
||||
return (List<Dictionary<string, object>>)WebConnection.SendWebServer(ExchangeWebReqType.BitgetAccountList_Future, BitgetURL_AccountList_Future, null, MCandleTimeType.M1, "", "", nvc);
|
||||
}
|
||||
|
||||
public Dictionary<string, object> CancelFutureOrder(string symbol, string orderId)
|
||||
{
|
||||
var timeSpan = DateTime.Now;
|
||||
|
||||
var timestamp = (((DateTimeOffset)timeSpan).ToUnixTimeSeconds() * 1000).ToString();
|
||||
|
||||
var reqStr = "/api/v2/mix/order/cancel-order";
|
||||
var postStr = "{\"symbol\" : \"" + symbol + "\", \"orderId\" : \"" + orderId + "\", \"productType\" : \"usdt-futures\" , \"marginCoin\" : \"USDT\"}";
|
||||
var nvc = new NameValueCollection {
|
||||
{"ACCESS-KEY", YHKIM_AccessKey},
|
||||
{"ACCESS-SIGN", GenerateSignString(timestamp, "POST", reqStr, "", postStr, YHKIM_SecreteKey)},
|
||||
{"ACCESS-PASSPHRASE", YHKIM_PassphraseKey },
|
||||
{"ACCESS-TIMESTAMP", timestamp}
|
||||
};
|
||||
|
||||
return (Dictionary<string, object>)WebConnection.SendWebServer(ExchangeWebReqType.BitgetCancelOrder_Future, BitgetURL_CancelOrder_Future, null, MCandleTimeType.M1, postStr, "", nvc);
|
||||
}
|
||||
|
||||
public Dictionary<string, object> ChangeFuturePositionMode(FuturePositionMode mode)
|
||||
{
|
||||
var timeSpan = DateTime.Now;
|
||||
|
||||
var timestamp = (((DateTimeOffset)timeSpan).ToUnixTimeSeconds() * 1000).ToString();
|
||||
|
||||
var reqStr = "/api/v2/mix/account/set-position-mode";
|
||||
var postStr = "{\"productType\" : \"USDT-FUTURES\", \"posMode\" : \"" + Utils.Convertor.GetEnumDescription((Enum)mode) + "\"}";
|
||||
|
||||
var nvc = new NameValueCollection {
|
||||
{"ACCESS-KEY", YHKIM_AccessKey},
|
||||
{"ACCESS-SIGN", GenerateSignString(timestamp, "POST", reqStr, "", postStr, YHKIM_SecreteKey)},
|
||||
{"ACCESS-PASSPHRASE", YHKIM_PassphraseKey },
|
||||
{"ACCESS-TIMESTAMP", timestamp}
|
||||
};
|
||||
|
||||
return (Dictionary<string, object>)WebConnection.SendWebServer(ExchangeWebReqType.BitgetChangePositionMode_Future, BitgetURL_ChangePositionMode_Future, null, MCandleTimeType.M1, postStr, "", nvc);
|
||||
}
|
||||
|
||||
|
||||
public Dictionary<string, object> FutureOrder(string symbol, FutureMarginMode marginMode, double size, double price, FutureSide futureSide, OrderType orderType, string leverage, string id = "")
|
||||
{
|
||||
var side = "";
|
||||
var tradeSide = "";
|
||||
|
||||
if (futureSide == FutureSide.BuyShort)
|
||||
{
|
||||
id = new Guid().ToString();
|
||||
side = "sell";
|
||||
tradeSide = "open";
|
||||
}
|
||||
else if (futureSide == FutureSide.BuyLong)
|
||||
{
|
||||
id = new Guid().ToString();
|
||||
side = "buy";
|
||||
tradeSide = "Open";
|
||||
}
|
||||
else if (futureSide == FutureSide.SellShort)
|
||||
{
|
||||
side = "sell";
|
||||
tradeSide = "close";
|
||||
}
|
||||
else if (futureSide == FutureSide.SellShort)
|
||||
{
|
||||
side = "buy";
|
||||
tradeSide = "close";
|
||||
}
|
||||
|
||||
if (orderType == OrderType.limit)
|
||||
price = 0;
|
||||
|
||||
var timeSpan = DateTime.Now;
|
||||
|
||||
var timestamp = (((DateTimeOffset)timeSpan).ToUnixTimeSeconds() * 1000).ToString();
|
||||
|
||||
var reqStr = "/api/v2/mix/order/place-order";
|
||||
|
||||
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 nvcMargin = new NameValueCollection {
|
||||
{"ACC ESS-KEY", YHKIM_AccessKey},
|
||||
{"ACCESS-SIGN", GenerateSignString(timestamp, "POST", "/api/v2/mix/account/set-margin-mode", "", null, YHKIM_SecreteKey)},
|
||||
{"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);
|
||||
if (result["msg"]?.ToString() != "success")
|
||||
{
|
||||
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 nvcLeverage = new NameValueCollection {
|
||||
{"ACCESS-KEY", YHKIM_AccessKey},
|
||||
{"ACCESS-SIGN", GenerateSignString(timestamp, "POST", "/api/v2/mix/account/set-leverage", "", null, YHKIM_SecreteKey)},
|
||||
{"ACCESS-PASSPHRASE", YHKIM_PassphraseKey },
|
||||
{"ACCESS-TIMESTAMP", timestamp}
|
||||
};
|
||||
result = (Dictionary<string, object>)WebConnection.SendWebServer(ExchangeWebReqType.BitgetChangeLeverage_Future, BitgetURL_ChangeLeverage_Future, null, MCandleTimeType.M1, leverageStr, "", nvcLeverage);
|
||||
if (result["msg"]?.ToString() != "success")
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// sell은 ClientOID 가 필요
|
||||
var orderDetailStr = "/api/v2/mix/order/detail";
|
||||
|
||||
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) },
|
||||
{"ACCESS-PASSPHRASE", YHKIM_PassphraseKey },
|
||||
{"ACCESS-TIMESTAMP",timestamp}
|
||||
};
|
||||
|
||||
var orderDetail = (Dictionary<string, object>)WebConnection.SendWebServer(ExchangeWebReqType.BitgetOrderDetail_Future, BitgetURL_OrderDetail_Future, null, MCandleTimeType.M1, "", "", orderDetailnvc);
|
||||
if (orderDetail["msg"]?.ToString() != "success") return null;
|
||||
var data = JsonConvert.DeserializeObject<Dictionary<string, object>>(JsonConvert.SerializeObject(orderDetail["data"]));
|
||||
id = data["clientOid"].ToString();
|
||||
}
|
||||
|
||||
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 + "\" }";
|
||||
|
||||
var nvc = new NameValueCollection {
|
||||
{"ACCESS-KEY", YHKIM_AccessKey},
|
||||
{"ACCESS-SIGN", GenerateSignString(timestamp, "POST", reqStr, "", postStr, YHKIM_SecreteKey)},
|
||||
{"ACCESS-PASSPHRASE", YHKIM_PassphraseKey },
|
||||
{"ACCESS-TIMESTAMP", timestamp}
|
||||
};
|
||||
return (Dictionary<string, object>)WebConnection.SendWebServer(ExchangeWebReqType.BitgetOrder_Future, BitgetURL_BuySellOrder_Future, null, MCandleTimeType.M1, postStr, "", nvc);
|
||||
}
|
||||
|
||||
public string GenerateSignString(string timestamp, string method, string requestPath, string queryString, string body, string secretKey)
|
||||
{
|
||||
method = method.ToUpper();
|
||||
body = body == null ? "" : body;
|
||||
queryString = string.IsNullOrWhiteSpace(queryString) ? "" : "?" + queryString;
|
||||
string preHash = timestamp + method + requestPath + queryString + body;
|
||||
|
||||
var encSecretKey_byteData = System.Text.Encoding.UTF8.GetBytes(secretKey);
|
||||
var encPreHash_byteData = System.Text.Encoding.UTF8.GetBytes(preHash);
|
||||
|
||||
return Convert.ToBase64String(new HMACSHA256(encSecretKey_byteData).ComputeHash(encPreHash_byteData));
|
||||
}
|
||||
|
||||
public void calIchimokuProcess_Add()
|
||||
{
|
||||
|
||||
|
||||
Reference in New Issue
Block a user