diff --git a/src/client/spark_excel/rtd/subscriptions/MDSubscribe.cs b/src/client/spark_excel/rtd/subscriptions/MDSubscribe.cs index b2db0617d..a96272d2a 100644 --- a/src/client/spark_excel/rtd/subscriptions/MDSubscribe.cs +++ b/src/client/spark_excel/rtd/subscriptions/MDSubscribe.cs @@ -45,7 +45,7 @@ namespace bts.excel.rtd Venue ven; if (!Utilities.parse_venue(exchange, out ven)) return Observable.Return("Can't Parse Exchange: " + exchange ?? string.Empty); - MDSubscribe.market_data(ven).lookup_security_desc_glbx((uint)security_key, out string desc); + MDSubscribe.market_data(ven).lookup_security_desc((uint)security_key, out string desc); return desc ?? string.Empty; } diff --git a/src/client/spark_fix/spark_fix.csproj b/src/client/spark_fix/spark_fix.csproj index bcc342f02..d854241d7 100644 --- a/src/client/spark_fix/spark_fix.csproj +++ b/src/client/spark_fix/spark_fix.csproj @@ -15,7 +15,7 @@ - + diff --git a/src/client/sparkcmd/Cmd/FIXCommand.cs b/src/client/sparkcmd/Cmd/FIXCommand.cs index 2517708c6..c2036e87e 100644 --- a/src/client/sparkcmd/Cmd/FIXCommand.cs +++ b/src/client/sparkcmd/Cmd/FIXCommand.cs @@ -1,49 +1,58 @@ using System; using System.Linq; -using ManyConsole.CommandLineUtils; +using CommandLine; using bts.fix; namespace bts { - public class FIXCommand : ConsoleCommand + [Verb("fix", HelpText = "Fix command")] + public class FIXCommandOptions { - bool _initiator, _orders, _dropcopy; - string _config, _http; - public FIXCommand() - { - IsCommand("fix", "start a fix acceptor or initiator session"); - HasRequiredOption("f|configfile=", "Set the config file", h => _config = h); - HasOption("i|initiator", "Start a FIX Initiator", h => _initiator = true); - HasOption("w|http=", "Start http server {address}", h => _http = h); + [Option('f', "config", Required = true)] + public string config_file { get; set; } - HasOption("o|order_session", "Start a FIX Acceptor session for orders", h => _orders = true); - HasOption("d|dropcopy_only", "Start a FIX Acceptor session for dropcopy", h => _dropcopy = true); + [Option('i', "initiator", Default = false, Required = false)] + public bool initiator{ get; set; } - //HasAdditionalArguments(null, " [other params]"); - } - public override int Run(string[] remaining_args) + [Option('w', "http", Required = false)] + public string http{ get; set; } + + [Option('o', "order_session", Default = false, Required = false)] + public bool order_session{ get; set; } + + [Option('d', "dropcopy_only", Default = false, Required = false)] + public bool dropcopy_only { get; set; } + } + + public class FIXCommand + { + public static int Run(FIXCommandOptions opt) { - if (_orders) + if (opt.order_session) { - Console.WriteLine("Starting FIX ORDERS Acceptor using " + _config); - if(!string.IsNullOrEmpty(_http)) - Console.WriteLine(" Http server " + _http); - return FixInit.start_acceptor(_config, true, (string.IsNullOrEmpty(_http) ? null : _http)); + Console.WriteLine("Starting FIX ORDERS Acceptor using " + opt.config_file); + if(!string.IsNullOrEmpty(opt.http)) + Console.WriteLine(" Http server " + opt.http); + return FixInit.start_acceptor(opt.config_file, true, (string.IsNullOrEmpty(opt.http) ? null : opt.http)); } - else if (_dropcopy) + else if (opt.dropcopy_only) { - Console.WriteLine("Starting FIX DROP Acceptor using " + _config); - if (!string.IsNullOrEmpty(_http)) - Console.WriteLine(" Http server " + _http); - return FixInit.start_acceptor(_config, false, (string.IsNullOrEmpty(_http) ? null : _http)); + Console.WriteLine("Starting FIX DROP Acceptor using " + opt.config_file); + if (!string.IsNullOrEmpty(opt.http)) + Console.WriteLine(" Http server " + opt.http); + return FixInit.start_acceptor(opt.config_file, false, (string.IsNullOrEmpty(opt.http) ? null : opt.http)); } - else if (_initiator) + else if (opt.initiator) { Console.WriteLine("Initiator not supported yet"); + return -1; } - Console.WriteLine("Must select either orders or dropcopy session"); - return -1; + string[] args = Parser.Default.FormatCommandLine(opt).Split(' '); + var res = Parser.Default.ParseArguments(args); + var help = CommandLine.Text.HelpText.AutoBuild(res, h => h, r => r).ToString(); + Console.WriteLine(help); + return -1; } } } diff --git a/src/client/sparkcmd/Program.cs b/src/client/sparkcmd/Program.cs index 8999b8bcc..d13c81c81 100644 --- a/src/client/sparkcmd/Program.cs +++ b/src/client/sparkcmd/Program.cs @@ -39,7 +39,8 @@ namespace sparkcmd { SettingsManagerOptions, TestCommandOptions, OrderStressOptions, - MBOCommandOptions + MBOCommandOptions, + FIXCommandOptions >(BTS.remove_config_arg(args)) .MapResult< ConfigcheckOptions, @@ -50,6 +51,7 @@ namespace sparkcmd { TestCommandOptions, OrderStressOptions, MBOCommandOptions, + FIXCommandOptions, int>( Configcheck.Run, ScriptClientCommand.Run, @@ -59,6 +61,7 @@ namespace sparkcmd { TestCommand.Run, OrderStress.Run, MBOCommand.Run, + FIXCommand.Run, errors => 1); } } diff --git a/src/client/sparkcmd/sparkcmd.csproj b/src/client/sparkcmd/sparkcmd.csproj index 81232b7fb..6459b95e4 100644 --- a/src/client/sparkcmd/sparkcmd.csproj +++ b/src/client/sparkcmd/sparkcmd.csproj @@ -17,6 +17,7 @@ + diff --git a/src/server/sparkd/fix/FixInit.cpp b/src/server/sparkd/fix/FixInit.cpp new file mode 100644 index 000000000..608208bfc --- /dev/null +++ b/src/server/sparkd/fix/FixInit.cpp @@ -0,0 +1,42 @@ +#include "FixInit.h" + +#include "IFixSession.h" + +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include + +namespace bts +{ +namespace fix +{ + +int FixInit::start_acceptor(const std::string& settings_file, bool orders_allowed) +{ + std::ifstream str{settings_file}; + FIX::SessionSettings settings( str ); + + // std::shared_ptr session; + // if(orders_allowed) + // session.reset(new OrderSession + ex_sim::ExchangeSimApplication application(mbo); + FIX::FileStoreFactory storeFactory( settings ); + FIX::FileLogFactory logFactory( settings ); + FIX::SocketAcceptor acceptor( application, storeFactory, settings, logFactory ); + + acceptor.start(); + +} + +} +} \ No newline at end of file diff --git a/src/server/sparkd/fix/FixInit.h b/src/server/sparkd/fix/FixInit.h new file mode 100644 index 000000000..1d30df552 --- /dev/null +++ b/src/server/sparkd/fix/FixInit.h @@ -0,0 +1,14 @@ +#pragma once + +#include + +namespace bts { +namespace fix { + +class FixInit +{ +public: + static int start_acceptor(const std::string& settings_file, bool orders_allowed); +}; + +}} \ No newline at end of file diff --git a/src/server/sparkd/fix/FixRouter.cpp b/src/server/sparkd/fix/FixRouter.cpp index e69de29bb..cca79f1c0 100644 --- a/src/server/sparkd/fix/FixRouter.cpp +++ b/src/server/sparkd/fix/FixRouter.cpp @@ -0,0 +1,42 @@ +#include "FixRouter.h" + +#include "IFixSession.h" + +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include + +namespace bts +{ +namespace fix +{ + +int FixRouter::start_acceptor(const std::string& settings_file, bool orders_allowed) +{ + std::ifstream str{settings_file}; + FIX::SessionSettings settings( str ); + + // std::shared_ptr session; + // if(orders_allowed) + // session.reset(new OrderSession + ex_sim::ExchangeSimApplication application(mbo); + FIX::FileStoreFactory storeFactory( settings ); + FIX::FileLogFactory logFactory( settings ); + FIX::SocketAcceptor acceptor( application, storeFactory, settings, logFactory ); + + acceptor.start(); + +} + +} +} \ No newline at end of file diff --git a/src/server/sparkd/fix/FixRouter.h b/src/server/sparkd/fix/FixRouter.h index e69de29bb..b244c7c33 100644 --- a/src/server/sparkd/fix/FixRouter.h +++ b/src/server/sparkd/fix/FixRouter.h @@ -0,0 +1,19 @@ +#pragma once + +#include "IFixSession.h" + +#include +#include + +namespace bts { +namespace fix { + +class FixRouter : public IFixSession, public FIX::MessageCracker +{ +public: + + + +}; + +}} \ No newline at end of file diff --git a/src/server/sparkd/fix/IFixRouter.h b/src/server/sparkd/fix/IFixRouter.h new file mode 100644 index 000000000..ce9c279b2 --- /dev/null +++ b/src/server/sparkd/fix/IFixRouter.h @@ -0,0 +1,38 @@ +#pragma once + +#include "lib/domain_model/Security.pb.h" + +#include +#include + +namespace FIX +{ + class Message; + class SessionID; +} + +namespace bts +{ + +namespace api +{ + class Security; +} + +namespace fix +{ + typedef uint32_t security_key; + const security_key invalid_security_key = 0; + + class IFixRouter + { + std::vector get_securities(); + const api::Security* lookup(security_key key); + const api::Security* lookup(const std::string& desc); + + void send(const FIX::Message& mess, const FIX::SessionID& sess); + void send_session_reject(const FIX::SessionID& sess, const std::string& text, const FIX::Message* refmessage = nullptr); + void send_biz_reject(const FIX::SessionID sess, const std::string& text, const FIX::Message& refmessage, int reason_code = 0); + } +} +} diff --git a/src/server/sparkd/fix/IFixSession.h b/src/server/sparkd/fix/IFixSession.h index e69de29bb..462af6b20 100644 --- a/src/server/sparkd/fix/IFixSession.h +++ b/src/server/sparkd/fix/IFixSession.h @@ -0,0 +1,10 @@ +#pragma once + +#include + +namespace bts { +namespace fix { + class IFIXSession : public FIX::Application + { + }; +}} \ No newline at end of file