- 시뮬레이션 수정중 : 표준편차 이용
This commit is contained in:
@@ -15,11 +15,13 @@ namespace AutoSellerNS
|
||||
{
|
||||
class SimulationHelper
|
||||
{
|
||||
AutoSeller m_AutoSeller = null;
|
||||
CybosHelper m_CybosHelper = null;
|
||||
RichTextBox m_tbLogView = null;
|
||||
|
||||
public SimulationHelper(CybosHelper CybosHelper, RichTextBox tbLog)
|
||||
public SimulationHelper(AutoSeller autoSeller, CybosHelper CybosHelper, RichTextBox tbLog)
|
||||
{
|
||||
m_AutoSeller = autoSeller;
|
||||
m_CybosHelper = CybosHelper;
|
||||
m_tbLogView = tbLog;
|
||||
}
|
||||
@@ -130,7 +132,7 @@ namespace AutoSellerNS
|
||||
DateTime StartDT;
|
||||
DateTime.TryParse(strDate+" "+strSimulationTime, out StartDT);
|
||||
|
||||
string strOutFileName = Util.GetSimulationPath() + "/" + strCodeName + "-" + StartDT.ToString("yyyy-MM-dd") + ".xlsx";
|
||||
string strOutFileName = Util.GetSimulationPath() + "/" + StartDT.ToString("yyyy-MM-dd") + "-" + strCodeName + "StockChart" + ".xlsx";
|
||||
if(File.Exists(strOutFileName) == true)
|
||||
{
|
||||
if(StartDT.DayOfYear == DateTime.Now.DayOfYear)
|
||||
@@ -216,7 +218,7 @@ namespace AutoSellerNS
|
||||
DateTime StartDT;
|
||||
DateTime.TryParse(strDate+" "+strSimulationTime, out StartDT);
|
||||
|
||||
string strOutFileName = Util.GetSimulationPath() + "/" + strCodeName + "-" + StartDT.ToString("yyyy-MM-dd") + ".xlsx";
|
||||
string strOutFileName = Util.GetSimulationPath() + "/" + StartDT.ToString("yyyy-MM-dd") + "-" + strCodeName + "StockChart" + ".xlsx";
|
||||
if(File.Exists(strOutFileName) == true)
|
||||
{
|
||||
if(StartDT.DayOfYear == DateTime.Now.DayOfYear)
|
||||
@@ -298,7 +300,7 @@ namespace AutoSellerNS
|
||||
int iStartPrice;
|
||||
int.TryParse(strStartPrice, NumberStyles.AllowThousands, CultureInfo.CurrentCulture, out iStartPrice);
|
||||
|
||||
string strFileName = Util.GetSimulationPath() + "/" + strCodeName + "-" + StartDT.ToString("yyyy-MM-dd") + ".xlsx";
|
||||
string strFileName = Util.GetSimulationPath() + "/" + StartDT.ToString("yyyy-MM-dd") + "-JpBid-" + strCodeName + ".xlsx";
|
||||
|
||||
|
||||
FileInfo newFile = new FileInfo(strFileName);
|
||||
@@ -414,6 +416,7 @@ namespace AutoSellerNS
|
||||
var strNewTime = tokens[1];
|
||||
var strSimulationTime = tokens[2];
|
||||
var strCodeName = tokens[3];
|
||||
strCodeName = strCodeName.Trim();
|
||||
var strCode = tokens[4];
|
||||
var strStartPrice = tokens[5];
|
||||
|
||||
@@ -423,7 +426,7 @@ namespace AutoSellerNS
|
||||
int iStartPrice;
|
||||
int.TryParse(strStartPrice, NumberStyles.AllowThousands, CultureInfo.CurrentCulture, out iStartPrice);
|
||||
|
||||
string strFileName = Util.GetSimulationPath() + "/" + strCodeName + "-" + StartDT.ToString("yyyy-MM-dd") + ".xlsx";
|
||||
string strFileName = Util.GetSimulationPath() + "/" + StartDT.ToString("yyyy-MM-dd") + "-JpBid-" + strCodeName + ".xlsx";
|
||||
|
||||
|
||||
FileInfo newFile = new FileInfo(strFileName);
|
||||
@@ -448,10 +451,27 @@ namespace AutoSellerNS
|
||||
bool bPrevAsk = false;
|
||||
int iMaxAskPrice = 0;
|
||||
|
||||
int iCheckCount = 50;
|
||||
List<int> m_PriceList = new List<int>();
|
||||
int iListCnt;
|
||||
double dFastSD;
|
||||
int iFastCnt;
|
||||
double dSlowSD;
|
||||
int iSlowCnt;
|
||||
|
||||
int.TryParse(m_AutoSeller.tbSMListSize.Text, out iListCnt);
|
||||
double.TryParse(m_AutoSeller.tbSMFastSD.Text, out dFastSD);
|
||||
int.TryParse(m_AutoSeller.tbSMFastCnt.Text, out iFastCnt);
|
||||
double.TryParse(m_AutoSeller.tbSMSlowSD.Text, out dSlowSD);
|
||||
int.TryParse(m_AutoSeller.tbSMSlowCnt.Text, out iSlowCnt);
|
||||
|
||||
int iPrevAskPrice = 0;
|
||||
|
||||
for(int iRow = 2; iRow<=iMaxRow; iRow++)
|
||||
{
|
||||
if(Sheet.Cells[iRow, 2].Value == "*")
|
||||
continue;
|
||||
|
||||
int iTime = (int)(double)Sheet.Cells[iRow, 1].Value;
|
||||
int iPrice = (int)(double)Sheet.Cells[iRow, 3].Value;
|
||||
int iAskPrice = (int)(double)Sheet.Cells[iRow, 4].Value;
|
||||
@@ -469,10 +489,39 @@ namespace AutoSellerNS
|
||||
iStartRow = iRow;
|
||||
iMaxAskPrice = iAskPrice;
|
||||
iPrevAskPrice = iAskPrice;
|
||||
|
||||
m_PriceList.Clear();
|
||||
m_PriceList.Add(iPrice);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_PriceList.Add(iPrice);
|
||||
if(m_PriceList.Count > iListCnt)
|
||||
m_PriceList.RemoveAt(0);
|
||||
|
||||
double dAverage = (float)m_PriceList.Average();
|
||||
double sumOfSquaresOfDifferences = m_PriceList.Select(val => Math.Pow((val-dAverage)/m_CybosHelper.GetUnitValue(val), 2)).Sum();
|
||||
double sd = Math.Sqrt(sumOfSquaresOfDifferences / m_PriceList.Count);
|
||||
|
||||
if(sd >= dFastSD)
|
||||
{
|
||||
if(iPrice >= m_PriceList[m_PriceList.Count-2])
|
||||
iCheckCount += iFastCnt;
|
||||
else if(iCheckCount > 30)
|
||||
iCheckCount -= iFastCnt;
|
||||
}
|
||||
else if(sd <= dSlowSD)
|
||||
{
|
||||
if(iPrice >= m_PriceList[m_PriceList.Count-2])
|
||||
iCheckCount += iSlowCnt;
|
||||
else if(iCheckCount > 30)
|
||||
iCheckCount -= iSlowCnt;
|
||||
}
|
||||
|
||||
int k = 0;
|
||||
|
||||
|
||||
//// 체결가 비교
|
||||
//if(iPrice > iPrevPrice)
|
||||
//{
|
||||
@@ -545,20 +594,28 @@ namespace AutoSellerNS
|
||||
//else
|
||||
// iDealCountInSec = 1;
|
||||
|
||||
if(iAskCount >= Config.GetBidCount())
|
||||
if(iAskCount >= Math.Round(iCheckCount/10.0f))
|
||||
{
|
||||
m_tbLogView.AppendText(string.Format("[{0,-10}] 조건1 매도 {1} line:{2} {3:n0}원 ({4} : {5:n2}%) (매수 : {6:n0}원, {7}, line:{8})\n",
|
||||
int iSellPrice = iPrice - m_CybosHelper.GetUnitValue(iPrice);
|
||||
m_tbLogView.AppendText(string.Format("[{0}] 조건1 매도 (매수 : {1:n0}원, {2}, line:{3}) (매도 : {4:n0}원(매도가:{5:n0}원) {6} line:{7}) ({8}, {9:n0} : {10:n2}%) {11} \n",
|
||||
strCodeName,
|
||||
RowDT.ToString("yyyy-MM-dd HH:mm:ss"),
|
||||
iRow,
|
||||
iPrice,
|
||||
iPrice-iStartPrice,
|
||||
(iPrice-iStartPrice)*100/(float)iStartPrice,
|
||||
|
||||
iStartPrice,
|
||||
StartDT.ToString("yyyy-MM-dd HH:mm:ss"),
|
||||
iStartRow
|
||||
StartDT.ToString("HH:mm:ss"),
|
||||
iStartRow,
|
||||
|
||||
iPrice,
|
||||
iSellPrice,
|
||||
RowDT.ToString("HH:mm:ss"),
|
||||
iRow,
|
||||
|
||||
iSellPrice-iStartPrice,
|
||||
(iSellPrice-iStartPrice)*iStockCount,
|
||||
(iSellPrice-iStartPrice)*100/(float)iStartPrice,
|
||||
|
||||
iCheckCount
|
||||
));
|
||||
iTotalProfit += (iPrice-iStartPrice)*iStockCount;
|
||||
iTotalProfit += (iSellPrice-iStartPrice)*iStockCount;
|
||||
iTotalBid += iStartPrice*iStockCount;
|
||||
break;
|
||||
}
|
||||
@@ -566,15 +623,15 @@ namespace AutoSellerNS
|
||||
//if(aPrevDT.Count > 3 && aPrevDT.Last() - aPrevDT[aPrevDT.Count-3] > TimeSpan.FromSeconds(1) && iAskDownCount >= Config.GetBidCount())
|
||||
//if(iAskDownCount >= 5)
|
||||
//{
|
||||
// m_tbLogView.AppendText(string.Format("[{0,-10}] 조건2 매도 {1} line:{2} {3:n0}원 ({4} : {5:n2}%) (매수 : {6:n0}원, {7}, line:{8})\n",
|
||||
// m_tbLogView.AppendText(string.Format("[{0}] 조건2 매도 {1} line:{2} {3:n0}원 ({4} : {5:n2}%) (매수 : {6:n0}원, {7}, line:{8})\n",
|
||||
// strCodeName,
|
||||
// RowDT.ToString("yyyy-MM-dd HH:mm:ss"),
|
||||
// RowDT.ToString("HH:mm:ss"),
|
||||
// iRow,
|
||||
// iPrice,
|
||||
// iPrice-iStartPrice,
|
||||
// (iPrice-iStartPrice)*100/(float)iStartPrice,
|
||||
// iStartPrice,
|
||||
// StartDT.ToString("yyyy-MM-dd HH:mm:ss"),
|
||||
// StartDT.ToString("HH:mm:ss"),
|
||||
// iStartRow
|
||||
// ));
|
||||
// iTotalProfit += (iPrice-iStartPrice)*iStockCount;
|
||||
@@ -590,18 +647,26 @@ namespace AutoSellerNS
|
||||
|
||||
if(iTrailingCount >= Config.GetTrailingCnt())
|
||||
{
|
||||
m_tbLogView.AppendText(string.Format("[{0}] 트레일링 매도 {1} line:{2} {3:n0}원 ({4} : {5:n2}%) (매수 : {6:n0}원, {7} line:{8})\n",
|
||||
int iSellPrice = iPrice - m_CybosHelper.GetUnitValue(iPrice);
|
||||
m_tbLogView.AppendText(string.Format("[{0}] 트레일링 매도 (매수 : {1:n0}원, {2}, line:{3}) (매도 : {4:n0}원(매도가:{5:n0}원) {6} line:{7}) ({8}, {9:n0} : {10:n2}%) \n",
|
||||
strCodeName,
|
||||
RowDT.ToString("yyyy-MM-dd HH:mm:ss"),
|
||||
iRow,
|
||||
iPrice,
|
||||
iPrice-iStartPrice,
|
||||
(iPrice-iStartPrice)*100/(float)iStartPrice,
|
||||
|
||||
iStartPrice,
|
||||
StartDT.ToString("yyyy-MM-dd HH:mm:ss"),
|
||||
iStartRow
|
||||
StartDT.ToString("HH:mm:ss"),
|
||||
iStartRow,
|
||||
|
||||
iPrice,
|
||||
iSellPrice,
|
||||
RowDT.ToString("HH:mm:ss"),
|
||||
iRow,
|
||||
|
||||
iSellPrice-iStartPrice,
|
||||
(iSellPrice-iStartPrice)*iStockCount,
|
||||
(iSellPrice-iStartPrice)*100/(float)iStartPrice
|
||||
|
||||
));
|
||||
iTotalProfit += (iPrice-iStartPrice)*iStockCount;
|
||||
|
||||
iTotalProfit += (iSellPrice-iStartPrice)*iStockCount;
|
||||
iTotalBid += iStartPrice*iStockCount;
|
||||
break;
|
||||
}
|
||||
@@ -615,7 +680,7 @@ namespace AutoSellerNS
|
||||
}
|
||||
}
|
||||
|
||||
m_tbLogView.AppendText(string.Format("[시뮬레이션 종료] 총수익 : {0:n0}원 : {1:n2}%\n\n", iTotalProfit, iTotalProfit*100/(float)iTotalBid));
|
||||
m_tbLogView.AppendText(string.Format("[시뮬레이션 종료] 총수익 : {0:n0}원 : {1:n2}%\n\n", iTotalProfit, iTotalProfit*100/(float)1000000));
|
||||
m_tbLogView.SelectionStart = m_tbLogView.TextLength;
|
||||
m_tbLogView.ScrollToCaret();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user