Files
Million/Million/CommonProperty.cs
2024-03-11 11:43:25 +09:00

400 lines
13 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Million.Data;
using Million.WebMangement.Upbit;
namespace Million
{
/// <summary>
/// 전역 변수 및 Enumable 선언
/// </summary>
public class CommonProperty
{
#region default로 가지고 있어야하는 데이터
public static string accessKey = "FIkdR3xF4AxJpCI16xaM6qzQkVkFeQPBNONDDMtg";
public static string secretKey = "Uk8iulXofcfw8EJvWY6WMoHsmWZ5GWHZ2d5uycli";
public static Dictionary<string, Dictionary<string, string>> keyList = new Dictionary<string, Dictionary<string, string>>
{
{ "이장화", new Dictionary<string, string>()
{
{ "accessKey", "qzhqT9zrwdziVNZMelLoPmCQHVky6PiXDPGtEYIA" },
{"secretKey", "tK6yCtFxCbyAte20NNitbzL8z0LiSokxaldjkWSf" }
}
},
{ "김영호", new Dictionary<string, string>()
{
{ "accessKey", "oe3b2z6xN7NrBbxK1t57zzw2ucNNMMtFZSVn3DJz" },
{"secretKey", "74WRxxSpLqOXjCa9PBgm2NmPcqbjgFGpXXLFEzeg" }
}
},
{ "이찬균", new Dictionary<string, string>()
{
{ "accessKey", "nYnlB1pdmK72jUSTDG9BilrjZukxcIxR8wao43cW" },
{"secretKey", "IOqoTIVp0N7DhTsdUQRv4lZFNQSba3IExx9zbyP0" }
}
}
};
public static UpbitAPI UpbitApi = new UpbitAPI(accessKey, secretKey);
public static bool ChangeUpbitApiKey(string key)
{
if (keyList.ContainsKey(key))
{
var data = keyList[key];
if (string.IsNullOrWhiteSpace(data["accessKey"]) || string.IsNullOrWhiteSpace(data["secretKey"]))
return false;
UpbitApi = new UpbitAPI(data["accessKey"], data["secretKey"]);
return true;
}
return false;
}
#endregion
#region Enumable
// HTTP 통신 타입
public enum WebConnectionType
{
POST = 0,
GET = 1
}
public enum ExchangeTime
{
UpbitorBithumb = 9
}
// 거래소 타입
public enum ExchangePlace
{
Upbit = 0,
Bithumb = 1
}
// 코인 Payument 타입
public enum PaymentType
{
KRW = 0,
BTC = 1,
USDT = 2,
}
// 최신, 가장오래된, None
public enum CandleType
{
None = 0,
Old = 1,
New = 2
}
/// <summary>
/// TODO 업비트 기능 추가
/// </summary>
// 빗썸 Web 요청 타입
public enum ExchangeWebReqType
{
#region 빗썸 웹 요청 타입
[Description("/Public/CandleStick")]
BithumbCandleStick = 0,
[Description("/public/ticker")]
BithumbCandleTicker = 1,
[Description("/public/Orderbook")]
BithumbMarket = 2,
#endregion
#region 업비트 웹 요청 타입
[Description("UpbitCandle")]
UpbitCandleStick = 10,
[Description("UpbitMarket")]
UpbitMarket = 11
#endregion
}
// 공통 비교 조건 종류
public enum SubIndicatorSetupType
{
단순비교 = 0,
돌파비교 = 1,
최초돌파 = 2,
크로스 = 3
}
// 시가/고가/종가/저가
public enum CandlePriceType
{
시가 = 1,
고가 = 2,
저가 = 3,
종가 = 4
}
// 캔들 데이터 (1분) (3분) (5분) (10분) (15분) (30분) (1시간) (4시간)
public enum MCandleTimeType
{
M1 = 1,
M2 = 2,
M3 = 3,
M4 = 4,
M5 = 5,
M6 = 6,
M10 = 10,
M15 = 15,
M20 = 20,
M30 = 30,
H1 = 60,
H2 = 120,
H3 = 180,
H4 = 240,
H6 = 360,
H8 = 480,
H12 = 720,
D1 = 1440,
W1 = 10000,
MT1 = 100000
}
// 캔들 데이터
public static int[] IMCandleTimeType = new int[] { 1, 3, 5, 10, 15, 30, 60, 240};
// 지표
public enum IndicatorType
{
일목균형표 = 1,
볼린저밴드 = 2,
이동평균선 = 3,
ParabolicSAR = 4,
거래량비율 = 5,
가격비율 = 6,
조건단순비교 =7
}
// 이동평균선 종류
public enum MovingAverageType
{
캔들 = 1,
거래량 = 2
}
// 크로스 종류
public enum CrossType
{
CrossOver = 1,
CrossOverStatus = 2
}
public enum OverStatus
{
Under = -4,//하양돌파
UnderCancle,//하양돌파 후 올라감
OverUnder,//시가 상향돌파 후 하양돌파
UnderOverCancle,//시가하양돌파후 상향돌파 취소
None = 0,
OverUnderCancle, //시가상향돌파 후 하양돌파취소
UnderOver,//시가 하양돌파후 상향돌파
OverCancle,//상향돌파후 내려옴
Over,//Over 상향돌파
//돌파 over, overcancle, UnderOver, OverUnderCancle, UnderOverCancle, OverUnder
}
public enum Indicator_over
{
아래 = -1,
없음 = 0,
위 = 1
}
// 기준선 설정 (볼린저)
public enum Indicator_BolingerOverLine
{
하향선 = -1,
기준선 = 0,
상향선 = 1
}
// 기준선 설정 (일목)
public enum Indicator_IchmokuOverLine
{
선행스팬1 = 1,
선행스팬2 = 2,
선행스팬1OR2중고가 = 3,
선행스팬1OR2중저가 = 4
}
// 구매/판매 조건 설정
public enum BuySellType
{
Buy = 0,
Sell = 1
}
// 이동평균선 종류
public enum MAType
{
단순 = 0,
지수 = 1,
가중 = 2
}
// 가격비율지표
public enum PriceRateSetupConditionType
{
비율 = 0,
가격 = 1,
종가 = 2
}
#endregion
#region 업비트 Type
public enum UpbitOrderSide { ask, bid }
public enum UpbitOrderType { limit, price, market }
public enum UpbitCandleKindsType { minutes, days, weeks, months }
public enum UpbitOrderListTypes { wait, watch, done, cancel, waitwatch, donecancel}
public enum UpbitOrderListOrderByType { asc, desc }
#endregion
#region 빗썸 URL
public static string BithumbURL = "https://api.bithumb.com/";
public static string BithumbURL_CandleStick = "https://api.bithumb.com/public/candlestick/";
public static string BithumbURL_CoinGoods = "https://api.bithumb.com/public/orderbook/ALL_KRW";
#endregion
#region 업비트 URL
public static string UpbitURL = "https://api.upbit.com/";
public static string UpbitURL_MarketInfo = "https://api.upbit.com/v1/market/all";
public static string UpbitURL_MCandleStick = "https://api.upbit.com/v1/candles/minutes/";
public static string UpbitURL_DCandleStick = "https://api.upbit.com/v1/candles/days";
public static string UpbitURL_WCandleStick = "https://api.upbit.com/v1/candles/weeks";
public static string UpbitURL_MTCandleStick = "https://api.upbit.com/v1/candles/months";
public static string UpbitURL_Accounts = "https://api.upbit.com/v1/accounts";
public static string UpbitURL_Ticker = "https://api.upbit.com/v1/ticker";
public static string UpbitURL_Ticks = "https://api.upbit.com/v1/trades/ticks";
public static string UpbitURL_Orders = "https://api.upbit.com/v1/orders";
public static string UpbitURL_Order = "https://api.upbit.com/v1/order";
public static string UpbitURL_Orderbook = "https://api.upbit.com/v1/orderbook";
public static string UpbitURL_OrderChace = "https://api.upbit.com/v1/orders/chance";
#endregion
#region 공용 리스트
// 거래소 코인 종목 리스트
public List<Data.MarketData> ConiCoinGoodsDataList;
public Dictionary<string, string> BithumbEndPointTypeLIst = new Dictionary<string, string>
{
{"CandleStick","/public/CandleStic"}
};
/// <summary>
/// 사용자 List Name
/// </summary>
public static string[] UserList = new string[] { "이장화", "김영호", "이찬균" };
#endregion
#region 저장 데이터 관련
// 저장 데이터 폴더 경로
public static string SaveProgramDirecotryPath = $"{System.Windows.Forms.Application.StartupPath}\\SaveData";
// ini 파일 경로
public static string IniFileName = $"{SaveProgramDirecotryPath}\\" + "setting.ini";
// 거래소 코인 종목 저장 파일 경로 (DB 조회로 대체 예정)
//public static string BitThumJasonFilePath = $"{SaveProgramDirecotryPath}\\CoinGoods.txt";
#endregion
//TODO 추후 관리 방안 고려
#region # 데이터 베이스 정보 #
public const string DbServerIp = "59.26.54.110";
public const string DbServerUserId = "million";
public const string DbServerUserPassword = "million!";
public static string DbConnectionStr = $"Data Source={DbServerIp};uid={DbServerUserId};pwd={DbServerUserPassword};Database=";
public static string DbConnectionMarket = DbConnectionStr + "Market";
public static string DbConnectionResultData = DbConnectionStr + "ResultData";
public const int UpdateServerPort = 6666;
#endregion
#region DataSaver 사용되는 공용 변수
// 현재 시점에서 사용되고 있는 Place의 Market List 정보
public static List<MarketData> selectedMarketOfPlaceList { get; set; } = null;
public static List<MarketData> recentlyMarketOfPlaceList = null;
#endregion
#region Sell Logic Key List
public enum SellLogicKeyList
{
IchMok = 1,
Bol = 2
}
#endregion
#region 파일 저장 관련
// 계산 결과 데이터 파일 저장 경로
public string SavedResultDataFilePath =
(new System.IO.DirectoryInfo(Application.StartupPath + @"\SaveData")).FullName;
// Save Info 파일 확장자
public static string InfoExtend = ".info";
// Save 결과 리스트 파일 확장자
public static string DataExtend = ".data";
// Save 결과 분석 데이터
public static string AnalysisExtendFolder = "_analysis";
public static bool InsertLogFlag = true;
#endregion
#region Buyer Flag
public static bool UpperMainIndicatorFlag = true;
public static bool DownBeforeValueFlag = true;
public enum BuyerMode
{
BuyerRealtime,
Buyer,
HunterRealtime
}
#endregion
#region Realtime Hunter Flag
public static bool RealtimeHunterMode = false;
public static bool StarValueLowBuyValueUp = false;
#endregion
#region Realtime 관련 Sub data 사용하는 부분예외처리
/// <summary>
/// Sub 조건 Flag
/// </summary>
public static Dictionary<string, Dictionary<string, bool>> subIndicatorStateManagement = new Dictionary<string, Dictionary<string, bool>>();
#endregion
#region 장화형 요청 사항(조건단순 비교할때 첫번째는 포함되지 않도록 예외처리
public static Dictionary<string, Dictionary<string, bool>> compareIndicatorState = new Dictionary<string, Dictionary<string, bool>>();
#endregion
#region Compare 조건문 Flag
public enum CompareType
{
Origin_Up_Compare_Down = 0,
Origin_UpOrSame_Compare_Down = 1,
Origin_Down_Compare_Up = 2,
Origin_DownOrSame_Compare_Up = 3
}
#endregion
}
}