├── .gitattributes
├── .gitignore
├── DemoStrategy
├── DemoStrategy.csproj
├── DemoStrategyActor.cs
├── Properties
│ └── AssemblyInfo.cs
├── app.config
└── packages.config
├── LICENSE
├── Quanter.Akka.sln
├── Quanter.BusinessEntity
├── ECube.cs
├── ECube.hbm.xml
├── EStockHolder.cs
├── EStockHolder.hbm.xml
├── EStrategy.cs
├── EStrategy.hbm.xml
├── ETrader.cs
├── ETrader.hbm.xml
├── EntrustRecord.hbm.xml
├── Properties
│ └── AssemblyInfo.cs
├── Quanter.BusinessEntity.csproj
├── StockHolder.hbm.xml
├── SubTradingAccount.hbm.xml
├── TransactionRecord.hbm.xml
├── hibernate.cfg.xml
├── packages.config
└── stock.db3
├── Quanter.Common
├── BarData.cs
├── BidCacheQueue.cs
├── DllUtils.cs
├── HttpClient.cs
├── Properties
│ └── AssemblyInfo.cs
├── Quanter.Common.csproj
├── QuoteData.cs
├── Securities.cs
├── SecuritiesTypes.cs
├── StockUtil.cs
├── TickData.cs
├── TraderResult.cs
└── packages.config
├── Quanter.Domain
├── Properties
│ └── AssemblyInfo.cs
├── Quanter.Domain.csproj
├── StrategyDesc.cs
├── User.cs
└── config
│ ├── StockHolder.hbm.xml
│ ├── StrategyDesc.hbm.xml
│ ├── SubTradingAccount.hbm.xml
│ ├── TransactionRecord.hbm.xml
│ ├── XueQiuCube.hbm.xml
│ └── hibernate.cfg.xml
├── Quanter.Market.Sina
├── LastClosePriceData.cs
├── Properties
│ └── AssemblyInfo.cs
├── Quanter.Market.Sina.csproj
├── SinaQuotationActor.cs
├── app.config
├── job_scheduling_data_2_0.xsd
├── jobs
│ ├── FetchSinaQuoteDataJob.cs
│ ├── ReadLastClosePriceJob.cs
│ └── WriteLastClosePriceJob.cs
└── packages.config
├── Quanter.Persistence
├── App.config
├── PersistenceActor.cs
├── Properties
│ └── AssemblyInfo.cs
├── Quanter.Persistence.Server.csproj
└── packages.config
├── Quanter.Strategy
├── Class1.cs
├── Properties
│ └── AssemblyInfo.cs
└── Quanter.Strategy.csproj
├── Quanter.Trader.Connector
├── BaseStockTrader.cs
├── Enums.cs
├── IStockTrader.cs
├── ITrader.cs
├── Properties
│ └── AssemblyInfo.cs
├── Quanter.Trader.Connector.csproj
├── Structs.cs
├── TradeManagerActor.cs
├── TraderResult.cs
├── Win32API.cs
├── Win32Code.cs
└── packages.config
├── Quanter.Trader.Gui
├── App.config
├── CHANGES.txt
├── MainForm.Designer.cs
├── MainForm.cs
├── MainForm.resx
├── Program.cs
├── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ ├── Settings.Designer.cs
│ └── Settings.settings
├── Quanter.Trader.Gui.csproj
├── licenses
│ ├── license.txt
│ └── protoc-license.txt
├── packages.config
└── protos
│ ├── google
│ └── protobuf
│ │ ├── csharp_options.proto
│ │ └── descriptor.proto
│ └── tutorial
│ └── addressbook.proto
├── Quanter.Trader.Indicator
├── IComplexIndicator.cs
├── IIndicator.cs
├── IIndicatorValue.cs
├── IIndicatorValueList.cs
├── Properties
│ └── AssemblyInfo.cs
└── Quanter.Trader.Indicator.csproj
├── Quanter.Trader.MarketServer
├── BaseQuotationActor.cs
├── CHANGES.txt
├── MarketReceiverConfigurationSection.cs
├── Properties
│ └── AssemblyInfo.cs
├── Quanter.MarketServer.csproj
├── SecuritiesMarketManagerActor.cs
├── SecuritiesQuotationActor.cs
├── licenses
│ ├── license.txt
│ └── protoc-license.txt
├── packages.config
├── protos
│ ├── google
│ │ └── protobuf
│ │ │ ├── csharp_options.proto
│ │ │ └── descriptor.proto
│ └── tutorial
│ │ └── addressbook.proto
├── stock_list - 复制.csv
├── stock_list.csv
└── stocklist.csv
├── Quanter.Trader.Messages
├── CHANGES.txt
├── ClientMessages.cs
├── Constants.cs
├── ErrorMessages.cs
├── MarketMessages.cs
├── PersistenceMessages.cs
├── Properties
│ └── AssemblyInfo.cs
├── Quanter.Trader.Messages.csproj
├── SecuritiesQuotationMessages.cs
├── StrategyMessages.cs
├── TradeMessages.cs
├── UserMessages.cs
├── app.manifest
├── licenses
│ ├── license.txt
│ └── protoc-license.txt
├── packages.config
└── protos
│ ├── google
│ └── protobuf
│ │ ├── csharp_options.proto
│ │ └── descriptor.proto
│ └── tutorial
│ └── addressbook.proto
├── Quanter.Trader.StrategyServer
├── BaseStrategyActor.cs
├── CHANGES.txt
├── IAccount.cs
├── IStrategy.cs
├── Properties
│ └── AssemblyInfo.cs
├── Quanter.StrategyServer.csproj
├── Risk
│ ├── IRiskRule.cs
│ ├── RiskActions.cs
│ ├── RiskManager.cs
│ └── RiskRules.cs
├── StrategyActor.cs
├── StrategyManagerActor.cs
├── TradeMode.cs
├── app.config
├── licenses
│ ├── license.txt
│ └── protoc-license.txt
├── packages.config
└── protos
│ ├── google
│ └── protobuf
│ │ ├── csharp_options.proto
│ │ └── descriptor.proto
│ └── tutorial
│ └── addressbook.proto
├── README.md
└── Tests.Quanter.Persistence
├── App.config
├── PersistenceActorSpec.cs
├── Properties
└── AssemblyInfo.cs
├── Tests.Quanter.Persistence.csproj
└── packages.config
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.userosscache
8 | *.sln.docstates
9 |
10 | # User-specific files (MonoDevelop/Xamarin Studio)
11 | *.userprefs
12 |
13 | # Build results
14 | [Dd]ebug/
15 | [Dd]ebugPublic/
16 | [Rr]elease/
17 | [Rr]eleases/
18 | x64/
19 | x86/
20 | build/
21 | bld/
22 | [Bb]in/
23 | [Oo]bj/
24 |
25 | # Visual Studio 2015 cache/options directory
26 | .vs/
27 |
28 | # MSTest test Results
29 | [Tt]est[Rr]esult*/
30 | [Bb]uild[Ll]og.*
31 |
32 | # NUNIT
33 | *.VisualState.xml
34 | TestResult.xml
35 |
36 | # Build Results of an ATL Project
37 | [Dd]ebugPS/
38 | [Rr]eleasePS/
39 | dlldata.c
40 |
41 | # DNX
42 | project.lock.json
43 | artifacts/
44 |
45 | *_i.c
46 | *_p.c
47 | *_i.h
48 | *.ilk
49 | *.meta
50 | *.obj
51 | *.pch
52 | *.pdb
53 | *.pgc
54 | *.pgd
55 | *.rsp
56 | *.sbr
57 | *.tlb
58 | *.tli
59 | *.tlh
60 | *.tmp
61 | *.tmp_proj
62 | *.log
63 | *.vspscc
64 | *.vssscc
65 | .builds
66 | *.pidb
67 | *.svclog
68 | *.scc
69 |
70 | # Chutzpah Test files
71 | _Chutzpah*
72 |
73 | # Visual C++ cache files
74 | ipch/
75 | *.aps
76 | *.ncb
77 | *.opensdf
78 | *.sdf
79 | *.cachefile
80 |
81 | # Visual Studio profiler
82 | *.psess
83 | *.vsp
84 | *.vspx
85 |
86 | # TFS 2012 Local Workspace
87 | $tf/
88 |
89 | # Guidance Automation Toolkit
90 | *.gpState
91 |
92 | # ReSharper is a .NET coding add-in
93 | _ReSharper*/
94 | *.[Rr]e[Ss]harper
95 | *.DotSettings.user
96 |
97 | # JustCode is a .NET coding add-in
98 | .JustCode
99 |
100 | # TeamCity is a build add-in
101 | _TeamCity*
102 |
103 | # DotCover is a Code Coverage Tool
104 | *.dotCover
105 |
106 | # NCrunch
107 | _NCrunch_*
108 | .*crunch*.local.xml
109 |
110 | # MightyMoose
111 | *.mm.*
112 | AutoTest.Net/
113 |
114 | # Web workbench (sass)
115 | .sass-cache/
116 |
117 | # Installshield output folder
118 | [Ee]xpress/
119 |
120 | # DocProject is a documentation generator add-in
121 | DocProject/buildhelp/
122 | DocProject/Help/*.HxT
123 | DocProject/Help/*.HxC
124 | DocProject/Help/*.hhc
125 | DocProject/Help/*.hhk
126 | DocProject/Help/*.hhp
127 | DocProject/Help/Html2
128 | DocProject/Help/html
129 |
130 | # Click-Once directory
131 | publish/
132 |
133 | # Publish Web Output
134 | *.[Pp]ublish.xml
135 | *.azurePubxml
136 | ## TODO: Comment the next line if you want to checkin your
137 | ## web deploy settings but do note that will include unencrypted
138 | ## passwords
139 | #*.pubxml
140 |
141 | *.publishproj
142 |
143 | # NuGet Packages
144 | *.nupkg
145 | # The packages folder can be ignored because of Package Restore
146 | **/packages/*
147 | # except build/, which is used as an MSBuild target.
148 | !**/packages/build/
149 | # Uncomment if necessary however generally it will be regenerated when needed
150 | #!**/packages/repositories.config
151 |
152 | # Windows Azure Build Output
153 | csx/
154 | *.build.csdef
155 |
156 | # Windows Store app package directory
157 | AppPackages/
158 |
159 | # Visual Studio cache files
160 | # files ending in .cache can be ignored
161 | *.[Cc]ache
162 | # but keep track of directories ending in .cache
163 | !*.[Cc]ache/
164 |
165 | # Others
166 | ClientBin/
167 | [Ss]tyle[Cc]op.*
168 | ~$*
169 | *~
170 | *.dbmdl
171 | *.dbproj.schemaview
172 | *.pfx
173 | *.publishsettings
174 | node_modules/
175 | orleans.codegen.cs
176 |
177 | # RIA/Silverlight projects
178 | Generated_Code/
179 |
180 | # Backup & report files from converting an old project file
181 | # to a newer Visual Studio version. Backup files are not needed,
182 | # because we have git ;-)
183 | _UpgradeReport_Files/
184 | Backup*/
185 | UpgradeLog*.XML
186 | UpgradeLog*.htm
187 |
188 | # SQL Server files
189 | *.mdf
190 | *.ldf
191 |
192 | # Business Intelligence projects
193 | *.rdl.data
194 | *.bim.layout
195 | *.bim_*.settings
196 |
197 | # Microsoft Fakes
198 | FakesAssemblies/
199 |
200 | # Node.js Tools for Visual Studio
201 | .ntvs_analysis.dat
202 |
203 | # Visual Studio 6 build log
204 | *.plg
205 |
206 | # Visual Studio 6 workspace options file
207 | *.opt
208 |
209 | # LightSwitch generated files
210 | GeneratedArtifacts/
211 | _Pvt_Extensions/
212 | ModelManifest.xml
213 |
--------------------------------------------------------------------------------
/DemoStrategy/DemoStrategy.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {9A3793DB-03DE-4C99-9525-C7C7BEE9CB93}
8 | Library
9 | Properties
10 | Quanter.Strategy
11 | Quanter.Strategy.Demo
12 | v4.5.2
13 | 512
14 |
15 |
16 | true
17 | full
18 | false
19 | bin\Debug\
20 | DEBUG;TRACE
21 | prompt
22 | 4
23 |
24 |
25 | pdbonly
26 | true
27 | bin\Release\
28 | TRACE
29 | prompt
30 | 4
31 |
32 |
33 |
34 | ..\..\quanter.private\packages\Akka.1.0.6\lib\net45\Akka.dll
35 | True
36 |
37 |
38 | ..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll
39 | True
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 | {34db14a6-e4ed-4c4a-8ca6-939201a572be}
57 | Quanter.BusinessEntity
58 |
59 |
60 | {a3fa3c71-a7b0-4bb6-bd32-0aee20493593}
61 | Quanter.Common
62 |
63 |
64 | {dde08214-ec3a-4dd7-8cee-49973e17ae8f}
65 | Quanter.Trader.Messages
66 |
67 |
68 | {f0e12b5e-7012-4345-b4a4-be4cedce5e91}
69 | Quanter.StrategyServer
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
84 |
--------------------------------------------------------------------------------
/DemoStrategy/DemoStrategyActor.cs:
--------------------------------------------------------------------------------
1 | using Akka.Actor;
2 | using Akka.Event;
3 | using Quanter.BusinessEntity;
4 | using Quanter.Common;
5 | using Quanter.Trader.Messages;
6 | using System;
7 |
8 | namespace Quanter.Strategy.Demo
9 | {
10 | public class DemoStrategyActor : BaseStrategyActor
11 | {
12 | private readonly ILoggingAdapter _log = Logging.GetLogger(Context);
13 |
14 | public DemoStrategyActor(EStrategy strategy) : base(strategy)
15 | {
16 | _log.Debug("创建编码为 {0} StrategyActor实例", strategy.Id);
17 | }
18 |
19 | protected override void onInit()
20 | {
21 | _log.Debug("初始化编号为{0}Strategy", Desc.Id);
22 | AddSecurities(new Securities(SecuritiesTypes.Stock, MarketType.XSHE, "000002"));
23 | AddSecurities(new Securities(SecuritiesTypes.Stock, MarketType.XSHG, "603998"));
24 | }
25 |
26 |
27 | protected override void onQuoteData(QuoteData data)
28 | {
29 | _log.Debug("Demo策略处理{0}报价数据", data.Symbol);
30 | this.buySecurities(new Securities( SecuritiesTypes.Stock, data.Symbol), data.SellPrice1, 100);
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/DemoStrategy/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的一般信息由以下
6 | // 控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("DemoStrategy")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("DemoStrategy")]
13 | [assembly: AssemblyCopyright("Copyright © 2015")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | //将 ComVisible 设置为 false 将使此程序集中的类型
18 | //对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
19 | //请将此类型的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("9a3793db-03de-4c99-9525-c7c7bee9cb93")]
24 |
25 | // 程序集的版本信息由下列四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 生成号
30 | // 修订号
31 | //
32 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
33 | // 方法是按如下所示使用“*”: :
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/DemoStrategy/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/DemoStrategy/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/Quanter.BusinessEntity/ECube.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Quanter.BusinessEntity
8 | {
9 | public class ECube
10 | {
11 | public virtual int Id { get; set; }
12 | public virtual EStrategy Strategy { get; set; } // 策略
13 | public virtual String Symbol { get; set; } // 组合代码
14 | public virtual long PreAdjustmentId { get; set; } //调整ID
15 |
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Quanter.BusinessEntity/ECube.hbm.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/Quanter.BusinessEntity/EStockHolder.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Quanter.BusinessEntity
8 | {
9 | public class EStockHolder
10 | {
11 | public virtual int Id { get; set; }
12 | public virtual EStrategy Strategy { get; set; }
13 | public virtual String Symbol { get; set; }
14 | public virtual String Code { get; set; }
15 | public virtual String Name { get; set; }
16 | public virtual float MarketValue { get { return LastPrice * CurrentAmount; } }
17 | public virtual float CostPrice { get; set; }
18 | public virtual int CurrentAmount { get { return EnableAmount + IncomeAmount; } }
19 | public virtual int EnableAmount { get; set; }
20 | public virtual int IncomeAmount { get; set; } // 冻结
21 | public virtual float LastPrice { get; set; }
22 |
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/Quanter.BusinessEntity/EStockHolder.hbm.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/Quanter.BusinessEntity/EStrategy.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Quanter.BusinessEntity
8 | {
9 | public class EStrategy
10 | {
11 | public virtual int Id { get; set; }
12 | public virtual String Name { get; set; }
13 | public virtual String Desc { get; set; }
14 | public virtual String Type { get; set; }
15 |
16 | public virtual ETrader Trader { get; set; }
17 |
18 | public virtual bool Enabled { get; set; }
19 | // public virtual float CurrentBalance { get; set; } // 资金余额
20 | // public virtual float FetchBalance { get; set; } // 可取金额
21 | public virtual float EnableBalance { get; set; } // 可用金额
22 | public virtual float FrozenBalance { get; set; } // 冻结金额
23 | public virtual float MarketValue
24 | {
25 | get {
26 | float mv = 0;
27 | foreach(var share in holders)
28 | {
29 | mv += share.MarketValue;
30 | }
31 | return mv;
32 | }
33 | } // 股票市值
34 | public virtual float AssetBalance { get { return EnableBalance + MarketValue; } } // 总资产
35 |
36 | public virtual DateTime Date { get; set; }
37 |
38 | private IList holders = new List();
39 |
40 | public virtual IList Holders
41 | {
42 | get { return this.holders; }
43 | set { this.holders = value; }
44 | }
45 |
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/Quanter.BusinessEntity/EStrategy.hbm.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/Quanter.BusinessEntity/ETrader.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Quanter.BusinessEntity
8 | {
9 | public class ETrader
10 | {
11 | public virtual int Id { get; set; }
12 |
13 | public virtual String Name { get; set; }
14 |
15 | public virtual String Desc { get; set; }
16 |
17 | public virtual String Username { get; set; }
18 | public virtual String Password { get; set; }
19 | public virtual String ServicePwd { get; set; }
20 |
21 | public virtual String Path { get; set; }
22 |
23 | public virtual String Type { get; set; }
24 | public virtual DateTime Date { get; set; }
25 |
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/Quanter.BusinessEntity/ETrader.hbm.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/Quanter.BusinessEntity/EntrustRecord.hbm.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Quanter.BusinessEntity/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的一般信息由以下
6 | // 控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("Stock.BusinessEntity")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Stock.BusinessEntity")]
13 | [assembly: AssemblyCopyright("Copyright © 2015")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | //将 ComVisible 设置为 false 将使此程序集中的类型
18 | //对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
19 | //请将此类型的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("34db14a6-e4ed-4c4a-8ca6-939201a572be")]
24 |
25 | // 程序集的版本信息由下列四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 生成号
30 | // 修订号
31 | //
32 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
33 | // 方法是按如下所示使用“*”: :
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/Quanter.BusinessEntity/Quanter.BusinessEntity.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {34DB14A6-E4ED-4C4A-8CA6-939201A572BE}
8 | Library
9 | Properties
10 | Quanter.BusinessEntity
11 | Quanter.BusinessEntity
12 | v4.5.2
13 | 512
14 |
15 |
16 | true
17 | full
18 | false
19 | bin\Debug\
20 | DEBUG;TRACE
21 | prompt
22 | 4
23 |
24 |
25 | pdbonly
26 | true
27 | bin\Release\
28 | TRACE
29 | prompt
30 | 4
31 |
32 |
33 |
34 | ..\packages\Iesi.Collections.4.0.0.4000\lib\net40\Iesi.Collections.dll
35 | True
36 |
37 |
38 | ..\packages\NHibernate.4.0.4.4000\lib\net40\NHibernate.dll
39 | True
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 | Always
61 |
62 |
63 |
64 |
65 | Designer
66 |
67 |
68 | Always
69 |
70 |
71 | Always
72 |
73 |
74 | Always
75 |
76 |
77 | Always
78 |
79 |
80 |
81 | Always
82 |
83 |
84 |
85 |
86 |
87 |
94 |
--------------------------------------------------------------------------------
/Quanter.BusinessEntity/StockHolder.hbm.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/Quanter.BusinessEntity/SubTradingAccount.hbm.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/Quanter.BusinessEntity/TransactionRecord.hbm.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Quanter.BusinessEntity/hibernate.cfg.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 | NHibernate.Connection.DriverConnectionProvider
10 | NHibernate.Driver.SQLite20Driver
11 | Data Source=stock.db3;Version=3;
12 | NHibernate.Dialect.SQLiteDialect
13 | true=1;false=0
14 | true
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/Quanter.BusinessEntity/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/Quanter.BusinessEntity/stock.db3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/superquanter/quanter/2291bbc24ad352d54aa2deb114e9897963576a7c/Quanter.BusinessEntity/stock.db3
--------------------------------------------------------------------------------
/Quanter.Common/BarData.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Quanter.Common
8 | {
9 | public class BarData
10 | {
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/Quanter.Common/BidCacheQueue.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Quanter.Common
8 | {
9 | ///
10 | /// 股票价格队列, 当价格发生变动时,发送给观察者
11 | ///
12 | public class BidCacheQueue
13 | {
14 | ///
15 | /// 定义一个委托类型
16 | ///
17 | ///
18 | ///
19 | public delegate void BidChangeHandler(object sender, TickData bid);
20 |
21 | /// 定义一个事件
22 | public event BidChangeHandler OnBidChange;
23 |
24 | private TickData lastData;
25 | private Queue queue = new Queue();
26 |
27 | private String code = null;
28 | // private String name = null;
29 |
30 | public BidCacheQueue(String code)
31 | {
32 | this.code = code;
33 | }
34 |
35 | public String Code { get { return code; } }
36 | // public String Name {get {return name;}}
37 |
38 | public TickData LastData
39 | {
40 | get
41 | {
42 | if (lastData == null)
43 | lastData = new TickData();
44 | return lastData;
45 | }
46 | }
47 |
48 | List bids = new List();
49 | public List BidList
50 | {
51 | get { return this.bids; }
52 | }
53 |
54 | public void Enqueue(TickData obj)
55 | {
56 | bids.Insert(0, obj);
57 | queue.Enqueue(obj);
58 | lastData = obj;
59 | if (OnBidChange != null)
60 | {
61 | OnBidChange(this, obj);
62 | }
63 | }
64 |
65 | public TickData Dequeue()
66 | {
67 | return queue.Dequeue();
68 | }
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/Quanter.Common/DllUtils.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Reflection;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace Quanter.Common
9 | {
10 | public class DllUtils
11 | {
12 | public static T CreateInstance(string dllPath, String className)
13 | {
14 | Assembly ass = Assembly.LoadFrom(dllPath);
15 |
16 | Type type = ass.GetType(className);
17 | try
18 | {
19 | object obj = Activator.CreateInstance(type);
20 | return (T)obj;
21 | }
22 | catch (Exception e)
23 | {
24 | return default(T);
25 | }
26 |
27 | }
28 |
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/Quanter.Common/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的一般信息由以下
6 | // 控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("Stock.Common")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Stock.Common")]
13 | [assembly: AssemblyCopyright("Copyright © 2015")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | //将 ComVisible 设置为 false 将使此程序集中的类型
18 | //对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
19 | //请将此类型的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("a3fa3c71-a7b0-4bb6-bd32-0aee20493593")]
24 |
25 | // 程序集的版本信息由下列四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 生成号
30 | // 修订号
31 | //
32 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
33 | // 方法是按如下所示使用“*”: :
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/Quanter.Common/QuoteData.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Quanter.Common
8 | {
9 | public class QuoteData
10 | {
11 | //public class GoodsData : ICloneable
12 | //{
13 | // public float Price { get; set; }
14 | // public int OrderAmount { get; set; }
15 |
16 | // public GoodsData(float price, int amount)
17 | // {
18 | // Price = price;
19 | // OrderAmount = amount;
20 | // }
21 |
22 | // public GoodsData DeepClone()
23 | // {
24 | // return (GoodsData)Clone();
25 | // }
26 | // public object Clone()
27 | // {
28 | // GoodsData data = new GoodsData(Price, OrderAmount);
29 |
30 | // return data;
31 | // }
32 | //}
33 |
34 | public String Symbol { get; set; } // 证券代码 国际标准
35 | public String Alias { get; set; } // 证券代码
36 | public string Name { get; set; } // 名称
37 |
38 | public float LastClose { get; set; }
39 | public float Open { get; set; }
40 | public float High { get; set; }
41 | public float Low { get; set; }
42 |
43 | public float CurrentPrice { get; set; } // 成交价
44 | public long Volume { get; set; } // 成交量
45 | public float Turnover { get; set; } // 成交金额
46 | public String PushTime { get; set; } // 推送时间
47 |
48 | //private ICollection buyList = new List();
49 | //private ICollection sellList = new List();
50 |
51 | //public GoodsData[] BuyList
52 | //{
53 | // get
54 | // {
55 | // if (buyList.Count == 0) return new GoodsData[5] { new GoodsData(0, 0), new GoodsData(0, 0), new GoodsData(0, 0), new GoodsData(0, 0), new GoodsData(0, 0) };
56 | // return this.buyList.ToArray();
57 | // }
58 | //}
59 |
60 | //public GoodsData[] SellList
61 | //{
62 | // get
63 | // {
64 | // if (sellList.Count == 0) return new GoodsData[5] { new GoodsData(0, 0), new GoodsData(0, 0), new GoodsData(0, 0), new GoodsData(0, 0), new GoodsData(0, 0) };
65 |
66 | // return this.sellList.ToArray();
67 | // }
68 | //}
69 |
70 | #region 买卖5档
71 | public long SellVolume { get; set; }
72 | public long BuyVolume { get; set; }
73 | public float SellPrice1 { get; set; }
74 | public long SellVolume1 { get; set; }
75 | public float SellPrice2 { get; set; }
76 | public long SellVolume2 { get; set; }
77 | public float SellPrice3 { get; set; }
78 | public long SellVolume3 { get; set; }
79 | public float SellPrice4 { get; set; }
80 | public long SellVolume4 { get; set; }
81 | public float SellPrice5 { get; set; }
82 | public long SellVolume5 { get; set; }
83 | public float BuyPrice1 { get; set; }
84 | public long BuyVolume1 { get; set; }
85 | public float BuyPrice2 { get; set; }
86 | public long BuyVolume2 { get; set; }
87 | public float BuyPrice3 { get; set; }
88 | public long BuyVolume3 { get; set; }
89 | public float BuyPrice4 { get; set; }
90 | public long BuyVolume4 { get; set; }
91 | public float BuyPrice5 { get; set; }
92 | public long BuyVolume5 { get; set; }
93 | #endregion
94 |
95 | public float PE { get; set; }
96 | public float Amplitude { get; set; }
97 | public float HighLimit { get; set; }
98 | public float LowLimit { get; set; }
99 |
100 | //public void AddBuyGoodsData(GoodsData data)
101 | //{
102 | // this.buyList.Add(data);
103 | //}
104 |
105 | //public void AddSellGoodsData(GoodsData data)
106 | //{
107 | // this.sellList.Add(data);
108 | //}
109 |
110 | //public TickData DeepClone()
111 | //{
112 | // return (TickData)Clone();
113 | //}
114 | //public object Clone()
115 | //{
116 | // QuoteData bid = new QuoteData();
117 | // bid.Symbol = Symbol;
118 | // bid.High = High;
119 | // bid.Low = Low;
120 | // bid.Open = Open;
121 | // bid.LastClose = LastClose;
122 |
123 | // bid.CurrentPrice = CurrentPrice;
124 | // bid.Turnover = Turnover;
125 | // bid.Volumn = Volumn;
126 | // bid.PushTime = PushTime;
127 |
128 | // bid.buyList = new List();
129 | // buyList.AsParallel().ForAll(d =>
130 | // {
131 | // bid.buyList.Add(d.DeepClone());
132 | // });
133 |
134 | // bid.sellList = new List();
135 | // sellList.AsParallel().ForAll(d =>
136 | // {
137 | // bid.sellList.Add(d.DeepClone());
138 | // });
139 |
140 | // return bid;
141 | //}
142 | }
143 | }
144 |
--------------------------------------------------------------------------------
/Quanter.Common/Securities.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Runtime.Serialization;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace Quanter.Common
9 | {
10 | [Serializable]
11 | public class Securities : ISerializable
12 | {
13 | public SecuritiesTypes Type { get; private set; }
14 | public MarketType MarketType { get; private set; }
15 |
16 | public String Symbol { get; private set; }
17 |
18 | public String Name { get; set; }
19 | public String Alias {
20 | get
21 | {
22 | String alias = string.Empty;
23 | switch(MarketType)
24 | {
25 | case MarketType.XSHG:
26 | alias = "sh" + Symbol.Substring(0,6);
27 | break;
28 | case MarketType.XSHE:
29 | alias = "sz" + Symbol.Substring(0, 6);
30 | break;
31 | default:
32 | break;
33 | }
34 |
35 | return alias;
36 | }
37 | }
38 |
39 | public Securities(SecuritiesTypes secType, MarketType marketType, String code)
40 | {
41 | this.Type = secType;
42 | this.MarketType = marketType;
43 | this.Symbol = code + "." + marketType.ToString();
44 | }
45 |
46 | public Securities(SecuritiesTypes secType, String symbol)
47 | {
48 | this.Type = secType;
49 | this.Symbol = symbol;
50 | int index = symbol.IndexOf(".");
51 | this.MarketType = (MarketType)Enum.Parse(MarketType.GetType(), symbol.Substring(index+1));
52 | }
53 |
54 | public void GetObjectData(SerializationInfo info, StreamingContext context)
55 | {
56 | info.AddValue("Type", Type);
57 | info.AddValue("MarketType", MarketType);
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/Quanter.Common/SecuritiesTypes.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Quanter.Common
8 | {
9 | public enum SecuritiesTypes
10 | {
11 | Stock,
12 | Future,
13 | Option,
14 | Commodity,
15 | Cfd,
16 | Swap
17 | }
18 |
19 | public enum MarketType
20 | {
21 | XSHG, // 上交所
22 | XSHE, // 深交所
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/Quanter.Common/StockUtil.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Quanter.Common
8 | {
9 | public class StockUtil
10 | {
11 | private static Random random = new Random();
12 | public static string getCode(String code)
13 | {
14 | if (code.Length == 6)
15 | return code;
16 | else if (code.Length == 8)
17 | return code.Substring(2);
18 |
19 | return code;
20 | }
21 |
22 | public static string GetFullCode(String stockCode)
23 | {
24 | if (stockCode.Length == 6)
25 | {
26 | switch (stockCode.Substring(0, 2))
27 | {
28 | case "51":
29 | case "50":
30 | case "60":
31 | stockCode = "sh" + stockCode;
32 | return stockCode;
33 |
34 | case "00":
35 | case "15":
36 | case "16":
37 | case "30":
38 | stockCode = "sz" + stockCode;
39 | return stockCode;
40 | }
41 | }
42 | return stockCode;
43 | }
44 |
45 | public static int GetExchangeType(String code)
46 | {
47 | if (GetFullCode(code).StartsWith("sz")) return 2;
48 | else if (GetFullCode(code).StartsWith("sh")) return 1;
49 |
50 | return 0;
51 | }
52 |
53 | public static string Base64Encode(String s, Encoding e)
54 | {
55 | byte[] bytes = e.GetBytes(s);
56 |
57 | return Convert.ToBase64String(bytes);
58 | }
59 |
60 | public static string Base64Decode(String s, Encoding e)
61 | {
62 | byte[] bytes = Convert.FromBase64String(s);
63 | return e.GetString(bytes);
64 | }
65 |
66 | public static string RandomString
67 | {
68 | get
69 | {
70 | return random.Next().ToString();
71 | }
72 | }
73 |
74 | public static string GetFundCode(string code)
75 | {
76 | if (code.Length == 6)
77 | return "f_" + code;
78 | else if (code.Length == 8)
79 | return "f_" + code.Substring(2, 6);
80 | else return code;
81 | }
82 |
83 | public static string GetShortCode(string code)
84 | {
85 | switch (code.Length)
86 | {
87 | case 6:
88 | return code;
89 | case 7:
90 | return code.Substring(1);
91 | case 8:
92 | return code.Substring(2);
93 | default:
94 | return code;
95 | }
96 | }
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/Quanter.Common/TickData.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Quanter.Common
8 | {
9 | public class TickData : ICloneable
10 | {
11 | ///
12 | /// 每价格挂单的数据
13 | ///
14 | public class GoodsData : ICloneable
15 | {
16 | public float Price { get; set; }
17 | public int OrderAmount { get; set; }
18 |
19 | public GoodsData(float price, int amount)
20 | {
21 | Price = price;
22 | OrderAmount = amount;
23 | }
24 |
25 | public GoodsData DeepClone()
26 | {
27 | return (GoodsData)Clone();
28 | }
29 | public object Clone()
30 | {
31 | GoodsData data = new GoodsData(Price, OrderAmount);
32 |
33 | return data;
34 | }
35 | }
36 |
37 | public String Code { get; set; } // 证券代码
38 | public string Name { get; set; } // 名称
39 |
40 | public float LastClose { get; set; }
41 | public float Open { get; set; }
42 | public float High { get; set; }
43 | public float Low { get; set; }
44 |
45 | public float CurrentPrice { get; set; } // 成交价
46 | public long Volumn { get; set; } // 成交量
47 | public float Turnover { get; set; } // 成交金额
48 | public String PushTime { get; set; } // 推送时间
49 |
50 | private ICollection buyList = new List();
51 | private ICollection sellList = new List();
52 |
53 | public GoodsData[] BuyList
54 | {
55 | get
56 | {
57 | if (buyList.Count == 0) return new GoodsData[5] { new GoodsData(0, 0), new GoodsData(0, 0), new GoodsData(0, 0), new GoodsData(0, 0), new GoodsData(0, 0) };
58 | return this.buyList.ToArray();
59 | }
60 | }
61 |
62 | public GoodsData[] SellList
63 | {
64 | get
65 | {
66 | if (sellList.Count == 0) return new GoodsData[5] { new GoodsData(0, 0), new GoodsData(0, 0), new GoodsData(0, 0), new GoodsData(0, 0), new GoodsData(0, 0) };
67 |
68 | return this.sellList.ToArray();
69 | }
70 | }
71 |
72 | public void AddBuyGoodsData(GoodsData data)
73 | {
74 | this.buyList.Add(data);
75 | }
76 |
77 | public void AddSellGoodsData(GoodsData data)
78 | {
79 | this.sellList.Add(data);
80 | }
81 |
82 | public TickData DeepClone()
83 | {
84 | return (TickData)Clone();
85 | }
86 | public object Clone()
87 | {
88 | TickData bid = new TickData();
89 | bid.Code = Code;
90 | bid.High = High;
91 | bid.Low = Low;
92 | bid.Open = Open;
93 | bid.LastClose = LastClose;
94 |
95 | bid.CurrentPrice = CurrentPrice;
96 | bid.Turnover = Turnover;
97 | bid.Volumn = Volumn;
98 | bid.PushTime = PushTime;
99 |
100 | bid.buyList = new List();
101 | buyList.AsParallel().ForAll(d=>
102 | {
103 | bid.buyList.Add(d.DeepClone());
104 | });
105 |
106 | bid.sellList = new List();
107 | sellList.AsParallel().ForAll(d =>
108 | {
109 | bid.sellList.Add(d.DeepClone());
110 | });
111 |
112 | return bid;
113 | }
114 | }
115 | }
116 |
--------------------------------------------------------------------------------
/Quanter.Common/TraderResult.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Quanter.Common
8 | {
9 | public enum TraderResultEnum
10 | {
11 | SUCCESS, // 成功
12 | ERROR, // 错误
13 | UNLOGIN, // 未登录
14 | TIMEOUT // 超时
15 | }
16 |
17 | public class TraderResult
18 | {
19 | ///
20 | /// -1: 表示调用不成功
21 | ///
22 | public TraderResultEnum Code { get; set; }
23 | public string Message { get; set; }
24 | public int EntrustNo { get; set; }
25 | public object Result { get; set; }
26 |
27 | public TraderResult()
28 | {
29 | Code = TraderResultEnum.TIMEOUT;
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/Quanter.Common/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/Quanter.Domain/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的一般信息由以下
6 | // 控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("Stock.Domain")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Stock.Domain")]
13 | [assembly: AssemblyCopyright("Copyright © 2015")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | //将 ComVisible 设置为 false 将使此程序集中的类型
18 | //对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
19 | //请将此类型的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("ec87bcae-62f6-46dd-90df-68f39a475752")]
24 |
25 | // 程序集的版本信息由下列四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 生成号
30 | // 修订号
31 | //
32 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
33 | // 方法是按如下所示使用“*”: :
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/Quanter.Domain/Quanter.Domain.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {EC87BCAE-62F6-46DD-90DF-68F39A475752}
8 | Library
9 | Properties
10 | Quanter.Domain
11 | Quanter.Domain
12 | v4.5.2
13 | 512
14 |
15 |
16 | true
17 | full
18 | false
19 | bin\Debug\
20 | DEBUG;TRACE
21 | prompt
22 | 4
23 |
24 |
25 | pdbonly
26 | true
27 | bin\Release\
28 | TRACE
29 | prompt
30 | 4
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 | PreserveNewest
50 |
51 |
52 | PreserveNewest
53 |
54 |
55 | PreserveNewest
56 |
57 |
58 | PreserveNewest
59 |
60 |
61 | PreserveNewest
62 |
63 |
64 | PreserveNewest
65 |
66 |
67 |
68 |
75 |
--------------------------------------------------------------------------------
/Quanter.Domain/StrategyDesc.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Quanter.Domain
8 | {
9 | ///
10 | /// 策略的种类
11 | ///
12 | public class StrategyDesc
13 | {
14 | public virtual int Id { get; set; }
15 | public virtual String Dll { get; set; }
16 | public virtual String Clazz { get; set; }
17 | public virtual String Name { get; set; }
18 | public virtual String Desc { get; set; }
19 | public virtual DateTime Date { get; set; }
20 | public virtual bool Enabled { get; set; }
21 |
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/Quanter.Domain/User.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Quanter.Domain
8 | {
9 | public class User
10 | {
11 | public virtual int Id { get; set; }
12 | public virtual String Username { get; set; }
13 | public virtual String Password { get; set; }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/Quanter.Domain/config/StockHolder.hbm.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/Quanter.Domain/config/StrategyDesc.hbm.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/Quanter.Domain/config/SubTradingAccount.hbm.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/Quanter.Domain/config/TransactionRecord.hbm.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Quanter.Domain/config/XueQiuCube.hbm.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/Quanter.Domain/config/hibernate.cfg.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 | NHibernate.Connection.DriverConnectionProvider
10 | NHibernate.Driver.SQLite20Driver
11 | Data Source=stock.db3;Version=3;
12 | NHibernate.Dialect.SQLiteDialect
13 | true=1;false=0
14 | true
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Quanter.Market.Sina/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的一般信息由以下
6 | // 控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("Stock.Market.Sina")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Stock.Market.Sina")]
13 | [assembly: AssemblyCopyright("Copyright © 2015")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | //将 ComVisible 设置为 false 将使此程序集中的类型
18 | //对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
19 | //请将此类型的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("ee7d7c04-1126-4c3f-8e24-a7a6008ed8a1")]
24 |
25 | // 程序集的版本信息由下列四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 生成号
30 | // 修订号
31 | //
32 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
33 | // 方法是按如下所示使用“*”: :
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/Quanter.Market.Sina/SinaQuotationActor.cs:
--------------------------------------------------------------------------------
1 | using Quanter.Common;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Net;
6 | using System.Text;
7 | using System.Threading;
8 | using System.Threading.Tasks;
9 | using Akka.Actor;
10 | using Akka.Event;
11 | using Quanter.Trader.Messages;
12 |
13 | namespace Quanter.Market.Sina
14 | {
15 | public class SinaQuotationActor : BaseQuotationActor
16 | {
17 | private CookieContainer Cookie = new CookieContainer();
18 |
19 | private const string dataurl = "http://hq.sinajs.cn/list={0}";
20 | private HttpClient client = null;
21 | private List symbols = new List();
22 |
23 | protected override void PreStart()
24 | {
25 | client = new HttpClient();
26 | }
27 | protected override void run()
28 | {
29 | _run();
30 | }
31 |
32 | private List t_ReqSymbols = new List();
33 | private readonly int n = 150;
34 |
35 | private void _run()
36 | {
37 | _log.Info("sina level1 行情接收器开始运行");
38 | bool isSent = false;
39 | if (aliases.Count != 0)
40 | {
41 | StringBuilder sb = new StringBuilder();
42 | for (int i = 0; i < aliases.Count; i++)
43 | {
44 | isSent = false;
45 | sb.Append(aliases[i]);
46 | sb.Append(",");
47 |
48 | if (i % n == (n - 1))
49 | {
50 | sb.Remove(sb.Length - 1, 1);
51 | t_ReqSymbols.Add(sb.ToString());
52 | sb.Clear();
53 | isSent = true;
54 | }
55 | }
56 | if (!isSent)
57 | {
58 | sb.Remove(sb.Length - 1, 1);
59 | t_ReqSymbols.Add(sb.ToString());
60 | }
61 | }
62 |
63 | foreach (string item in t_ReqSymbols)
64 | {
65 | _sendRequest(item);
66 | }
67 | }
68 |
69 | private void _sendRequest(String s)
70 | {
71 | string resp = client.Get(String.Format(dataurl, s));
72 | if (resp == null)
73 | {
74 | _log.Warning("没有获取到数据 {0}", s);
75 | return;
76 | }
77 | string[] respData = resp.Split(new char[] { '\n' });
78 | for (int i = 0; i < respData.Length; i++)
79 | {
80 | if (respData[i].Length != 0)
81 | {
82 | QuoteData qdata = _parseQuoteData(respData[i]);
83 | newQuoteDataArrived(qdata);
84 | }
85 | }
86 | }
87 |
88 | private QuoteData _parseQuoteData(string data)
89 | {
90 | String[] items = data.Split(new char[] { ',' });
91 | if (items.Length < 10) return null;
92 |
93 | QuoteData bid = new QuoteData();
94 |
95 | bid.Alias = data.Substring(11, 8);
96 | if (bid.Alias.StartsWith("sz")) {
97 | bid.Symbol = bid.Alias.Substring(2, 6) + ".XSHE";
98 | } else
99 | {
100 | bid.Symbol = bid.Alias.Substring(2, 6) + ".XSHG";
101 | }
102 |
103 | bid.Name = items[0].Substring(21, items[0].Length - 21); // var hq_str_sz150023="深成指B
104 | bid.Open = float.Parse(items[1]);
105 | bid.LastClose = float.Parse(items[2]);
106 | bid.CurrentPrice = float.Parse(items[3]);
107 | bid.High = float.Parse(items[4]);
108 | bid.Low = float.Parse(items[5]);
109 | //bid.Buy = decimal.Parse(items[6]);
110 | //bid.Sell = decimal.Parse(items[7]);
111 | bid.Volume = long.Parse(items[8]);
112 | bid.Turnover = float.Parse(items[9]);
113 |
114 | //bid.AddBuyGoodsData(new TickData.GoodsData(float.Parse(items[BUY_1_P]), int.Parse(items[BUY_1_A])));
115 | //bid.AddBuyGoodsData(new TickData.GoodsData(float.Parse(items[BUY_2_P]), int.Parse(items[BUY_2_A])));
116 | //bid.AddBuyGoodsData(new TickData.GoodsData(float.Parse(items[BUY_3_P]), int.Parse(items[BUY_3_A])));
117 | //bid.AddBuyGoodsData(new TickData.GoodsData(float.Parse(items[BUY_4_P]), int.Parse(items[BUY_4_A])));
118 | //bid.AddBuyGoodsData(new TickData.GoodsData(float.Parse(items[BUY_5_P]), int.Parse(items[BUY_5_A])));
119 |
120 |
121 | //bid.AddSellGoodsData(new TickData.GoodsData(float.Parse(items[SELL_1_P]), int.Parse(items[SELL_1_A])));
122 | //bid.AddSellGoodsData(new TickData.GoodsData(float.Parse(items[SELL_2_P]), int.Parse(items[SELL_2_A])));
123 | //bid.AddSellGoodsData(new TickData.GoodsData(float.Parse(items[SELL_3_P]), int.Parse(items[SELL_3_A])));
124 | //bid.AddSellGoodsData(new TickData.GoodsData(float.Parse(items[SELL_4_P]), int.Parse(items[SELL_4_A])));
125 | //bid.AddSellGoodsData(new TickData.GoodsData(float.Parse(items[SELL_5_P]), int.Parse(items[SELL_5_A])));
126 |
127 | bid.PushTime = items[31];
128 | return bid;
129 | }
130 |
131 | }
132 | }
133 |
--------------------------------------------------------------------------------
/Quanter.Market.Sina/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/Quanter.Market.Sina/jobs/FetchSinaQuoteDataJob.cs:
--------------------------------------------------------------------------------
1 | using Akka.Actor;
2 | using Quanter.Trader.Messages;
3 | using Quartz;
4 | using slf4net;
5 | using System;
6 | using System.Collections.Generic;
7 | using System.Linq;
8 | using System.Text;
9 | using System.Threading.Tasks;
10 |
11 | namespace Quanter.Market.Jobs
12 | {
13 | public class FetchSinaQuoteDataJob : IJob
14 | {
15 | private ILogger _log = LoggerFactory.GetILoggerFactory().GetLogger("Quanter.Market.Jobs.FetchSinaQuoteDataJob");
16 | ActorSystem actorSystem = null;
17 | ActorSelection sinaActor = null;
18 |
19 | public FetchSinaQuoteDataJob()
20 | {
21 | _init();
22 | }
23 |
24 | private void _init()
25 | {
26 | _log.Debug("初始化监听sina的作业");
27 | actorSystem = ActorSystem.Create(ConstantsHelper.AKKA_PATH_SERVER);
28 | // var path = String.Format("akka.tcp://{2}@localhost:8091/user/{0}/{1}", ConstantsHelper.AKKA_PATH_MARKET_MANAGER, "sina.quotation", ConstantsHelper.AKKA_PATH_SERVER);
29 | var path = String.Format("/user/{0}/{1}", ConstantsHelper.AKKA_PATH_MARKET_MANAGER, "sina.quotation");
30 | sinaActor = actorSystem.ActorSelection(path);
31 | }
32 |
33 | public void Execute(IJobExecutionContext context)
34 | {
35 | _log.Debug("执行监听sina的作业");
36 | QuotationRequest req = new QuotationRequest() { Type = QuotationRequest.RequestType.RUN };
37 | sinaActor.Tell(req);
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/Quanter.Market.Sina/jobs/ReadLastClosePriceJob.cs:
--------------------------------------------------------------------------------
1 | using Quanter.Market.Sina;
2 | using Quartz;
3 | using slf4net;
4 | using System;
5 | using System.Collections.Generic;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 |
10 | namespace Quanter.Market.Jobs
11 | {
12 | public class ReadLastClosePriceJob : IJob
13 | {
14 | private ILogger _log = LoggerFactory.GetILoggerFactory().GetLogger("Quanter.Market.Jobs.ReadLastClosePriceJob");
15 |
16 | public void Execute(IJobExecutionContext context)
17 | {
18 | _log.Info("执行作业:读入最新的收盘价。");
19 | LastClosePriceDataHelper.Instance.ReadLastClosePrice();
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/Quanter.Market.Sina/jobs/WriteLastClosePriceJob.cs:
--------------------------------------------------------------------------------
1 | using Quanter.Market.Sina;
2 | using Quartz;
3 | using slf4net;
4 | using System;
5 | using System.Collections.Generic;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 |
10 | namespace Quanter.Market.Jobs
11 | {
12 | public class WriteLastClosePriceJob : IJob
13 | {
14 | private ILogger _log = LoggerFactory.GetILoggerFactory().GetLogger("Quanter.Market.Jobs.WriteLastClosePriceJob");
15 |
16 | public void Execute(IJobExecutionContext context)
17 | {
18 | _log.Info("执行作业:更新最新的收盘价。");
19 | LastClosePriceDataHelper.Instance.WriteLastClosePrice();
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/Quanter.Market.Sina/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/Quanter.Persistence/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/Quanter.Persistence/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的一般信息由以下
6 | // 控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("Stock.Persistence")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Stock.Persistence")]
13 | [assembly: AssemblyCopyright("Copyright © 2015")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | //将 ComVisible 设置为 false 将使此程序集中的类型
18 | //对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
19 | //请将此类型的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("351aaa08-f483-403c-b4a4-a5725381c5e4")]
24 |
25 | // 程序集的版本信息由下列四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 生成号
30 | // 修订号
31 | //
32 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
33 | // 方法是按如下所示使用“*”: :
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/Quanter.Persistence/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/Quanter.Strategy/Class1.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Quanter.Strategy
8 | {
9 | public class Class1
10 | {
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/Quanter.Strategy/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的一般信息由以下
6 | // 控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("Quanter.Strategy")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Quanter.Strategy")]
13 | [assembly: AssemblyCopyright("Copyright © 2016")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | //将 ComVisible 设置为 false 将使此程序集中的类型
18 | //对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
19 | //请将此类型的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("fb1fe6c9-329e-440c-ae97-2218a961d30f")]
24 |
25 | // 程序集的版本信息由下列四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 生成号
30 | // 修订号
31 | //
32 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
33 | // 方法是按如下所示使用“*”: :
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/Quanter.Strategy/Quanter.Strategy.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | fb1fe6c9-329e-440c-ae97-2218a961d30f
8 | Library
9 | Properties
10 | Quanter.Strategy
11 | Quanter.Strategy
12 | v4.5.2
13 | 512
14 |
15 |
16 | true
17 | full
18 | false
19 | bin\Debug\
20 | DEBUG;TRACE
21 | prompt
22 | 4
23 |
24 |
25 | pdbonly
26 | true
27 | bin\Release\
28 | TRACE
29 | prompt
30 | 4
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/Quanter.Trader.Connector/IStockTrader.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Quanter.Trader.Connector
8 | {
9 | public delegate void TurnoverReturnHandler(int entrustNo, String code, float price, int amount);
10 | public interface IStockTrader
11 | {
12 | event TurnoverReturnHandler OnTurnoverReturn;
13 | void Init();
14 |
15 | ///
16 | /// 卖股票
17 | ///
18 | ///
19 | ///
20 | ///
21 | /// 合同号
22 | TraderResult SellStock(String code, float price, int num);
23 |
24 | ///
25 | /// 买股票
26 | ///
27 | ///
28 | ///
29 | ///
30 | /// 合同号
31 | TraderResult BuyStock(String code, float price, int num);
32 |
33 | ///
34 | /// 撤单
35 | ///
36 | /// 合约号
37 | /// 合同号
38 | TraderResult CancelStock(int entrustNo);
39 |
40 | ///
41 | /// 获取成交信息
42 | ///
43 | TraderResult GetTodayTradeList();
44 |
45 | ///
46 | /// 获取成交信息
47 | ///
48 | TraderResult GetTodayEntrustList();
49 |
50 | ///
51 | /// 保持连接
52 | ///
53 | void Keep();
54 |
55 | ///
56 | /// 获取资金信息
57 | ///
58 | TraderResult GetTradingAccountInfo();
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/Quanter.Trader.Connector/ITrader.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Quanter.Trader.Connector
8 | {
9 | public interface ITrader
10 | {
11 | void Connection();
12 |
13 | void Login();
14 |
15 | void Trade();
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Quanter.Trader.Connector/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的一般信息由以下
6 | // 控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("Stock.Trader.Connector")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Stock.Trader.Connector")]
13 | [assembly: AssemblyCopyright("Copyright © 2015")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | //将 ComVisible 设置为 false 将使此程序集中的类型
18 | //对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
19 | //请将此类型的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("5dc68754-1d48-41a0-a3ee-bf91b336ef93")]
24 |
25 | // 程序集的版本信息由下列四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 生成号
30 | // 修订号
31 | //
32 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
33 | // 方法是按如下所示使用“*”: :
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/Quanter.Trader.Connector/Quanter.Trader.Connector.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {5DC68754-1D48-41A0-A3EE-BF91B336EF93}
8 | Library
9 | Properties
10 | Quanter.Trader.Connector
11 | Quanter.Trader.Connector
12 | v4.5.2
13 | 512
14 |
15 |
16 | true
17 | full
18 | false
19 | bin\Debug\
20 | DEBUG;TRACE
21 | prompt
22 | 4
23 |
24 |
25 | pdbonly
26 | true
27 | bin\Release\
28 | TRACE
29 | prompt
30 | 4
31 |
32 |
33 |
34 | ..\..\quanter.private\packages\Akka.1.0.6\lib\net45\Akka.dll
35 | True
36 |
37 |
38 | ..\packages\Akka.Logger.slf4net.1.0.5\lib\net45\Akka.Logger.slf4net.dll
39 | True
40 |
41 |
42 | ..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll
43 | True
44 |
45 |
46 | ..\packages\slf4net.0.1.32.1\lib\net35\slf4net.dll
47 | True
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 | {34db14a6-e4ed-4c4a-8ca6-939201a572be}
78 | Quanter.BusinessEntity
79 |
80 |
81 | {a3fa3c71-a7b0-4bb6-bd32-0aee20493593}
82 | Quanter.Common
83 |
84 |
85 | {dde08214-ec3a-4dd7-8cee-49973e17ae8f}
86 | Quanter.Trader.Messages
87 |
88 |
89 |
90 |
97 |
--------------------------------------------------------------------------------
/Quanter.Trader.Connector/TradeManagerActor.cs:
--------------------------------------------------------------------------------
1 | using Akka.Actor;
2 | using Akka.Event;
3 | using Quanter.BusinessEntity;
4 | using Quanter.Trader.Messages;
5 | using System;
6 | using System.Collections.Generic;
7 | using System.Linq;
8 | using System.Text;
9 | using System.Threading.Tasks;
10 |
11 | namespace Quanter.Trader.Connector
12 | {
13 | public class TradeManagerActor : TypedActor, IHandle
14 | {
15 | private readonly ILoggingAdapter _log = Logging.GetLogger(Context);
16 | private ActorSelection persistenceActor;
17 | private IDictionary traders = new Dictionary();
18 |
19 | public void Handle(TradeManagerRequest message)
20 | {
21 | try
22 | {
23 | switch(message.Type)
24 | {
25 | case TradeManagerRequest.RequestType.INIT:
26 | _init();
27 | break;
28 | }
29 | } catch (Exception e)
30 | {
31 | _log.Error("TradeManagerActor发生异常 {0}", e.StackTrace);
32 | }
33 | }
34 |
35 | private void _init()
36 | {
37 | _log.Debug("从数据库中读取交易接口的信息");
38 | persistenceActor = Context.ActorSelection(String.Format("/user/{0}", ConstantsHelper.AKKA_PATH_PERSISTENCE));
39 | // 读取交易接口
40 | PersistenceRequest req = new PersistenceRequest() { Type = PersistenceType.LIST, Body = "from ETrader" };
41 | var result = persistenceActor.Ask>(req, TimeSpan.FromSeconds(3));
42 | result.Wait();
43 | var traders = result.Result;
44 | foreach(var o in traders)
45 | {
46 | var trader = (ETrader)o;
47 | _createTradeActor(trader);
48 | _log.Debug("加载交易接口 {0}", trader.Name);
49 | }
50 | }
51 |
52 | private void _createTradeActor(ETrader trader)
53 | {
54 | Type t = Type.GetType(trader.Type);
55 | var tr = Context.ActorOf(Props.Create(t), trader.Id.ToString());
56 |
57 | tr.Tell(new TradeRequest() { Type = TradeRequest.RequestType.INIT });
58 |
59 | traders.Add(trader.Id, tr);
60 | }
61 |
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/Quanter.Trader.Connector/TraderResult.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Quanter.Trader.Connector
8 | {
9 | public enum TraderResultEnum
10 | {
11 | SUCCESS, // 成功
12 | ERROR, // 错误
13 | UNLOGIN, // 未登录
14 | TIMEOUT // 超时
15 | }
16 | public class TraderResult
17 | {
18 | public TraderResultEnum Code { get; set; }
19 | public string Message { get; set; }
20 | public int EntrustNo { get; set; }
21 | public object Result { get; set; }
22 |
23 | public TraderResult()
24 | {
25 | Code = TraderResultEnum.TIMEOUT;
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/Quanter.Trader.Connector/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/Quanter.Trader.Gui/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
--------------------------------------------------------------------------------
/Quanter.Trader.Gui/CHANGES.txt:
--------------------------------------------------------------------------------
1 | ===============================================================================
2 | Welcome to the C# port of Google Protocol Buffers, written by Jon Skeet
3 | (skeet@pobox.com) based on the work of many talented people.
4 |
5 | For more information about this port, visit its homepage:
6 | http://protobuf-csharp-port.googlecode.com
7 |
8 | For more information about Protocol Buffers in general, visit the project page
9 | for the C++, Java and Python project:
10 | http://protobuf.googlecode.com
11 | ===============================================================================
12 | RELEASE NOTES - Version 2.4.1.473
13 | ===============================================================================
14 |
15 | Features:
16 | - Added option service_generator_type to control service generation with
17 | NONE, GENERIC, INTERFACE, or IRPCDISPATCH
18 | - Added interfaces IRpcDispatch and IRpcServerStub to provide for blocking
19 | services and implementations.
20 | - Added ProtoGen.exe command-line argument "--protoc_dir=" to specify the
21 | location of protoc.exe.
22 | - Extracted interfaces for ICodedInputStream and ICodedOutputStream to allow
23 | custom implementation of writers with both speed and size optimizations.
24 | - Addition of the "Google.ProtoBuffers.Serialization" assembly to support
25 | reading and writing messages to/from XML, JSON, IDictionary<,> and others.
26 | - Several performance related fixes and tweeks
27 | - Issue 3: Add option to mark generated code with attribute
28 | - Issue 20: Support for decorating classes [Serializable]
29 | - Issue 21: Decorate fields with [deprecated=true] as [System.Obsolete]
30 | - Issue 22: Reusable Builder classes
31 | - Issue 24: Support for using Json/Xml formats with ICodedInputStream
32 | - Issue 25: Added support for NuGet packages
33 | - Issue 31: Upgraded protoc.exe and descriptor to 2.4.1
34 |
35 | Fixes:
36 | - Issue 13: Message with Field same name as message causes uncompilable .cs
37 | - Issue 16: Does not integrate well with other tooling
38 | - Issue 19: Support for negative enum values
39 | - Issue 26: AddRange in GeneratedBuilder iterates twice.
40 | - Issue 27: Remove XML documentation output from test projects to clear
41 | warnings/errors.
42 | - Issue 28: Circular message dependencies result in null default values for
43 | Message fields.
44 | - Issue 29: Message classes generated have a public default constructor. You
45 | can disable private ctor generation with the option generate_private_ctor.
46 | - Issue 35: Fixed a bug in ProtoGen handling of arguments with trailing \
47 | - Big-endian support for float, and double on Silverlight
48 | - Packed and Unpacked parsing allow for all repeated, as per version 2.3
49 | - Fix for leaving Builder a public ctor on internal classes for use with
50 | generic "where T: new()" constraints.
51 |
52 | Other:
53 | - Changed the code signing key to a privately held key
54 | - Reformatted all code and line-endings to C# defaults
55 | - Reworking of performance benchmarks to produce reliable results, option /v2
56 | - Issue 34: Silverlight assemblies are now unit tested
57 |
58 | ===============================================================================
59 | RELEASE NOTES - Version 2.3.0.277
60 | ===============================================================================
61 |
62 | Features:
63 | - Added cls_compliance option to generate attributes indicating
64 | non-CLS-compliance.
65 | - Added file_extension option to control the generated output file's extension.
66 | - Added umbrella_namespace option to place the umbrella class into a nested
67 | namespace to address issues with proto files having the same name as a
68 | message it contains.
69 | - Added output_directory option to set the output path for the source file(s).
70 | - Added ignore_google_protobuf option to avoid generating code for includes
71 | from the google.protobuf package.
72 | - Added the LITE framework (Google.ProtoBuffersLite.dll) and the ability to
73 | generate code with "option optimize_for = LITE_RUNTIME;".
74 | - Added ability to invoke protoc.exe from within ProtoGen.exe.
75 | - Upgraded to protoc.exe (2.3) compiler.
76 |
77 | Fixes:
78 | - Issue 9: Class cannot be static and sealed error
79 | - Issue 12: default value for enumerate fields must be filled out
80 |
81 | Other:
82 | - Rewrite of build using MSBbuild instead of NAnt
83 | - Moved to NUnit Version 2.2.8.0
84 | - Changed to using secure .snk for releases
85 |
86 | ===============================================================================
87 | RELEASE NOTES - Version 0.9.1
88 | ===============================================================================
89 |
90 | Fixes:
91 | - issue 10: Incorrect encoding of packed fields when serialized
92 |
93 | ===============================================================================
94 | RELEASE NOTES - Version 0.9.0
95 | ===============================================================================
96 |
97 | - Initial release
98 |
99 | ===============================================================================
--------------------------------------------------------------------------------
/Quanter.Trader.Gui/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using System.Windows.Forms;
6 |
7 | namespace Quanter.Trader.Gui
8 | {
9 | static class Program
10 | {
11 | ///
12 | /// 应用程序的主入口点。
13 | ///
14 | [STAThread]
15 | static void Main()
16 | {
17 | Application.EnableVisualStyles();
18 | Application.SetCompatibleTextRenderingDefault(false);
19 | Application.Run(new MainForm());
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/Quanter.Trader.Gui/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的一般信息由以下
6 | // 控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("Stock.Trader.Gui")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Stock.Trader.Gui")]
13 | [assembly: AssemblyCopyright("Copyright © 2015")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | //将 ComVisible 设置为 false 将使此程序集中的类型
18 | //对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
19 | //请将此类型的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("c37de5a0-3069-4eca-8560-7ff207a93cad")]
24 |
25 | // 程序集的版本信息由下列四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 生成号
30 | // 修订号
31 | //
32 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
33 | // 方法是按如下所示使用“*”: :
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/Quanter.Trader.Gui/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // 此代码由工具生成。
4 | // 运行时版本:4.0.30319.42000
5 | //
6 | // 对此文件的更改可能会导致不正确的行为,并且如果
7 | // 重新生成代码,这些更改将会丢失。
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace Quanter.Trader.Gui.Properties {
12 | using System;
13 |
14 |
15 | ///
16 | /// 一个强类型的资源类,用于查找本地化的字符串等。
17 | ///
18 | // 此类是由 StronglyTypedResourceBuilder
19 | // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
20 | // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
21 | // (以 /str 作为命令选项),或重新生成 VS 项目。
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resources() {
33 | }
34 |
35 | ///
36 | /// 返回此类使用的缓存的 ResourceManager 实例。
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Quanter.Trader.Gui.Properties.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// 使用此强类型资源类,为所有资源查找
51 | /// 重写当前线程的 CurrentUICulture 属性。
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/Quanter.Trader.Gui/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // 此代码由工具生成。
4 | // 运行时版本:4.0.30319.42000
5 | //
6 | // 对此文件的更改可能会导致不正确的行为,并且如果
7 | // 重新生成代码,这些更改将会丢失。
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace Quanter.Trader.Gui.Properties {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")]
16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17 |
18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
19 |
20 | public static Settings Default {
21 | get {
22 | return defaultInstance;
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/Quanter.Trader.Gui/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Quanter.Trader.Gui/licenses/license.txt:
--------------------------------------------------------------------------------
1 | Protocol Buffers - Google's data interchange format
2 | Copyright 2008-2010 Google Inc. All rights reserved.
3 | http://github.com/jskeet/dotnet-protobufs/
4 | Original C++/Java/Python code:
5 | http://code.google.com/p/protobuf/
6 |
7 | Redistribution and use in source and binary forms, with or without
8 | modification, are permitted provided that the following conditions are
9 | met:
10 |
11 | * Redistributions of source code must retain the above copyright
12 | notice, this list of conditions and the following disclaimer.
13 | * Redistributions in binary form must reproduce the above
14 | copyright notice, this list of conditions and the following disclaimer
15 | in the documentation and/or other materials provided with the
16 | distribution.
17 | * Neither the name of Google Inc. nor the names of its
18 | contributors may be used to endorse or promote products derived from
19 | this software without specific prior written permission.
20 |
21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 |
--------------------------------------------------------------------------------
/Quanter.Trader.Gui/licenses/protoc-license.txt:
--------------------------------------------------------------------------------
1 | protoc.exe was built from the original source at http://code.google.com/p/protobuf/
2 | The licence for this code is as follows:
3 |
4 | Copyright 2008, Google Inc.
5 | All rights reserved.
6 |
7 | Redistribution and use in source and binary forms, with or without
8 | modification, are permitted provided that the following conditions are
9 | met:
10 |
11 | * Redistributions of source code must retain the above copyright
12 | notice, this list of conditions and the following disclaimer.
13 | * Redistributions in binary form must reproduce the above
14 | copyright notice, this list of conditions and the following disclaimer
15 | in the documentation and/or other materials provided with the
16 | distribution.
17 | * Neither the name of Google Inc. nor the names of its
18 | contributors may be used to endorse or promote products derived from
19 | this software without specific prior written permission.
20 |
21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 |
33 | Code generated by the Protocol Buffer compiler is owned by the owner
34 | of the input file used when generating it. This code is not
35 | standalone and requires a support library to be linked with it. This
36 | support library is itself covered by the above license.
--------------------------------------------------------------------------------
/Quanter.Trader.Gui/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/Quanter.Trader.Gui/protos/google/protobuf/csharp_options.proto:
--------------------------------------------------------------------------------
1 | // Extra options for C# generator
2 |
3 | import "google/protobuf/descriptor.proto";
4 |
5 | package google.protobuf;
6 |
7 | message CSharpFileOptions {
8 |
9 | // Namespace for generated classes; defaults to the package.
10 | optional string namespace = 1;
11 |
12 | // Name of the "umbrella" class used for metadata about all
13 | // the messages within this file. Default is based on the name
14 | // of the file.
15 | optional string umbrella_classname = 2;
16 |
17 | // Whether classes should be public (true) or internal (false)
18 | optional bool public_classes = 3 [default = true];
19 |
20 | // Whether to generate a single file for everything within the
21 | // .proto file (false), or one file per message (true).
22 | // This option is not currently honored; please log a feature
23 | // request if you really want it.
24 | optional bool multiple_files = 4;
25 |
26 | // Whether to nest messages within a single umbrella class (true)
27 | // or create the umbrella class as a peer, with messages as
28 | // top-level classes in the namespace (false)
29 | optional bool nest_classes = 5;
30 |
31 | // Generate appropriate support for Code Contracts
32 | // (Ongoing; support should improve over time)
33 | optional bool code_contracts = 6;
34 |
35 | // Create subdirectories for namespaces, e.g. namespace "Foo.Bar"
36 | // would generate files within [output directory]/Foo/Bar
37 | optional bool expand_namespace_directories = 7;
38 |
39 | // Generate attributes indicating non-CLS-compliance
40 | optional bool cls_compliance = 8 [default = true];
41 |
42 | // Generate messages/builders with the [Serializable] attribute
43 | optional bool add_serializable = 9 [default = false];
44 |
45 | // Generates a private ctor for Message types
46 | optional bool generate_private_ctor = 10 [default = true];
47 |
48 | // The extension that should be appended to the umbrella_classname when creating files.
49 | optional string file_extension = 221 [default = ".cs"];
50 |
51 | // A nested namespace for the umbrella class. Helpful for name collisions caused by
52 | // umbrella_classname conflicting with an existing type. This will be automatically
53 | // set to 'Proto' if a collision is detected with types being generated. This value
54 | // is ignored when nest_classes == true
55 | optional string umbrella_namespace = 222;
56 |
57 | // The output path for the source file(s) generated
58 | optional string output_directory = 223 [default = "."];
59 |
60 | // Will ignore the type generations and remove dependencies for the descriptor proto
61 | // files that declare their package to be "google.protobuf"
62 | optional bool ignore_google_protobuf = 224 [default = false];
63 |
64 | // Controls how services are generated, GENERIC is the deprecated original implementation
65 | // INTERFACE generates service interfaces only, RPCINTEROP generates interfaces and
66 | // implementations using the included Windows RPC interop libarary.
67 | optional CSharpServiceType service_generator_type = 225 [default = NONE];
68 |
69 | // Used to add the System.Runtime.CompilerServices.CompilerGeneratedAttribute and
70 | // System.CodeDom.Compiler.GeneratedCodeAttribute attributes to generated code.
71 | optional bool generated_code_attributes = 226 [default = false];
72 | }
73 |
74 | enum CSharpServiceType {
75 | // Services are ignored by the generator
76 | NONE = 0;
77 | // Generates the original Java generic service implementations
78 | GENERIC = 1;
79 | // Generates an interface for the service and nothing else
80 | INTERFACE = 2;
81 | // Generates an interface for the service and client/server wrappers for the interface
82 | IRPCDISPATCH = 3;
83 | }
84 |
85 | extend FileOptions {
86 | optional CSharpFileOptions csharp_file_options = 1000;
87 | }
88 |
89 | extend FieldOptions {
90 | optional CSharpFieldOptions csharp_field_options = 1000;
91 | }
92 |
93 | message CSharpFieldOptions {
94 | // Provides the ability to override the name of the property
95 | // generated for this field. This is applied to all properties
96 | // and methods to do with this field, including HasFoo, FooCount,
97 | // FooList etc.
98 | optional string property_name = 1;
99 | }
100 |
101 | message CSharpServiceOptions {
102 | optional string interface_id = 1;
103 | }
104 |
105 | extend ServiceOptions {
106 | optional CSharpServiceOptions csharp_service_options = 1000;
107 | }
108 |
109 | message CSharpMethodOptions {
110 | optional int32 dispatch_id = 1;
111 | }
112 |
113 | extend MethodOptions {
114 | optional CSharpMethodOptions csharp_method_options = 1000;
115 | }
--------------------------------------------------------------------------------
/Quanter.Trader.Gui/protos/tutorial/addressbook.proto:
--------------------------------------------------------------------------------
1 | package tutorial;
2 |
3 | import "google/protobuf/csharp_options.proto";
4 | option (google.protobuf.csharp_file_options).namespace = "Google.ProtocolBuffers.Examples.AddressBook";
5 | option (google.protobuf.csharp_file_options).umbrella_classname = "AddressBookProtos";
6 |
7 | option optimize_for = SPEED;
8 |
9 | message Person {
10 | required string name = 1;
11 | required int32 id = 2; // Unique ID number for this person.
12 | optional string email = 3;
13 |
14 | enum PhoneType {
15 | MOBILE = 0;
16 | HOME = 1;
17 | WORK = 2;
18 | }
19 |
20 | message PhoneNumber {
21 | required string number = 1;
22 | optional PhoneType type = 2 [default = HOME];
23 | }
24 |
25 | repeated PhoneNumber phone = 4;
26 | }
27 |
28 | // Our address book file is just one of these.
29 | message AddressBook {
30 | repeated Person person = 1;
31 | }
32 |
--------------------------------------------------------------------------------
/Quanter.Trader.Indicator/IComplexIndicator.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Quanter.Trader.Indicator
8 | {
9 | interface IComplexIndicator : IIndicator
10 | {
11 | IEnumerable InnerIndicators { get; }
12 |
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/Quanter.Trader.Indicator/IIndicator.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Quanter.Trader.Indicator
8 | {
9 | public interface IIndicator : ICloneable
10 | {
11 | IIndicatorValueList Calculate();
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/Quanter.Trader.Indicator/IIndicatorValue.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Quanter.Trader.Indicator
8 | {
9 | public interface IIndicatorValue
10 | {
11 | DateTime Time { get; set; }
12 | float Value { get; set; }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/Quanter.Trader.Indicator/IIndicatorValueList.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Quanter.Trader.Indicator
8 | {
9 | public interface IIndicatorValueList : IList
10 | {
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/Quanter.Trader.Indicator/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的一般信息由以下
6 | // 控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("Stock.Trader.Indicator")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Stock.Trader.Indicator")]
13 | [assembly: AssemblyCopyright("Copyright © 2015")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | //将 ComVisible 设置为 false 将使此程序集中的类型
18 | //对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
19 | //请将此类型的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("44a87744-bf18-4658-a45c-fc4cbaca7e0f")]
24 |
25 | // 程序集的版本信息由下列四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 生成号
30 | // 修订号
31 | //
32 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
33 | // 方法是按如下所示使用“*”: :
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/Quanter.Trader.Indicator/Quanter.Trader.Indicator.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {44A87744-BF18-4658-A45C-FC4CBACA7E0F}
8 | Library
9 | Properties
10 | Quanter.Trader.Indicator
11 | Quanter.Trader.Indicator
12 | v4.5.2
13 | 512
14 |
15 |
16 | true
17 | full
18 | false
19 | bin\Debug\
20 | DEBUG;TRACE
21 | prompt
22 | 4
23 |
24 |
25 | pdbonly
26 | true
27 | bin\Release\
28 | TRACE
29 | prompt
30 | 4
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
59 |
--------------------------------------------------------------------------------
/Quanter.Trader.MarketServer/BaseQuotationActor.cs:
--------------------------------------------------------------------------------
1 | using Akka.Actor;
2 | using Akka.Event;
3 | using Quanter.Common;
4 | using Quanter.Trader.Messages;
5 | using System;
6 | using System.Collections.Generic;
7 | using System.Linq;
8 | using System.Text;
9 | using System.Threading;
10 | using System.Threading.Tasks;
11 |
12 | namespace Quanter.Market
13 | {
14 | ///
15 | ///
16 | ///
17 | public abstract class BaseQuotationActor : TypedActor, IHandle
18 | {
19 | protected readonly ILoggingAdapter _log = Logging.GetLogger(Context);
20 | protected IDictionary symbolActors = new Dictionary();
21 | protected IList aliases = new List();
22 |
23 | public void Handle(QuotationRequest message)
24 | {
25 | try {
26 | switch (message.Type)
27 | {
28 | case QuotationRequest.RequestType.ASKED_SECURITIES:
29 | _handleAskedSecurities(message.Body as IList);
30 | break;
31 | case QuotationRequest.RequestType.RUN:
32 | run();
33 | break;
34 | }
35 | }catch (Exception e)
36 | {
37 | _log.Error("BaseQuotationActor.Handle发生异常:{0}", e.StackTrace);
38 | }
39 | }
40 |
41 | protected virtual void _handleAskedSecurities(IList seces)
42 | {
43 | // 初始化证券Actor列表
44 | foreach (var sec in seces)
45 | {
46 | if (!aliases.Contains(sec.Alias))
47 | {
48 | _log.Debug("准备接收证券代码 {0}的行情数据", sec.Symbol);
49 | var actor = Context.ActorSelection(String.Format("/user/{0}/{1}", ConstantsHelper.AKKA_PATH_MARKET_MANAGER, sec.Symbol));
50 | symbolActors.Add(sec.Symbol, actor);
51 |
52 | aliases.Add(sec.Alias); // 用于获取数据
53 | }
54 | }
55 | }
56 |
57 |
58 | protected virtual void run()
59 | {
60 | }
61 |
62 | protected void newQuoteDataArrived(QuoteData data)
63 | {
64 | _log.Debug("通知股票{0}Actor,有新Quote数据到达", data.Alias);
65 | symbolActors[data.Symbol].Tell(new SecuritiesQuotationRequest() { Type = SecuritiesQuotationRequest.RequestType.NEW_QUOTEDATA, Body = data });
66 | }
67 |
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/Quanter.Trader.MarketServer/CHANGES.txt:
--------------------------------------------------------------------------------
1 | ===============================================================================
2 | Welcome to the C# port of Google Protocol Buffers, written by Jon Skeet
3 | (skeet@pobox.com) based on the work of many talented people.
4 |
5 | For more information about this port, visit its homepage:
6 | http://protobuf-csharp-port.googlecode.com
7 |
8 | For more information about Protocol Buffers in general, visit the project page
9 | for the C++, Java and Python project:
10 | http://protobuf.googlecode.com
11 | ===============================================================================
12 | RELEASE NOTES - Version 2.4.1.473
13 | ===============================================================================
14 |
15 | Features:
16 | - Added option service_generator_type to control service generation with
17 | NONE, GENERIC, INTERFACE, or IRPCDISPATCH
18 | - Added interfaces IRpcDispatch and IRpcServerStub to provide for blocking
19 | services and implementations.
20 | - Added ProtoGen.exe command-line argument "--protoc_dir=" to specify the
21 | location of protoc.exe.
22 | - Extracted interfaces for ICodedInputStream and ICodedOutputStream to allow
23 | custom implementation of writers with both speed and size optimizations.
24 | - Addition of the "Google.ProtoBuffers.Serialization" assembly to support
25 | reading and writing messages to/from XML, JSON, IDictionary<,> and others.
26 | - Several performance related fixes and tweeks
27 | - Issue 3: Add option to mark generated code with attribute
28 | - Issue 20: Support for decorating classes [Serializable]
29 | - Issue 21: Decorate fields with [deprecated=true] as [System.Obsolete]
30 | - Issue 22: Reusable Builder classes
31 | - Issue 24: Support for using Json/Xml formats with ICodedInputStream
32 | - Issue 25: Added support for NuGet packages
33 | - Issue 31: Upgraded protoc.exe and descriptor to 2.4.1
34 |
35 | Fixes:
36 | - Issue 13: Message with Field same name as message causes uncompilable .cs
37 | - Issue 16: Does not integrate well with other tooling
38 | - Issue 19: Support for negative enum values
39 | - Issue 26: AddRange in GeneratedBuilder iterates twice.
40 | - Issue 27: Remove XML documentation output from test projects to clear
41 | warnings/errors.
42 | - Issue 28: Circular message dependencies result in null default values for
43 | Message fields.
44 | - Issue 29: Message classes generated have a public default constructor. You
45 | can disable private ctor generation with the option generate_private_ctor.
46 | - Issue 35: Fixed a bug in ProtoGen handling of arguments with trailing \
47 | - Big-endian support for float, and double on Silverlight
48 | - Packed and Unpacked parsing allow for all repeated, as per version 2.3
49 | - Fix for leaving Builder a public ctor on internal classes for use with
50 | generic "where T: new()" constraints.
51 |
52 | Other:
53 | - Changed the code signing key to a privately held key
54 | - Reformatted all code and line-endings to C# defaults
55 | - Reworking of performance benchmarks to produce reliable results, option /v2
56 | - Issue 34: Silverlight assemblies are now unit tested
57 |
58 | ===============================================================================
59 | RELEASE NOTES - Version 2.3.0.277
60 | ===============================================================================
61 |
62 | Features:
63 | - Added cls_compliance option to generate attributes indicating
64 | non-CLS-compliance.
65 | - Added file_extension option to control the generated output file's extension.
66 | - Added umbrella_namespace option to place the umbrella class into a nested
67 | namespace to address issues with proto files having the same name as a
68 | message it contains.
69 | - Added output_directory option to set the output path for the source file(s).
70 | - Added ignore_google_protobuf option to avoid generating code for includes
71 | from the google.protobuf package.
72 | - Added the LITE framework (Google.ProtoBuffersLite.dll) and the ability to
73 | generate code with "option optimize_for = LITE_RUNTIME;".
74 | - Added ability to invoke protoc.exe from within ProtoGen.exe.
75 | - Upgraded to protoc.exe (2.3) compiler.
76 |
77 | Fixes:
78 | - Issue 9: Class cannot be static and sealed error
79 | - Issue 12: default value for enumerate fields must be filled out
80 |
81 | Other:
82 | - Rewrite of build using MSBbuild instead of NAnt
83 | - Moved to NUnit Version 2.2.8.0
84 | - Changed to using secure .snk for releases
85 |
86 | ===============================================================================
87 | RELEASE NOTES - Version 0.9.1
88 | ===============================================================================
89 |
90 | Fixes:
91 | - issue 10: Incorrect encoding of packed fields when serialized
92 |
93 | ===============================================================================
94 | RELEASE NOTES - Version 0.9.0
95 | ===============================================================================
96 |
97 | - Initial release
98 |
99 | ===============================================================================
--------------------------------------------------------------------------------
/Quanter.Trader.MarketServer/MarketReceiverConfigurationSection.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Configuration;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace Quanter.Market
9 | {
10 | public class MarketReceiverConfigurationSection : ConfigurationSection
11 | {
12 | [ConfigurationProperty("receiver", IsDefaultCollection = true)]
13 | public ReceiverElementCollection Receivers
14 | {
15 | get
16 | {
17 | return (ReceiverElementCollection)base["receiver"];
18 | }
19 | }
20 | }
21 |
22 | public class ReceiverElementCollection : ConfigurationElementCollection
23 | {
24 | protected override ConfigurationElement CreateNewElement()
25 | {
26 | return new ReceiverElement();
27 | }
28 |
29 | protected override object GetElementKey(ConfigurationElement element)
30 | {
31 | return ((ReceiverElement)element).Name;
32 | }
33 | }
34 |
35 | public class ReceiverElement : ConfigurationElement
36 | {
37 | [ConfigurationProperty("name", IsRequired = true, IsKey = true)]
38 | public string Name
39 | {
40 | get
41 | {
42 | return base["name"].ToString();
43 | }
44 | set
45 | {
46 | base["name"] = value;
47 | }
48 | }
49 |
50 | [ConfigurationProperty("type", IsRequired = true)]
51 | public string Type
52 | {
53 | get
54 | {
55 | return base["type"].ToString();
56 | }
57 | set
58 | {
59 | base["type"] = value;
60 | }
61 | }
62 |
63 | [ConfigurationProperty("threads", IsRequired = false)]
64 | public int Threads
65 | {
66 | get
67 | {
68 | return int.Parse(base["threads"].ToString());
69 | }
70 | set
71 | {
72 | base["threads"] = value;
73 | }
74 | }
75 |
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/Quanter.Trader.MarketServer/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的一般信息由以下
6 | // 控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("Stock.Trader.MarketServer")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Stock.Trader.MarketServer")]
13 | [assembly: AssemblyCopyright("Copyright © 2015")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | //将 ComVisible 设置为 false 将使此程序集中的类型
18 | //对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
19 | //请将此类型的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("6d5c9c0a-3c0f-47f3-9bff-2621cb1c5f10")]
24 |
25 | // 程序集的版本信息由下列四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 生成号
30 | // 修订号
31 | //
32 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
33 | // 方法是按如下所示使用“*”: :
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/Quanter.Trader.MarketServer/licenses/license.txt:
--------------------------------------------------------------------------------
1 | Protocol Buffers - Google's data interchange format
2 | Copyright 2008-2010 Google Inc. All rights reserved.
3 | http://github.com/jskeet/dotnet-protobufs/
4 | Original C++/Java/Python code:
5 | http://code.google.com/p/protobuf/
6 |
7 | Redistribution and use in source and binary forms, with or without
8 | modification, are permitted provided that the following conditions are
9 | met:
10 |
11 | * Redistributions of source code must retain the above copyright
12 | notice, this list of conditions and the following disclaimer.
13 | * Redistributions in binary form must reproduce the above
14 | copyright notice, this list of conditions and the following disclaimer
15 | in the documentation and/or other materials provided with the
16 | distribution.
17 | * Neither the name of Google Inc. nor the names of its
18 | contributors may be used to endorse or promote products derived from
19 | this software without specific prior written permission.
20 |
21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 |
--------------------------------------------------------------------------------
/Quanter.Trader.MarketServer/licenses/protoc-license.txt:
--------------------------------------------------------------------------------
1 | protoc.exe was built from the original source at http://code.google.com/p/protobuf/
2 | The licence for this code is as follows:
3 |
4 | Copyright 2008, Google Inc.
5 | All rights reserved.
6 |
7 | Redistribution and use in source and binary forms, with or without
8 | modification, are permitted provided that the following conditions are
9 | met:
10 |
11 | * Redistributions of source code must retain the above copyright
12 | notice, this list of conditions and the following disclaimer.
13 | * Redistributions in binary form must reproduce the above
14 | copyright notice, this list of conditions and the following disclaimer
15 | in the documentation and/or other materials provided with the
16 | distribution.
17 | * Neither the name of Google Inc. nor the names of its
18 | contributors may be used to endorse or promote products derived from
19 | this software without specific prior written permission.
20 |
21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 |
33 | Code generated by the Protocol Buffer compiler is owned by the owner
34 | of the input file used when generating it. This code is not
35 | standalone and requires a support library to be linked with it. This
36 | support library is itself covered by the above license.
--------------------------------------------------------------------------------
/Quanter.Trader.MarketServer/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Quanter.Trader.MarketServer/protos/google/protobuf/csharp_options.proto:
--------------------------------------------------------------------------------
1 | // Extra options for C# generator
2 |
3 | import "google/protobuf/descriptor.proto";
4 |
5 | package google.protobuf;
6 |
7 | message CSharpFileOptions {
8 |
9 | // Namespace for generated classes; defaults to the package.
10 | optional string namespace = 1;
11 |
12 | // Name of the "umbrella" class used for metadata about all
13 | // the messages within this file. Default is based on the name
14 | // of the file.
15 | optional string umbrella_classname = 2;
16 |
17 | // Whether classes should be public (true) or internal (false)
18 | optional bool public_classes = 3 [default = true];
19 |
20 | // Whether to generate a single file for everything within the
21 | // .proto file (false), or one file per message (true).
22 | // This option is not currently honored; please log a feature
23 | // request if you really want it.
24 | optional bool multiple_files = 4;
25 |
26 | // Whether to nest messages within a single umbrella class (true)
27 | // or create the umbrella class as a peer, with messages as
28 | // top-level classes in the namespace (false)
29 | optional bool nest_classes = 5;
30 |
31 | // Generate appropriate support for Code Contracts
32 | // (Ongoing; support should improve over time)
33 | optional bool code_contracts = 6;
34 |
35 | // Create subdirectories for namespaces, e.g. namespace "Foo.Bar"
36 | // would generate files within [output directory]/Foo/Bar
37 | optional bool expand_namespace_directories = 7;
38 |
39 | // Generate attributes indicating non-CLS-compliance
40 | optional bool cls_compliance = 8 [default = true];
41 |
42 | // Generate messages/builders with the [Serializable] attribute
43 | optional bool add_serializable = 9 [default = false];
44 |
45 | // Generates a private ctor for Message types
46 | optional bool generate_private_ctor = 10 [default = true];
47 |
48 | // The extension that should be appended to the umbrella_classname when creating files.
49 | optional string file_extension = 221 [default = ".cs"];
50 |
51 | // A nested namespace for the umbrella class. Helpful for name collisions caused by
52 | // umbrella_classname conflicting with an existing type. This will be automatically
53 | // set to 'Proto' if a collision is detected with types being generated. This value
54 | // is ignored when nest_classes == true
55 | optional string umbrella_namespace = 222;
56 |
57 | // The output path for the source file(s) generated
58 | optional string output_directory = 223 [default = "."];
59 |
60 | // Will ignore the type generations and remove dependencies for the descriptor proto
61 | // files that declare their package to be "google.protobuf"
62 | optional bool ignore_google_protobuf = 224 [default = false];
63 |
64 | // Controls how services are generated, GENERIC is the deprecated original implementation
65 | // INTERFACE generates service interfaces only, RPCINTEROP generates interfaces and
66 | // implementations using the included Windows RPC interop libarary.
67 | optional CSharpServiceType service_generator_type = 225 [default = NONE];
68 |
69 | // Used to add the System.Runtime.CompilerServices.CompilerGeneratedAttribute and
70 | // System.CodeDom.Compiler.GeneratedCodeAttribute attributes to generated code.
71 | optional bool generated_code_attributes = 226 [default = false];
72 | }
73 |
74 | enum CSharpServiceType {
75 | // Services are ignored by the generator
76 | NONE = 0;
77 | // Generates the original Java generic service implementations
78 | GENERIC = 1;
79 | // Generates an interface for the service and nothing else
80 | INTERFACE = 2;
81 | // Generates an interface for the service and client/server wrappers for the interface
82 | IRPCDISPATCH = 3;
83 | }
84 |
85 | extend FileOptions {
86 | optional CSharpFileOptions csharp_file_options = 1000;
87 | }
88 |
89 | extend FieldOptions {
90 | optional CSharpFieldOptions csharp_field_options = 1000;
91 | }
92 |
93 | message CSharpFieldOptions {
94 | // Provides the ability to override the name of the property
95 | // generated for this field. This is applied to all properties
96 | // and methods to do with this field, including HasFoo, FooCount,
97 | // FooList etc.
98 | optional string property_name = 1;
99 | }
100 |
101 | message CSharpServiceOptions {
102 | optional string interface_id = 1;
103 | }
104 |
105 | extend ServiceOptions {
106 | optional CSharpServiceOptions csharp_service_options = 1000;
107 | }
108 |
109 | message CSharpMethodOptions {
110 | optional int32 dispatch_id = 1;
111 | }
112 |
113 | extend MethodOptions {
114 | optional CSharpMethodOptions csharp_method_options = 1000;
115 | }
--------------------------------------------------------------------------------
/Quanter.Trader.MarketServer/protos/tutorial/addressbook.proto:
--------------------------------------------------------------------------------
1 | package tutorial;
2 |
3 | import "google/protobuf/csharp_options.proto";
4 | option (google.protobuf.csharp_file_options).namespace = "Google.ProtocolBuffers.Examples.AddressBook";
5 | option (google.protobuf.csharp_file_options).umbrella_classname = "AddressBookProtos";
6 |
7 | option optimize_for = SPEED;
8 |
9 | message Person {
10 | required string name = 1;
11 | required int32 id = 2; // Unique ID number for this person.
12 | optional string email = 3;
13 |
14 | enum PhoneType {
15 | MOBILE = 0;
16 | HOME = 1;
17 | WORK = 2;
18 | }
19 |
20 | message PhoneNumber {
21 | required string number = 1;
22 | optional PhoneType type = 2 [default = HOME];
23 | }
24 |
25 | repeated PhoneNumber phone = 4;
26 | }
27 |
28 | // Our address book file is just one of these.
29 | message AddressBook {
30 | repeated Person person = 1;
31 | }
32 |
--------------------------------------------------------------------------------
/Quanter.Trader.Messages/CHANGES.txt:
--------------------------------------------------------------------------------
1 | ===============================================================================
2 | Welcome to the C# port of Google Protocol Buffers, written by Jon Skeet
3 | (skeet@pobox.com) based on the work of many talented people.
4 |
5 | For more information about this port, visit its homepage:
6 | http://protobuf-csharp-port.googlecode.com
7 |
8 | For more information about Protocol Buffers in general, visit the project page
9 | for the C++, Java and Python project:
10 | http://protobuf.googlecode.com
11 | ===============================================================================
12 | RELEASE NOTES - Version 2.4.1.473
13 | ===============================================================================
14 |
15 | Features:
16 | - Added option service_generator_type to control service generation with
17 | NONE, GENERIC, INTERFACE, or IRPCDISPATCH
18 | - Added interfaces IRpcDispatch and IRpcServerStub to provide for blocking
19 | services and implementations.
20 | - Added ProtoGen.exe command-line argument "--protoc_dir=" to specify the
21 | location of protoc.exe.
22 | - Extracted interfaces for ICodedInputStream and ICodedOutputStream to allow
23 | custom implementation of writers with both speed and size optimizations.
24 | - Addition of the "Google.ProtoBuffers.Serialization" assembly to support
25 | reading and writing messages to/from XML, JSON, IDictionary<,> and others.
26 | - Several performance related fixes and tweeks
27 | - Issue 3: Add option to mark generated code with attribute
28 | - Issue 20: Support for decorating classes [Serializable]
29 | - Issue 21: Decorate fields with [deprecated=true] as [System.Obsolete]
30 | - Issue 22: Reusable Builder classes
31 | - Issue 24: Support for using Json/Xml formats with ICodedInputStream
32 | - Issue 25: Added support for NuGet packages
33 | - Issue 31: Upgraded protoc.exe and descriptor to 2.4.1
34 |
35 | Fixes:
36 | - Issue 13: Message with Field same name as message causes uncompilable .cs
37 | - Issue 16: Does not integrate well with other tooling
38 | - Issue 19: Support for negative enum values
39 | - Issue 26: AddRange in GeneratedBuilder iterates twice.
40 | - Issue 27: Remove XML documentation output from test projects to clear
41 | warnings/errors.
42 | - Issue 28: Circular message dependencies result in null default values for
43 | Message fields.
44 | - Issue 29: Message classes generated have a public default constructor. You
45 | can disable private ctor generation with the option generate_private_ctor.
46 | - Issue 35: Fixed a bug in ProtoGen handling of arguments with trailing \
47 | - Big-endian support for float, and double on Silverlight
48 | - Packed and Unpacked parsing allow for all repeated, as per version 2.3
49 | - Fix for leaving Builder a public ctor on internal classes for use with
50 | generic "where T: new()" constraints.
51 |
52 | Other:
53 | - Changed the code signing key to a privately held key
54 | - Reformatted all code and line-endings to C# defaults
55 | - Reworking of performance benchmarks to produce reliable results, option /v2
56 | - Issue 34: Silverlight assemblies are now unit tested
57 |
58 | ===============================================================================
59 | RELEASE NOTES - Version 2.3.0.277
60 | ===============================================================================
61 |
62 | Features:
63 | - Added cls_compliance option to generate attributes indicating
64 | non-CLS-compliance.
65 | - Added file_extension option to control the generated output file's extension.
66 | - Added umbrella_namespace option to place the umbrella class into a nested
67 | namespace to address issues with proto files having the same name as a
68 | message it contains.
69 | - Added output_directory option to set the output path for the source file(s).
70 | - Added ignore_google_protobuf option to avoid generating code for includes
71 | from the google.protobuf package.
72 | - Added the LITE framework (Google.ProtoBuffersLite.dll) and the ability to
73 | generate code with "option optimize_for = LITE_RUNTIME;".
74 | - Added ability to invoke protoc.exe from within ProtoGen.exe.
75 | - Upgraded to protoc.exe (2.3) compiler.
76 |
77 | Fixes:
78 | - Issue 9: Class cannot be static and sealed error
79 | - Issue 12: default value for enumerate fields must be filled out
80 |
81 | Other:
82 | - Rewrite of build using MSBbuild instead of NAnt
83 | - Moved to NUnit Version 2.2.8.0
84 | - Changed to using secure .snk for releases
85 |
86 | ===============================================================================
87 | RELEASE NOTES - Version 0.9.1
88 | ===============================================================================
89 |
90 | Fixes:
91 | - issue 10: Incorrect encoding of packed fields when serialized
92 |
93 | ===============================================================================
94 | RELEASE NOTES - Version 0.9.0
95 | ===============================================================================
96 |
97 | - Initial release
98 |
99 | ===============================================================================
--------------------------------------------------------------------------------
/Quanter.Trader.Messages/ClientMessages.cs:
--------------------------------------------------------------------------------
1 | using Quanter.BusinessEntity;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace Quanter.Trader.Messages
9 | {
10 | public enum RequestType : int
11 | {
12 | LOGIN, // 登录
13 | START_MY_STRATEGIES, // 启动
14 | STOP_MY_STRATEGIES, // 停止
15 | PAUSE, // 暂停
16 | RESTORE, // 恢复
17 | GET_ALL_STRATEGIES, // 获取所有策略列表
18 | GET_MY_STRATEGIES, // 获取我的策略
19 | ADD_MY_STRATEGY, // 增加我的策略
20 | REMOVE_MY_STRATEGY, // 移除我的策略
21 | SETUP_STRATEGY, // 配置我的策略
22 | QUERY_STRATEGY_ACCOUNT, // 获取指定策略的账户信息
23 | UPDATE_ACCOUNT, // 更新账户
24 | START_MARKET,
25 | STOP_MARKET
26 | }
27 |
28 | public enum ResponseType : int
29 | {
30 | RETURN_ALL_STRATEGIES,
31 | RETURN_MY_STRATEGIES,
32 | RETURN_LOGIN_INFO,
33 | }
34 |
35 | public class ClientRequest
36 | {
37 | public RequestType? Action { get; set; }
38 |
39 | public int Userid { get; set; }
40 |
41 | public object Body { get; set; }
42 |
43 | }
44 |
45 | public class ClientResponse
46 | {
47 | public ResponseType Action { get; set; }
48 |
49 | public Object Body { get; set; }
50 | }
51 |
52 | public class EStrategyList : List
53 | {
54 |
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/Quanter.Trader.Messages/Constants.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Quanter.Trader.Messages
8 | {
9 | public class ConstantsHelper
10 | {
11 | public static String AKKA_PATH_SERVER = "server";
12 | public static String AKKA_PATH_STRATEGY_MANAGER = "strategy";
13 | public static String AKKA_PATH_MARKET_MANAGER = "market";
14 | public static String AKKA_PATH_PERSISTENCE = "persistence";
15 | public static readonly String AKKA_PATH_TRADER = "trader";
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Quanter.Trader.Messages/ErrorMessages.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Quanter.Trader.Messages
8 | {
9 | public class ErrorResponse
10 | {
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/Quanter.Trader.Messages/MarketMessages.cs:
--------------------------------------------------------------------------------
1 | using Akka.Actor;
2 | using Quanter.Common;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 |
9 | namespace Quanter.Trader.Messages
10 | {
11 | public class ConnectedRequest
12 | {
13 | public String Username { get; set; }
14 | public String Password { get; set; }
15 | }
16 |
17 | public class ConnectedResponse
18 | {
19 | public String Message { get; set; }
20 | }
21 |
22 | public class MarketRequest
23 | {
24 | public enum RequestType
25 | {
26 | INIT,
27 | START,
28 | STOP,
29 | ADD_SECURITIES,
30 | ADD_STRATEGY,
31 | REMOVE_STARTEGY,
32 | }
33 |
34 | public RequestType Type { get; set; }
35 |
36 | public Object Body { get; set; }
37 | }
38 |
39 | public class StopMarketRequest
40 | {
41 |
42 | }
43 |
44 | public class AddStrategyRequest
45 | {
46 | private List secs = new List();
47 | public Securities[] Securitiess { get { return this.secs.ToArray(); } }
48 |
49 | public void AddSecurities(Securities sec)
50 | {
51 | secs.Add(sec);
52 | }
53 | }
54 |
55 | public class RemoveStrategyRequest
56 | {
57 | private List secs = new List();
58 | public Securities[] Securitiess { get { return this.secs.ToArray(); } }
59 |
60 | public void AddSecurities(Securities sec)
61 | {
62 | secs.Add(sec);
63 | }
64 | }
65 |
66 | ///
67 | /// 订阅股票数据请求
68 | ///
69 | public class WatchStockRequest
70 | {
71 | public String Symbol { get; set; }
72 |
73 | public IActorRef Watcher { get; set; }
74 | }
75 |
76 | ///
77 | /// 取消订阅股票数据的请求
78 | ///
79 | public class UnwatchStockRequest
80 | {
81 | public String Symbol { get; set; }
82 |
83 | public IActorRef Watcher { get; set; }
84 | }
85 |
86 | public class StockCurrentBidRequest
87 | {
88 | public String Symbol { get; set; }
89 |
90 | public IActorRef Watcher { get; set; }
91 | }
92 |
93 | public class NewBidArrivedRequest
94 | {
95 | public TickData Bid { get; set; }
96 | }
97 |
98 | public class StockDataResponse
99 | {
100 |
101 | }
102 |
103 | ///
104 | /// 股票历史数据请求
105 | ///
106 | public class StockHistoryDataRequest
107 | {
108 | public DateTime Start { get; set; }
109 | public DateTime End { get; set; }
110 | public String Symbol { get; set; }
111 | }
112 |
113 | public class StockHistoryDataResponse
114 | {
115 |
116 | }
117 |
118 |
119 | }
120 |
--------------------------------------------------------------------------------
/Quanter.Trader.Messages/PersistenceMessages.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Quanter.Trader.Messages
8 | {
9 | public enum PersistenceType
10 | {
11 | INIT_DATABASE,
12 | OPEN,
13 | CLOSE,
14 | SAVE,
15 | UPDATE,
16 | DELETE,
17 | LOAD,
18 | FIND,
19 | LIST,
20 | }
21 | public class PersistenceRequest
22 | {
23 | public PersistenceType Type { get; set; }
24 | public Object Body { get; set; }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/Quanter.Trader.Messages/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的一般信息由以下
6 | // 控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("Stock.Trader.Messages")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Stock.Trader.Messages")]
13 | [assembly: AssemblyCopyright("Copyright © 2015")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | //将 ComVisible 设置为 false 将使此程序集中的类型
18 | //对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
19 | //请将此类型的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("dde08214-ec3a-4dd7-8cee-49973e17ae8f")]
24 |
25 | // 程序集的版本信息由下列四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 生成号
30 | // 修订号
31 | //
32 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
33 | // 方法是按如下所示使用“*”: :
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/Quanter.Trader.Messages/SecuritiesQuotationMessages.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using Quanter.Common;
7 |
8 | namespace Quanter.Trader.Messages
9 | {
10 | public class QuotationRequest
11 | {
12 | public enum RequestType
13 | {
14 | ASKED_SECURITIES, // 请求接收行情的证券列表
15 | RUN, // 开始接收行情
16 | }
17 |
18 | public RequestType Type { get; set; }
19 | public Object Body { get; set; }
20 | }
21 |
22 | public class SecuritiesQuotationRequest
23 | {
24 | public enum RequestType
25 | {
26 |
27 | WATCH_QUOTEDATA,
28 | WATCH_TICKDATA,
29 | WATCH_BARDATA,
30 | UNWATCH,
31 | NEW_TICKDATA,
32 | NEW_BARDATA,
33 | NEW_QUOTEDATA,
34 | }
35 |
36 | public RequestType Type { get; set; }
37 |
38 | public Object Body { get; set; }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/Quanter.Trader.Messages/StrategyMessages.cs:
--------------------------------------------------------------------------------
1 | using Quanter.BusinessEntity;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace Quanter.Trader.Messages
9 | {
10 |
11 | public class StrategiesRequest
12 | {
13 | private EStrategyList sds = new EStrategyList();
14 | public EStrategy[] Strategies { get { return sds.ToArray(); } }
15 |
16 | public void AddStrategy(EStrategy sd)
17 | {
18 | sds.Add(sd);
19 | }
20 |
21 | public void RemoveStrategy(EStrategy sd)
22 | {
23 | sds.Remove(sd);
24 | }
25 | }
26 |
27 | public class StrategiesResponse
28 | {
29 | private EStrategyList sds = new EStrategyList();
30 | public EStrategy[] Strategies { get { return sds.ToArray(); } }
31 |
32 | public void Add(EStrategy sd)
33 | {
34 | sds.Add(sd);
35 | }
36 |
37 | public void Remove(EStrategy sd)
38 | {
39 | sds.Remove(sd);
40 | }
41 |
42 | }
43 |
44 | public class MyStrategiesRequest : StrategiesRequest
45 | {
46 | public String Username { get; set; }
47 |
48 | }
49 |
50 | public class MyStrategiesResponse : StrategiesResponse
51 | {
52 |
53 | }
54 |
55 | public enum StrategyRequestType
56 | {
57 | CREATE,
58 | START,
59 | STOP,
60 | INIT,
61 | SETTLEMENT,
62 | BUY,
63 | SELL
64 | }
65 | public class StrategyRequest
66 | {
67 | public StrategyRequestType Type { get; set; }
68 |
69 | public object Body { get; set; }
70 | }
71 |
72 | public class StrategyResponse
73 | {
74 | public enum ResponseType
75 | {
76 | TICK_ARRIVED,
77 | BAR_ARRIVED,
78 | QUOTE_ARRIVED,
79 | RUN_ARRIVED,
80 | }
81 |
82 | public ResponseType Type { get; set; }
83 |
84 | public object Body { get; set; }
85 | }
86 |
87 | public class StartStrateiesReponse
88 | {
89 |
90 | }
91 |
92 | }
93 |
--------------------------------------------------------------------------------
/Quanter.Trader.Messages/TradeMessages.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Quanter.Trader.Messages
8 | {
9 | public enum OrderType {
10 | BUY,
11 | SELL,
12 | CANCEL,
13 | }
14 |
15 | public enum TradeType
16 | {
17 | ALGO, //算法下单
18 | LIMIT, // 涨跌停板下单
19 | }
20 |
21 | public enum TradeInterface
22 | {
23 | FIX,
24 | CTP,
25 | CTP2,
26 | LTS,
27 | THS,
28 | TDX,
29 | }
30 |
31 | public class Order
32 | {
33 | ///
34 | /// 订单号
35 | ///
36 | public int Id { get; set; }
37 | ///
38 | /// 委托号 > 0,表示成功
39 | /// <=0表示有错误,错误标识在细化
40 | /// -1: 表示资金不足
41 | /// -2: 表示股票数量不足
42 | /// -3: 输入的证券代码不对
43 | ///
44 | public int EntrustNo { get; set; }
45 |
46 | public int StrategyId { get; set; }
47 | public String Symbol { get; set; }
48 | public float Price { get; set; }
49 | public int Amount { get; set; }
50 | public OrderType Type { get; set; }
51 |
52 | ///
53 | /// 下单时间
54 | ///
55 | public DateTime Date { get; set; }
56 |
57 | }
58 |
59 | public class TradeRequest
60 | {
61 | public enum RequestType
62 | {
63 | INIT,
64 | BUY,
65 | SELL,
66 | KEEP,
67 | }
68 |
69 | public RequestType Type { get; set; }
70 |
71 | public OrderType OrderType { get; set; }
72 |
73 | public TradeInterface TradeInterface { get; set; }
74 |
75 | public TradeType TradeType { get; set; }
76 |
77 | public Order SecuritiesOrder { get; set; }
78 | }
79 |
80 | public class TradeResponse
81 | {
82 | public int EntrustNo { get; set; }
83 | public String Message { get; set; }
84 | }
85 |
86 | public class TradeManagerRequest
87 | {
88 | public enum RequestType
89 | {
90 | INIT,
91 | }
92 |
93 | public RequestType Type { get; set; }
94 | public Object Body { get; set; }
95 | }
96 |
97 | }
98 |
--------------------------------------------------------------------------------
/Quanter.Trader.Messages/UserMessages.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Quanter.Trader.Messages
8 | {
9 | public enum UserActionType
10 | {
11 | LOGIN,
12 | REGISTER,
13 | FETCH_MY_STRATEGIES,
14 | ADD_MY_STRATEGY,
15 | REMOVE_MY_STRATEGY,
16 | START_ALL_STRATEGY,
17 | STOP_ALL_STRATEGY,
18 | }
19 |
20 | public class UserRequest
21 | {
22 | public UserActionType Action { get; set; }
23 |
24 | public Object Body { get; set; }
25 | }
26 |
27 | public class UserResponse
28 | {
29 | public Object Body { get; set; }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/Quanter.Trader.Messages/app.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
45 |
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/Quanter.Trader.Messages/licenses/license.txt:
--------------------------------------------------------------------------------
1 | Protocol Buffers - Google's data interchange format
2 | Copyright 2008-2010 Google Inc. All rights reserved.
3 | http://github.com/jskeet/dotnet-protobufs/
4 | Original C++/Java/Python code:
5 | http://code.google.com/p/protobuf/
6 |
7 | Redistribution and use in source and binary forms, with or without
8 | modification, are permitted provided that the following conditions are
9 | met:
10 |
11 | * Redistributions of source code must retain the above copyright
12 | notice, this list of conditions and the following disclaimer.
13 | * Redistributions in binary form must reproduce the above
14 | copyright notice, this list of conditions and the following disclaimer
15 | in the documentation and/or other materials provided with the
16 | distribution.
17 | * Neither the name of Google Inc. nor the names of its
18 | contributors may be used to endorse or promote products derived from
19 | this software without specific prior written permission.
20 |
21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 |
--------------------------------------------------------------------------------
/Quanter.Trader.Messages/licenses/protoc-license.txt:
--------------------------------------------------------------------------------
1 | protoc.exe was built from the original source at http://code.google.com/p/protobuf/
2 | The licence for this code is as follows:
3 |
4 | Copyright 2008, Google Inc.
5 | All rights reserved.
6 |
7 | Redistribution and use in source and binary forms, with or without
8 | modification, are permitted provided that the following conditions are
9 | met:
10 |
11 | * Redistributions of source code must retain the above copyright
12 | notice, this list of conditions and the following disclaimer.
13 | * Redistributions in binary form must reproduce the above
14 | copyright notice, this list of conditions and the following disclaimer
15 | in the documentation and/or other materials provided with the
16 | distribution.
17 | * Neither the name of Google Inc. nor the names of its
18 | contributors may be used to endorse or promote products derived from
19 | this software without specific prior written permission.
20 |
21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 |
33 | Code generated by the Protocol Buffer compiler is owned by the owner
34 | of the input file used when generating it. This code is not
35 | standalone and requires a support library to be linked with it. This
36 | support library is itself covered by the above license.
--------------------------------------------------------------------------------
/Quanter.Trader.Messages/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Quanter.Trader.Messages/protos/google/protobuf/csharp_options.proto:
--------------------------------------------------------------------------------
1 | // Extra options for C# generator
2 |
3 | import "google/protobuf/descriptor.proto";
4 |
5 | package google.protobuf;
6 |
7 | message CSharpFileOptions {
8 |
9 | // Namespace for generated classes; defaults to the package.
10 | optional string namespace = 1;
11 |
12 | // Name of the "umbrella" class used for metadata about all
13 | // the messages within this file. Default is based on the name
14 | // of the file.
15 | optional string umbrella_classname = 2;
16 |
17 | // Whether classes should be public (true) or internal (false)
18 | optional bool public_classes = 3 [default = true];
19 |
20 | // Whether to generate a single file for everything within the
21 | // .proto file (false), or one file per message (true).
22 | // This option is not currently honored; please log a feature
23 | // request if you really want it.
24 | optional bool multiple_files = 4;
25 |
26 | // Whether to nest messages within a single umbrella class (true)
27 | // or create the umbrella class as a peer, with messages as
28 | // top-level classes in the namespace (false)
29 | optional bool nest_classes = 5;
30 |
31 | // Generate appropriate support for Code Contracts
32 | // (Ongoing; support should improve over time)
33 | optional bool code_contracts = 6;
34 |
35 | // Create subdirectories for namespaces, e.g. namespace "Foo.Bar"
36 | // would generate files within [output directory]/Foo/Bar
37 | optional bool expand_namespace_directories = 7;
38 |
39 | // Generate attributes indicating non-CLS-compliance
40 | optional bool cls_compliance = 8 [default = true];
41 |
42 | // Generate messages/builders with the [Serializable] attribute
43 | optional bool add_serializable = 9 [default = false];
44 |
45 | // Generates a private ctor for Message types
46 | optional bool generate_private_ctor = 10 [default = true];
47 |
48 | // The extension that should be appended to the umbrella_classname when creating files.
49 | optional string file_extension = 221 [default = ".cs"];
50 |
51 | // A nested namespace for the umbrella class. Helpful for name collisions caused by
52 | // umbrella_classname conflicting with an existing type. This will be automatically
53 | // set to 'Proto' if a collision is detected with types being generated. This value
54 | // is ignored when nest_classes == true
55 | optional string umbrella_namespace = 222;
56 |
57 | // The output path for the source file(s) generated
58 | optional string output_directory = 223 [default = "."];
59 |
60 | // Will ignore the type generations and remove dependencies for the descriptor proto
61 | // files that declare their package to be "google.protobuf"
62 | optional bool ignore_google_protobuf = 224 [default = false];
63 |
64 | // Controls how services are generated, GENERIC is the deprecated original implementation
65 | // INTERFACE generates service interfaces only, RPCINTEROP generates interfaces and
66 | // implementations using the included Windows RPC interop libarary.
67 | optional CSharpServiceType service_generator_type = 225 [default = NONE];
68 |
69 | // Used to add the System.Runtime.CompilerServices.CompilerGeneratedAttribute and
70 | // System.CodeDom.Compiler.GeneratedCodeAttribute attributes to generated code.
71 | optional bool generated_code_attributes = 226 [default = false];
72 | }
73 |
74 | enum CSharpServiceType {
75 | // Services are ignored by the generator
76 | NONE = 0;
77 | // Generates the original Java generic service implementations
78 | GENERIC = 1;
79 | // Generates an interface for the service and nothing else
80 | INTERFACE = 2;
81 | // Generates an interface for the service and client/server wrappers for the interface
82 | IRPCDISPATCH = 3;
83 | }
84 |
85 | extend FileOptions {
86 | optional CSharpFileOptions csharp_file_options = 1000;
87 | }
88 |
89 | extend FieldOptions {
90 | optional CSharpFieldOptions csharp_field_options = 1000;
91 | }
92 |
93 | message CSharpFieldOptions {
94 | // Provides the ability to override the name of the property
95 | // generated for this field. This is applied to all properties
96 | // and methods to do with this field, including HasFoo, FooCount,
97 | // FooList etc.
98 | optional string property_name = 1;
99 | }
100 |
101 | message CSharpServiceOptions {
102 | optional string interface_id = 1;
103 | }
104 |
105 | extend ServiceOptions {
106 | optional CSharpServiceOptions csharp_service_options = 1000;
107 | }
108 |
109 | message CSharpMethodOptions {
110 | optional int32 dispatch_id = 1;
111 | }
112 |
113 | extend MethodOptions {
114 | optional CSharpMethodOptions csharp_method_options = 1000;
115 | }
--------------------------------------------------------------------------------
/Quanter.Trader.Messages/protos/tutorial/addressbook.proto:
--------------------------------------------------------------------------------
1 | package tutorial;
2 |
3 | import "google/protobuf/csharp_options.proto";
4 | option (google.protobuf.csharp_file_options).namespace = "Google.ProtocolBuffers.Examples.AddressBook";
5 | option (google.protobuf.csharp_file_options).umbrella_classname = "AddressBookProtos";
6 |
7 | option optimize_for = SPEED;
8 |
9 | message Person {
10 | required string name = 1;
11 | required int32 id = 2; // Unique ID number for this person.
12 | optional string email = 3;
13 |
14 | enum PhoneType {
15 | MOBILE = 0;
16 | HOME = 1;
17 | WORK = 2;
18 | }
19 |
20 | message PhoneNumber {
21 | required string number = 1;
22 | optional PhoneType type = 2 [default = HOME];
23 | }
24 |
25 | repeated PhoneNumber phone = 4;
26 | }
27 |
28 | // Our address book file is just one of these.
29 | message AddressBook {
30 | repeated Person person = 1;
31 | }
32 |
--------------------------------------------------------------------------------
/Quanter.Trader.StrategyServer/CHANGES.txt:
--------------------------------------------------------------------------------
1 | ===============================================================================
2 | Welcome to the C# port of Google Protocol Buffers, written by Jon Skeet
3 | (skeet@pobox.com) based on the work of many talented people.
4 |
5 | For more information about this port, visit its homepage:
6 | http://protobuf-csharp-port.googlecode.com
7 |
8 | For more information about Protocol Buffers in general, visit the project page
9 | for the C++, Java and Python project:
10 | http://protobuf.googlecode.com
11 | ===============================================================================
12 | RELEASE NOTES - Version 2.4.1.473
13 | ===============================================================================
14 |
15 | Features:
16 | - Added option service_generator_type to control service generation with
17 | NONE, GENERIC, INTERFACE, or IRPCDISPATCH
18 | - Added interfaces IRpcDispatch and IRpcServerStub to provide for blocking
19 | services and implementations.
20 | - Added ProtoGen.exe command-line argument "--protoc_dir=" to specify the
21 | location of protoc.exe.
22 | - Extracted interfaces for ICodedInputStream and ICodedOutputStream to allow
23 | custom implementation of writers with both speed and size optimizations.
24 | - Addition of the "Google.ProtoBuffers.Serialization" assembly to support
25 | reading and writing messages to/from XML, JSON, IDictionary<,> and others.
26 | - Several performance related fixes and tweeks
27 | - Issue 3: Add option to mark generated code with attribute
28 | - Issue 20: Support for decorating classes [Serializable]
29 | - Issue 21: Decorate fields with [deprecated=true] as [System.Obsolete]
30 | - Issue 22: Reusable Builder classes
31 | - Issue 24: Support for using Json/Xml formats with ICodedInputStream
32 | - Issue 25: Added support for NuGet packages
33 | - Issue 31: Upgraded protoc.exe and descriptor to 2.4.1
34 |
35 | Fixes:
36 | - Issue 13: Message with Field same name as message causes uncompilable .cs
37 | - Issue 16: Does not integrate well with other tooling
38 | - Issue 19: Support for negative enum values
39 | - Issue 26: AddRange in GeneratedBuilder iterates twice.
40 | - Issue 27: Remove XML documentation output from test projects to clear
41 | warnings/errors.
42 | - Issue 28: Circular message dependencies result in null default values for
43 | Message fields.
44 | - Issue 29: Message classes generated have a public default constructor. You
45 | can disable private ctor generation with the option generate_private_ctor.
46 | - Issue 35: Fixed a bug in ProtoGen handling of arguments with trailing \
47 | - Big-endian support for float, and double on Silverlight
48 | - Packed and Unpacked parsing allow for all repeated, as per version 2.3
49 | - Fix for leaving Builder a public ctor on internal classes for use with
50 | generic "where T: new()" constraints.
51 |
52 | Other:
53 | - Changed the code signing key to a privately held key
54 | - Reformatted all code and line-endings to C# defaults
55 | - Reworking of performance benchmarks to produce reliable results, option /v2
56 | - Issue 34: Silverlight assemblies are now unit tested
57 |
58 | ===============================================================================
59 | RELEASE NOTES - Version 2.3.0.277
60 | ===============================================================================
61 |
62 | Features:
63 | - Added cls_compliance option to generate attributes indicating
64 | non-CLS-compliance.
65 | - Added file_extension option to control the generated output file's extension.
66 | - Added umbrella_namespace option to place the umbrella class into a nested
67 | namespace to address issues with proto files having the same name as a
68 | message it contains.
69 | - Added output_directory option to set the output path for the source file(s).
70 | - Added ignore_google_protobuf option to avoid generating code for includes
71 | from the google.protobuf package.
72 | - Added the LITE framework (Google.ProtoBuffersLite.dll) and the ability to
73 | generate code with "option optimize_for = LITE_RUNTIME;".
74 | - Added ability to invoke protoc.exe from within ProtoGen.exe.
75 | - Upgraded to protoc.exe (2.3) compiler.
76 |
77 | Fixes:
78 | - Issue 9: Class cannot be static and sealed error
79 | - Issue 12: default value for enumerate fields must be filled out
80 |
81 | Other:
82 | - Rewrite of build using MSBbuild instead of NAnt
83 | - Moved to NUnit Version 2.2.8.0
84 | - Changed to using secure .snk for releases
85 |
86 | ===============================================================================
87 | RELEASE NOTES - Version 0.9.1
88 | ===============================================================================
89 |
90 | Fixes:
91 | - issue 10: Incorrect encoding of packed fields when serialized
92 |
93 | ===============================================================================
94 | RELEASE NOTES - Version 0.9.0
95 | ===============================================================================
96 |
97 | - Initial release
98 |
99 | ===============================================================================
--------------------------------------------------------------------------------
/Quanter.Trader.StrategyServer/IAccount.cs:
--------------------------------------------------------------------------------
1 | using Stock.Common;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace Stock.Trader.Strategy
9 | {
10 | public interface IAccount
11 | {
12 |
13 | void BuySecurities(Securities securities, float price, int amount);
14 |
15 | void SellSecurities(Securities securities, float price, int amount);
16 |
17 | void CancelSecurities(int entrustNo);
18 |
19 |
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/Quanter.Trader.StrategyServer/IStrategy.cs:
--------------------------------------------------------------------------------
1 | using Quanter.Common;
2 | using Quanter.Domain;
3 | using Quanter.Trader.Messages;
4 | using System;
5 | using System.Collections.Generic;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 |
10 | namespace Quanter.Strategy
11 | {
12 | public interface IStrategy
13 | {
14 | int Id { get; }
15 |
16 | String Name { get; set; }
17 |
18 | StrategyDesc Desc { get; set; }
19 |
20 | TradeMode TradeMode { get; set; }
21 |
22 | List SecuritiesList { get; set; }
23 |
24 | ///
25 | /// 初始化策略
26 | ///
27 | void Init();
28 |
29 | ///
30 | /// 启动策略
31 | ///
32 | void Start();
33 |
34 | ///
35 | /// 停止策略
36 | ///
37 | void Stop();
38 |
39 | ///
40 | /// Tick 数据到达
41 | ///
42 | void OnTickData();
43 |
44 | ///
45 | /// Bar数据到达
46 | ///
47 | void OnBarData();
48 |
49 | ///
50 | /// 报价数据到达
51 | ///
52 | void OnQuoteData();
53 |
54 | ///
55 | /// 外部其他因素触发
56 | ///
57 | void Run();
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/Quanter.Trader.StrategyServer/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的一般信息由以下
6 | // 控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("Stock.Trader.StrategyServer")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Stock.Trader.StrategyServer")]
13 | [assembly: AssemblyCopyright("Copyright © 2015")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | //将 ComVisible 设置为 false 将使此程序集中的类型
18 | //对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
19 | //请将此类型的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("f0e12b5e-7012-4345-b4a4-be4cedce5e91")]
24 |
25 | // 程序集的版本信息由下列四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 生成号
30 | // 修订号
31 | //
32 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
33 | // 方法是按如下所示使用“*”: :
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/Quanter.Trader.StrategyServer/Risk/IRiskRule.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Quanter.Strategy.Risk
8 | {
9 | public interface IRiskRule
10 | {
11 | String Title { get; }
12 |
13 | RiskActions Action { get; set; }
14 |
15 | ///
16 | /// 处理单个订单,资金组合等
17 | ///
18 | ///
19 | bool ProcessMessage(RiskMessage message);
20 |
21 | void Reset();
22 | }
23 |
24 | public class RiskMessage
25 | {
26 | public enum MessageType
27 | {
28 | ORDER,
29 | }
30 |
31 | public MessageType Type { get; set; }
32 | public Object Body { get; set; }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/Quanter.Trader.StrategyServer/Risk/RiskActions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Quanter.Strategy.Risk
8 | {
9 | public enum RiskActions
10 | {
11 | CancelOrder,
12 | }
13 |
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/Quanter.Trader.StrategyServer/Risk/RiskManager.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Quanter.Strategy.Risk
8 | {
9 | public class RiskManager
10 | {
11 | private readonly IList _rules = new List();
12 |
13 | public void Reset()
14 | {
15 | _rules.AsParallel().ForAll( r => r.Reset());
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/Quanter.Trader.StrategyServer/Risk/RiskRules.cs:
--------------------------------------------------------------------------------
1 | using CsvHelper;
2 | using Quanter.Trader.Messages;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.IO;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 |
10 | namespace Quanter.Strategy.Risk
11 | {
12 | public abstract class AbstractRiskRule : IRiskRule
13 | {
14 | public RiskActions Action { get; set; }
15 |
16 | public string Title { get; protected set; }
17 |
18 | public abstract bool ProcessMessage(RiskMessage message);
19 |
20 | public void Reset()
21 | {
22 |
23 | }
24 | }
25 |
26 | public class PnLRiskRule : AbstractRiskRule
27 | {
28 | private decimal pnL;
29 | public decimal PnL
30 | {
31 | get { return this.pnL; }
32 | set {
33 | this.pnL = value;
34 | Title = pnL.ToString();
35 | }
36 | }
37 | public override bool ProcessMessage(RiskMessage message)
38 | {
39 | throw new NotImplementedException();
40 | }
41 | }
42 |
43 | public class BlankListRiskRule : AbstractRiskRule
44 | {
45 | private IList symbols = new List();
46 |
47 | public BlankListRiskRule(String file)
48 | {
49 | _init(file);
50 | this.Title = "黑名单管理";
51 | }
52 |
53 | private void _init(String file)
54 | {
55 | using (StreamReader sr = new StreamReader(file))
56 | using (CsvReader reader = new CsvReader(sr))
57 | {
58 | while (reader.Read())
59 | {
60 | String symbol = reader.GetField(0);
61 | AddBlankList(symbol);
62 | }
63 | }
64 | }
65 |
66 | public void AddBlankList(String symbol)
67 | {
68 | symbols.Add(symbol);
69 | }
70 |
71 | public override bool ProcessMessage(RiskMessage message)
72 | {
73 | bool ret = false;
74 | switch (message.Type)
75 | {
76 | case RiskMessage.MessageType.ORDER:
77 | ret = _processOrder((Order)message.Body);
78 | break;
79 | default:
80 | break;
81 | }
82 | return ret;
83 | }
84 |
85 | private bool _processOrder(Order order)
86 | {
87 | if (symbols.Contains(order.Symbol))
88 | {
89 | Action = RiskActions.CancelOrder;
90 | return false;
91 | }
92 |
93 | return true;
94 |
95 | }
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/Quanter.Trader.StrategyServer/StrategyActor.cs:
--------------------------------------------------------------------------------
1 | using Akka.Actor;
2 | using Akka.Event;
3 | using Quanter.Common;
4 | using Quanter.Trader.Messages;
5 | using System;
6 |
7 | namespace Quanter.Strategy
8 | {
9 | ///
10 | /// 接收的消息
11 | /// 1、价格变动
12 | /// 2、启动策略
13 | /// 3、停止策略
14 | ///
15 | /// 发出的请求
16 | /// 1、订阅证券价格 证券市场
17 | /// 2、取消订阅证券价格 证券市场
18 | /// 3、下单操作 交易接口
19 | ///
20 | public class StrategyActor : TypedActor
21 | {
22 | private readonly ILoggingAdapter log = Logging.GetLogger(Context);
23 |
24 | private ActorSelection _market = null;
25 |
26 | IStrategy strategy = null;
27 |
28 | public StrategyActor(IStrategy strategy)
29 | {
30 | this.strategy = strategy;
31 | }
32 |
33 | private void _start()
34 | {
35 | if (strategy.TradeMode == TradeMode.BACK_TEST)
36 | {
37 | // 获取历史行情
38 | _market = Context.ActorSelection("akka.tcp://myServer@localhost:8081/securities/market/history");
39 | }
40 | else
41 | {
42 | //
43 | _market = Context.ActorSelection("akka.tcp://myServer@localhost:8081/securities/market");
44 | }
45 | _watchStock();
46 | strategy.Start();
47 | }
48 |
49 | private void _stop()
50 | {
51 | _unwatchStock();
52 | strategy.Stop();
53 | }
54 |
55 | private void _tickData(TickData data)
56 | {
57 | strategy.OnTickData();
58 | }
59 |
60 | ///
61 | /// Bar数据达到
62 | ///
63 | ///
64 | private void _barData(TickData data)
65 | {
66 | strategy.OnBarData();
67 | }
68 |
69 | private void _quoteData()
70 | {
71 | strategy.OnQuoteData();
72 | }
73 |
74 | private void _run()
75 | {
76 | strategy.Run();
77 | }
78 |
79 | ///
80 | /// 创建一个策略
81 | ///
82 | private void _createStrategy()
83 | {
84 | strategy = null;
85 | }
86 |
87 | ///
88 | /// 下单操作
89 | ///
90 | private void _createOrder(String symbol, float price, int amount, OrderType type)
91 | {
92 | // IAccount account = strategy as IAccount;
93 | }
94 |
95 | ///
96 | /// 订阅股票价格
97 | ///
98 | private void _watchStock()
99 | {
100 | foreach (var item in strategy.SecuritiesList)
101 | {
102 | _market.Tell("订阅价格");
103 | }
104 | }
105 |
106 | ///
107 | /// 取消订阅股票价格
108 | ///
109 | private void _unwatchStock()
110 | {
111 | foreach (var item in strategy.SecuritiesList)
112 | {
113 | _market.Tell("取消订阅价格");
114 | }
115 | }
116 |
117 | }
118 | }
--------------------------------------------------------------------------------
/Quanter.Trader.StrategyServer/StrategyManagerActor.cs:
--------------------------------------------------------------------------------
1 | using Akka.Actor;
2 | using Akka.Event;
3 | using Quanter.BusinessEntity;
4 | using Quanter.Trader.Messages;
5 | using System;
6 | using System.Collections.Generic;
7 | using System.Linq;
8 | using System.Text;
9 | using System.Threading.Tasks;
10 |
11 | namespace Quanter.Strategy
12 | {
13 | ///
14 | /// 处理的接收消息有
15 | /// 1、启动指定的策略 StartStrategiesRequest
16 | /// 2、注册策略
17 | /// 3、配置指定的策略 SetupStrategyRequest
18 | /// 4、停止所有的策略(depreated)
19 | /// 5、停止指定的策略 StopStrategiesRequest
20 | /// 6、请求所有的策略列表 StrategiesRequest
21 | ///
22 | /// 发出的请求有
23 | /// 1、证券市场订阅关注的证券
24 | /// 2、证券市场取消关注的证券
25 | /// 3、
26 | ///
27 | public class StrategyManagerActor : TypedActor, IHandle// , IHandle
28 | {
29 | private readonly ILoggingAdapter _log = Logging.GetLogger(Context);
30 |
31 | private Dictionary strategyActors = new Dictionary();
32 |
33 | public void Handle(StrategyRequest message)
34 | {
35 | switch(message.Type)
36 | {
37 | case StrategyRequestType.CREATE:
38 | _createStrategyActor((EStrategy)message.Body);
39 | break;
40 | case StrategyRequestType.START:
41 | case StrategyRequestType.STOP:
42 | _log.Error("错误的Request Type {0}", message.Type);
43 | break;
44 | default:
45 | _log.Warning("不支持的Request Type {0}", message.Type);
46 | break;
47 | }
48 | }
49 |
50 | private void _createStrategyActor(EStrategy sd)
51 | {
52 | if (!strategyActors.ContainsKey(sd.Id))
53 | {
54 | _log.Info("创建策略 {0}", sd.Id);
55 | Type t = Type.GetType(sd.Type);
56 | var strategyActor = Context.ActorOf(Props.Create(t, sd), sd.Id.ToString());
57 | strategyActor.Tell(new StrategyRequest() { Type = StrategyRequestType.INIT });
58 | strategyActors.Add(sd.Id, strategyActor);
59 | }else
60 | {
61 | _log.Warning("重复注册策略,策略号 {0}", sd.Id);
62 | }
63 | }
64 |
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/Quanter.Trader.StrategyServer/TradeMode.cs:
--------------------------------------------------------------------------------
1 | namespace Quanter.Strategy
2 | {
3 | ///
4 | /// 支持三种交易方式, 其中回测必须的数据源必须是历史数据,下单为虚拟下单
5 | ///
6 | public enum TradeMode
7 | {
8 | BACK_TEST, // 回测
9 | MOCK_TRADE, // 模拟交易
10 | AUTO_TRADE, // 实盘自动交易
11 | }
12 | }
--------------------------------------------------------------------------------
/Quanter.Trader.StrategyServer/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/Quanter.Trader.StrategyServer/licenses/license.txt:
--------------------------------------------------------------------------------
1 | Protocol Buffers - Google's data interchange format
2 | Copyright 2008-2010 Google Inc. All rights reserved.
3 | http://github.com/jskeet/dotnet-protobufs/
4 | Original C++/Java/Python code:
5 | http://code.google.com/p/protobuf/
6 |
7 | Redistribution and use in source and binary forms, with or without
8 | modification, are permitted provided that the following conditions are
9 | met:
10 |
11 | * Redistributions of source code must retain the above copyright
12 | notice, this list of conditions and the following disclaimer.
13 | * Redistributions in binary form must reproduce the above
14 | copyright notice, this list of conditions and the following disclaimer
15 | in the documentation and/or other materials provided with the
16 | distribution.
17 | * Neither the name of Google Inc. nor the names of its
18 | contributors may be used to endorse or promote products derived from
19 | this software without specific prior written permission.
20 |
21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 |
--------------------------------------------------------------------------------
/Quanter.Trader.StrategyServer/licenses/protoc-license.txt:
--------------------------------------------------------------------------------
1 | protoc.exe was built from the original source at http://code.google.com/p/protobuf/
2 | The licence for this code is as follows:
3 |
4 | Copyright 2008, Google Inc.
5 | All rights reserved.
6 |
7 | Redistribution and use in source and binary forms, with or without
8 | modification, are permitted provided that the following conditions are
9 | met:
10 |
11 | * Redistributions of source code must retain the above copyright
12 | notice, this list of conditions and the following disclaimer.
13 | * Redistributions in binary form must reproduce the above
14 | copyright notice, this list of conditions and the following disclaimer
15 | in the documentation and/or other materials provided with the
16 | distribution.
17 | * Neither the name of Google Inc. nor the names of its
18 | contributors may be used to endorse or promote products derived from
19 | this software without specific prior written permission.
20 |
21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 |
33 | Code generated by the Protocol Buffer compiler is owned by the owner
34 | of the input file used when generating it. This code is not
35 | standalone and requires a support library to be linked with it. This
36 | support library is itself covered by the above license.
--------------------------------------------------------------------------------
/Quanter.Trader.StrategyServer/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/Quanter.Trader.StrategyServer/protos/google/protobuf/csharp_options.proto:
--------------------------------------------------------------------------------
1 | // Extra options for C# generator
2 |
3 | import "google/protobuf/descriptor.proto";
4 |
5 | package google.protobuf;
6 |
7 | message CSharpFileOptions {
8 |
9 | // Namespace for generated classes; defaults to the package.
10 | optional string namespace = 1;
11 |
12 | // Name of the "umbrella" class used for metadata about all
13 | // the messages within this file. Default is based on the name
14 | // of the file.
15 | optional string umbrella_classname = 2;
16 |
17 | // Whether classes should be public (true) or internal (false)
18 | optional bool public_classes = 3 [default = true];
19 |
20 | // Whether to generate a single file for everything within the
21 | // .proto file (false), or one file per message (true).
22 | // This option is not currently honored; please log a feature
23 | // request if you really want it.
24 | optional bool multiple_files = 4;
25 |
26 | // Whether to nest messages within a single umbrella class (true)
27 | // or create the umbrella class as a peer, with messages as
28 | // top-level classes in the namespace (false)
29 | optional bool nest_classes = 5;
30 |
31 | // Generate appropriate support for Code Contracts
32 | // (Ongoing; support should improve over time)
33 | optional bool code_contracts = 6;
34 |
35 | // Create subdirectories for namespaces, e.g. namespace "Foo.Bar"
36 | // would generate files within [output directory]/Foo/Bar
37 | optional bool expand_namespace_directories = 7;
38 |
39 | // Generate attributes indicating non-CLS-compliance
40 | optional bool cls_compliance = 8 [default = true];
41 |
42 | // Generate messages/builders with the [Serializable] attribute
43 | optional bool add_serializable = 9 [default = false];
44 |
45 | // Generates a private ctor for Message types
46 | optional bool generate_private_ctor = 10 [default = true];
47 |
48 | // The extension that should be appended to the umbrella_classname when creating files.
49 | optional string file_extension = 221 [default = ".cs"];
50 |
51 | // A nested namespace for the umbrella class. Helpful for name collisions caused by
52 | // umbrella_classname conflicting with an existing type. This will be automatically
53 | // set to 'Proto' if a collision is detected with types being generated. This value
54 | // is ignored when nest_classes == true
55 | optional string umbrella_namespace = 222;
56 |
57 | // The output path for the source file(s) generated
58 | optional string output_directory = 223 [default = "."];
59 |
60 | // Will ignore the type generations and remove dependencies for the descriptor proto
61 | // files that declare their package to be "google.protobuf"
62 | optional bool ignore_google_protobuf = 224 [default = false];
63 |
64 | // Controls how services are generated, GENERIC is the deprecated original implementation
65 | // INTERFACE generates service interfaces only, RPCINTEROP generates interfaces and
66 | // implementations using the included Windows RPC interop libarary.
67 | optional CSharpServiceType service_generator_type = 225 [default = NONE];
68 |
69 | // Used to add the System.Runtime.CompilerServices.CompilerGeneratedAttribute and
70 | // System.CodeDom.Compiler.GeneratedCodeAttribute attributes to generated code.
71 | optional bool generated_code_attributes = 226 [default = false];
72 | }
73 |
74 | enum CSharpServiceType {
75 | // Services are ignored by the generator
76 | NONE = 0;
77 | // Generates the original Java generic service implementations
78 | GENERIC = 1;
79 | // Generates an interface for the service and nothing else
80 | INTERFACE = 2;
81 | // Generates an interface for the service and client/server wrappers for the interface
82 | IRPCDISPATCH = 3;
83 | }
84 |
85 | extend FileOptions {
86 | optional CSharpFileOptions csharp_file_options = 1000;
87 | }
88 |
89 | extend FieldOptions {
90 | optional CSharpFieldOptions csharp_field_options = 1000;
91 | }
92 |
93 | message CSharpFieldOptions {
94 | // Provides the ability to override the name of the property
95 | // generated for this field. This is applied to all properties
96 | // and methods to do with this field, including HasFoo, FooCount,
97 | // FooList etc.
98 | optional string property_name = 1;
99 | }
100 |
101 | message CSharpServiceOptions {
102 | optional string interface_id = 1;
103 | }
104 |
105 | extend ServiceOptions {
106 | optional CSharpServiceOptions csharp_service_options = 1000;
107 | }
108 |
109 | message CSharpMethodOptions {
110 | optional int32 dispatch_id = 1;
111 | }
112 |
113 | extend MethodOptions {
114 | optional CSharpMethodOptions csharp_method_options = 1000;
115 | }
--------------------------------------------------------------------------------
/Quanter.Trader.StrategyServer/protos/tutorial/addressbook.proto:
--------------------------------------------------------------------------------
1 | package tutorial;
2 |
3 | import "google/protobuf/csharp_options.proto";
4 | option (google.protobuf.csharp_file_options).namespace = "Google.ProtocolBuffers.Examples.AddressBook";
5 | option (google.protobuf.csharp_file_options).umbrella_classname = "AddressBookProtos";
6 |
7 | option optimize_for = SPEED;
8 |
9 | message Person {
10 | required string name = 1;
11 | required int32 id = 2; // Unique ID number for this person.
12 | optional string email = 3;
13 |
14 | enum PhoneType {
15 | MOBILE = 0;
16 | HOME = 1;
17 | WORK = 2;
18 | }
19 |
20 | message PhoneNumber {
21 | required string number = 1;
22 | optional PhoneType type = 2 [default = HOME];
23 | }
24 |
25 | repeated PhoneNumber phone = 4;
26 | }
27 |
28 | // Our address book file is just one of these.
29 | message AddressBook {
30 | repeated Person person = 1;
31 | }
32 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Quanter - 策略化交易平台 #
2 | ## 说明
3 | 基于原有的StockStrader改进而来,采用了 [akka.net](https://github.com/akkadotnet) 架构重新构建。
4 | (正在开发中)
5 |
6 | ## 功能
7 | * 开放式策略,完美支持自定义 OK
8 | * 支持多种的开发语言C#, PYTHON, MATLAB
9 | * 支持多种交易接口,LTS,CTP, FIX,同花顺外挂接口OK,华泰Web接口 OK
10 | * 支持自定义交易接口开发 OK
11 | * 同时支持多交易接口,每个策略可以指定一个交易接口 OK
12 | * 支持算法下单
13 | * 支持可视化自定义策略,可自定义指标
14 | * 支持股票公式,兼容通达信常用指标函数
15 | * 支持多策略组合
16 | * 支持虚拟账户,每个策略都有一个虚拟账户 OK
17 | * 支持风险控制,内嵌了3个风控措施。仓位管理,成交量管理,黑名单管理
18 | * 支持策略回测,提供完整的回测报告
19 | * 支持多种数据库(mysql, oracle, sqlite) ok
20 | * ......
21 |
22 | ## 支持
23 | 提供社区支持
24 |
25 | ## 开源协议
26 | Quanter采用 [LGPL 3.0 license](../master/LICENSE).发布
27 |
28 |
--------------------------------------------------------------------------------
/Tests.Quanter.Persistence/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/Tests.Quanter.Persistence/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的一般信息由以下
6 | // 控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("Tests.Stock.Persistence")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Tests.Stock.Persistence")]
13 | [assembly: AssemblyCopyright("Copyright © 2015")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | //将 ComVisible 设置为 false 将使此程序集中的类型
18 | //对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
19 | //请将此类型的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("86c3100a-2b80-4232-972b-4aa2ac97fd81")]
24 |
25 | // 程序集的版本信息由下列四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 生成号
30 | // 修订号
31 | //
32 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
33 | // 方法是按如下所示使用“*”: :
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/Tests.Quanter.Persistence/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------