- Simulation 기초

This commit is contained in:
2017-02-11 13:25:42 +09:00
parent af9ef4aa60
commit 8f6937c112
16 changed files with 65920 additions and 80 deletions

1
.gitignore vendored
View File

@@ -5,3 +5,4 @@ configure/
log/
publish/
*.user
simulation/

54
AutoSeller.Designer.cs generated
View File

@@ -69,6 +69,9 @@
this.btApply = new MaterialSkin.Controls.MaterialFlatButton();
this.tbSubAccount = new MaterialSkin.Controls.MaterialSingleLineTextField();
this.cbAccount = new System.Windows.Forms.ComboBox();
this.tabPage3 = new System.Windows.Forms.TabPage();
this.btLoad = new MaterialSkin.Controls.MaterialFlatButton();
this.btSimulate = new MaterialSkin.Controls.MaterialFlatButton();
this.materialTabControl1.SuspendLayout();
this.tabPage1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).BeginInit();
@@ -80,6 +83,7 @@
this.splitContainer1.Panel2.SuspendLayout();
this.splitContainer1.SuspendLayout();
this.tabPage2.SuspendLayout();
this.tabPage3.SuspendLayout();
this.SuspendLayout();
//
// materialTabSelector1
@@ -102,6 +106,7 @@
| System.Windows.Forms.AnchorStyles.Right)));
this.materialTabControl1.Controls.Add(this.tabPage1);
this.materialTabControl1.Controls.Add(this.tabPage2);
this.materialTabControl1.Controls.Add(this.tabPage3);
this.materialTabControl1.Depth = 0;
this.materialTabControl1.Location = new System.Drawing.Point(3, 115);
this.materialTabControl1.MouseState = MaterialSkin.MouseState.HOVER;
@@ -543,6 +548,50 @@
this.cbAccount.Size = new System.Drawing.Size(121, 20);
this.cbAccount.TabIndex = 0;
//
// tabPage3
//
this.tabPage3.Controls.Add(this.btSimulate);
this.tabPage3.Controls.Add(this.btLoad);
this.tabPage3.Location = new System.Drawing.Point(4, 22);
this.tabPage3.Name = "tabPage3";
this.tabPage3.Padding = new System.Windows.Forms.Padding(3);
this.tabPage3.Size = new System.Drawing.Size(1060, 546);
this.tabPage3.TabIndex = 2;
this.tabPage3.Text = "Simulation";
this.tabPage3.UseVisualStyleBackColor = true;
//
// btLoad
//
this.btLoad.AutoSize = true;
this.btLoad.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.btLoad.Depth = 0;
this.btLoad.Location = new System.Drawing.Point(44, 47);
this.btLoad.Margin = new System.Windows.Forms.Padding(4, 6, 4, 6);
this.btLoad.MouseState = MaterialSkin.MouseState.HOVER;
this.btLoad.Name = "btLoad";
this.btLoad.Primary = false;
this.btLoad.Size = new System.Drawing.Size(86, 36);
this.btLoad.TabIndex = 0;
this.btLoad.Text = "Load data";
this.btLoad.UseVisualStyleBackColor = true;
this.btLoad.Click += new System.EventHandler(this.btLoad_Click);
//
// btSimulate
//
this.btSimulate.AutoSize = true;
this.btSimulate.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.btSimulate.Depth = 0;
this.btSimulate.Location = new System.Drawing.Point(44, 95);
this.btSimulate.Margin = new System.Windows.Forms.Padding(4, 6, 4, 6);
this.btSimulate.MouseState = MaterialSkin.MouseState.HOVER;
this.btSimulate.Name = "btSimulate";
this.btSimulate.Primary = false;
this.btSimulate.Size = new System.Drawing.Size(139, 36);
this.btSimulate.TabIndex = 1;
this.btSimulate.Text = "simulation start";
this.btSimulate.UseVisualStyleBackColor = true;
this.btSimulate.Click += new System.EventHandler(this.btSimulate_Click);
//
// AutoSeller
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
@@ -566,6 +615,8 @@
this.splitContainer1.ResumeLayout(false);
this.tabPage2.ResumeLayout(false);
this.tabPage2.PerformLayout();
this.tabPage3.ResumeLayout(false);
this.tabPage3.PerformLayout();
this.ResumeLayout(false);
}
@@ -611,5 +662,8 @@
private MaterialSkin.Controls.MaterialSingleLineTextField tbTrailingP;
private MaterialSkin.Controls.MaterialLabel materialLabel5;
private MaterialSkin.Controls.MaterialLabel materialLabel4;
private System.Windows.Forms.TabPage tabPage3;
private MaterialSkin.Controls.MaterialFlatButton btLoad;
private MaterialSkin.Controls.MaterialFlatButton btSimulate;
}
}

View File

@@ -362,5 +362,19 @@ namespace AutoSellerNS
int.TryParse(tbTrailingCnt.Text, out iTrailingCnt);
Config.SetTrailing(fTrailingPercent, iTrailingCnt);
}
#region Simulation
private void btLoad_Click(object sender, EventArgs e)
{
SimulationHelper helper = new SimulationHelper(m_CybosHelper);
helper.LoadExcel();
}
private void btSimulate_Click(object sender, EventArgs e)
{
SimulationHelper helper = new SimulationHelper(m_CybosHelper);
helper.StartSimuation();
}
#endregion
}
}

View File

@@ -7,7 +7,7 @@
<ProjectGuid>{D22B6894-B97F-4B53-92D3-D2B77FC929D5}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>AutoSeller</RootNamespace>
<RootNamespace>AutoSellerNS</RootNamespace>
<AssemblyName>AutoSeller</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
@@ -66,6 +66,10 @@
<ApplicationIcon>icon.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="EPPlus, Version=4.1.0.0, Culture=neutral, PublicKeyToken=ea159fdaa78159a1, processorArchitecture=MSIL">
<HintPath>packages\EPPlus.4.1.0\lib\net40\EPPlus.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="MaterialSkin, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\MaterialSkin.0.2.1\lib\MaterialSkin.dll</HintPath>
<Private>True</Private>
@@ -91,11 +95,13 @@
<Compile Include="AutoSeller.Designer.cs">
<DependentUpon>AutoSeller.cs</DependentUpon>
</Compile>
<Compile Include="ExcelHandler.cs" />
<Compile Include="ListViewNF.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SimulationHelper.cs" />
<Compile Include="Util.cs" />
<EmbeddedResource Include="AutoSeller.resx">
<DependentUpon>AutoSeller.cs</DependentUpon>
@@ -108,6 +114,7 @@
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="packages.config" />
<None Include="Properties\app.manifest">

107
ExcelHandler.cs Normal file
View File

@@ -0,0 +1,107 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Reflection;
using OfficeOpenXml;
using System.Drawing;
namespace AutoSellerNS
{
public class ExcelHandler
{
string m_strFileName = "";
string m_strToday = DateTime.Now.ToString("yyyy-MM-dd");
public ExcelHandler(string strFileName, string[] astrColumns)
{
m_strFileName = strFileName;
if(File.Exists(m_strFileName) == false)
Create(astrColumns);
}
private void Create(string[] astrColumns)
{
lock(this)
{
FileInfo newFile = new FileInfo(m_strFileName);
ExcelPackage package = new ExcelPackage(newFile);
ExcelWorksheet Sheet = package.Workbook.Worksheets.Add("sheet");
for(int i = 0; i<astrColumns.Length; i++)
Sheet.Cells[1, i+1].Value = astrColumns[i];
package.Save();
}
}
public bool AddRow(object[] row)
{
lock(this)
{
FileInfo newFile = new FileInfo(m_strFileName);
ExcelPackage package = new ExcelPackage(newFile);
ExcelWorksheet Sheet = package.Workbook.Worksheets["sheet"];
int iRowNo = Sheet.Dimension.Rows+1;
for(int i=0; i<row.Length; i++)
{
Sheet.Cells[iRowNo, i+1].Value = row[i];
if(row[i].GetType() == typeof(int))
{
Sheet.Cells[iRowNo, i+1].Style.Numberformat.Format = "###,###,##0";
}
else if(row[i].GetType() == typeof(float) || row[i].GetType() == typeof(double))
{
Sheet.Cells[iRowNo, i+1].Style.Numberformat.Format = "###,###,##0.00";
float fValue = (float)row[i];
Sheet.Cells[iRowNo, i+1].Style.Font.Color.SetColor(fValue>0 ? Color.Red : fValue<0 ? Color.Blue : Color.Black);
}
}
Sheet.Cells.AutoFitColumns(0);
package.Save();
}
return true;
}
public bool AddRows(object[][] rows)
{
lock(this)
{
FileInfo newFile = new FileInfo(m_strFileName);
ExcelPackage package = new ExcelPackage(newFile);
ExcelWorksheet Sheet = package.Workbook.Worksheets["sheet"];
int iRowNo = Sheet.Dimension.Rows+1;
foreach(object[] row in rows)
{
for(int i = 0; i<row.Length; i++)
{
Sheet.Cells[iRowNo, i+1].Value = row[i];
if(row[i].GetType() == typeof(int))
{
Sheet.Cells[iRowNo, i+1].Style.Numberformat.Format = "###,###,##0";
}
else if(row[i].GetType() == typeof(float) || row[i].GetType() == typeof(double))
{
Sheet.Cells[iRowNo, i+1].Style.Numberformat.Format = "###,###,##0.00";
float fValue = (float)row[i];
Sheet.Cells[iRowNo, i+1].Style.Font.Color.SetColor(fValue>0 ? Color.Red : fValue<0 ? Color.Blue : Color.Black);
}
}
iRowNo++;
}
Sheet.Cells.AutoFitColumns(0);
package.Save();
}
return true;
}
}
}

View File

@@ -8,64 +8,56 @@
// </auto-generated>
//------------------------------------------------------------------------------
namespace AutoSellerNS.Properties
{
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("AutoSeller.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
}
namespace AutoSellerNS.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("AutoSellerNS.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}

View File

@@ -8,23 +8,19 @@
// </auto-generated>
//------------------------------------------------------------------------------
namespace AutoSellerNS.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
return defaultInstance;
}
}
}
namespace AutoSellerNS.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
}
}

289
SimulationHelper.cs Normal file
View File

@@ -0,0 +1,289 @@
using CPSYSDIBLib;
using OfficeOpenXml;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AutoSellerNS
{
class SimulationHelper
{
CybosHelper m_CybosHelper = null;
class SIMUL_ITEM
{
}
public SimulationHelper(CybosHelper CybosHelper)
{
m_CybosHelper = CybosHelper;
}
public void LoadTxt()
{
List<string> aItems = new List<string>();
StockChart CPStockChart = new StockChart();
foreach(string strLine in File.ReadLines(Util.GetSimulationPath()+"/0-input.txt", Encoding.UTF8))
{
var tokens = strLine.Split('\t');
var strDate = tokens[0];
var strNewTime = tokens[1];
var strSimulationTime = tokens[2];
var strCodeName = tokens[3];
var strCode = tokens[4];
var strStartPrice = tokens[5];
DateTime StartDT;
DateTime.TryParse(strDate+" "+strSimulationTime, out StartDT);
uint uiStartDate;
uint.TryParse(StartDT.ToString("yyyyMMdd"), out uiStartDate);
string strOutFileName = Util.GetSimulationPath() + "/" + strCodeName + "-" + StartDT.ToString("yyyy-MM-dd") + ".txt";
if(File.Exists(strOutFileName) == true)
continue;
CPStockChart.SetInputValue(0, "A"+strCode);
CPStockChart.SetInputValue(1, '1');
CPStockChart.SetInputValue(2, uiStartDate);
CPStockChart.SetInputValue(3, uiStartDate);
CPStockChart.SetInputValue(4, 100000);
CPStockChart.SetInputValue(5, new int[] { 0, 1, 5, 8, 9, 10, 11 });
CPStockChart.SetInputValue(6, 'T');
CPStockChart.BlockRequest2(0);
int iFieldCnt = CPStockChart.GetHeaderValue(1);
string[] astrFieldName = CPStockChart.GetHeaderValue(2);
string strOutLine = "";
for(int j = 0; j<iFieldCnt; j++)
{
strOutLine += astrFieldName[j];
strOutLine += '\t';
}
File.AppendAllText(strOutFileName, strOutLine+Environment.NewLine, new UTF8Encoding(true));
strOutLine = "";
bool bContinue = true;
while(bContinue == true)
{
int iCnt = CPStockChart.GetHeaderValue(3);
for(int i = 0; i<iCnt; i++)
{
for(int j = 0; j<iFieldCnt; j++)
{
strOutLine += CPStockChart.GetDataValue(j, i);
strOutLine += '\t';
}
strOutLine += Environment.NewLine;
if(i % 1000 == 999)
{
File.AppendAllText(strOutFileName, strOutLine, new UTF8Encoding(true));
strOutLine = "";
}
}
bContinue = (CPStockChart.Continue==1);
if(bContinue == true)
CPStockChart.BlockRequest2(0);
Console.WriteLine(string.Format("RequestRQ({0})", m_CybosHelper.GetLimitRemainCountRQ()));
}
if(strOutLine.Length > 0)
{
File.AppendAllText(strOutFileName, strOutLine, new UTF8Encoding(true));
strOutLine = "";
}
Console.WriteLine("[Load] " + strOutFileName + " End");
}
Console.WriteLine("[Load] All End");
}
public void LoadExcel()
{
List<string> aItems = new List<string>();
StockChart CPStockChart = new StockChart();
ExcelHandler Excel = null;
foreach(string strLine in File.ReadLines(Util.GetSimulationPath()+"/0-input.txt", Encoding.UTF8))
{
var tokens = strLine.Split('\t');
var strDate = tokens[0];
var strNewTime = tokens[1];
var strSimulationTime = tokens[2];
var strCodeName = tokens[3];
var strCode = tokens[4];
var strStartPrice = tokens[5];
DateTime StartDT;
DateTime.TryParse(strDate+" "+strSimulationTime, out StartDT);
string strOutFileName = Util.GetSimulationPath() + "/" + strCodeName + "-" + StartDT.ToString("yyyy-MM-dd") + ".xlsx";
if(File.Exists(strOutFileName) == true)
continue;
CPStockChart.SetInputValue(0, "A"+strCode);
CPStockChart.SetInputValue(1, '1');
CPStockChart.SetInputValue(2, StartDT.ToString("yyyyMMdd"));
CPStockChart.SetInputValue(3, StartDT.ToString("yyyyMMdd"));
CPStockChart.SetInputValue(5, new int[] { 0, 1, 5, 8, 9, 10, 11 });
CPStockChart.SetInputValue(6, 'T');
CPStockChart.BlockRequest2(0);
int iFieldCnt = CPStockChart.GetHeaderValue(1);
string[] astrFieldName = CPStockChart.GetHeaderValue(2);
List<object> aRow = new List<object>();
List<object[]> aRows = new List<object[]>();
Excel = new ExcelHandler(strOutFileName, astrFieldName);
bool bContinue = true;
while(bContinue == true)
{
int iCnt = CPStockChart.GetHeaderValue(3);
for(int i = 0; i<iCnt; i++)
{
for(int j = 0; j<iFieldCnt; j++)
aRow.Add(CPStockChart.GetDataValue(j, i));
aRows.Add(aRow.ToArray());
aRow.Clear();
}
bContinue = (CPStockChart.Continue==1);
if(bContinue == true)
CPStockChart.BlockRequest2(0);
Console.WriteLine(string.Format("RequestRQ({0})", m_CybosHelper.GetLimitRemainCountRQ()));
}
aRows.Reverse();
Excel.AddRows(aRows.ToArray());
Console.WriteLine("[Load] " + strOutFileName + " End");
}
Console.WriteLine("[Load] All End");
}
public void StartSimuation()
{
int iTotalProfit = 0;
int iTotalBid = 0;
foreach(string strLine in File.ReadLines(Util.GetSimulationPath()+"/0-input.txt", Encoding.UTF8))
{
var tokens = strLine.Split('\t');
var strDate = tokens[0];
var strNewTime = tokens[1];
var strSimulationTime = tokens[2];
var strCodeName = tokens[3];
var strCode = tokens[4];
var strStartPrice = tokens[5];
DateTime StartDT;
DateTime.TryParse(strDate+" "+strSimulationTime, out StartDT);
int iStartPrice;
int.TryParse(strStartPrice, out iStartPrice);
string strFileName = Util.GetSimulationPath() + "/" + strCodeName + "-" + StartDT.ToString("yyyy-MM-dd") + ".xlsx";
FileInfo newFile = new FileInfo(strFileName);
newFile.IsReadOnly = true;
ExcelPackage package = new ExcelPackage(newFile);
ExcelWorksheet Sheet = package.Workbook.Worksheets["sheet"];
int iMaxRow = Sheet.Dimension.Rows;
DateTime RowDT;
bool bStart = false;
int iTotalAskCount = 0;
int iTotalBidCount = 0;
int iPrevAskCount = 0;
int iPrevBidCount = 0;
bool bBid = false;
int iAskCount = 0;
int iTrailingCount = 0;
int iMaxPrice = int.MinValue;
int iStockCount = 0;
for(int iRow = 2; iRow<=iMaxRow; iRow++)
{
int iTime = (int)(double)Sheet.Cells[iRow, 2].Value;
int iPrice = (int)(double)Sheet.Cells[iRow, 3].Value;
iTotalAskCount = (int)(double)Sheet.Cells[iRow, 6].Value;
iTotalBidCount = (int)(double)Sheet.Cells[iRow, 7].Value;
bBid = (iTotalAskCount == iPrevAskCount);
DateTime.TryParse(strDate+" "+string.Format("{0}:{1}:{2}", iTime/100, iTime%100, 59), out RowDT);
iStockCount = 1000000/iStartPrice;
if(bStart == false)
{
if(RowDT >= StartDT && iPrice==iStartPrice)
bStart = true;
}
else
{
if(bBid == false)
iAskCount++;
else
iAskCount = 0;
if(iAskCount >= Config.GetBidCount())
{
Console.WriteLine("[{0}] 시뮬레이션 매도 {1} {2} {3} ({4} : {5:n2}%)",
strCodeName,
RowDT.ToString("yyyy-MM-dd HH:mm:00"),
iRow,
iPrice,
iPrice-iStartPrice,
(iPrice-iStartPrice)*100/(float)iStartPrice
);
iTotalProfit += (iPrice-iStartPrice)*iStockCount;
iTotalBid += iStartPrice*iStockCount;
break;
}
if(iPrice > iMaxPrice)
iTrailingCount = 0;
else if(iPrice <= iMaxPrice*(100-Config.GetTrailingRate())/100)
iTrailingCount++;
iMaxPrice = Math.Max(iPrice, iMaxPrice);
if(iTrailingCount >= Config.GetTrailingCnt())
{
Console.WriteLine("[{0}] 트레일링 매도 {1} {2} {3} ({4} : {5:n2}%)",
strCodeName,
RowDT.ToString("yyyy-MM-dd HH:mm:00"),
iRow,
iPrice,
iPrice-iStartPrice,
(iPrice-iStartPrice)*100/(float)iStartPrice
);
iTotalProfit += (iPrice-iStartPrice)*iStockCount;
iTotalBid += iStartPrice*iStockCount;
break;
}
}
iPrevAskCount = iTotalAskCount;
iPrevBidCount = iTotalBidCount;
}
}
Console.WriteLine("[시뮬레이션 종료] 총수익 : {0} : {1:n2}%", iTotalProfit, iTotalProfit*100/iTotalBid);
}
}
}

15
Util.cs
View File

@@ -133,5 +133,20 @@ namespace AutoSellerNS
return strPath;
}
public static string GetSimulationPath()
{
string strPath = "";
if(IsDebugging())
strPath = Path.GetDirectoryName(Path.GetDirectoryName(Directory.GetCurrentDirectory()));
else
strPath = Directory.GetCurrentDirectory();
strPath += "/simulation";
if(Directory.Exists(strPath) == false)
Directory.CreateDirectory(strPath);
return strPath;
}
}
}

View File

@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="EPPlus" version="4.1.0" targetFramework="net452" />
<package id="MaterialSkin" version="0.2.1" targetFramework="net452" />
</packages>

BIN
packages/EPPlus.4.1.0/EPPlus.4.1.0.nupkg vendored Normal file

Binary file not shown.

32621
packages/EPPlus.4.1.0/lib/net35/EPPlus.XML vendored Normal file

File diff suppressed because it is too large Load Diff

Binary file not shown.

32621
packages/EPPlus.4.1.0/lib/net40/EPPlus.XML vendored Normal file

File diff suppressed because it is too large Load Diff

Binary file not shown.

122
packages/EPPlus.4.1.0/lib/readme.txt vendored Normal file
View File

@@ -0,0 +1,122 @@
EPPlus 4.1
Visit epplus.codeplex.com for the latest information
EPPlus-Create Advanced Excel spreadsheet.
New features 4.0
Replaced Packaging API with DotNetZip
* This will remove any problems with Isolated Storage and enable multithreading
New Cell store
* Less memory consumption
* Insert columns (not on the range level)
* Faster row inserts,
Formula Parser
* Calculates all formulas in a workbook, a worksheet or in a specified range
* 100+ functions implemented
* Access via Calculate methods on Workbook, Worksheet and Range objects.
* Add custom/missing Excel functions via Workbook. FormulaParserManager.
* Samples added to the EPPlusSamples project.
The formula parser does not support Array Formulas
* Intersect operator (Space)
* References to external workbooks
* And probably a whole lot of other stuff as well :)
Performance
*Of course the performance of the formula parser is nowhere near Excels. Our focus has been functionality.
Agile Encryption (Office 2012-)
* Support for newer type of encryption.
Minor new features
* Chart worksheets
* New Chart Types Bubblecharts
* Radar Charts
* Area Charts
* And lots of bug fixes...
Beta 2 Changes
* Fixed bug when using RepeatColumns & RepeatRows at the same time.
* VBA project will be left untouched if its not accessed.
* Fixed problem with strings on save.
* Added locks to the cell store for access by multiple threads.
* Implemented Indirect function
* Used DisplayNameAttribute to generate column headers from LoadFromCollection
* Rewrote ExcelRangeBase.Copy function.
* Added caching to Save ZipStream for Cells and shared strings to speed up the Save method.
* Added Missing InsertColumn and DeleteColumn
* Added pull request to support Date1904
* Added pull request ExcelWorksheet. LoadFromDataReader
Release Candidate changes
* Fixed some problems with Range.Copy Function
* InsertColumn and Delete column didn't work in some cases
* Chart.DisplayBlankAs had the wrong default type in Excel 2010+
* Datavalidation list overflow caused corruption of the package
* Fixed a few Calculation when referring ranges (for example If function)
* Added ChartAxis.DisplayUnit
* Fixed a bug related to shared formulas
* Named styles failed in some cases.
* Style.Indent got an invalid value in some cases.
* Fixed a problem with AutofitColumns method.
* Performance fix.
* A whole lot of other small fixes.
4.0.1 Fixes
* VBA unreadable content
* Fixed a few issues with InsertRow and DeleteRow
* Fixed bug in Average and AverageA
* Handling of Div/0 in functions
* Fixed VBA CodeModule error when copying a worksheet.
* Value decoding when reading str element for cell value.
* Better exception when accessing a worksheet out of range in the Excelworksheets indexer.
* Added Small and Large function to formula parser. Performance fix when encountering an unknown function.
* Fixed handling strings in formulas
* Calculate hangs if formula start with a parenthes.
* Worksheet.Dimension returned an invalid range in some cases.
* Rowheight was wrong in some cases.
* ExcelSeries.Header had an incorrect validation check.
4.0.2 Fixes
* Fixes a whole bunch of bugs related to the cell store (Worksheet.InsertColumn, Worksheet.InsertRow, Worksheet.DeleteColumn, Worksheet.DeleteRow, Range.Copy, Range.Clear)
* Added functions Acos, Acosh, Asinh, Atanh, Atan, CountBlank, CountIfs, Mina, Offset, Median, Hyperlink, Rept
* Fix for reading Excel comment content from the t-element.
* Fix to make Range.LoadFromCollection work better with inheritence
* And alot of other small fixes
4.0.3 Fixes
* Added compilation directive for MONO (Thanks Danny)
* Added functions IfError, Char, Error.Type, Degrees, Fixed, IsNonText, IfNa and SumIfs
* And fixed a lot of issues. See http://epplus.codeplex.com/SourceControl/list/changesets for more details
4.0.4 Fixes
* Added functions Daverage, Dvar Dvarp, DMax, DMin DSum, DGet, DCount and DCountA
* Exposed the formula parser logging functionality via FormulaParserManager.
* And fixed a lot of issues. See http://epplus.codeplex.com/SourceControl/list/changesets for more details
4.0.5 Fixes
* Switched to Visual Studio 2015 for code and sample projects.
* Added LineColor, MarkerSize, LineWidth and MarkerLineColor properties to line charts
* Added LineEnd properties to shapes
* Added functions Value, DateValue, TimeValue
* Removed WPF depedency.
* And fixed a lot of issues. See http://epplus.codeplex.com/SourceControl/list/changesets for more details
4.1
* Added functions Rank, Rank.eq, Rank.avg and Search
* Custom function compilers can now be added via FormulaParserManager
* Applied a whole bunch of pull requests...
* Performance and memory usage tweeks
* Ability to set and retrieve 'custom' extended application propeties.
* Added style QuotePrefix
* Added support for MajorTimeUnit and MinorTimeUnit to chart axes
* Added GapWidth Property to BarChart and Gapwidth.
* Added Fill and Border properties to ChartSerie.
* Added support for MajorTimeUnit and MinorTimeUnit to chart axes
* Insert/delete row/column now shifts named ranges, comments, tables and pivottables.
* And fixed a lot of issues. See http://epplus.codeplex.com/SourceControl/list/changesets for more details