- BinaryRage DB 로그 추가

This commit is contained in:
2016-08-02 02:03:22 +09:00
parent a5783ad90f
commit d41130fcdd
13 changed files with 227 additions and 150 deletions

64
MainForm.Designer.cs generated
View File

@@ -51,18 +51,18 @@
this.splitContainer2 = new System.Windows.Forms.SplitContainer();
this.splitContainer3 = new System.Windows.Forms.SplitContainer();
this.btMATest = new System.Windows.Forms.Button();
this.button1 = new System.Windows.Forms.Button();
this.btTimeSync = new System.Windows.Forms.Button();
this.cbStart = new System.Windows.Forms.CheckBox();
this.btCybosPlus = new System.Windows.Forms.Button();
this.btCybos5 = new System.Windows.Forms.Button();
this.lbSBCnt = new System.Windows.Forms.Label();
this.lbRQCnt = new System.Windows.Forms.Label();
this.lbEvalProfit = new System.Windows.Forms.Label();
this.lbCacheBalance = new System.Windows.Forms.Label();
this.statusBar1 = new System.Windows.Forms.StatusBar();
this.statusBarPanel1 = new System.Windows.Forms.StatusBarPanel();
this.statusBarPanel2 = new System.Windows.Forms.StatusBarPanel();
this.lbCacheBalance = new System.Windows.Forms.Label();
this.lbEvalProfit = new System.Windows.Forms.Label();
this.btLogDump = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
@@ -288,8 +288,8 @@
//
// splitContainer2.Panel2
//
this.splitContainer2.Panel2.Controls.Add(this.btLogDump);
this.splitContainer2.Panel2.Controls.Add(this.btMATest);
this.splitContainer2.Panel2.Controls.Add(this.button1);
this.splitContainer2.Panel2.Controls.Add(this.btTimeSync);
this.splitContainer2.Panel2.Controls.Add(this.cbStart);
this.splitContainer2.Panel2.Controls.Add(this.btCybosPlus);
@@ -332,7 +332,7 @@
//
// btMATest
//
this.btMATest.Location = new System.Drawing.Point(138, 430);
this.btMATest.Location = new System.Drawing.Point(122, 421);
this.btMATest.Name = "btMATest";
this.btMATest.Size = new System.Drawing.Size(75, 23);
this.btMATest.TabIndex = 24;
@@ -340,16 +340,6 @@
this.btMATest.UseVisualStyleBackColor = true;
this.btMATest.Click += new System.EventHandler(this.btMATest_Click);
//
// button1
//
this.button1.Location = new System.Drawing.Point(142, 371);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 23;
this.button1.Text = "button1";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// btTimeSync
//
this.btTimeSync.Location = new System.Drawing.Point(16, 341);
@@ -411,6 +401,24 @@
this.lbRQCnt.TabIndex = 18;
this.lbRQCnt.Text = "RQ Count : ";
//
// lbEvalProfit
//
this.lbEvalProfit.AutoSize = true;
this.lbEvalProfit.Location = new System.Drawing.Point(38, 244);
this.lbEvalProfit.Name = "lbEvalProfit";
this.lbEvalProfit.Size = new System.Drawing.Size(53, 12);
this.lbEvalProfit.TabIndex = 13;
this.lbEvalProfit.Text = "평가손익";
//
// lbCacheBalance
//
this.lbCacheBalance.AutoSize = true;
this.lbCacheBalance.Location = new System.Drawing.Point(38, 222);
this.lbCacheBalance.Name = "lbCacheBalance";
this.lbCacheBalance.Size = new System.Drawing.Size(29, 12);
this.lbCacheBalance.TabIndex = 13;
this.lbCacheBalance.Text = "잔고";
//
// statusBar1
//
this.statusBar1.Location = new System.Drawing.Point(0, 720);
@@ -435,23 +443,15 @@
this.statusBarPanel2.Name = "statusBarPanel2";
this.statusBarPanel2.Width = 120;
//
// lbCacheBalance
// btLogDump
//
this.lbCacheBalance.AutoSize = true;
this.lbCacheBalance.Location = new System.Drawing.Point(38, 222);
this.lbCacheBalance.Name = "lbCacheBalance";
this.lbCacheBalance.Size = new System.Drawing.Size(29, 12);
this.lbCacheBalance.TabIndex = 13;
this.lbCacheBalance.Text = "잔고";
//
// lbEvalProfit
//
this.lbEvalProfit.AutoSize = true;
this.lbEvalProfit.Location = new System.Drawing.Point(38, 244);
this.lbEvalProfit.Name = "lbEvalProfit";
this.lbEvalProfit.Size = new System.Drawing.Size(53, 12);
this.lbEvalProfit.TabIndex = 13;
this.lbEvalProfit.Text = "평가손익";
this.btLogDump.Location = new System.Drawing.Point(22, 555);
this.btLogDump.Name = "btLogDump";
this.btLogDump.Size = new System.Drawing.Size(75, 23);
this.btLogDump.TabIndex = 25;
this.btLogDump.Text = "Dump Log";
this.btLogDump.UseVisualStyleBackColor = true;
this.btLogDump.Click += new System.EventHandler(this.btLogDump_Click);
//
// MainForm
//
@@ -512,10 +512,10 @@
private System.Windows.Forms.StatusBar statusBar1;
private System.Windows.Forms.StatusBarPanel statusBarPanel1;
private System.Windows.Forms.StatusBarPanel statusBarPanel2;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button btMATest;
private System.Windows.Forms.Label lbCacheBalance;
private System.Windows.Forms.Label lbEvalProfit;
private System.Windows.Forms.Button btLogDump;
}
}

View File

@@ -212,54 +212,6 @@ namespace upper_limit_crawler
ULUtil.SyncServerTime();
}
DSCBO1Lib.StockCur cur = new DSCBO1Lib.StockCur();
DSCBO1Lib.StockOutCur outCur = new DSCBO1Lib.StockOutCur();
string strCheckCode = "A004565";
private void button1_Click(object sender, EventArgs e)
{
{
DSCBO1Lib.StockMst mst = new DSCBO1Lib.StockMst();
mst.SetInputValue(0, strCheckCode);
mst.BlockRequest();
short time = mst.GetHeaderValue(4);
Console.WriteLine("StockMst : {0}", time);
}
{
DSCBO1Lib.StockMst2 mst2 = new DSCBO1Lib.StockMst2();
mst2.SetInputValue(0, strCheckCode);
mst2.BlockRequest();
long time = mst2.GetDataValue(2, 0);
Console.WriteLine("StockMst2 : {0}", time);
}
{
cur.SetInputValue(0, strCheckCode);
cur.Received += Cur_Received;
cur.SubscribeLatest();
}
{
outCur.SetInputValue(0, strCheckCode);
outCur.Received += OutCur_Received;
outCur.SubscribeLatest();
}
}
private void OutCur_Received()
{
long time = outCur.GetHeaderValue(1);
Console.WriteLine("StockOutCur : {0}", time);
}
private void Cur_Received()
{
long time = cur.GetHeaderValue(3);
long time2 = cur.GetHeaderValue(18);
Console.WriteLine("StockCur : {0} / {1}", time, time2);
}
struct chart_data
{
public chart_data(int iTime, int iPrice)
@@ -280,10 +232,16 @@ namespace upper_limit_crawler
Console.WriteLine("시뮬레이션 시작");
List<string> aCodeList = new List<string> { "039230", "054620", "077970", "079950", "085370", "090470", "123010", "123860", "191420", "208860" };
//List<string> aCodeList = new List<string> { "077970" };
string strPrevDate = "20160728";
string strDate = "20160729";
List<string> aCodeList = new List<string> {
"064240",
"090410",
"208860",
"044180",
"127160",
"123570",
};
string strPrevDate = "20160729";
string strDate = "20160801";
int iTotalProfit = 0;
foreach (string code in aCodeList)
@@ -371,6 +329,8 @@ namespace upper_limit_crawler
float fCompRate = WatchItem.m_iCurPrice / (float)WatchItem.m_iPrevClosing - 1.0f;
if (fCompRate >= m_DataMgr.m_Setting.m_fBidMin && fCompRate <= m_DataMgr.m_Setting.m_fBidMax)
{
m_DataMgr.AddAvailableItem(strCode);
if (m_DataMgr.IsInPostponeList(iTime, strCode) == true)
{
//Console.WriteLine("[{0}] 조건 매수 실패. black list {1}원 ({2})", item.m_strCodeName, item.m_iCurPrice, fCompRate.ToString("0.00%"));
@@ -382,7 +342,7 @@ namespace upper_limit_crawler
}
float f5MASlope = WatchItem.GetPrev5MASlope(iTime);
if (float.IsNaN(f5MASlope) || f5MASlope < 0.002f)
if(f5MASlope < 0.002f)
{
//Console.WriteLine("[{0}] 조건 매수 실패. 5ma 상승하지 않음 {1}원 ({2})", item.m_strCodeName, item.m_iCurPrice, fCompRate.ToString("0.00%"));
continue;
@@ -392,6 +352,8 @@ namespace upper_limit_crawler
Console.WriteLine("[{0}] [{1}] 조건 매수 {2}원 ({3}) (5MA slop:{4})", iTime, WatchItem.m_strCodeName, WatchItem.m_iCurPrice, fCompRate.ToString("0.00%"), f5MASlope.ToString("0.00%"));
ULUtil.TraceCSV(iTime, "[시뮬레이션] 조건 매수", WatchItem.m_strCodeName, WatchItem.m_iCurPrice, fCompRate.ToString("0.00%"), f5MASlope.ToString("0.00%"));
m_DataMgr.AddBidLog(strCode, WatchItem.m_strCodeName, iTime, WatchItem.m_iCurPrice, f5MASlope);
int iBidCnt = (int)m_DataMgr.m_Setting.m_fBidAmount / iCurPrice;
iTotalBidPrice += iCurPrice* iBidCnt;
@@ -412,8 +374,12 @@ namespace upper_limit_crawler
{
m_DataMgr.AddLosscutItem(strCode);
Console.WriteLine("[{0}] [{1}] 손절 {2}원 ({3}:{4})", iTime, OwnItem.m_strCodeName, iCurPrice, iCurPrice - OwnItem.m_iUnitBEP, (iCurPrice / (float)OwnItem.m_iUnitBEP - 1.0f).ToString("0.00%"));
ULUtil.TraceCSV(iTime, "[시뮬레이션] 손절", OwnItem.m_strCodeName, iCurPrice, (iCurPrice / (float)OwnItem.m_iUnitBEP - 1.0f).ToString("0.00%"));
int iProfit = iCurPrice - (int)OwnItem.m_iUnitBEP;
float fProfitRate = (iCurPrice / (float)OwnItem.m_iUnitBEP - 1.0f);
Console.WriteLine("[{0}] [{1}] 손절 {2}원 ({3}:{4})", iTime, OwnItem.m_strCodeName, iCurPrice, iProfit, fProfitRate.ToString("0.00%"));
ULUtil.TraceCSV(iTime, "[시뮬레이션] 손절", OwnItem.m_strCodeName, iCurPrice, fProfitRate.ToString("0.00%"));
m_DataMgr.AddAskLog(strCode, WatchItem.m_strCodeName, iTime, iCurPrice, float.NaN, true, iProfit, fProfitRate);
iTotalAskPrice += iCurPrice * OwnItem.m_iConclusionBalanceCnt;
OwnItem.m_iUnitBEP = 0;
@@ -437,8 +403,12 @@ namespace upper_limit_crawler
continue;
}
Console.WriteLine("[{0}] [{1}] 트레일링 매도 {2}원 ({3}:{4}) (5MA slop:{5})", iTime, OwnItem.m_strCodeName, iCurPrice, iCurPrice - OwnItem.m_iUnitBEP, (iCurPrice / (float)OwnItem.m_iUnitBEP - 1.0f).ToString("0.00%"), f5MASlope.ToString("0.00%"));
ULUtil.TraceCSV(iTime, "[시뮬레이션] 트레일링 매도", OwnItem.m_strCodeName, iCurPrice, iCurPrice - OwnItem.m_iUnitBEP, (iCurPrice / (float)OwnItem.m_iUnitBEP - 1.0f).ToString("0.00%"), f5MASlope.ToString("0.00%"));
int iProfit = iCurPrice - (int)OwnItem.m_iUnitBEP;
float fProfitRate = (iCurPrice / (float)OwnItem.m_iUnitBEP - 1.0f);
Console.WriteLine("[{0}] [{1}] 트레일링 매도 {2}원 ({3}:{4}) (5MA slop:{5})", iTime, OwnItem.m_strCodeName, iCurPrice, iProfit, fProfitRate.ToString("0.00%"), f5MASlope.ToString("0.00%"));
ULUtil.TraceCSV(iTime, "[시뮬레이션] 트레일링 매도", OwnItem.m_strCodeName, iCurPrice, iProfit, fProfitRate.ToString("0.00%"), f5MASlope.ToString("0.00%"));
m_DataMgr.AddAskLog(strCode, WatchItem.m_strCodeName, iTime, iCurPrice, f5MASlope, false, iProfit, fProfitRate);
iTotalAskPrice += iCurPrice * OwnItem.m_iConclusionBalanceCnt;
OwnItem.m_iUnitBEP = 0;
@@ -489,5 +459,10 @@ namespace upper_limit_crawler
Console.WriteLine("시뮬레이션 끝");
}
private void btLogDump_Click(object sender, EventArgs e)
{
m_DataMgr.DumpLog();
}
}
}

View File

@@ -14,9 +14,17 @@ namespace upper_limit_crawler
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainForm());
}
try
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainForm());
}
catch(Exception e)
{
Console.WriteLine(e.ToString());
}
}
}
}

View File

@@ -265,7 +265,7 @@ namespace upper_limit_crawler
f5MASlope.ToString("0.00%"),
WatchItem.m_iHighestPrice);
ULUtil.TraceCSV("트레일링 매도", OwnItem.m_strCodeName, iCurPrice, iCurPrice - OwnItem.m_iUnitBEP, fProfitRate.ToString("0.00%"), f5MASlope.ToString("0.00%"), WatchItem.m_iHighestPrice);
m_DataMgr.AddAskLog(strCode, WatchItem.m_strCodeName, iTime, iCurPrice, float.NaN, false, iProfit, fProfitRate);
m_DataMgr.AddAskLog(strCode, WatchItem.m_strCodeName, iTime, iCurPrice, f5MASlope, false, iProfit, fProfitRate);
}
}
@@ -322,6 +322,7 @@ namespace upper_limit_crawler
foreach(ListViewItem item in lvBalance.SelectedItems)
{
ULUtil.Trace("[{0}] 수동 매도", item.SubItems[chName.Index].Text);
ULUtil.TraceCSV(ULUtil.GetCurTimeInt(), "수동 매도", item.SubItems[chName.Index], item.SubItems[chCurPrice.Index], item.SubItems[chProfitRate.Index]);
string strCode = item.SubItems[chCode.Index].Text;
int iCnt = int.Parse(item.SubItems[chBalance.Index].Text);
@@ -334,6 +335,7 @@ namespace upper_limit_crawler
foreach (ListViewItem item in lvBalance.Items)
{
ULUtil.Trace("[{0}] 모두 청산", item.SubItems[chName.Index].Text);
ULUtil.TraceCSV(ULUtil.GetCurTimeInt(), "모두 청산", item.SubItems[chName.Index], item.SubItems[chCurPrice.Index], item.SubItems[chProfitRate.Index]);
string strCode = item.SubItems[chCode.Index].Text;
int iCnt = int.Parse(item.SubItems[chBalance.Index].Text);

22
ULDB.cs
View File

@@ -11,26 +11,24 @@ namespace upper_limit_crawler
{
const string DBNAME = "DB";
LevelDB.DB m_DB = null;
LevelDB.WriteOptions m_DefaultWriteOption = new LevelDB.WriteOptions();
LevelDB.ReadOptions m_DefaultReadOption = new LevelDB.ReadOptions();
public ULDB()
{
LevelDB.Options OpenOption = new LevelDB.Options();
OpenOption.CreateIfMissing=true;
m_DB=LevelDB.DB.Open(DBNAME, OpenOption);
}
public void Put(string strKey, LevelDB.Slice Value)
public void Insert<T>(string strKey, T Value)
{
m_DB.Put(m_DefaultWriteOption, strKey, Value);
BinaryRage.DB.Insert(strKey, Value, DBNAME);
}
public LevelDB.Slice Get(string strKey)
public T Get<T>(string strKey)
{
LevelDB.Slice Value = m_DB.Get(m_DefaultReadOption, strKey);
return Value;
object data = BinaryRage.DB.Get<T>(strKey, DBNAME);
return (T)data;
}
public bool IsExist(string strKey)
{
return BinaryRage.DB.Exists(strKey, DBNAME);
}
}
}

View File

@@ -32,7 +32,30 @@ namespace upper_limit_crawler
public int m_iTime;
}
public class ULDataMgr
[Serializable]
struct BID_LOG
{
public string m_strCode { get; set; }
public string m_strCodeName { get; set; }
public int m_iTime { get; set; }
public int m_iBidPrice { get; set; }
public float m_f5MAslope { get; set; }
}
[Serializable]
struct ASK_LOG
{
public string m_strCode { get; set; }
public string m_strCodeName { get; set; }
public int m_iTime { get; set; }
public int m_iAskPrice { get; set; }
public float m_f5MAslope { get; set; }
public bool m_bLosscut { get; set; }
public int m_iProfit { get; set; }
public float m_fProfitRate { get; set; }
}
public class ULDataMgr
{
public SETTING m_Setting = new SETTING();
public ULDB m_DB = new ULDB();
@@ -47,14 +70,24 @@ namespace upper_limit_crawler
string m_AvailableListKey;
List<string> m_AvailableList = new List<string>();
List<BID_LOG> m_BidLogs = new List<BID_LOG>();
List<ASK_LOG> m_AskLogs = new List<ASK_LOG>();
long m_iCacheBalance = 0;
long m_iEvalProfit = 0;
string m_strToday = ULUtil.GetCurTime().ToString("yyyy-MM-dd");
public ULDataMgr()
{
m_AvailableListKey= "available-"+ULUtil.GetCurTime().ToString("yyyy-MM-dd");
string strValue = m_DB.Get(m_AvailableListKey).ToString();
m_AvailableList=strValue.Split(',').ToList();
m_AvailableListKey= "available-"+m_strToday;
if(m_DB.IsExist(m_AvailableListKey) == true)
m_AvailableList = m_DB.Get<List<string>>(m_AvailableListKey);
else
m_AvailableList = new List<string>();
m_BidLogs = GetBidLog(m_strToday);
m_AskLogs = GetAskLog(m_strToday);
}
public void Init()
@@ -186,22 +219,74 @@ namespace upper_limit_crawler
if(m_AvailableList.Any(r => r==strCode)==false)
{
m_AvailableList.Add(strCode);
m_DB.Put(m_AvailableListKey, string.Join(",", m_AvailableList));
m_DB.Insert(m_AvailableListKey, m_AvailableList);
}
}
public void AddBidLog(string strCode, string strCodeName, int iTime, int iBidPrice, float f5MAslope)
{
string strKey = string.Format("bid-{0}-{1}-{2}", ULUtil.GetCurTime().ToString("yyyyMMdd"), iTime, strCodeName);
string strValue = string.Format("{0},{1},{2},{3},{4}", strCodeName, strCode, iTime, iBidPrice, f5MAslope);
m_DB.Put(strKey, strValue);
string strKey = "bid-"+m_strToday;
BID_LOG log = new BID_LOG();
log.m_strCode = strCode;
log.m_strCodeName = strCodeName;
log.m_iTime = iTime;
log.m_iBidPrice = iBidPrice;
log.m_f5MAslope = f5MAslope;
m_BidLogs.Add(log);
m_DB.Insert(strKey, m_BidLogs);
}
public void AddAskLog(string strCode, string strCodeName, int iTime, int iBidPrice, float f5MAslope, bool bLosscut, int iProfit, float fProfitRate)
List<BID_LOG> GetBidLog(string strDate)
{
string strKey = "bid-"+strDate;
if(m_DB.IsExist(strKey) == true)
return m_DB.Get<List<BID_LOG>>(strKey);
else
return new List<BID_LOG>();
}
public void AddAskLog(string strCode, string strCodeName, int iTime, int iAskPrice, float f5MAslope, bool bLosscut, int iProfit, float fProfitRate)
{
string strKey = string.Format("ask-{0}-{1}-{2}", ULUtil.GetCurTime().ToString("yyyyMMdd"), iTime, strCodeName);
string strValue = string.Format("{0},{1},{2},{3},{4},{5},{6},{7}", strCodeName, strCode, iTime, iBidPrice, f5MAslope, bLosscut?"Losscut":"Trailing", iProfit, fProfitRate);
m_DB.Put(strKey, strValue);
string strKey = "ask-"+m_strToday;
ASK_LOG log = new ASK_LOG();
log.m_strCode = strCode;
log.m_strCodeName = strCodeName;
log.m_iTime = iTime;
log.m_iAskPrice = iAskPrice;
log.m_f5MAslope = f5MAslope;
log.m_bLosscut = bLosscut;
log.m_iProfit = iProfit;
log.m_fProfitRate = fProfitRate;
m_AskLogs.Add(log);
m_DB.Insert(strKey, m_AskLogs);
}
}
List<ASK_LOG> GetAskLog(string strDate)
{
string strKey = "ask-"+strDate;
if(m_DB.IsExist(strKey) == true)
return m_DB.Get<List<ASK_LOG>>(strKey);
else
return new List<ASK_LOG>();
}
public void DumpLog()
{
StringBuilder sb = new StringBuilder();
foreach(string strCode in m_AvailableList)
sb.AppendLine(strCode+",");
foreach(BID_LOG log in m_BidLogs)
sb.AppendFormat("매수, {0}, {1}, {2}, {3}"+Environment.NewLine, log.m_iTime, log.m_strCodeName, log.m_iBidPrice, log.m_f5MAslope.ToString("0.00%"));
foreach(ASK_LOG log in m_AskLogs)
sb.AppendFormat("매도, {0}, {1}, {2}, {3}, {4}, {5}"+Environment.NewLine, log.m_iTime, log.m_strCodeName, log.m_iAskPrice, log.m_f5MAslope.ToString("0.00%"), log.m_iProfit, log.m_fProfitRate.ToString("0.00%"));
System.IO.File.WriteAllText(ULUtil.GetLogDir()+"dblog-"+m_strToday+".csv", sb.ToString(), Encoding.UTF8);
}
}
}

View File

@@ -172,8 +172,8 @@ namespace upper_limit_crawler
continue;
}
float f5MASlope = item.GetPrev5MASlope(iTime);
if(float.IsNaN(f5MASlope) == false && f5MASlope < 0.002f)
float f5MASlope = item.GetPrev5MASlope(item.m_iCurTime);
if(f5MASlope < 0.002f)
{
//ULUtil.Trace("[{0}] 조건 매수 실패. 5ma 상승하지 않음 {1}원 ({2})", item.m_strCodeName, item.m_iCurPrice, fCompRate.ToString("0.00%"));
continue;

View File

@@ -56,6 +56,7 @@ namespace upper_limit_crawler
public string m_strCode;
public string m_strCodeName;
public DSCBO1Lib.StockCur m_StockCur = null;
public int m_iCurTime;
public int m_iCurPrice;
public int m_iPrevClosing;
public int m_iStartPrice;
@@ -94,6 +95,7 @@ namespace upper_limit_crawler
int iTime = (int)m_StockCur.GetHeaderValue(18);
int iTime2 = m_StockCur.GetHeaderValue(3);
m_iCurTime = iTime;
m_iCurPrice = m_StockCur.GetHeaderValue(13);
m_iPrevClosing = m_iCurPrice - m_StockCur.GetHeaderValue(2);
m_iStartPrice = m_StockCur.GetHeaderValue(4);
@@ -158,7 +160,6 @@ namespace upper_limit_crawler
int iMin = GetMinute(iTime);
int iSec = GetSecond(iTime);
int iKey = GetTimeKey1Min(iHour, iMin, iSec);
bool bMadeNew = false;
if (m_1MinChart.ContainsKey(iKey) == false)
@@ -308,7 +309,8 @@ namespace upper_limit_crawler
public float GetPrev5MASlope(int iTime)
{
int iLastIdx = m_1MinChart.IndexOfKey(iTime)-1;
int iTimeKey = GetTimeKey1Min(GetHour(iTime), GetMinute(iTime), 0);
int iLastIdx = m_1MinChart.IndexOfKey(iTimeKey)-1;
if(iLastIdx <= 1 || iLastIdx >= m_5MAChart.Count)
return float.NaN;

View File

@@ -14,30 +14,29 @@ namespace upper_limit_crawler
{
//static string m_strLogServer = "http://mjjo53.us.to:8000";
static CPUTILLib.CpCybos m_CPUtil = new CPUTILLib.CpCybos();
static CPUTILLib.CpCodeMgr m_CPCodeMgr = new CPUTILLib.CpCodeMgr();
static CPUTILLib.CpCybos m_CPUtil = null;
static CPUTILLib.CpCodeMgr m_CPCodeMgr = null;
static TextBox m_tbLog = null;
static string m_strLogDir;
static string m_strLogFileName;
static string m_strCSVFileName;
static TimeSpan m_TimeDiff = TimeSpan.Zero;
public static void Init(TextBox tbLog)
{
m_CPUtil = new CPUTILLib.CpCybos();
m_CPCodeMgr = new CPUTILLib.CpCodeMgr();
m_tbLog = tbLog;
if (Debugger.IsAttached == true)
{
m_strLogFileName = Directory.GetParent(Environment.CurrentDirectory).Parent.FullName + "\\";
m_strCSVFileName = Directory.GetParent(Environment.CurrentDirectory).Parent.FullName + "\\";
}
m_strLogDir = Directory.GetParent(Environment.CurrentDirectory).Parent.FullName + "\\";
m_strLogDir += "log\\";
if (Directory.Exists(m_strLogDir) == false)
Directory.CreateDirectory(m_strLogDir);
m_strLogFileName += "log\\";
if (Directory.Exists(m_strLogFileName) == false)
Directory.CreateDirectory(m_strLogFileName);
m_strLogFileName += "log-" + GetCurTime().ToString("yyyy-MM-dd") + ".txt";
m_strCSVFileName += "log\\";
m_strCSVFileName += "log-" + GetCurTime().ToString("yyyy-MM-dd") + ".csv";
m_strLogFileName = m_strLogDir + "log-" + GetCurTime().ToString("yyyy-MM-dd") + ".txt";
m_strCSVFileName = m_strLogDir + "log-" + GetCurTime().ToString("yyyy-MM-dd") + ".csv";
}
public static void SyncServerTime()
@@ -197,6 +196,11 @@ namespace upper_limit_crawler
}
}
public static string GetLogDir()
{
return m_strLogDir;
}
public static void Trace(string strMsg)
{
string strLog = "["+GetCurTimeString()+"] "+strMsg;

View File

@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="BinaryRage" version="1.4.0.0" targetFramework="net45" />
<package id="LevelDB.Net" version="1.2.1" targetFramework="net45" />
</packages>

Binary file not shown.

View File

@@ -24,29 +24,30 @@
<PropertyGroup>
<ApplicationManifest>Properties\app.manifest</ApplicationManifest>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="LevelDB.Net">
<HintPath>packages\LevelDB.Net.1.2.1\lib\net40\LevelDB.Net.dll</HintPath>
<Reference Include="BinaryRage, Version=1.4.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\BinaryRage.1.4.0.0\lib\net40\BinaryRage.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
@@ -105,6 +106,7 @@
<EmbeddedResource Include="ULMonitorDlg.resx">
<DependentUpon>ULMonitorDlg.cs</DependentUpon>
</EmbeddedResource>
<None Include="packages.config" />
<None Include="Properties\app.manifest">
<SubType>Designer</SubType>
</None>

View File

@@ -7,14 +7,14 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "upper-limit-crawler", "uppe
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Release|x64 = Release|x64
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{591FA710-356A-498A-8133-7E9E60AB4E40}.Debug|x64.ActiveCfg = Debug|x64
{591FA710-356A-498A-8133-7E9E60AB4E40}.Debug|x64.Build.0 = Debug|x64
{591FA710-356A-498A-8133-7E9E60AB4E40}.Release|x64.ActiveCfg = Release|x64
{591FA710-356A-498A-8133-7E9E60AB4E40}.Release|x64.Build.0 = Release|x64
{591FA710-356A-498A-8133-7E9E60AB4E40}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{591FA710-356A-498A-8133-7E9E60AB4E40}.Debug|Any CPU.Build.0 = Debug|Any CPU
{591FA710-356A-498A-8133-7E9E60AB4E40}.Release|Any CPU.ActiveCfg = Release|Any CPU
{591FA710-356A-498A-8133-7E9E60AB4E40}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE