diff --git a/.gitignore b/.gitignore
index 5ad99a6..9ba7f54 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,3 +5,4 @@ configure/
log/
publish/
*.user
+simulation/
diff --git a/AutoSeller.Designer.cs b/AutoSeller.Designer.cs
index e3be389..453605c 100644
--- a/AutoSeller.Designer.cs
+++ b/AutoSeller.Designer.cs
@@ -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;
}
}
\ No newline at end of file
diff --git a/AutoSeller.cs b/AutoSeller.cs
index 35d961b..f933c7c 100644
--- a/AutoSeller.cs
+++ b/AutoSeller.cs
@@ -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
}
}
diff --git a/AutoSeller.csproj b/AutoSeller.csproj
index 9c8a567..5712a43 100644
--- a/AutoSeller.csproj
+++ b/AutoSeller.csproj
@@ -7,7 +7,7 @@
{D22B6894-B97F-4B53-92D3-D2B77FC929D5}
WinExe
Properties
- AutoSeller
+ AutoSellerNS
AutoSeller
v4.5.2
512
@@ -66,6 +66,10 @@
icon.ico
+
+ packages\EPPlus.4.1.0\lib\net40\EPPlus.dll
+ True
+
packages\MaterialSkin.0.2.1\lib\MaterialSkin.dll
True
@@ -91,11 +95,13 @@
AutoSeller.cs
+
Component
+
AutoSeller.cs
@@ -108,6 +114,7 @@
True
Resources.resx
+ True
diff --git a/ExcelHandler.cs b/ExcelHandler.cs
new file mode 100644
index 0000000..19f46b5
--- /dev/null
+++ b/ExcelHandler.cs
@@ -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; i0 ? 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; i0 ? Color.Red : fValue<0 ? Color.Blue : Color.Black);
+ }
+ }
+
+ iRowNo++;
+ }
+
+ Sheet.Cells.AutoFitColumns(0);
+ package.Save();
+ }
+
+ return true;
+ }
+ }
+}
diff --git a/Properties/Resources.Designer.cs b/Properties/Resources.Designer.cs
index 155893d..a17731c 100644
--- a/Properties/Resources.Designer.cs
+++ b/Properties/Resources.Designer.cs
@@ -8,64 +8,56 @@
//
//------------------------------------------------------------------------------
-namespace AutoSellerNS.Properties
-{
-
-
- ///
- /// A strongly-typed resource class, for looking up localized strings, etc.
- ///
- // 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()
- {
- }
-
- ///
- /// Returns the cached ResourceManager instance used by this class.
- ///
- [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;
- }
- }
-
- ///
- /// Overrides the current thread's CurrentUICulture property for all
- /// resource lookups using this strongly typed resource class.
- ///
- [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;
+
+
+ ///
+ /// A strongly-typed resource class, for looking up localized strings, etc.
+ ///
+ // 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() {
+ }
+
+ ///
+ /// Returns the cached ResourceManager instance used by this class.
+ ///
+ [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;
+ }
+ }
+
+ ///
+ /// Overrides the current thread's CurrentUICulture property for all
+ /// resource lookups using this strongly typed resource class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+ }
}
diff --git a/Properties/Settings.Designer.cs b/Properties/Settings.Designer.cs
index 89422bd..730bbb6 100644
--- a/Properties/Settings.Designer.cs
+++ b/Properties/Settings.Designer.cs
@@ -8,23 +8,19 @@
//
//------------------------------------------------------------------------------
-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;
+ }
+ }
+ }
}
diff --git a/SimulationHelper.cs b/SimulationHelper.cs
new file mode 100644
index 0000000..5db3127
--- /dev/null
+++ b/SimulationHelper.cs
@@ -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 aItems = new List();
+ 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 0)
+ {
+ File.AppendAllText(strOutFileName, strOutLine, new UTF8Encoding(true));
+ strOutLine = "";
+ }
+
+ Console.WriteLine("[Load] " + strOutFileName + " End");
+ }
+
+ Console.WriteLine("[Load] All End");
+ }
+
+ public void LoadExcel()
+ {
+ List aItems = new List();
+ 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