spark_sdk md works
This commit is contained in:
1 parent
cc815c0778
commit
ebecef31f4
18 files changed
+584
-48
No files matched your search
+1
-1
Submodule docker/linux updated: 95918627ce...735b688327.
+1
-1
Submodule externals updated: 9dd9d7a5dd...445b75b8cc.
+63
-38
@@ -1,10 +1,10 @@
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.27004.2005
|
||||
VisualStudioVersion = 15.0.27130.2024
|
||||
MinimumVisualStudioVersion = 15.0.26124.0
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "spark_api", "src\client\spark_api\spark_api.csproj", "{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "spark_lib", "build\src\lib\spark_lib.vcxproj", "{9186D3A8-1C5C-372A-A4EE-E1045BCCB0C7}"
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "spark_lib", "build\src\lib\spark_lib.vcxproj", "{502FD050-679A-3B50-B438-098500700919}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Spark", "src\client\spark\Spark.csproj", "{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}"
|
||||
EndProject
|
||||
@@ -12,12 +12,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "sparkcmd", "src\client\spar
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "spark_core", "src\client\spark_core\spark_core.csproj", "{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ZERO_CHECK", "build\ZERO_CHECK.vcxproj", "{33E7E6C5-04E3-36A8-A751-639BE5E72B9B}"
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ZERO_CHECK", "build\ZERO_CHECK.vcxproj", "{2256015B-E7D5-3614-8F39-814CA68A4444}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "spark_sdk", "src\client\spark_sdk\spark_sdk.csproj", "{6963C314-83C4-4667-B0D0-C2F7AE208C29}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{502FD050-679A-3B50-B438-098500700919} = {502FD050-679A-3B50-B438-098500700919}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(Performance) = preSolution
|
||||
HasPerformanceSessions = true
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Debug|x64 = Debug|x64
|
||||
@@ -53,22 +55,22 @@ Global
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.RelWithDebInfo|x64.Build.0 = Release|x64
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.RelWithDebInfo|x86.ActiveCfg = Release|x64
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.RelWithDebInfo|x86.Build.0 = Release|x64
|
||||
{9186D3A8-1C5C-372A-A4EE-E1045BCCB0C7}.Debug|Any CPU.ActiveCfg = Debug|x64
|
||||
{9186D3A8-1C5C-372A-A4EE-E1045BCCB0C7}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{9186D3A8-1C5C-372A-A4EE-E1045BCCB0C7}.Debug|x64.Build.0 = Debug|x64
|
||||
{9186D3A8-1C5C-372A-A4EE-E1045BCCB0C7}.Debug|x86.ActiveCfg = Debug|x64
|
||||
{9186D3A8-1C5C-372A-A4EE-E1045BCCB0C7}.MinSizeRel|Any CPU.ActiveCfg = MinSizeRel|x64
|
||||
{9186D3A8-1C5C-372A-A4EE-E1045BCCB0C7}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
|
||||
{9186D3A8-1C5C-372A-A4EE-E1045BCCB0C7}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
|
||||
{9186D3A8-1C5C-372A-A4EE-E1045BCCB0C7}.MinSizeRel|x86.ActiveCfg = MinSizeRel|x64
|
||||
{9186D3A8-1C5C-372A-A4EE-E1045BCCB0C7}.Release|Any CPU.ActiveCfg = Release|x64
|
||||
{9186D3A8-1C5C-372A-A4EE-E1045BCCB0C7}.Release|x64.ActiveCfg = Release|x64
|
||||
{9186D3A8-1C5C-372A-A4EE-E1045BCCB0C7}.Release|x64.Build.0 = Release|x64
|
||||
{9186D3A8-1C5C-372A-A4EE-E1045BCCB0C7}.Release|x86.ActiveCfg = Release|x64
|
||||
{9186D3A8-1C5C-372A-A4EE-E1045BCCB0C7}.RelWithDebInfo|Any CPU.ActiveCfg = RelWithDebInfo|x64
|
||||
{9186D3A8-1C5C-372A-A4EE-E1045BCCB0C7}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
|
||||
{9186D3A8-1C5C-372A-A4EE-E1045BCCB0C7}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
|
||||
{9186D3A8-1C5C-372A-A4EE-E1045BCCB0C7}.RelWithDebInfo|x86.ActiveCfg = RelWithDebInfo|x64
|
||||
{502FD050-679A-3B50-B438-098500700919}.Debug|Any CPU.ActiveCfg = Debug|x64
|
||||
{502FD050-679A-3B50-B438-098500700919}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{502FD050-679A-3B50-B438-098500700919}.Debug|x64.Build.0 = Debug|x64
|
||||
{502FD050-679A-3B50-B438-098500700919}.Debug|x86.ActiveCfg = Debug|x64
|
||||
{502FD050-679A-3B50-B438-098500700919}.MinSizeRel|Any CPU.ActiveCfg = MinSizeRel|x64
|
||||
{502FD050-679A-3B50-B438-098500700919}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
|
||||
{502FD050-679A-3B50-B438-098500700919}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
|
||||
{502FD050-679A-3B50-B438-098500700919}.MinSizeRel|x86.ActiveCfg = MinSizeRel|x64
|
||||
{502FD050-679A-3B50-B438-098500700919}.Release|Any CPU.ActiveCfg = Release|x64
|
||||
{502FD050-679A-3B50-B438-098500700919}.Release|x64.ActiveCfg = Release|x64
|
||||
{502FD050-679A-3B50-B438-098500700919}.Release|x64.Build.0 = Release|x64
|
||||
{502FD050-679A-3B50-B438-098500700919}.Release|x86.ActiveCfg = Release|x64
|
||||
{502FD050-679A-3B50-B438-098500700919}.RelWithDebInfo|Any CPU.ActiveCfg = RelWithDebInfo|x64
|
||||
{502FD050-679A-3B50-B438-098500700919}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
|
||||
{502FD050-679A-3B50-B438-098500700919}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
|
||||
{502FD050-679A-3B50-B438-098500700919}.RelWithDebInfo|x86.ActiveCfg = RelWithDebInfo|x64
|
||||
{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}.Debug|Any CPU.ActiveCfg = Debug|x64
|
||||
{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}.Debug|x64.Build.0 = Debug|x64
|
||||
@@ -129,22 +131,42 @@ Global
|
||||
{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}.RelWithDebInfo|x64.Build.0 = Release|x64
|
||||
{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}.RelWithDebInfo|x86.ActiveCfg = Release|x64
|
||||
{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}.RelWithDebInfo|x86.Build.0 = Release|x64
|
||||
{33E7E6C5-04E3-36A8-A751-639BE5E72B9B}.Debug|Any CPU.ActiveCfg = Debug|x64
|
||||
{33E7E6C5-04E3-36A8-A751-639BE5E72B9B}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{33E7E6C5-04E3-36A8-A751-639BE5E72B9B}.Debug|x64.Build.0 = Debug|x64
|
||||
{33E7E6C5-04E3-36A8-A751-639BE5E72B9B}.Debug|x86.ActiveCfg = Debug|x64
|
||||
{33E7E6C5-04E3-36A8-A751-639BE5E72B9B}.MinSizeRel|Any CPU.ActiveCfg = MinSizeRel|x64
|
||||
{33E7E6C5-04E3-36A8-A751-639BE5E72B9B}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
|
||||
{33E7E6C5-04E3-36A8-A751-639BE5E72B9B}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
|
||||
{33E7E6C5-04E3-36A8-A751-639BE5E72B9B}.MinSizeRel|x86.ActiveCfg = MinSizeRel|x64
|
||||
{33E7E6C5-04E3-36A8-A751-639BE5E72B9B}.Release|Any CPU.ActiveCfg = Release|x64
|
||||
{33E7E6C5-04E3-36A8-A751-639BE5E72B9B}.Release|x64.ActiveCfg = Release|x64
|
||||
{33E7E6C5-04E3-36A8-A751-639BE5E72B9B}.Release|x64.Build.0 = Release|x64
|
||||
{33E7E6C5-04E3-36A8-A751-639BE5E72B9B}.Release|x86.ActiveCfg = Release|x64
|
||||
{33E7E6C5-04E3-36A8-A751-639BE5E72B9B}.RelWithDebInfo|Any CPU.ActiveCfg = RelWithDebInfo|x64
|
||||
{33E7E6C5-04E3-36A8-A751-639BE5E72B9B}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
|
||||
{33E7E6C5-04E3-36A8-A751-639BE5E72B9B}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
|
||||
{33E7E6C5-04E3-36A8-A751-639BE5E72B9B}.RelWithDebInfo|x86.ActiveCfg = RelWithDebInfo|x64
|
||||
{2256015B-E7D5-3614-8F39-814CA68A4444}.Debug|Any CPU.ActiveCfg = Debug|x64
|
||||
{2256015B-E7D5-3614-8F39-814CA68A4444}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{2256015B-E7D5-3614-8F39-814CA68A4444}.Debug|x64.Build.0 = Debug|x64
|
||||
{2256015B-E7D5-3614-8F39-814CA68A4444}.Debug|x86.ActiveCfg = Debug|x64
|
||||
{2256015B-E7D5-3614-8F39-814CA68A4444}.MinSizeRel|Any CPU.ActiveCfg = MinSizeRel|x64
|
||||
{2256015B-E7D5-3614-8F39-814CA68A4444}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
|
||||
{2256015B-E7D5-3614-8F39-814CA68A4444}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
|
||||
{2256015B-E7D5-3614-8F39-814CA68A4444}.MinSizeRel|x86.ActiveCfg = MinSizeRel|x64
|
||||
{2256015B-E7D5-3614-8F39-814CA68A4444}.Release|Any CPU.ActiveCfg = Release|x64
|
||||
{2256015B-E7D5-3614-8F39-814CA68A4444}.Release|x64.ActiveCfg = Release|x64
|
||||
{2256015B-E7D5-3614-8F39-814CA68A4444}.Release|x64.Build.0 = Release|x64
|
||||
{2256015B-E7D5-3614-8F39-814CA68A4444}.Release|x86.ActiveCfg = Release|x64
|
||||
{2256015B-E7D5-3614-8F39-814CA68A4444}.RelWithDebInfo|Any CPU.ActiveCfg = RelWithDebInfo|x64
|
||||
{2256015B-E7D5-3614-8F39-814CA68A4444}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
|
||||
{2256015B-E7D5-3614-8F39-814CA68A4444}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
|
||||
{2256015B-E7D5-3614-8F39-814CA68A4444}.RelWithDebInfo|x86.ActiveCfg = RelWithDebInfo|x64
|
||||
{6963C314-83C4-4667-B0D0-C2F7AE208C29}.Debug|Any CPU.ActiveCfg = Debug|x64
|
||||
{6963C314-83C4-4667-B0D0-C2F7AE208C29}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{6963C314-83C4-4667-B0D0-C2F7AE208C29}.Debug|x64.Build.0 = Debug|x64
|
||||
{6963C314-83C4-4667-B0D0-C2F7AE208C29}.Debug|x86.ActiveCfg = Debug|x64
|
||||
{6963C314-83C4-4667-B0D0-C2F7AE208C29}.MinSizeRel|Any CPU.ActiveCfg = Release|x64
|
||||
{6963C314-83C4-4667-B0D0-C2F7AE208C29}.MinSizeRel|Any CPU.Build.0 = Release|x64
|
||||
{6963C314-83C4-4667-B0D0-C2F7AE208C29}.MinSizeRel|x64.ActiveCfg = Release|x64
|
||||
{6963C314-83C4-4667-B0D0-C2F7AE208C29}.MinSizeRel|x64.Build.0 = Release|x64
|
||||
{6963C314-83C4-4667-B0D0-C2F7AE208C29}.MinSizeRel|x86.ActiveCfg = Release|x64
|
||||
{6963C314-83C4-4667-B0D0-C2F7AE208C29}.MinSizeRel|x86.Build.0 = Release|x64
|
||||
{6963C314-83C4-4667-B0D0-C2F7AE208C29}.Release|Any CPU.ActiveCfg = Release|x64
|
||||
{6963C314-83C4-4667-B0D0-C2F7AE208C29}.Release|x64.ActiveCfg = Release|x64
|
||||
{6963C314-83C4-4667-B0D0-C2F7AE208C29}.Release|x64.Build.0 = Release|x64
|
||||
{6963C314-83C4-4667-B0D0-C2F7AE208C29}.Release|x86.ActiveCfg = Release|x64
|
||||
{6963C314-83C4-4667-B0D0-C2F7AE208C29}.RelWithDebInfo|Any CPU.ActiveCfg = Release|x64
|
||||
{6963C314-83C4-4667-B0D0-C2F7AE208C29}.RelWithDebInfo|Any CPU.Build.0 = Release|x64
|
||||
{6963C314-83C4-4667-B0D0-C2F7AE208C29}.RelWithDebInfo|x64.ActiveCfg = Release|x64
|
||||
{6963C314-83C4-4667-B0D0-C2F7AE208C29}.RelWithDebInfo|x64.Build.0 = Release|x64
|
||||
{6963C314-83C4-4667-B0D0-C2F7AE208C29}.RelWithDebInfo|x86.ActiveCfg = Release|x64
|
||||
{6963C314-83C4-4667-B0D0-C2F7AE208C29}.RelWithDebInfo|x86.Build.0 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@@ -152,4 +174,7 @@ Global
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {422D1620-0166-4C26-9A81-CA8A2EB1AB58}
|
||||
EndGlobalSection
|
||||
GlobalSection(Performance) = preSolution
|
||||
HasPerformanceSessions = true
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -17,7 +17,8 @@
|
||||
<RootNamespace>bts</RootNamespace>
|
||||
<LangVersion>7.1</LangVersion>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<WarningsAsErrors />
|
||||
<WarningsAsErrors />
|
||||
<Version>1.0.0</Version>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="../spark_api/spark_api.csproj" />
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace mbts.spark {
|
||||
if (_settings != null && _security != null) {
|
||||
var mid = _handle.mid();
|
||||
(double low, double high) = tick_range(_last_mid, _settings.ticks_to_recenter, _security.Value.ContractSpec);
|
||||
if (mid < low || mid > high ||
|
||||
if (//mid < low || mid > high ||
|
||||
(_last_recenter + TimeSpan.FromSeconds(_settings.seconds_to_recenter) < DateTime.UtcNow)) {
|
||||
trigger_recenter(mid);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace bts.api {
|
||||
public string ToString(string format, IFormatProvider formatProvider=null) =>
|
||||
Format(this, string.IsNullOrEmpty(format) ? _standard_format : Parse(format));
|
||||
|
||||
public static security_key key(Security s) { return s.Id; }
|
||||
public static security_key key(Security s) { return s.Id; }
|
||||
}
|
||||
|
||||
partial struct SecurityImmutable : IComparable<SecurityImmutable>, IComparable {
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
using System;
|
||||
using bts.api;
|
||||
|
||||
namespace bts.api
|
||||
{
|
||||
public static class SecurityExtensions
|
||||
{
|
||||
public static SecurityType security_type(this Security s) { return ((SecurityImmutable)s).security_type(); }
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>netstandard2.0</TargetFrameworks>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<Authors>Blue Trading Systems</Authors>
|
||||
<Company>Blue Trading Systems</Company>
|
||||
<Product>Spark</Product>
|
||||
@@ -11,6 +10,7 @@
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<WarningsAsErrors />
|
||||
<Version>1.0.0</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -22,7 +22,8 @@
|
||||
<Proto3 Include="**/*.proto" />
|
||||
<Proto3 Include="../../lib/api/*.proto" />
|
||||
<Proto3 Include="../../lib/api/services/*.proto" />
|
||||
<Proto3 Remove="../../lib/api/services/MarketDataRelay.proto" />
|
||||
<!--Proto3 Remove="../../lib/api/services/MarketDataRelay.proto" /-->
|
||||
<Proto3 Include="../../lib/md/protos/co2.proto" />
|
||||
<Proto3 Include="../../lib/domain_model/Security.proto" />
|
||||
<Proto3 Include="../../lib/sparkproto/SparkProtos.proto" />
|
||||
<Proto3 Update="../../lib/api/services/OutOfProcessURLListener.proto">
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<WarningsAsErrors />
|
||||
<Version>1.0.0</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -17,12 +18,11 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Proto3 Include="../../lib/md/protos/co2.proto" />
|
||||
<Proto2 Include="../../lib/config/protos/*.proto" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
|
||||
<ItemGroup>
|
||||
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,2 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
@@ -0,0 +1,121 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using bts.api;
|
||||
using bts.api.core;
|
||||
|
||||
namespace bts.sdk
|
||||
{
|
||||
|
||||
public class MainClass
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
MarketDataClient client = new MarketDataClient();
|
||||
if (args.FirstOrDefault() == "ui")
|
||||
{
|
||||
if (args.Length >= 5)
|
||||
{
|
||||
using (var ui = new ui.UISample(client))
|
||||
{
|
||||
ui.simple_price_ui(args[1], args[2], args[3], args[4]);
|
||||
}
|
||||
}
|
||||
else
|
||||
ui_help();
|
||||
}
|
||||
else
|
||||
{
|
||||
MarketDataSample s = new MarketDataSample(client);
|
||||
if (args.FirstOrDefault() == "md")
|
||||
{
|
||||
if (args.Length >= 4)
|
||||
{
|
||||
s.print_channel(args[1], args[2], args[3]);
|
||||
}
|
||||
else
|
||||
md_help();
|
||||
}
|
||||
else if (args.FirstOrDefault() == "md_threaded")
|
||||
{
|
||||
if (args.Length >= 4)
|
||||
{
|
||||
s.print_channel(args[1], args[2], args[3],
|
||||
System.Reactive.Concurrency.Scheduler.Default);
|
||||
}
|
||||
else
|
||||
md_help();
|
||||
}
|
||||
else
|
||||
{
|
||||
help();
|
||||
}
|
||||
|
||||
int ms = 10;
|
||||
string p = args.FirstOrDefault(x => x.Contains("--pump="));
|
||||
if (p != null)
|
||||
ms = int.Parse(p.Replace("--pump=", string.Empty));
|
||||
client.start_pump(TimeSpan.FromMilliseconds(ms))
|
||||
.ContinueWith(ex => Console.WriteLine(ex.ToString()), TaskContinuationOptions.OnlyOnFaulted);
|
||||
wait_for_stop(client);
|
||||
}
|
||||
}
|
||||
|
||||
static void wait_for_stop(MarketDataClient client)
|
||||
{
|
||||
Console.WriteLine("Hit q to stop");
|
||||
ConsoleKeyInfo c;
|
||||
do
|
||||
{
|
||||
c = Console.ReadKey();
|
||||
Console.WriteLine();
|
||||
} while (c.KeyChar != 'q');
|
||||
client.Dispose();
|
||||
}
|
||||
|
||||
static void help()
|
||||
{
|
||||
Console.WriteLine("BTS Spark SDK");
|
||||
Console.WriteLine("Usages: spark_sdk [command] [arguments]");
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("Commands:");
|
||||
Console.WriteLine(" md <Exchange> <SecurityType> <Symbol>");
|
||||
Console.WriteLine(" md_threaded <Exchange> <SecurityType> <Symbol>");
|
||||
Console.WriteLine(" ui");
|
||||
Console.WriteLine(" orders");
|
||||
Console.WriteLine("Arguments:");
|
||||
Console.WriteLine(" --pump=<pump_interval_in_ms>");
|
||||
Environment.Exit(1);
|
||||
}
|
||||
|
||||
static void md_help()
|
||||
{
|
||||
Console.WriteLine("md <exchange> <security_type> <symbol>");
|
||||
Console.WriteLine("This command subscribes to market data for an exchange-type-symbol channel and writes to console.");
|
||||
Console.WriteLine("Marketdata is read off the wire on the same thread as is used to read and print");
|
||||
Console.WriteLine(" example: ui GLBX Future ES 12/21/2018");
|
||||
Console.WriteLine(" ui GLBX Spread ES 12/21/2018");
|
||||
Environment.Exit(1);
|
||||
}
|
||||
|
||||
static void md_threaded_help()
|
||||
{
|
||||
Console.WriteLine("md_threaded <exchange> <security_type> <symbol>");
|
||||
Console.WriteLine("This command subscribes to market data for an exchange-type-symbol channel and writes to console.");
|
||||
Console.WriteLine("Marketdata is read off the wire on one thread and read and printed on another through IScheduler");
|
||||
Console.WriteLine(" example: md_threaded GLBX Future ES");
|
||||
Console.WriteLine(" md_threaded GLBX Spread ES");
|
||||
Environment.Exit(1);
|
||||
}
|
||||
|
||||
static void ui_help()
|
||||
{
|
||||
Console.WriteLine("ui <exchange> <security_type> <symbol> <expiration> <ui_refresh_interval_in_ms>");
|
||||
Console.WriteLine("This command subscribes to market data for a specific security and writes to a UI on a specified refresh interval (in ms).");
|
||||
Console.WriteLine("Marketdata is read off the wire on one thread and posted to the GUI on another through Observable.Timer()");
|
||||
Console.WriteLine(" example: ui GLBX Future ES 12/21/2018 25");
|
||||
Environment.Exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,163 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Reactive.Linq;
|
||||
using System.Reactive.Concurrency;
|
||||
using System.Reactive.Subjects;
|
||||
|
||||
using bts.api;
|
||||
using bts.api.core;
|
||||
using bts.co2;
|
||||
|
||||
namespace bts.sdk
|
||||
{
|
||||
using SecurityChannelKey = System.Tuple<bts.api.Venue, bts.api.SecurityType, string>;
|
||||
using security_key = System.UInt32;
|
||||
|
||||
public class MarketDataClient : IDisposable
|
||||
{
|
||||
readonly ConcurrentDictionary<SecurityChannelKey, BehaviorSubject<ChannelReply>> _replies =
|
||||
new ConcurrentDictionary<SecurityChannelKey, BehaviorSubject<ChannelReply>>();
|
||||
readonly List<IDisposable> _disps = new List<IDisposable>();
|
||||
readonly ConcurrentDictionary<security_key, ChannelUpdate> _data = new ConcurrentDictionary<security_key, ChannelUpdate>();
|
||||
readonly CancellationTokenSource _cts = new CancellationTokenSource();
|
||||
|
||||
readonly Lazy<MarketDataRelay> _md = new Lazy<MarketDataRelay>( () => locate(), true);
|
||||
public MarketDataClient()
|
||||
{
|
||||
}
|
||||
|
||||
static MarketDataRelay locate()
|
||||
{
|
||||
using (var ctx = new api.core.ServiceContext())
|
||||
{
|
||||
//locate the service using the ServiceContext and cache it.
|
||||
//this represents a connection to the server, so we don't want more than one of these instances per application, if we can avoid it
|
||||
return ctx.locate<MarketDataRelay>();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Subscribe to a data channel. This callback comes on the pump thread, you don't want to hold this up
|
||||
/// </summary>
|
||||
/// <param name="exchange"></param>
|
||||
/// <param name="sectype"></param>
|
||||
/// <param name="symbol"></param>
|
||||
/// <returns></returns>
|
||||
public IObservable<ChannelReply> subscribe(Venue exchange, api.SecurityType sectype, string symbol)
|
||||
{
|
||||
var key = Tuple.Create(exchange, sectype, symbol);
|
||||
SecurityChannel channel = new SecurityChannel()
|
||||
{
|
||||
Exchange = exchange,
|
||||
Type = sectype,
|
||||
Symbol = symbol,
|
||||
Flags = (System.UInt32) (MDRequest.Types.Flags.Security | MDRequest.Types.Flags.Bbo | MDRequest.Types.Flags.Depth),
|
||||
};
|
||||
ChannelReply initial = new ChannelReply() { Channel = channel };
|
||||
var sub = new BehaviorSubject<ChannelReply>(initial);
|
||||
_replies[key] = sub;
|
||||
return sub;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Subscribe to a data channel. This callback comes on the scheduler thread, so you don't have to worry about holding up the pump
|
||||
/// </summary>
|
||||
/// <param name="exchange"></param>
|
||||
/// <param name="sectype"></param>
|
||||
/// <param name="symbol"></param>
|
||||
/// <param name="scheduler"></param>
|
||||
/// <returns></returns>
|
||||
public IObservable<ChannelReply> subscribe(Venue exchange, api.SecurityType sectype, string symbol, IScheduler scheduler)
|
||||
{
|
||||
if(scheduler == null)
|
||||
return subscribe(exchange, sectype, symbol);
|
||||
else
|
||||
return subscribe(exchange, sectype, symbol).ObserveOn(scheduler);
|
||||
}
|
||||
|
||||
IObservable<long> timer_observable(TimeSpan interval, IScheduler scheduler = null)
|
||||
{
|
||||
IObservable<long> timer;
|
||||
if (scheduler != null)
|
||||
timer = Observable.Timer(interval, scheduler);
|
||||
else
|
||||
timer = Observable.Timer(interval);
|
||||
return timer;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Subscribe to updates for a single security on a specified update_interval
|
||||
/// </summary>
|
||||
/// <param name="security"></param>
|
||||
/// <param name="update_interval"></param>
|
||||
/// <returns></returns>
|
||||
public IObservable<ChannelUpdate> subscribe(Security security, TimeSpan update_interval)
|
||||
{
|
||||
return subscribe(security, update_interval, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Subscribe to updates for a single security on a specified update_interval, on the specified scheduler
|
||||
/// </summary>
|
||||
/// <param name="security"></param>
|
||||
/// <param name="update_interval"></param>
|
||||
/// <param name="scheduler"></param>
|
||||
/// <returns></returns>
|
||||
public IObservable<ChannelUpdate> subscribe(Security security, TimeSpan update_interval, IScheduler scheduler)
|
||||
{
|
||||
var timer = timer_observable(update_interval, scheduler);
|
||||
return timer.Select(x =>
|
||||
{
|
||||
ChannelUpdate update;
|
||||
var key = Security.key(security);
|
||||
if (_data.TryGetValue(key, out update))
|
||||
return update;
|
||||
else
|
||||
return new ChannelUpdate() { Key = key, Security = security };
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Start pumping market data for all subscribed channels and securities. Call this without await
|
||||
/// </summary>
|
||||
/// <param name="interval"></param>
|
||||
/// <returns></returns>
|
||||
public async Task start_pump(TimeSpan interval)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
MDRequest req = new MDRequest();
|
||||
req.Channels.AddRange(_replies.Values.Select(x => x.Value.Channel));
|
||||
var reply = await _md.Value.requestmd_async(req);
|
||||
if (reply.success)
|
||||
{
|
||||
foreach (var channel in reply.value.Channels)
|
||||
{
|
||||
BehaviorSubject<ChannelReply> rep;
|
||||
if (_replies.TryGetValue(Tuple.Create(channel.Channel.Exchange, channel.Channel.Type, channel.Channel.Symbol), out rep))
|
||||
{
|
||||
rep.OnNext(channel);
|
||||
foreach (var update in channel.Updates)
|
||||
_data[update.Key] = update;
|
||||
}
|
||||
}
|
||||
}
|
||||
await Task.Delay(interval, _cts.Token);
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_cts.Cancel();
|
||||
_cts.Dispose();
|
||||
_disps.ForEach(x => x.Dispose());
|
||||
if(_md.IsValueCreated)
|
||||
_md.Value.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Reactive.Linq;
|
||||
using System.Reactive.Concurrency;
|
||||
using System.Reactive.Subjects;
|
||||
|
||||
using bts.api;
|
||||
using bts.api.core;
|
||||
using bts.co2;
|
||||
|
||||
namespace bts.sdk
|
||||
{
|
||||
|
||||
public class MarketDataSample : IDisposable
|
||||
{
|
||||
readonly MarketDataClient _md;
|
||||
public MarketDataSample(MarketDataClient client)
|
||||
{
|
||||
_md = client;
|
||||
}
|
||||
|
||||
void print_update(ChannelUpdate update)
|
||||
{
|
||||
Console.WriteLine(update.ToString());
|
||||
Console.WriteLine();
|
||||
}
|
||||
|
||||
public void print_channel(string exch, string sectype, string symbol, IScheduler scheduler = null)
|
||||
{
|
||||
Venue ven;
|
||||
if(!Enum.TryParse(exch.ToUpper(), true, out ven))
|
||||
ven = (Venue)Enum.Parse(typeof(Venue), "VENUE_" + exch.ToUpper());
|
||||
|
||||
SecurityType st;
|
||||
if (!Enum.TryParse(sectype.ToUpper(), true, out st))
|
||||
st = (SecurityType)Enum.Parse(typeof(SecurityType), "SECURITY_TYPE" + sectype.ToUpper());
|
||||
_md.subscribe(ven, st, symbol.ToUpper(), scheduler).Subscribe(x =>
|
||||
{
|
||||
foreach(var xx in x.Updates)
|
||||
print_update(xx);
|
||||
});
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_md.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace bts.sdk.ui
|
||||
{
|
||||
public class UISample : IDisposable
|
||||
{
|
||||
readonly MarketDataClient _md;
|
||||
public UISample(MarketDataClient client)
|
||||
{
|
||||
_md = client;
|
||||
}
|
||||
|
||||
public void simple_price_ui(string exch, string sectype, string symbol, string expiration)
|
||||
{
|
||||
#if NET471
|
||||
System.Windows.Forms.Application.EnableVisualStyles();
|
||||
System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false);
|
||||
System.Windows.Forms.Application.Run(new SparkSDKUI());
|
||||
#endif
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
#if NET471
|
||||
System.Windows.Forms.Application.Exit();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
|
||||
<TargetFrameworks>netstandard2.0;net471</TargetFrameworks>
|
||||
<OutputType>Exe</OutputType>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<IncludeSource>true</IncludeSource>
|
||||
<IncludeSymbols>true</IncludeSymbols>
|
||||
<TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);CopyProjectReferencesToPackage</TargetsForTfmSpecificBuildOutput>
|
||||
|
||||
<Authors>Blue Trading Systems</Authors>
|
||||
<Company>Blue Trading Systems</Company>
|
||||
<Product>Spark</Product>
|
||||
<Description />
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<Platforms>x64</Platforms>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<WarningsAsErrors />
|
||||
<Version>1.0.0</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Google.Protobuf" Version="3.4.0" />
|
||||
<PackageReference Include="System.Reactive" Version="3.1.1" />
|
||||
<PackageReference Include="System.Reactive.PlatformServices" Version="3.1.1" />
|
||||
<PackageReference Include="NUnit" Version="3.8.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition=" '$(TargetFramework)' == 'net471' ">
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Deployment" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="../spark_api/spark_api.csproj"/>
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="CopyProjectReferencesToPackage" DependsOnTargets="ResolveReferences">
|
||||
<ItemGroup>
|
||||
<BuildOutputInPackage Include="@(ReferenceCopyLocalPaths->WithMetadataValue('ReferenceSourceTarget', 'ProjectReference'))" />
|
||||
<BuildOutputInPackage Include="$(OutputPath)..\net471\spark_lib.dll"/>
|
||||
</ItemGroup>
|
||||
</Target>
|
||||
</Project>
|
||||
@@ -0,0 +1,45 @@
|
||||
#if NET471
|
||||
|
||||
namespace bts.sdk.ui
|
||||
{
|
||||
partial class SparkSDKUI
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if(disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Text = "SparkSDKUI";
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,27 @@
|
||||
#if NET471
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace bts.sdk.ui
|
||||
{
|
||||
public partial class SparkSDKUI : Form
|
||||
{
|
||||
public SparkSDKUI()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -9,6 +9,7 @@
|
||||
<Product>Spark</Product>
|
||||
<Platforms>x64</Platforms>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<Version>1.0.0</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
Reference in new issue
Block a user