Merge branch 'develop' of git.mjjo53.us.to:mjjo/upper-limit-crawler into develop
This commit is contained in:
@@ -225,18 +225,21 @@ namespace upper_limit_crawler
|
||||
if (iCurPrice <= OwnItem.m_iUnitBEP * (1.0f - m_DataMgr.m_Setting.m_fLossCut))
|
||||
{
|
||||
m_DataMgr.GetTrader().SellCurPrice(OwnItem.m_strCode, OwnItem.m_iPayBalance);
|
||||
m_OwnList.Remove(OwnItem);
|
||||
m_OwnList.Remove(OwnItem);
|
||||
m_DataMgr.RemoveWatch(strCode);
|
||||
m_DataMgr.AddLosscutItem(strCode);
|
||||
|
||||
ULUtil.Trace("[{0}] 손절 {1}원 ({2}) {3}", OwnItem.m_strCodeName, iCurPrice, (iCurPrice/(float)OwnItem.m_iUnitBEP-1.0f).ToString("0.00%"), WatchItem.m_iHighestPrice);
|
||||
ULUtil.TraceCSV("손절", OwnItem.m_strCodeName, iCurPrice, (iCurPrice / (float)OwnItem.m_iUnitBEP - 1.0f).ToString("0.00%"), WatchItem.m_iHighestPrice);
|
||||
|
||||
int iProfit = iCurPrice-(int)OwnItem.m_iUnitBEP;
|
||||
float fProfitRate = iCurPrice/(float)OwnItem.m_iUnitBEP-1.0f;
|
||||
|
||||
// own에서 삭제하고 미체결 리스트에 넣고, watch에서도 뺀다
|
||||
ULUtil.Trace("[{0}] 손절 {1}원 ({2}) {3}", OwnItem.m_strCodeName, iCurPrice, fProfitRate.ToString("0.00%"), WatchItem.m_iHighestPrice);
|
||||
ULUtil.TraceCSV("손절", OwnItem.m_strCodeName, iCurPrice, fProfitRate.ToString("0.00%"), WatchItem.m_iHighestPrice);
|
||||
m_DataMgr.AddAskLog(strCode, WatchItem.m_strCodeName, iTime, iCurPrice, float.NaN, true, iProfit, fProfitRate);
|
||||
|
||||
// 미체결 잔량 취소
|
||||
}
|
||||
// own에서 삭제하고 미체결 리스트에 넣고, watch에서도 뺀다
|
||||
|
||||
// 미체결 잔량 취소
|
||||
}
|
||||
// trailing
|
||||
else if (iCurPrice <= OwnItem.m_iMaxPrice - OwnItem.m_iUnitBEP * m_DataMgr.m_Setting.m_fTrailing)
|
||||
{
|
||||
@@ -251,15 +254,19 @@ namespace upper_limit_crawler
|
||||
m_OwnList.Remove(OwnItem);
|
||||
m_DataMgr.RemoveWatch(strCode);
|
||||
|
||||
ULUtil.Trace("[{0}] 트레일링 매도 {1}원 ({2}:{3}) (5MA slop:{4}) {5}",
|
||||
int iProfit = iCurPrice-(int)OwnItem.m_iUnitBEP;
|
||||
float fProfitRate = iCurPrice/(float)OwnItem.m_iUnitBEP-1.0f;
|
||||
|
||||
ULUtil.Trace("[{0}] 트레일링 매도 {1}원 ({2}:{3}) (5MA slop:{4}) {5}",
|
||||
OwnItem.m_strCodeName,
|
||||
iCurPrice,
|
||||
iCurPrice - OwnItem.m_iUnitBEP,
|
||||
(iCurPrice/(float)OwnItem.m_iUnitBEP-1.0f).ToString("0.00%"),
|
||||
f5MASlope.ToString("0.00%"),
|
||||
WatchItem.m_iHighestPrice);
|
||||
ULUtil.TraceCSV("트레일링 매도", OwnItem.m_strCodeName, iCurPrice, iCurPrice - OwnItem.m_iUnitBEP, (iCurPrice / (float)OwnItem.m_iUnitBEP - 1.0f).ToString("0.00%"), 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);
|
||||
}
|
||||
}
|
||||
|
||||
// steadiness
|
||||
|
||||
36
ULDB.cs
Normal file
36
ULDB.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace upper_limit_crawler
|
||||
{
|
||||
public class ULDB
|
||||
{
|
||||
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)
|
||||
{
|
||||
m_DB.Put(m_DefaultWriteOption, strKey, Value);
|
||||
}
|
||||
|
||||
public LevelDB.Slice Get(string strKey)
|
||||
{
|
||||
LevelDB.Slice Value = m_DB.Get(m_DefaultReadOption, strKey);
|
||||
return Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
42
ULDataMgr.cs
42
ULDataMgr.cs
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@@ -34,20 +35,27 @@ namespace upper_limit_crawler
|
||||
public class ULDataMgr
|
||||
{
|
||||
public SETTING m_Setting = new SETTING();
|
||||
public ULDB m_DB = new ULDB();
|
||||
|
||||
ULTrader m_Trader = new ULTrader();
|
||||
ULTrader m_Trader = new ULTrader();
|
||||
|
||||
Dictionary<string, ULWatchItem> m_WatchList = new Dictionary<string, ULWatchItem>();
|
||||
List<POSTPONE_ITEM> m_PostponeList = new List<POSTPONE_ITEM>();
|
||||
Dictionary<string, int> m_LossCutList = new Dictionary<string, int>();
|
||||
List<string> m_BlackList = new List<string>();
|
||||
|
||||
string m_AvailableListKey;
|
||||
List<string> m_AvailableList = new List<string>();
|
||||
|
||||
long m_iCacheBalance = 0;
|
||||
long m_iEvalProfit = 0;
|
||||
|
||||
public ULDataMgr()
|
||||
{
|
||||
}
|
||||
m_AvailableListKey= "available-"+ULUtil.GetCurTime().ToString("yyyy-MM-dd");
|
||||
string strValue = m_DB.Get(m_AvailableListKey).ToString();
|
||||
m_AvailableList=strValue.Split(',').ToList();
|
||||
}
|
||||
|
||||
public void Init()
|
||||
{
|
||||
@@ -167,5 +175,33 @@ namespace upper_limit_crawler
|
||||
{
|
||||
return m_iEvalProfit;
|
||||
}
|
||||
}
|
||||
|
||||
public ULDB GetDB()
|
||||
{
|
||||
return m_DB;
|
||||
}
|
||||
|
||||
public void AddAvailableItem(string strCode)
|
||||
{
|
||||
if(m_AvailableList.Any(r => r==strCode)==false)
|
||||
{
|
||||
m_AvailableList.Add(strCode);
|
||||
m_DB.Put(m_AvailableListKey, string.Join(",", 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);
|
||||
}
|
||||
|
||||
public void AddAskLog(string strCode, string strCodeName, int iTime, int iBidPrice, 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,6 +159,8 @@ namespace upper_limit_crawler
|
||||
|
||||
if (fCompRate >= m_DataMgr.m_Setting.m_fBidMin && fCompRate <= m_DataMgr.m_Setting.m_fBidMax)
|
||||
{
|
||||
m_DataMgr.AddAvailableItem(strCode);
|
||||
|
||||
int iTime = ULUtil.GetCurTimeInt();
|
||||
if (m_DataMgr.IsInPostponeList(iTime, strCode) == true)
|
||||
{
|
||||
@@ -171,7 +173,7 @@ namespace upper_limit_crawler
|
||||
}
|
||||
|
||||
float f5MASlope = item.GetPrev5MASlope(iTime);
|
||||
if(float.IsNaN(f5MASlope) || f5MASlope < 0.002f)
|
||||
if(float.IsNaN(f5MASlope) == false && f5MASlope < 0.002f)
|
||||
{
|
||||
//ULUtil.Trace("[{0}] 조건 매수 실패. 5ma 상승하지 않음 {1}원 ({2})", item.m_strCodeName, item.m_iCurPrice, fCompRate.ToString("0.00%"));
|
||||
continue;
|
||||
@@ -179,8 +181,8 @@ namespace upper_limit_crawler
|
||||
|
||||
// bid and add to black list
|
||||
m_DataMgr.GetTrader().Buy(strCode, item.m_iCurPrice, (int)m_DataMgr.m_Setting.m_fBidAmount);
|
||||
m_DataMgr.AddPostphoneItem(iTime, strCode);
|
||||
|
||||
m_DataMgr.AddBidLog(strCode, item.m_strCodeName, iTime, item.m_iCurPrice, f5MASlope);
|
||||
m_DataMgr.AddPostphoneItem(iTime, strCode);
|
||||
|
||||
ULUtil.Trace("[{0}] 조건 매수 {1}원 ({2}) (5MA slop:{3})",
|
||||
item.m_strCodeName,
|
||||
|
||||
4
packages.config
Normal file
4
packages.config
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="LevelDB.Net" version="1.2.1" targetFramework="net45" />
|
||||
</packages>
|
||||
BIN
packages/LevelDB.Net.1.2.1/LevelDB.Net.1.2.1.nupkg
vendored
Normal file
BIN
packages/LevelDB.Net.1.2.1/LevelDB.Net.1.2.1.nupkg
vendored
Normal file
Binary file not shown.
BIN
packages/LevelDB.Net.1.2.1/lib/net40/LevelDB.Net.dll
vendored
Normal file
BIN
packages/LevelDB.Net.1.2.1/lib/net40/LevelDB.Net.dll
vendored
Normal file
Binary file not shown.
@@ -12,25 +12,6 @@
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<SignManifests>false</SignManifests>
|
||||
</PropertyGroup>
|
||||
@@ -43,7 +24,30 @@
|
||||
<PropertyGroup>
|
||||
<ApplicationManifest>Properties\app.manifest</ApplicationManifest>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x64\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<OutputPath>bin\x64\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x64</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>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
@@ -56,6 +60,7 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ULDB.cs" />
|
||||
<Compile Include="ULWatchItem.cs" />
|
||||
<Compile Include="ULBalanceDlg.cs">
|
||||
<SubType>Form</SubType>
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2013
|
||||
VisualStudioVersion = 12.0.30723.0
|
||||
# Visual Studio 14
|
||||
VisualStudioVersion = 14.0.25123.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "upper-limit-crawler", "upper-limit-crawler.csproj", "{591FA710-356A-498A-8133-7E9E60AB4E40}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
Debug|x64 = Debug|x64
|
||||
Release|x64 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{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
|
||||
{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
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
Reference in New Issue
Block a user