병합
This commit is contained in:
@@ -17,6 +17,9 @@ using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using DocumentFormat.OpenXml;
|
||||
using DocumentFormat.OpenXml.Packaging;
|
||||
using DocumentFormat.OpenXml.Spreadsheet;
|
||||
using static Million.CommonProperty;
|
||||
|
||||
namespace Million_Prototype
|
||||
@@ -191,7 +194,7 @@ namespace Million_Prototype
|
||||
var candleDataH1 = new CandleDataList();
|
||||
var candleDataM1 = new CandleDataList();
|
||||
var splitDataM = new List<List<CandleData>>();
|
||||
var splitData = ValidationCheckManager.GetValidationCandleDatas(marketData,ref splitDataM, ref candleDataH1, ref candleDataM1, new DateTime(2020, 1, 1), new DateTime(2021, 1, 1));
|
||||
var splitData = ValidationCheckManager.GetValidationCandleDatas(marketData,ref splitDataM, ref candleDataH1, ref candleDataM1, new DateTime(2022, 1, 1), DateTime.Now);
|
||||
|
||||
var buyData = new CandleDataList();
|
||||
buyData.ConGoodsData = marketData;
|
||||
@@ -211,11 +214,11 @@ namespace Million_Prototype
|
||||
foreach (var item in splitDataM)
|
||||
{
|
||||
var sell1 = SellLogicManager.GetSellLogicOverUnderIch(item);
|
||||
//var sell2 = SellLogicManager.GetSellLogicOVerUnderBol(item, 40, 1);
|
||||
//var sell3 = SellLogicManager.GetSellLogicOVerUnderBol(item, 40, 2);
|
||||
var sell2 = SellLogicManager.GetSellLogicOVerUnderBol(item, 40, 1);
|
||||
var sell3 = SellLogicManager.GetSellLogicOVerUnderBol(item, 40, 2);
|
||||
|
||||
//sell1.AddRange(sell2);
|
||||
//sell1.AddRange(sell3);
|
||||
sell1.AddRange(sell2);
|
||||
sell1.AddRange(sell3);
|
||||
|
||||
var dateTimeList = sell1.Select(t => t.DateTime).Distinct().ToList();
|
||||
|
||||
@@ -321,6 +324,7 @@ namespace Million_Prototype
|
||||
|
||||
result = new SearchResult();
|
||||
result.BuyList.CandleDataLists_Im.Add(buy);
|
||||
result.CodeFullName = result.BuyList.ConGoodsData.CodeFullName;
|
||||
sellData = sellList.FirstOrDefault(t => t.DateTime > buy.DateTime);
|
||||
}
|
||||
}
|
||||
@@ -404,21 +408,23 @@ namespace Million_Prototype
|
||||
result.SellData = sellData;
|
||||
errorResultList.Add(result);
|
||||
}
|
||||
}
|
||||
|
||||
double total = 0;
|
||||
foreach (var item in resultList)
|
||||
{
|
||||
Console.WriteLine(item.TotalEarningRate);
|
||||
total += item.TotalEarningRate;
|
||||
}
|
||||
Console.WriteLine("Total 수익률 : " + total/resultList.Count);
|
||||
Console.WriteLine("Win : " + win);
|
||||
Console.WriteLine("Lose : " + lose);
|
||||
Console.WriteLine("승률 : " + win * 100 / (win+lose) );
|
||||
sellList.ToString();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
double total = 0;
|
||||
foreach (var item in resultList)
|
||||
{
|
||||
Console.WriteLine(item.CodeFullName);
|
||||
Console.WriteLine(item.TotalEarningRate);
|
||||
total += item.TotalEarningRate;
|
||||
}
|
||||
|
||||
Console.WriteLine("Total 수익률 : " + total / resultList.Count);
|
||||
Console.WriteLine("Win : " + win);
|
||||
Console.WriteLine("Lose : " + lose);
|
||||
Console.WriteLine("승률 : " + win * 100 / (win + lose));
|
||||
resultList.ToString();
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,9 @@
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="DocumentFormat.OpenXml, Version=2.16.0.0, Culture=neutral, PublicKeyToken=8fb06cb64d019a17, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\DocumentFormat.OpenXml.2.16.0\lib\net46\DocumentFormat.OpenXml.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
@@ -45,6 +48,7 @@
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="WindowsBase" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Form1.cs">
|
||||
@@ -68,6 +72,7 @@
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
<DesignTime>True</DesignTime>
|
||||
</Compile>
|
||||
<None Include="packages.config" />
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
|
||||
4
Million Prototype/packages.config
Normal file
4
Million Prototype/packages.config
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="DocumentFormat.OpenXml" version="2.16.0" targetFramework="net48" />
|
||||
</packages>
|
||||
176
Million/Manager/ExportManager.cs
Normal file
176
Million/Manager/ExportManager.cs
Normal file
@@ -0,0 +1,176 @@
|
||||
using DocumentFormat.OpenXml;
|
||||
using DocumentFormat.OpenXml.Packaging;
|
||||
using DocumentFormat.OpenXml.Spreadsheet;
|
||||
using Million.Data;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Million.Manager
|
||||
{
|
||||
/// <summary>
|
||||
/// 출력 관련 Manager
|
||||
/// </summary>
|
||||
public static class ExportManager
|
||||
{
|
||||
/// <summary>
|
||||
/// Excel Export 기능(Result 데이터로만)
|
||||
/// </summary>
|
||||
/// <param name="filePath"></param>
|
||||
/// <param name="resultList"></param>
|
||||
public static void CreateResultOfExcel(string filePath, List<SearchResult> resultList)
|
||||
{
|
||||
using (SpreadsheetDocument spreadSheet = SpreadsheetDocument.Create(filePath, SpreadsheetDocumentType.Workbook))
|
||||
{
|
||||
try
|
||||
{
|
||||
// Get the SharedStringTablePart. If it does not exist, create a new one.
|
||||
SharedStringTablePart shareStringPart;
|
||||
if (spreadSheet.WorkbookPart.GetPartsOfType<SharedStringTablePart>().Count() > 0)
|
||||
{
|
||||
shareStringPart = spreadSheet.WorkbookPart.GetPartsOfType<SharedStringTablePart>().First();
|
||||
}
|
||||
else
|
||||
{
|
||||
shareStringPart = spreadSheet.WorkbookPart.AddNewPart<SharedStringTablePart>();
|
||||
}
|
||||
|
||||
//result 돌면 서 데이터 처리
|
||||
var fieldList = new List<string>();
|
||||
|
||||
|
||||
|
||||
// Insert the text into the SharedStringTablePart.
|
||||
int index = InsertSharedStringItem("", shareStringPart);
|
||||
|
||||
// Insert a new worksheet.
|
||||
WorksheetPart worksheetPart = InsertWorksheet(spreadSheet.WorkbookPart);
|
||||
|
||||
// Insert cell A1 into the new worksheet.
|
||||
Cell cell = InsertCellInWorksheet("A", 1, worksheetPart);
|
||||
|
||||
// Set the value of cell A1.
|
||||
cell.CellValue = new CellValue(index.ToString());
|
||||
cell.DataType = new EnumValue<CellValues>(CellValues.SharedString);
|
||||
|
||||
// Save the new worksheet.
|
||||
worksheetPart.Worksheet.Save();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
spreadSheet.Close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Given text and a SharedStringTablePart, creates a SharedStringItem with the specified text
|
||||
// and inserts it into the SharedStringTablePart. If the item already exists, returns its index.
|
||||
private static int InsertSharedStringItem(string text, SharedStringTablePart shareStringPart)
|
||||
{
|
||||
// If the part does not contain a SharedStringTable, create one.
|
||||
if (shareStringPart.SharedStringTable == null)
|
||||
{
|
||||
shareStringPart.SharedStringTable = new SharedStringTable();
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
|
||||
// Iterate through all the items in the SharedStringTable. If the text already exists, return its index.
|
||||
foreach (SharedStringItem item in shareStringPart.SharedStringTable.Elements<SharedStringItem>())
|
||||
{
|
||||
if (item.InnerText == text)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
// The text does not exist in the part. Create the SharedStringItem and return its index.
|
||||
shareStringPart.SharedStringTable.AppendChild(new SharedStringItem(new DocumentFormat.OpenXml.Spreadsheet.Text(text)));
|
||||
shareStringPart.SharedStringTable.Save();
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
// Given a WorkbookPart, inserts a new worksheet.
|
||||
private static WorksheetPart InsertWorksheet(WorkbookPart workbookPart)
|
||||
{
|
||||
// Add a new worksheet part to the workbook.
|
||||
WorksheetPart newWorksheetPart = workbookPart.AddNewPart<WorksheetPart>();
|
||||
newWorksheetPart.Worksheet = new Worksheet(new SheetData());
|
||||
newWorksheetPart.Worksheet.Save();
|
||||
|
||||
Sheets sheets = workbookPart.Workbook.GetFirstChild<Sheets>();
|
||||
string relationshipId = workbookPart.GetIdOfPart(newWorksheetPart);
|
||||
|
||||
// Get a unique ID for the new sheet.
|
||||
uint sheetId = 1;
|
||||
if (sheets.Elements<Sheet>().Count() > 0)
|
||||
{
|
||||
sheetId = sheets.Elements<Sheet>().Select(s => s.SheetId.Value).Max() + 1;
|
||||
}
|
||||
|
||||
string sheetName = "Sheet" + sheetId;
|
||||
|
||||
// Append the new worksheet and associate it with the workbook.
|
||||
Sheet sheet = new Sheet() { Id = relationshipId, SheetId = sheetId, Name = sheetName };
|
||||
sheets.Append(sheet);
|
||||
workbookPart.Workbook.Save();
|
||||
|
||||
return newWorksheetPart;
|
||||
}
|
||||
|
||||
// Given a column name, a row index, and a WorksheetPart, inserts a cell into the worksheet.
|
||||
// If the cell already exists, returns it.
|
||||
private static Cell InsertCellInWorksheet(string columnName, uint rowIndex, WorksheetPart worksheetPart)
|
||||
{
|
||||
Worksheet worksheet = worksheetPart.Worksheet;
|
||||
SheetData sheetData = worksheet.GetFirstChild<SheetData>();
|
||||
string cellReference = columnName + rowIndex;
|
||||
|
||||
// If the worksheet does not contain a row with the specified row index, insert one.
|
||||
Row row;
|
||||
if (sheetData.Elements<Row>().Where(r => r.RowIndex == rowIndex).Count() != 0)
|
||||
{
|
||||
row = sheetData.Elements<Row>().Where(r => r.RowIndex == rowIndex).First();
|
||||
}
|
||||
else
|
||||
{
|
||||
row = new Row() { RowIndex = rowIndex };
|
||||
sheetData.Append(row);
|
||||
}
|
||||
|
||||
// If there is not a cell with the specified column name, insert one.
|
||||
if (row.Elements<Cell>().Where(c => c.CellReference.Value == columnName + rowIndex).Count() > 0)
|
||||
{
|
||||
return row.Elements<Cell>().Where(c => c.CellReference.Value == cellReference).First();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Cells must be in sequential order according to CellReference. Determine where to insert the new cell.
|
||||
Cell refCell = null;
|
||||
foreach (Cell cell in row.Elements<Cell>())
|
||||
{
|
||||
if (string.Compare(cell.CellReference.Value, cellReference, true) > 0)
|
||||
{
|
||||
refCell = cell;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Cell newCell = new Cell() { CellReference = cellReference };
|
||||
row.InsertBefore(newCell, refCell);
|
||||
|
||||
worksheet.Save();
|
||||
return newCell;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,9 +20,9 @@ namespace Million.Manager
|
||||
/// <returns></returns>
|
||||
public static List<CandleData> GetSellLogicOverUnderIch(List<CandleData> candleDataM)
|
||||
{
|
||||
var list = candleDataM.Where(t => t.IndicatorDic.ContainsKey("Ich") &&
|
||||
t.IndicatorDic["Ich"] != null && t.IndicatorDic["Ich"].overStatus != OverStatus.None &&
|
||||
((IchimokData)t.IndicatorDic["Ich"]).GetOverStatus() <= OverStatus.UnderOver).ToList();
|
||||
var list = candleDataM.Where(t => t.IndicatorDic.ContainsKey("Ich") && t.IndicatorDic["Ich"] != null
|
||||
&& ((IchimokData)t.IndicatorDic["Ich"]).GetOverStatus() != OverStatus.None
|
||||
&& ((IchimokData)t.IndicatorDic["Ich"]).GetOverStatus() <= OverStatus.UnderOver ).ToList();
|
||||
foreach(var item in list)
|
||||
{
|
||||
item.SellLogicFlag[Enum.GetName(typeof(CommonProperty.SellLogicKeyList), CommonProperty.SellLogicKeyList.IchMok)] = true;
|
||||
@@ -50,5 +50,15 @@ namespace Million.Manager
|
||||
return list;
|
||||
}
|
||||
|
||||
public static List<CandleData> GetSellLogicLossCut(List<CandleData> candleDataM, int lossFactor, double buyValue)
|
||||
{
|
||||
var lossVal = buyValue * ((100 - lossFactor) / 100);
|
||||
var list = candleDataM.Where(t => t.EndValue < lossVal).ToList();
|
||||
foreach (var item in list)
|
||||
{
|
||||
item.SellLogicFlag["LossCut"] = true;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,6 +56,9 @@
|
||||
<Reference Include="DevExpress.XtraRichEdit.v18.2, Version=18.2.8.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
|
||||
<Reference Include="DevExpress.XtraTreeList.v18.2, Version=18.2.8.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
|
||||
<Reference Include="DevExpress.XtraTreeMap.v18.2, Version=18.2.8.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
|
||||
<Reference Include="DocumentFormat.OpenXml, Version=2.16.0.0, Culture=neutral, PublicKeyToken=8fb06cb64d019a17, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\DocumentFormat.OpenXml.2.16.0\lib\net46\DocumentFormat.OpenXml.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="log4net, Version=2.0.12.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\log4net.2.0.12\lib\net45\log4net.dll</HintPath>
|
||||
</Reference>
|
||||
@@ -97,6 +100,7 @@
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="WindowsBase" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="CommonProperty.cs" />
|
||||
@@ -136,6 +140,7 @@
|
||||
<Compile Include="Manager\BuyLogicManager.cs" />
|
||||
<Compile Include="Manager\DataSettingManager.cs" />
|
||||
<Compile Include="Manager\OrderbookManager.cs" />
|
||||
<Compile Include="Manager\ExportManager.cs" />
|
||||
<Compile Include="Manager\ResultLogicManager.cs" />
|
||||
<Compile Include="Manager\SellLogicManager.cs" />
|
||||
<Compile Include="Manager\ValidationCheckManager.cs" />
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="DocumentFormat.OpenXml" version="2.16.0" targetFramework="net48" />
|
||||
<package id="log4net" version="2.0.12" targetFramework="net48" />
|
||||
<package id="Microsoft.IdentityModel.JsonWebTokens" version="6.12.0" targetFramework="net48" />
|
||||
<package id="Microsoft.IdentityModel.Logging" version="6.12.0" targetFramework="net48" />
|
||||
|
||||
BIN
packages/DocumentFormat.OpenXml.2.16.0/.signature.p7s
vendored
Normal file
BIN
packages/DocumentFormat.OpenXml.2.16.0/.signature.p7s
vendored
Normal file
Binary file not shown.
BIN
packages/DocumentFormat.OpenXml.2.16.0/DocumentFormat.OpenXml.2.16.0.nupkg
vendored
Normal file
BIN
packages/DocumentFormat.OpenXml.2.16.0/DocumentFormat.OpenXml.2.16.0.nupkg
vendored
Normal file
Binary file not shown.
BIN
packages/DocumentFormat.OpenXml.2.16.0/icon.png
vendored
Normal file
BIN
packages/DocumentFormat.OpenXml.2.16.0/icon.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.1 KiB |
BIN
packages/DocumentFormat.OpenXml.2.16.0/lib/net35/DocumentFormat.OpenXml.dll
vendored
Normal file
BIN
packages/DocumentFormat.OpenXml.2.16.0/lib/net35/DocumentFormat.OpenXml.dll
vendored
Normal file
Binary file not shown.
260734
packages/DocumentFormat.OpenXml.2.16.0/lib/net35/DocumentFormat.OpenXml.xml
vendored
Normal file
260734
packages/DocumentFormat.OpenXml.2.16.0/lib/net35/DocumentFormat.OpenXml.xml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
BIN
packages/DocumentFormat.OpenXml.2.16.0/lib/net40/DocumentFormat.OpenXml.dll
vendored
Normal file
BIN
packages/DocumentFormat.OpenXml.2.16.0/lib/net40/DocumentFormat.OpenXml.dll
vendored
Normal file
Binary file not shown.
260728
packages/DocumentFormat.OpenXml.2.16.0/lib/net40/DocumentFormat.OpenXml.xml
vendored
Normal file
260728
packages/DocumentFormat.OpenXml.2.16.0/lib/net40/DocumentFormat.OpenXml.xml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
BIN
packages/DocumentFormat.OpenXml.2.16.0/lib/net46/DocumentFormat.OpenXml.dll
vendored
Normal file
BIN
packages/DocumentFormat.OpenXml.2.16.0/lib/net46/DocumentFormat.OpenXml.dll
vendored
Normal file
Binary file not shown.
260722
packages/DocumentFormat.OpenXml.2.16.0/lib/net46/DocumentFormat.OpenXml.xml
vendored
Normal file
260722
packages/DocumentFormat.OpenXml.2.16.0/lib/net46/DocumentFormat.OpenXml.xml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
BIN
packages/DocumentFormat.OpenXml.2.16.0/lib/netstandard1.3/DocumentFormat.OpenXml.dll
vendored
Normal file
BIN
packages/DocumentFormat.OpenXml.2.16.0/lib/netstandard1.3/DocumentFormat.OpenXml.dll
vendored
Normal file
Binary file not shown.
260680
packages/DocumentFormat.OpenXml.2.16.0/lib/netstandard1.3/DocumentFormat.OpenXml.xml
vendored
Normal file
260680
packages/DocumentFormat.OpenXml.2.16.0/lib/netstandard1.3/DocumentFormat.OpenXml.xml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
BIN
packages/DocumentFormat.OpenXml.2.16.0/lib/netstandard2.0/DocumentFormat.OpenXml.dll
vendored
Normal file
BIN
packages/DocumentFormat.OpenXml.2.16.0/lib/netstandard2.0/DocumentFormat.OpenXml.dll
vendored
Normal file
Binary file not shown.
260722
packages/DocumentFormat.OpenXml.2.16.0/lib/netstandard2.0/DocumentFormat.OpenXml.xml
vendored
Normal file
260722
packages/DocumentFormat.OpenXml.2.16.0/lib/netstandard2.0/DocumentFormat.OpenXml.xml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user