fix fix fix

This commit is contained in:
Kevin Darby committed 2019-09-23 18:16:05 -04:00
1 parent 35a69396f1
commit aa8a56787b
11 files changed
+209 -31

No files matched your search

@@ -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;
}
+1 -1
View File
@@ -15,7 +15,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.4.0" />
<PackageReference Include="Google.Protobuf" Version="3.6.1" />
<PackageReference Include="System.Reactive" Version="3.1.1" />
<PackageReference Include="System.Reactive.PlatformServices" Version="3.1.1" />
<PackageReference Include="NUnit" Version="3.10.1" />
+37 -28
View File
@@ -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<string>("f|configfile=", "Set the config file", h => _config = h);
HasOption<string>("i|initiator", "Start a FIX Initiator", h => _initiator = true);
HasOption<string>("w|http=", "Start http server {address}", h => _http = h);
[Option('f', "config", Required = true)]
public string config_file { get; set; }
HasOption<string>("o|order_session", "Start a FIX Acceptor session for orders", h => _orders = true);
HasOption<string>("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<FIXCommandOptions>(args);
var help = CommandLine.Text.HelpText.AutoBuild(res, h => h, r => r).ToString();
Console.WriteLine(help);
return -1;
}
}
}
+4 -1
View File
@@ -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);
}
}
+1
View File
@@ -17,6 +17,7 @@
<ProjectReference Include="../spark_api/spark_api.csproj" />
<!--<ProjectReference Include="..\spark\Spark.csproj" />-->
<ProjectReference Include="..\spark_core\spark_core.csproj" />
<ProjectReference Include="..\spark_fix\spark_fix.csproj" />
<ProjectReference Include="..\spark_test\spark_test.csproj" />
<ProjectReference Include="../spark_fix/spark_fix.csproj" />
<!--<Proto3 Include="**/*.proto" />-->
+42
View File
@@ -0,0 +1,42 @@
#include "FixInit.h"
#include "IFixSession.h"
#include <quickfix/FileStore.h>
#include <quickfix/SocketAcceptor.h>
#include <quickfix/SessionSettings.h>
#include <quickfix/FileLog.h>
#include <quickfix/Message.h>
#include <quickfix/SessionID.h>
#include <boost/algorithm/string/replace.hpp>
#include <string>
#include <iostream>
#include <fstream>
#include <memory>
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<IFIXSession> 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();
}
}
}
+14
View File
@@ -0,0 +1,14 @@
#pragma once
#include <string>
namespace bts {
namespace fix {
class FixInit
{
public:
static int start_acceptor(const std::string& settings_file, bool orders_allowed);
};
}}
+42
View File
@@ -0,0 +1,42 @@
#include "FixRouter.h"
#include "IFixSession.h"
#include <quickfix/FileStore.h>
#include <quickfix/SocketAcceptor.h>
#include <quickfix/SessionSettings.h>
#include <quickfix/FileLog.h>
#include <quickfix/Message.h>
#include <quickfix/SessionID.h>
#include <boost/algorithm/string/replace.hpp>
#include <string>
#include <iostream>
#include <fstream>
#include <memory>
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<IFIXSession> 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();
}
}
}
+19
View File
@@ -0,0 +1,19 @@
#pragma once
#include "IFixSession.h"
#include <quickfix/MessageCracker.h>
#include <string>
namespace bts {
namespace fix {
class FixRouter : public IFixSession, public FIX::MessageCracker
{
public:
};
}}
+38
View File
@@ -0,0 +1,38 @@
#pragma once
#include "lib/domain_model/Security.pb.h"
#include <vector>
#include <memory>
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<const api::Security*> 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);
}
}
}
+10
View File
@@ -0,0 +1,10 @@
#pragma once
#include <quickfix/Application.h>
namespace bts {
namespace fix {
class IFIXSession : public FIX::Application
{
};
}}