From a16ff308739e61e86ba436eef201d481ae36ab07 Mon Sep 17 00:00:00 2001 From: Kevin Darby Date: Fri, 30 Nov 2018 18:32:51 -0500 Subject: [PATCH 01/28] lets see how hard this is --- spark_client.sln | 22 +++++++++++++ .../Properties/AssemblyAttributes.cs | 1 + src/client/spark_fix/FIXMain.cs | 31 +++++++++++++++++++ .../Properties/AssemblyAttributes.cs | 2 ++ src/client/spark_fix/README.md | 2 ++ src/client/spark_fix/spark_fix.csproj | 30 ++++++++++++++++++ 6 files changed, 88 insertions(+) create mode 100644 src/client/spark_fix/FIXMain.cs create mode 100644 src/client/spark_fix/Properties/AssemblyAttributes.cs create mode 100644 src/client/spark_fix/README.md create mode 100644 src/client/spark_fix/spark_fix.csproj diff --git a/spark_client.sln b/spark_client.sln index 1624dd1a5..9eb9adda9 100644 --- a/spark_client.sln +++ b/spark_client.sln @@ -23,6 +23,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "spark_test", "src\client\sp EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "spark_excel", "src\client\spark_excel\spark_excel.csproj", "{BE9F27C3-B583-47DF-95FA-1F8BBC89DCCB}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "spark_fix", "src\client\spark_fix\spark_fix.csproj", "{D8031C13-7BEA-430A-BB60-40927D15CFC3}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -219,6 +221,26 @@ Global {BE9F27C3-B583-47DF-95FA-1F8BBC89DCCB}.RelWithDebInfo|x64.Build.0 = Release|x64 {BE9F27C3-B583-47DF-95FA-1F8BBC89DCCB}.RelWithDebInfo|x86.ActiveCfg = Release|x64 {BE9F27C3-B583-47DF-95FA-1F8BBC89DCCB}.RelWithDebInfo|x86.Build.0 = Release|x64 + {D8031C13-7BEA-430A-BB60-40927D15CFC3}.Debug|Any CPU.ActiveCfg = Debug|x64 + {D8031C13-7BEA-430A-BB60-40927D15CFC3}.Debug|x64.ActiveCfg = Debug|x64 + {D8031C13-7BEA-430A-BB60-40927D15CFC3}.Debug|x64.Build.0 = Debug|x64 + {D8031C13-7BEA-430A-BB60-40927D15CFC3}.Debug|x86.ActiveCfg = Debug|x64 + {D8031C13-7BEA-430A-BB60-40927D15CFC3}.MinSizeRel|Any CPU.ActiveCfg = Release|x64 + {D8031C13-7BEA-430A-BB60-40927D15CFC3}.MinSizeRel|Any CPU.Build.0 = Release|x64 + {D8031C13-7BEA-430A-BB60-40927D15CFC3}.MinSizeRel|x64.ActiveCfg = Release|x64 + {D8031C13-7BEA-430A-BB60-40927D15CFC3}.MinSizeRel|x64.Build.0 = Release|x64 + {D8031C13-7BEA-430A-BB60-40927D15CFC3}.MinSizeRel|x86.ActiveCfg = Release|x64 + {D8031C13-7BEA-430A-BB60-40927D15CFC3}.MinSizeRel|x86.Build.0 = Release|x64 + {D8031C13-7BEA-430A-BB60-40927D15CFC3}.Release|Any CPU.ActiveCfg = Release|x64 + {D8031C13-7BEA-430A-BB60-40927D15CFC3}.Release|x64.ActiveCfg = Release|x64 + {D8031C13-7BEA-430A-BB60-40927D15CFC3}.Release|x64.Build.0 = Release|x64 + {D8031C13-7BEA-430A-BB60-40927D15CFC3}.Release|x86.ActiveCfg = Release|x64 + {D8031C13-7BEA-430A-BB60-40927D15CFC3}.RelWithDebInfo|Any CPU.ActiveCfg = Release|x64 + {D8031C13-7BEA-430A-BB60-40927D15CFC3}.RelWithDebInfo|Any CPU.Build.0 = Release|x64 + {D8031C13-7BEA-430A-BB60-40927D15CFC3}.RelWithDebInfo|x64.ActiveCfg = Release|x64 + {D8031C13-7BEA-430A-BB60-40927D15CFC3}.RelWithDebInfo|x64.Build.0 = Release|x64 + {D8031C13-7BEA-430A-BB60-40927D15CFC3}.RelWithDebInfo|x86.ActiveCfg = Release|x64 + {D8031C13-7BEA-430A-BB60-40927D15CFC3}.RelWithDebInfo|x86.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/client/spark_api/Properties/AssemblyAttributes.cs b/src/client/spark_api/Properties/AssemblyAttributes.cs index dbfda4671..c81bd6586 100644 --- a/src/client/spark_api/Properties/AssemblyAttributes.cs +++ b/src/client/spark_api/Properties/AssemblyAttributes.cs @@ -4,4 +4,5 @@ using System.Runtime.CompilerServices; [assembly: InternalsVisibleTo("sparkcmd")] [assembly: InternalsVisibleTo("spark_test")] [assembly: InternalsVisibleTo("spark_sdk")] +[assembly: InternalsVisibleTo("spark_fix")] diff --git a/src/client/spark_fix/FIXMain.cs b/src/client/spark_fix/FIXMain.cs new file mode 100644 index 000000000..6ecdd2dc7 --- /dev/null +++ b/src/client/spark_fix/FIXMain.cs @@ -0,0 +1,31 @@ +using System; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using System.Reactive.Disposables; + +using bts.api; +using bts.api.core; +using bts.api.md; + +namespace bts.fix +{ + + public class SDKMain + { + private static void user_test() + { + var ctx = new ServiceContext(); + + var s = ctx.locate(); + var r = new api.user.GetUsersRequest(); + var resp = s.get_users(r); + Console.WriteLine("{0}", resp); + } + public static void Main(string[] args) + { + bts.Log.Gen.info("Welcome to the BTS FIX API"); + user_test(); + } + } +} \ No newline at end of file diff --git a/src/client/spark_fix/Properties/AssemblyAttributes.cs b/src/client/spark_fix/Properties/AssemblyAttributes.cs new file mode 100644 index 000000000..116424f20 --- /dev/null +++ b/src/client/spark_fix/Properties/AssemblyAttributes.cs @@ -0,0 +1,2 @@ +using System.Runtime.CompilerServices; + diff --git a/src/client/spark_fix/README.md b/src/client/spark_fix/README.md new file mode 100644 index 000000000..a4a9554ff --- /dev/null +++ b/src/client/spark_fix/README.md @@ -0,0 +1,2 @@ +# BTS Spark FIX Adapter + diff --git a/src/client/spark_fix/spark_fix.csproj b/src/client/spark_fix/spark_fix.csproj new file mode 100644 index 000000000..607f2e3e9 --- /dev/null +++ b/src/client/spark_fix/spark_fix.csproj @@ -0,0 +1,30 @@ + + + netcoreapp2.1 + Exe + true + + Blue Trading Systems + Blue Trading Systems + Spark + + x64 + AnyCPU + true + + 1.0.0 + + + + + + + + + + + + + + + From 35a00740140d209b8ba7a75459e7ea6ebe613924 Mon Sep 17 00:00:00 2001 From: Kevin Darby Date: Mon, 3 Dec 2018 14:49:35 -0500 Subject: [PATCH 02/28] bts fix44 adapter --- src/client/spark/Spark.csproj | 1 - src/client/spark_api/utils/Log.cs | 6 +- src/client/spark_fix/Acceptor.cs | 52 + src/client/spark_fix/FIXMain.cs | 31 - src/client/spark_fix/FixInit.cs | 49 + src/client/spark_fix/HttpServer.cs | 585 + src/client/spark_fix/Initiator.cs | 0 src/client/spark_fix/spark_fix.cfg | 36 + src/client/spark_fix/spark_fix.csproj | 19 +- src/client/spark_fix/spec/fix/FIX40.xml | 828 ++ src/client/spark_fix/spec/fix/FIX41.xml | 1239 ++ src/client/spark_fix/spec/fix/FIX42.xml | 2623 ++++ src/client/spark_fix/spec/fix/FIX43.xml | 3996 ++++++ src/client/spark_fix/spec/fix/FIX44.xml | 6781 ++++++++++ src/client/spark_fix/spec/fix/FIX50.xml | 8272 ++++++++++++ src/client/spark_fix/spec/fix/FIX50SP1.xml | 9629 ++++++++++++++ src/client/spark_fix/spec/fix/FIX50SP2.xml | 10541 ++++++++++++++++ src/client/spark_fix/spec/fix/FIXT11.xml | 313 + src/client/spark_test/spark_test.csproj | 3 +- src/client/sparkcmd/Cmd/ConfigCheckCommand.cs | 2 +- src/client/sparkcmd/Cmd/FIXCommand.cs | 35 + .../sparkcmd/Cmd/ScriptClientCommand.cs | 2 +- src/client/sparkcmd/Cmd/ServiceTestCommand.cs | 2 +- .../sparkcmd/Cmd/SettingsManagerCommand.cs | 2 +- src/client/sparkcmd/Cmd/TestCommand.cs | 2 +- src/client/sparkcmd/Program.cs | 2 +- src/client/sparkcmd/sparkcmd.csproj | 14 +- src/lib/logging/logging.h | 1 + 28 files changed, 45014 insertions(+), 52 deletions(-) create mode 100644 src/client/spark_fix/Acceptor.cs delete mode 100644 src/client/spark_fix/FIXMain.cs create mode 100644 src/client/spark_fix/FixInit.cs create mode 100644 src/client/spark_fix/HttpServer.cs create mode 100644 src/client/spark_fix/Initiator.cs create mode 100644 src/client/spark_fix/spark_fix.cfg create mode 100644 src/client/spark_fix/spec/fix/FIX40.xml create mode 100644 src/client/spark_fix/spec/fix/FIX41.xml create mode 100644 src/client/spark_fix/spec/fix/FIX42.xml create mode 100644 src/client/spark_fix/spec/fix/FIX43.xml create mode 100644 src/client/spark_fix/spec/fix/FIX44.xml create mode 100644 src/client/spark_fix/spec/fix/FIX50.xml create mode 100644 src/client/spark_fix/spec/fix/FIX50SP1.xml create mode 100644 src/client/spark_fix/spec/fix/FIX50SP2.xml create mode 100644 src/client/spark_fix/spec/fix/FIXT11.xml create mode 100644 src/client/sparkcmd/Cmd/FIXCommand.cs diff --git a/src/client/spark/Spark.csproj b/src/client/spark/Spark.csproj index f3579dcd9..46634df58 100644 --- a/src/client/spark/Spark.csproj +++ b/src/client/spark/Spark.csproj @@ -8,7 +8,6 @@ true Debug;Release x64 - win7-x64 AnyCPU $(MSBuildExtensionsPath)\$(VisualStudioVersion)\Bin\Microsoft.CSharp.targets logo.ico diff --git a/src/client/spark_api/utils/Log.cs b/src/client/spark_api/utils/Log.cs index f6eb912e1..b166b2f23 100644 --- a/src/client/spark_api/utils/Log.cs +++ b/src/client/spark_api/utils/Log.cs @@ -33,7 +33,8 @@ namespace bts { Latency, DataFlow, Plugin, - ClientSdk + ClientSdk, + Fix // Please keep this list in sync with logging.h/logging.cpp } @@ -75,8 +76,9 @@ namespace bts { internal static Logger Assert => new Logger(Subsystem.Assert); internal static Logger Ui => new Logger(Subsystem.Ui); internal static Logger Testing => new Logger(Subsystem.Testing); - internal static Logger DataFlow => new Logger(Subsystem.DataFlow); + internal static Logger DataFlow => new Logger(Subsystem.DataFlow); public static Logger ClientSdk => new Logger(Subsystem.ClientSdk); + internal static Logger FIX => new Logger(Subsystem.Fix); [Conditional("DEBUG")] diff --git a/src/client/spark_fix/Acceptor.cs b/src/client/spark_fix/Acceptor.cs new file mode 100644 index 000000000..21a1e8608 --- /dev/null +++ b/src/client/spark_fix/Acceptor.cs @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using QuickFix; +using QuickFix.Fields; + +namespace bts.fix +{ + /// + /// Just a simple server that will let you connect to it and ignore any + /// application-level messages you send to it. + /// Note that this app is *NOT* a message cracker. + /// + + public class Acceptor : QuickFix.MessageCracker, QuickFix.IApplication + { + #region QuickFix.Application Methods + + public void FromApp(Message message, SessionID sessionID) + { + Console.WriteLine("IN: " + message); + Crack(message, sessionID); + } + + public void ToApp(Message message, SessionID sessionID) + { + Console.WriteLine("OUT: " + message); + } + + public void FromAdmin(Message message, SessionID sessionID) + { + Console.WriteLine("ADMININ: " + message); + } + + public void ToAdmin(Message message, SessionID sessionID) + { + Console.WriteLine("ADMINOUT: " + message); + } + + public void OnCreate(SessionID sessionID) { } + public void OnLogout(SessionID sessionID) { } + public void OnLogon(SessionID sessionID) { } + #endregion + + public void OnMessage(QuickFix.FIX42.BusinessMessageReject n, SessionID s) { } + public void OnMessage(QuickFix.FIX43.BusinessMessageReject n, SessionID s) { } + public void OnMessage(QuickFix.FIX44.BusinessMessageReject n, SessionID s) { } + public void OnMessage(QuickFix.FIX50.BusinessMessageReject n, SessionID s) { } + } +} \ No newline at end of file diff --git a/src/client/spark_fix/FIXMain.cs b/src/client/spark_fix/FIXMain.cs deleted file mode 100644 index 6ecdd2dc7..000000000 --- a/src/client/spark_fix/FIXMain.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using System.Reactive.Disposables; - -using bts.api; -using bts.api.core; -using bts.api.md; - -namespace bts.fix -{ - - public class SDKMain - { - private static void user_test() - { - var ctx = new ServiceContext(); - - var s = ctx.locate(); - var r = new api.user.GetUsersRequest(); - var resp = s.get_users(r); - Console.WriteLine("{0}", resp); - } - public static void Main(string[] args) - { - bts.Log.Gen.info("Welcome to the BTS FIX API"); - user_test(); - } - } -} \ No newline at end of file diff --git a/src/client/spark_fix/FixInit.cs b/src/client/spark_fix/FixInit.cs new file mode 100644 index 000000000..2191a7d53 --- /dev/null +++ b/src/client/spark_fix/FixInit.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using QuickFix; +using QuickFix.Fields; + +namespace bts.fix +{ + public class FixInit + { + public static int start_acceptor(string settings_file, string http_address = null) + { + try + { + SessionSettings settings = new SessionSettings(settings_file); + IApplication app = new Acceptor(); + IMessageStoreFactory storeFactory = new FileStoreFactory(settings); + ILogFactory logFactory = new FileLogFactory(settings); + IAcceptor acceptor = new ThreadedSocketAcceptor(app, storeFactory, settings, logFactory); + + acceptor.Start(); + HttpServer srv = null; + if (!string.IsNullOrEmpty(http_address)) + { + if(!http_address.StartsWith("http")) + http_address = "http://127.0.0.1:5080/"; + srv = new HttpServer(http_address, settings); + srv.Start(); + } + Console.WriteLine("press to quit"); + while (Console.Read() != 'q') { } + acceptor.Stop(); + if(srv != null) + srv.Stop(); + return 0; + } + catch (System.Exception e) + { + bts.Log.FIX.fatal(e.ToString()); + Console.WriteLine("==FATAL ERROR=="); + Console.WriteLine(e.ToString()); + return -1; + } + } + } +} + diff --git a/src/client/spark_fix/HttpServer.cs b/src/client/spark_fix/HttpServer.cs new file mode 100644 index 000000000..4385c03ad --- /dev/null +++ b/src/client/spark_fix/HttpServer.cs @@ -0,0 +1,585 @@ +using System; +using System.IO; +using System.Net; +using System.Text; +using System.Threading; +using System.Web; +using QuickFix; + +namespace bts.fix +{ + public class HttpServer : IDisposable + { + private readonly HttpListener _httpListener; + private Thread _connectionThread; + private Boolean _running, _disposed; + private readonly SessionSettings _sessionSettings; + private StringBuilder _sbHtmlHeader; + + + public HttpServer(string prefix, SessionSettings settings) + { + if (!HttpListener.IsSupported) + { + // Requires at least a Windows XP with Service Pack 2 + throw new NotSupportedException( + "The Http Server cannot run on this operating system."); + } + + _httpListener = new HttpListener(); + _httpListener.Prefixes.Add(prefix); + _sessionSettings = settings; + } + + public void Start() + { + if (!_httpListener.IsListening) + { + _httpListener.Start(); + _running = true; + // Use a thread to listen to the Http requests + _connectionThread = new Thread(ConnectionThreadStart); + _connectionThread.Start(); + } + } + + public void Stop() + { + if (_httpListener.IsListening) + { + _running = false; + _httpListener.Stop(); + } + } + + private void ConnectionThreadStart() + { + try + { + while (_running) + { + // Grab the context and pass it to the processor methods to handle it + HttpListenerContext context = _httpListener.GetContext(); + HttpListenerRequest request = context.Request; + HttpListenerResponse response = context.Response; + string responseString; + + _sbHtmlHeader = new StringBuilder(@"
QuickFIX Engine Web Interface

QuickFIX Engine Web Interface

"); + _sbHtmlHeader.AppendFormat(@"
[HOME] [RELOAD]

", request.Url.OriginalString); + + switch (request.Url.AbsolutePath) + { + case "/": + responseString = ProcessRoot(request); + break; + case "/session": + responseString = SessionDetails(request); + break; + case "/resetSession": + responseString = ResetSession(request); + break; + case "/resetSessions": + responseString = ResetSessions(request); + break; + case "/refreshSession": + responseString = RefreshSession(request); + break; + case "/refreshSessions": + responseString = RefreshSessions(request); + break; + case "/enableSessions": + responseString = EnableSessions(request); + break; + case "/disableSessions": + responseString = DisableSessions(request); + break; + default: + responseString = ProcessRoot(request); + break; + } + + byte[] buffer = Encoding.UTF8.GetBytes(responseString); + response.ContentLength64 = buffer.Length; + Stream output = response.OutputStream; + output.Write(buffer, 0, buffer.Length); + output.Close(); + } + } + catch (HttpListenerException) + { + Console.WriteLine("HTTP server was shut down."); + } + } + + private string DisableSessions(HttpListenerRequest request) + { + bool confirm = false; + StringBuilder sbHtmlPageBody = _sbHtmlHeader; + + if (request.QueryString["confirm"] != null) + { + if (Convert.ToInt16(request.QueryString["confirm"]) != 0) + { + confirm = true; + foreach (SessionID session in _sessionSettings.GetSessions()) + { + Session sessionDetails = Session.LookupSession(session); + sessionDetails.Logout(); + } + } + } + + if (confirm) + { + sbHtmlPageBody = new StringBuilder(); + sbHtmlPageBody.AppendFormat(@"
QuickFIX Engine Web Interface

QuickFIX Engine Web Interface

", "/"); + sbHtmlPageBody.AppendFormat("

Sessions have been disabled

", "/"); + } + else + { + sbHtmlPageBody.Append("

Are you sure you want to disable all sessions ?

"); + sbHtmlPageBody.AppendFormat("
[YES, disable sessions] [NO, do not disable sessions]
", request.Url.OriginalString); + } + return sbHtmlPageBody.ToString(); + } + + private string EnableSessions(HttpListenerRequest request) + { + bool confirm = false; + string urlOriginalString = request.Url.OriginalString; + StringBuilder sbHtmlPageBody = _sbHtmlHeader; + + if (request.QueryString["confirm"] != null) + { + if (Convert.ToInt16(request.QueryString["confirm"]) != 0) + { + confirm = true; + foreach (SessionID session in _sessionSettings.GetSessions()) + { + Session sessionDetails = Session.LookupSession(session); + sessionDetails.Logon(); + } + } + } + + if (confirm) + { + sbHtmlPageBody = new StringBuilder(); + sbHtmlPageBody.AppendFormat(@"
QuickFIX Engine Web Interface

QuickFIX Engine Web Interface

", "/"); + sbHtmlPageBody.AppendFormat("

Sessions have been enabled

", "/"); + } + else + { + sbHtmlPageBody.Append("

Are you sure you want to enable all sessions ?

"); + sbHtmlPageBody.AppendFormat("
[YES, enable sessions] [NO, do not enable sessions]
", urlOriginalString); + } + return sbHtmlPageBody.ToString(); + } + + private string RefreshSession(HttpListenerRequest request) + { + SessionID sessionId = new SessionID(request.QueryString["beginstring"], request.QueryString["sendercompid"], request.QueryString["targetcompid"]); + Session sessionDetails = Session.LookupSession(sessionId); + if (sessionDetails == null) throw new Exception("Session not found"); + StringBuilder sbHtmlPageBody = _sbHtmlHeader; + bool confirm = false; + string urlOriginalString = request.Url.OriginalString; + + string url = "/session?" + GetParameterList(urlOriginalString); + + if (request.QueryString["confirm"] != null) + { + if (Convert.ToInt16(request.QueryString["confirm"]) != 0) + { + confirm = true; + sessionDetails.Refresh(); + url = RemoveQueryStringByKey(urlOriginalString, "confirm"); + } + } + + if (confirm) + { + sbHtmlPageBody = new StringBuilder(); + sbHtmlPageBody.AppendFormat(@"
QuickFIX Engine Web Interface

QuickFIX Engine Web Interface

", GetParameterList(urlOriginalString)); + sbHtmlPageBody.AppendFormat(@"
[HOME] [RELOAD]

", urlOriginalString); + sbHtmlPageBody.AppendFormat("

{1} has been refreshed

", GetParameterList(url), sessionId); + } + else + { + sbHtmlPageBody.AppendFormat("

Are you sure you want to refresh session {1}?

", url, sessionId); + sbHtmlPageBody.AppendFormat("
[YES, refresh session] [NO, do not refresh session]
", url); + } + return sbHtmlPageBody.ToString(); + } + + private string RefreshSessions(HttpListenerRequest request) + { + bool confirm = false; + string urlOriginalString = request.Url.OriginalString; + StringBuilder sbHtmlPageBody = _sbHtmlHeader; + + if (request.QueryString["confirm"] != null) + { + if (Convert.ToInt16(request.QueryString["confirm"]) != 0) + { + confirm = true; + foreach (SessionID session in _sessionSettings.GetSessions()) + { + Session sessionDetails = Session.LookupSession(session); + sessionDetails.Refresh(); + } + } + } + + if (confirm) + { + sbHtmlPageBody = new StringBuilder(); + sbHtmlPageBody.AppendFormat(@"
QuickFIX Engine Web Interface

QuickFIX Engine Web Interface

", "/"); + sbHtmlPageBody.AppendFormat("

Sessions have been refreshed

", "/"); + } + else + { + sbHtmlPageBody.Append("

Are you sure you want to refresh all sessions ?

"); + sbHtmlPageBody.AppendFormat("
[YES, refresh sessions] [NO, do not refresh sessions]
", urlOriginalString); + } + return sbHtmlPageBody.ToString(); + } + + private string ResetSessions(HttpListenerRequest request) + { + bool confirm = false; + string urlOriginalString = request.Url.OriginalString; + StringBuilder sbHtmlPageBody = _sbHtmlHeader; + + if (request.QueryString["confirm"] != null) + { + if (Convert.ToInt16(request.QueryString["confirm"]) != 0) + { + confirm = true; + foreach (SessionID session in _sessionSettings.GetSessions()) + { + Session sessionDetails = Session.LookupSession(session); + sessionDetails.Reset("Reset from WebInterface"); + } + } + } + + if (confirm) + { + sbHtmlPageBody = new StringBuilder(); + sbHtmlPageBody.AppendFormat(@"
QuickFIX Engine Web Interface

QuickFIX Engine Web Interface

", "/"); + sbHtmlPageBody.AppendFormat("

Sessions have been reset

", "/"); + } + else + { + sbHtmlPageBody.Append("

Are you sure you want to reset all sessions ?

"); + sbHtmlPageBody.AppendFormat("
[YES, reset sessions] [NO, do not reset sessions]
", urlOriginalString); + } + return sbHtmlPageBody.ToString(); + } + + private string ResetSession(HttpListenerRequest request) + { + SessionID sessionId = new SessionID(request.QueryString["beginstring"], request.QueryString["sendercompid"], request.QueryString["targetcompid"]); + Session sessionDetails = Session.LookupSession(sessionId); + if (sessionDetails == null) throw new Exception("Session not found"); + StringBuilder sbHtmlPageBody = _sbHtmlHeader; + + bool confirm = false; + string urlOriginalString = request.Url.OriginalString; + + string url = "/session?" + GetParameterList(urlOriginalString); + + if (request.QueryString["confirm"] != null) + { + if (Convert.ToInt16(request.QueryString["confirm"]) != 0) + { + confirm = true; + sessionDetails.Reset("Reset from WebInterface"); + url = RemoveQueryStringByKey(urlOriginalString, "confirm"); + } + } + + if (confirm) + { + sbHtmlPageBody = new StringBuilder(); + sbHtmlPageBody.AppendFormat(@"
QuickFIX Engine Web Interface

QuickFIX Engine Web Interface

", GetParameterList(urlOriginalString)); + sbHtmlPageBody.AppendFormat(@"
[HOME] [RELOAD]

", urlOriginalString); + sbHtmlPageBody.AppendFormat("

{1} has been reset

", GetParameterList(url), sessionId); + } + else + { + sbHtmlPageBody.AppendFormat("

Are you sure you want to reset session {1}?

", url, sessionId); + sbHtmlPageBody.AppendFormat("
[YES, reset session] [NO, do not reset session]
", url); + } + return sbHtmlPageBody.ToString(); + } + + + private string ProcessRoot(HttpListenerRequest request) + { + StringBuilder sbHtmlPageBody = _sbHtmlHeader; + + //Session count + sbHtmlPageBody.AppendFormat("
{0} Sessions managed by QuickFIX

", _sessionSettings.GetSessions().Count); + + //session management links + sbHtmlPageBody.AppendFormat(@"
RESET REFRESH ENABLE DISABLE

", GetParameterList(request.Url.OriginalString)); + + //Start the table generation + sbHtmlPageBody.Append(""); + + sbHtmlPageBody.Append(""); + sbHtmlPageBody.Append(AddCell("Session", true)); + sbHtmlPageBody.Append(AddCell("Type", true)); + sbHtmlPageBody.Append(AddCell("Enabled", true)); + sbHtmlPageBody.Append(AddCell("Session Time", true)); + sbHtmlPageBody.Append(AddCell("Logged On", true)); + sbHtmlPageBody.Append(AddCell("Next Incoming", true)); + sbHtmlPageBody.Append(AddCell("Next Outgoing", true)); + sbHtmlPageBody.Append(""); + + foreach (SessionID session in _sessionSettings.GetSessions()) + { + Session sessionDetails = Session.LookupSession(session); + sbHtmlPageBody.Append(""); + sbHtmlPageBody.Append(AddCell(String.Format( + "{0}:{1}->{2}", + session.BeginString, session.SenderCompID, session.TargetCompID))); + sbHtmlPageBody.Append(AddCell(sessionDetails.IsInitiator ? "initiator" : "acceptor")); + sbHtmlPageBody.Append(AddCell(sessionDetails.IsEnabled ? "yes" : "no")); + sbHtmlPageBody.Append(AddCell(sessionDetails.IsSessionTime ? "yes" : "no")); + sbHtmlPageBody.Append(AddCell(sessionDetails.IsLoggedOn ? "yes" : "no")); + sbHtmlPageBody.Append(AddCell(sessionDetails.NextTargetMsgSeqNum.ToString())); + sbHtmlPageBody.Append(AddCell(sessionDetails.NextSenderMsgSeqNum.ToString())); + sbHtmlPageBody.Append(""); + } + + sbHtmlPageBody.Append("
"); + return sbHtmlPageBody.ToString(); + } + + public string SessionDetails(HttpListenerRequest request) + { + SessionID sessionId = new SessionID(request.QueryString["beginstring"], request.QueryString["sendercompid"], request.QueryString["targetcompid"]); + Session sessionDetails = Session.LookupSession(sessionId); + if (sessionDetails == null) throw new Exception("Session not found"); + StringBuilder sbHtmlPageBody = _sbHtmlHeader; + + string url = request.Url.OriginalString; + string urlOriginalString = request.Url.OriginalString; + + if (request.QueryString["enabled"] != null) + { + if (!Convert.ToBoolean(request.QueryString["enabled"])) + sessionDetails.Logout(); + else + sessionDetails.Logon(); + + url = RemoveQueryStringByKey(urlOriginalString, "Enabled"); + } + + if (request.QueryString["next incoming"] != null) + { + int value = Convert.ToInt16(request.QueryString["next incoming"]); + sessionDetails.NextTargetMsgSeqNum = value <= 0 ? 1 : value; + url = RemoveQueryStringByKey(urlOriginalString, "next incoming"); + } + + if (request.QueryString["Next Outgoing"] != null) + { + int value = Convert.ToInt16(request.QueryString["Next Outgoing"]); + sessionDetails.NextSenderMsgSeqNum = value <= 0 ? 1 : value; + url = RemoveQueryStringByKey(urlOriginalString, "Next Outgoing"); + } + + if (request.QueryString["SendRedundantResendRequests"] != null) + { + sessionDetails.SendRedundantResendRequests = Convert.ToBoolean(request.QueryString["SendRedundantResendRequests"]); + url = RemoveQueryStringByKey(urlOriginalString, "SendRedundantResendRequests"); + } + + if (request.QueryString["CheckCompId"] != null) + { + sessionDetails.CheckCompID = Convert.ToBoolean(request.QueryString["CheckCompId"]); + url = RemoveQueryStringByKey(urlOriginalString, "CheckCompId"); + } + + if (request.QueryString["CheckLatency"] != null) + { + sessionDetails.CheckLatency = Convert.ToBoolean(request.QueryString["CheckLatency"]); + url = RemoveQueryStringByKey(urlOriginalString, "CheckLatency"); + } + + if (request.QueryString["MaxLatency"] != null) + { + int value = Convert.ToInt16(request.QueryString["MaxLatency"]); + sessionDetails.MaxLatency = value <= 0 ? 1 : value; + url = RemoveQueryStringByKey(urlOriginalString, "MaxLatency"); + } + + if (request.QueryString["LogonTimeout"] != null) + { + int value = Convert.ToInt16(request.QueryString["LogonTimeout"]); + sessionDetails.LogonTimeout = value <= 0 ? 1 : value; + url = RemoveQueryStringByKey(urlOriginalString, "LogonTimeout"); + } + + if (request.QueryString["LogoutTimeout"] != null) + { + int value = Convert.ToInt16(request.QueryString["LogoutTimeout"]); + sessionDetails.LogoutTimeout = value <= 0 ? 1 : value; + url = RemoveQueryStringByKey(urlOriginalString, "LogoutTimeout"); + } + + if (request.QueryString["ResetOnLogon"] != null) + { + sessionDetails.ResetOnLogon = Convert.ToBoolean(request.QueryString["ResetOnLogon"]); + url = RemoveQueryStringByKey(urlOriginalString, "ResetOnLogon"); + } + + if (request.QueryString["ResetOnLogout"] != null) + { + sessionDetails.ResetOnLogout = Convert.ToBoolean(request.QueryString["ResetOnLogout"]); + url = RemoveQueryStringByKey(urlOriginalString, "ResetOnLogout"); + } + + if (request.QueryString["ResetOnDisconnect"] != null) + { + sessionDetails.ResetOnDisconnect = Convert.ToBoolean(request.QueryString["ResetOnDisconnect"]); + url = RemoveQueryStringByKey(urlOriginalString, "ResetOnDisconnect"); + } + + if (request.QueryString["RefreshOnLogon"] != null) + { + sessionDetails.RefreshOnLogon = Convert.ToBoolean(request.QueryString["RefreshOnLogon"]); + url = RemoveQueryStringByKey(urlOriginalString, "RefreshOnLogon"); + } + + if (request.QueryString["MillisecondsInTimestamp"] != null) + { + sessionDetails.MillisecondsInTimeStamp = Convert.ToBoolean(request.QueryString["MillisecondsInTimestamp"]); + url = RemoveQueryStringByKey(urlOriginalString, "MillisecondsInTimestamp"); + } + + if (request.QueryString["PersistMessages"] != null) + { + sessionDetails.PersistMessages = Convert.ToBoolean(request.QueryString["PersistMessages"]); + url = RemoveQueryStringByKey(urlOriginalString, "PersistMessages"); + } + + + sbHtmlPageBody.AppendFormat(@"
{0}

", sessionId); + sbHtmlPageBody.AppendFormat(@"
[RESET] [REFRESH]

", GetParameterList(urlOriginalString)); + + sbHtmlPageBody.Append(""); + + sbHtmlPageBody.Append(AddRow("Enabled", sessionDetails.IsEnabled, url)); + sbHtmlPageBody.Append(AddRow("ConnectionType", sessionDetails.IsInitiator ? "initiator" : "acceptor")); + sbHtmlPageBody.Append(AddRow("SessionTime", sessionDetails.IsSessionTime)); + sbHtmlPageBody.Append(AddRow("LoggedOn", sessionDetails.IsLoggedOn)); + sbHtmlPageBody.Append(AddRow("Next Incoming", sessionDetails.NextTargetMsgSeqNum, url)); + sbHtmlPageBody.Append(AddRow("Next Outgoing", sessionDetails.NextSenderMsgSeqNum, url)); + sbHtmlPageBody.Append(AddRow("SendRedundantResendRequests", sessionDetails.SendRedundantResendRequests, url)); + sbHtmlPageBody.Append(AddRow("CheckCompId", sessionDetails.CheckCompID, url)); + sbHtmlPageBody.Append(AddRow("CheckLatency", sessionDetails.CheckLatency, url)); + sbHtmlPageBody.Append(AddRow("MaxLatency", sessionDetails.MaxLatency, url)); + sbHtmlPageBody.Append(AddRow("LogonTimeout", sessionDetails.LogonTimeout, url)); + sbHtmlPageBody.Append(AddRow("LogoutTimeout", sessionDetails.LogoutTimeout, url)); + sbHtmlPageBody.Append(AddRow("ResetOnLogon", sessionDetails.ResetOnLogon, url)); + sbHtmlPageBody.Append(AddRow("ResetOnLogout", sessionDetails.ResetOnLogout, url)); + sbHtmlPageBody.Append(AddRow("ResetOnDisconnect", sessionDetails.ResetOnDisconnect, url)); + sbHtmlPageBody.Append(AddRow("RefreshOnLogon", sessionDetails.RefreshOnLogon, url)); + sbHtmlPageBody.Append(AddRow("MillisecondsInTimestamp", sessionDetails.MillisecondsInTimeStamp, url)); + sbHtmlPageBody.Append(AddRow("PersistMessages", sessionDetails.PersistMessages, url)); + + sbHtmlPageBody.Append("
"); + return sbHtmlPageBody.ToString(); + } + + public static string RemoveQueryStringByKey(string url, string key) + { + var uri = new Uri(url); + + // this gets all the query string key value pairs as a collection + var newQueryString = HttpUtility.ParseQueryString(uri.Query); + + // this removes the key if exists + newQueryString.Remove(key); + + // this gets the page path from root without QueryString + string pagePathWithoutQueryString = uri.GetLeftPart(UriPartial.Path); + + return newQueryString.Count > 0 + ? $"{pagePathWithoutQueryString}?{newQueryString}" + : pagePathWithoutQueryString; + } + + public static string GetParameterList(string url) + { + return HttpUtility.ParseQueryString((new Uri(url).Query)).ToString(); + } + + private static string AddRow(string colName, bool value, string url = "") + { + string valueAsStr = value ? "yes" : "no"; + string innerHtml = url.Length > 0 + ? $"toggle" + : ""; + return AddRow(colName, valueAsStr, innerHtml); + } + + private static string AddRow(string colName, int value, string url = "") + { + string innerHtml = $" << " + + $" < " + + " | " + + $" > " + + $" >> "; + return AddRow(colName, value.ToString(), innerHtml); + } + private static string AddRow(string colName, string value, string innerHtml = "") + { + StringBuilder row = new StringBuilder(); + row.Append(""); + row.Append(AddCell(colName)); + row.Append(AddCell(value)); + row.Append(AddCell(innerHtml)); + row.Append(""); + return row.ToString(); + } + + private static string AddCell(string cellContent, bool header = false) + { + string entryType = header ? "th" : "td"; + return "<" + entryType + " align=\"left\">" + cellContent + ""; + } + + public virtual void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + private void Dispose(bool disposing) + { + if (_disposed) + { + return; + } + if (disposing) + { + if (_running) + { + Stop(); + } + if (_connectionThread != null) + { + _connectionThread.Abort(); + _connectionThread = null; + } + } + _disposed = true; + } + } +} \ No newline at end of file diff --git a/src/client/spark_fix/Initiator.cs b/src/client/spark_fix/Initiator.cs new file mode 100644 index 000000000..e69de29bb diff --git a/src/client/spark_fix/spark_fix.cfg b/src/client/spark_fix/spark_fix.cfg new file mode 100644 index 000000000..a1318b449 --- /dev/null +++ b/src/client/spark_fix/spark_fix.cfg @@ -0,0 +1,36 @@ +[DEFAULT] +ConnectionType=acceptor +SocketAcceptPort=5001 +SocketReuseAddress=Y +StartTime=00:00:00 +EndTime=00:00:00 +FileLogPath=log +UseDataDictionary=Y +ResetOnLogon=Y +ResetOnLogout=Y +ResetOnDisconnect=Y +SSLEnable=N + +# SSLEnable=Y +# # It is recommended to install the certificate and refer to it by name instead of using filename + password +# SSLCertificate=QuickFixn-TestServer.pfx +# SSLCertificatePassword=QuickFixn-TestServer +# # For production refer to certificate by name instead: SSLCertificate=CN=QuickFixn-TestServer +# SSLCACertificate=QuickFixn-TestCA.cer +# SSLCheckCertificateRevocation=N + + +[SESSION] +BeginString=FIX.4.4 +SenderCompID=SPARK +TargetCompID=CLIENT1 +FileStorePath=store +DataDictionary=./spec/fix/FIX44.xml + +[SESSION] +BeginString=FIX.4.4 +SenderCompID=SPARK +TargetCompID=CLIENT2 +FileStorePath=store +DataDictionary=./spec/fix/FIX44.xml + diff --git a/src/client/spark_fix/spark_fix.csproj b/src/client/spark_fix/spark_fix.csproj index 607f2e3e9..96a9a9789 100644 --- a/src/client/spark_fix/spark_fix.csproj +++ b/src/client/spark_fix/spark_fix.csproj @@ -1,8 +1,6 @@ - netcoreapp2.1 - Exe - true + netstandard2.0 Blue Trading Systems Blue Trading Systems @@ -20,11 +18,22 @@ - + + + - + + + + + + + + + + diff --git a/src/client/spark_fix/spec/fix/FIX40.xml b/src/client/spark_fix/spec/fix/FIX40.xml new file mode 100644 index 000000000..08bd0e7d9 --- /dev/null +++ b/src/client/spark_fix/spec/fix/FIX40.xml @@ -0,0 +1,828 @@ + +
+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/client/spark_fix/spec/fix/FIX41.xml b/src/client/spark_fix/spec/fix/FIX41.xml new file mode 100644 index 000000000..d1d470eb1 --- /dev/null +++ b/src/client/spark_fix/spec/fix/FIX41.xml @@ -0,0 +1,1239 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/client/spark_fix/spec/fix/FIX42.xml b/src/client/spark_fix/spec/fix/FIX42.xml new file mode 100644 index 000000000..d209e06d4 --- /dev/null +++ b/src/client/spark_fix/spec/fix/FIX42.xml @@ -0,0 +1,2623 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/client/spark_fix/spec/fix/FIX43.xml b/src/client/spark_fix/spec/fix/FIX43.xml new file mode 100644 index 000000000..208187f50 --- /dev/null +++ b/src/client/spark_fix/spec/fix/FIX43.xml @@ -0,0 +1,3996 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/client/spark_fix/spec/fix/FIX44.xml b/src/client/spark_fix/spec/fix/FIX44.xml new file mode 100644 index 000000000..f889ddb4c --- /dev/null +++ b/src/client/spark_fix/spec/fix/FIX44.xml @@ -0,0 +1,6781 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/client/spark_fix/spec/fix/FIX50.xml b/src/client/spark_fix/spec/fix/FIX50.xml new file mode 100644 index 000000000..b4d5d5a8c --- /dev/null +++ b/src/client/spark_fix/spec/fix/FIX50.xml @@ -0,0 +1,8272 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/client/spark_fix/spec/fix/FIX50SP1.xml b/src/client/spark_fix/spec/fix/FIX50SP1.xml new file mode 100644 index 000000000..6bde1468d --- /dev/null +++ b/src/client/spark_fix/spec/fix/FIX50SP1.xml @@ -0,0 +1,9629 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/client/spark_fix/spec/fix/FIX50SP2.xml b/src/client/spark_fix/spec/fix/FIX50SP2.xml new file mode 100644 index 000000000..a97e87583 --- /dev/null +++ b/src/client/spark_fix/spec/fix/FIX50SP2.xml @@ -0,0 +1,10541 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/client/spark_fix/spec/fix/FIXT11.xml b/src/client/spark_fix/spec/fix/FIXT11.xml new file mode 100644 index 000000000..15054a8a2 --- /dev/null +++ b/src/client/spark_fix/spec/fix/FIXT11.xml @@ -0,0 +1,313 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/client/spark_test/spark_test.csproj b/src/client/spark_test/spark_test.csproj index 1c755b687..d6b2e5edd 100644 --- a/src/client/spark_test/spark_test.csproj +++ b/src/client/spark_test/spark_test.csproj @@ -1,7 +1,8 @@ - net471 + netstandard2.0 + x64 x64 diff --git a/src/client/sparkcmd/Cmd/ConfigCheckCommand.cs b/src/client/sparkcmd/Cmd/ConfigCheckCommand.cs index 432fce36b..47b8b07da 100644 --- a/src/client/sparkcmd/Cmd/ConfigCheckCommand.cs +++ b/src/client/sparkcmd/Cmd/ConfigCheckCommand.cs @@ -1,4 +1,4 @@ -using ManyConsole; +using ManyConsole.CommandLineUtils; using System.Linq; namespace bts { diff --git a/src/client/sparkcmd/Cmd/FIXCommand.cs b/src/client/sparkcmd/Cmd/FIXCommand.cs new file mode 100644 index 000000000..acb9ed7c6 --- /dev/null +++ b/src/client/sparkcmd/Cmd/FIXCommand.cs @@ -0,0 +1,35 @@ +using System; +using System.Linq; +using ManyConsole.CommandLineUtils; + +using bts.fix; + +namespace bts +{ + public class FIXCommand : ConsoleCommand + { + bool _acceptor, _initiator; + string _config, _http; + public FIXCommand() + { + IsCommand("fix", "start a fix acceptor or initiator session"); + HasOption("a|acceptor", "Start a FIX Acceptor", h => _acceptor = true); + HasOption("i|initiator", "Start a FIX Initiator", h => _initiator = true); + HasRequiredOption("f|configfile=", "Set the config file", h => _config = h); + HasOption("w|http=", "Start http server {address}", h => _http = h); + HasAdditionalArguments(null, " [other params]"); + } + public override int Run(string[] remaining_args) + { + if (_acceptor) + { + Console.WriteLine("Starting FIX Acceptor using " + _config + " " + _http ?? string.Empty); + return FixInit.start_acceptor(_config, (string.IsNullOrEmpty(_http) ? null : _http)); + } + else if (_initiator) + { + } + return -1; + } + } +} diff --git a/src/client/sparkcmd/Cmd/ScriptClientCommand.cs b/src/client/sparkcmd/Cmd/ScriptClientCommand.cs index 18f0c18c9..64e4a54ed 100644 --- a/src/client/sparkcmd/Cmd/ScriptClientCommand.cs +++ b/src/client/sparkcmd/Cmd/ScriptClientCommand.cs @@ -6,7 +6,7 @@ using System.Reflection; using System.Threading.Tasks; using System.Reactive.Linq; using System.Reactive; -using ManyConsole; +using ManyConsole.CommandLineUtils; using System.Linq; namespace sparkcmd { diff --git a/src/client/sparkcmd/Cmd/ServiceTestCommand.cs b/src/client/sparkcmd/Cmd/ServiceTestCommand.cs index dfad6cc5d..04cff9bb6 100644 --- a/src/client/sparkcmd/Cmd/ServiceTestCommand.cs +++ b/src/client/sparkcmd/Cmd/ServiceTestCommand.cs @@ -1,7 +1,7 @@ using bts.api; using bts.api.core; using bts.api.synthetic; -using ManyConsole; +using ManyConsole.CommandLineUtils; using System; namespace bts { diff --git a/src/client/sparkcmd/Cmd/SettingsManagerCommand.cs b/src/client/sparkcmd/Cmd/SettingsManagerCommand.cs index 3c74b9c87..996b5e7ca 100644 --- a/src/client/sparkcmd/Cmd/SettingsManagerCommand.cs +++ b/src/client/sparkcmd/Cmd/SettingsManagerCommand.cs @@ -1,4 +1,4 @@ -using ManyConsole; +using ManyConsole.CommandLineUtils; using System.Reflection; namespace bts { diff --git a/src/client/sparkcmd/Cmd/TestCommand.cs b/src/client/sparkcmd/Cmd/TestCommand.cs index 43bddadac..7f9f3d762 100644 --- a/src/client/sparkcmd/Cmd/TestCommand.cs +++ b/src/client/sparkcmd/Cmd/TestCommand.cs @@ -1,6 +1,6 @@ using bts.test; -using ManyConsole; +using ManyConsole.CommandLineUtils; using System; using mbts; using System.Collections.Generic; diff --git a/src/client/sparkcmd/Program.cs b/src/client/sparkcmd/Program.cs index 1feb68ecb..48f2df347 100644 --- a/src/client/sparkcmd/Program.cs +++ b/src/client/sparkcmd/Program.cs @@ -2,7 +2,7 @@ using bts.api.core; using bts.api.synthetic; using bts.api.test; -using ManyConsole; +using ManyConsole.CommandLineUtils; using System; using System.Linq; diff --git a/src/client/sparkcmd/sparkcmd.csproj b/src/client/sparkcmd/sparkcmd.csproj index 31c2efcd9..f41971ef3 100644 --- a/src/client/sparkcmd/sparkcmd.csproj +++ b/src/client/sparkcmd/sparkcmd.csproj @@ -2,9 +2,9 @@ Exe - net471 - - win7-x64;ubuntu.16.04-x64 + + net471;netcoreapp2.1 + win10-x64;ubuntu.18.04-x64 Blue Trading Systems Blue Trading Systems Spark @@ -18,11 +18,13 @@ - + + - + - + + diff --git a/src/lib/logging/logging.h b/src/lib/logging/logging.h index 919234a6e..95f0effea 100644 --- a/src/lib/logging/logging.h +++ b/src/lib/logging/logging.h @@ -44,6 +44,7 @@ constexpr log::Subsystem Latency {Testing.ordinal+1 }; constexpr log::Subsystem DataFlow {Latency.ordinal+1 }; constexpr log::Subsystem Plugin {DataFlow.ordinal+1 }; constexpr log::Subsystem ClientSdk {Plugin.ordinal+1 }; +constexpr log::Subsystem FIX {ClientSdk.ordinal+1 }; struct LoggerHandle { LoggerHandle(LoggerHandle const&) = delete; From 7e4ad55d9d08632c25fcd9f736cd9fc7c1c3feca Mon Sep 17 00:00:00 2001 From: Kevin Darby Date: Mon, 3 Dec 2018 15:32:45 -0500 Subject: [PATCH 03/28] established a session --- src/client/spark_fix/Acceptor.cs | 103 +++++++++++++++++++++++++- src/client/sparkcmd/Cmd/FIXCommand.cs | 2 +- 2 files changed, 101 insertions(+), 4 deletions(-) diff --git a/src/client/spark_fix/Acceptor.cs b/src/client/spark_fix/Acceptor.cs index 21a1e8608..ee06dd3ae 100644 --- a/src/client/spark_fix/Acceptor.cs +++ b/src/client/spark_fix/Acceptor.cs @@ -16,6 +16,14 @@ namespace bts.fix public class Acceptor : QuickFix.MessageCracker, QuickFix.IApplication { + static readonly decimal DEFAULT_MARKET_PRICE = 10; + + int orderID = 0; + int execID = 0; + + private string GenOrderID() { return (++orderID).ToString(); } + private string GenExecID() { return (++execID).ToString(); } + #region QuickFix.Application Methods public void FromApp(Message message, SessionID sessionID) @@ -44,9 +52,98 @@ namespace bts.fix public void OnLogon(SessionID sessionID) { } #endregion - public void OnMessage(QuickFix.FIX42.BusinessMessageReject n, SessionID s) { } - public void OnMessage(QuickFix.FIX43.BusinessMessageReject n, SessionID s) { } public void OnMessage(QuickFix.FIX44.BusinessMessageReject n, SessionID s) { } - public void OnMessage(QuickFix.FIX50.BusinessMessageReject n, SessionID s) { } + public void OnMessage(QuickFix.FIX44.News n, SessionID s) { } + + public void OnMessage(QuickFix.FIX44.NewOrderSingle n, SessionID s) + { + Symbol symbol = n.Symbol; + Side side = n.Side; + OrdType ordType = n.OrdType; + OrderQty orderQty = n.OrderQty; + Price price = new Price(DEFAULT_MARKET_PRICE); + ClOrdID clOrdID = n.ClOrdID; + + switch (ordType.getValue()) + { + case OrdType.LIMIT: + price = n.Price; + if (price.Obj == 0) + throw new IncorrectTagValue(price.Tag); + break; + case OrdType.MARKET: break; + default: throw new IncorrectTagValue(ordType.Tag); + } + + QuickFix.FIX44.ExecutionReport exReport = new QuickFix.FIX44.ExecutionReport( + new OrderID(GenOrderID()), + new ExecID(GenExecID()), + new ExecType(ExecType.FILL), + new OrdStatus(OrdStatus.FILLED), + symbol, //shouldn't be here? + side, + new LeavesQty(0), + new CumQty(orderQty.getValue()), + new AvgPx(price.getValue())); + + exReport.Set(clOrdID); + exReport.Set(symbol); + exReport.Set(orderQty); + exReport.Set(new LastQty(orderQty.getValue())); + exReport.Set(new LastPx(price.getValue())); + + if (n.IsSetAccount()) + exReport.SetField(n.Account); + + try + { + Session.SendToTarget(exReport, s); + } + catch (SessionNotFound ex) + { + Console.WriteLine("==session not found exception!=="); + Console.WriteLine(ex.ToString()); + } + catch (Exception ex) + { + Console.WriteLine(ex.ToString()); + } + } + + public void OnMessage(QuickFix.FIX44.OrderCancelRequest msg, SessionID s) + { + string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Obj : "unknown orderID"; + QuickFix.FIX44.OrderCancelReject ocj = new QuickFix.FIX44.OrderCancelReject( + new OrderID(orderid), msg.ClOrdID, msg.OrigClOrdID, new OrdStatus(OrdStatus.REJECTED), new CxlRejResponseTo(CxlRejResponseTo.ORDER_CANCEL_REQUEST)); + ocj.CxlRejReason = new CxlRejReason(CxlRejReason.OTHER); + ocj.Text = new Text("Executor does not support order cancels"); + + try + { + Session.SendToTarget(ocj, s); + } + catch (Exception ex) + { + Console.WriteLine(ex.ToString()); + } + } + + public void OnMessage(QuickFix.FIX44.OrderCancelReplaceRequest msg, SessionID s) + { + string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Obj : "unknown orderID"; + QuickFix.FIX44.OrderCancelReject ocj = new QuickFix.FIX44.OrderCancelReject( + new OrderID(orderid), msg.ClOrdID, msg.OrigClOrdID, new OrdStatus(OrdStatus.REJECTED), new CxlRejResponseTo(CxlRejResponseTo.ORDER_CANCEL_REPLACE_REQUEST)); + ocj.CxlRejReason = new CxlRejReason(CxlRejReason.OTHER); + ocj.Text = new Text("Executor does not support order cancel/replaces"); + + try + { + Session.SendToTarget(ocj, s); + } + catch (Exception ex) + { + Console.WriteLine(ex.ToString()); + } + } } } \ No newline at end of file diff --git a/src/client/sparkcmd/Cmd/FIXCommand.cs b/src/client/sparkcmd/Cmd/FIXCommand.cs index acb9ed7c6..e6ce5d572 100644 --- a/src/client/sparkcmd/Cmd/FIXCommand.cs +++ b/src/client/sparkcmd/Cmd/FIXCommand.cs @@ -23,7 +23,7 @@ namespace bts { if (_acceptor) { - Console.WriteLine("Starting FIX Acceptor using " + _config + " " + _http ?? string.Empty); + Console.WriteLine("Starting FIX Acceptor using " + _config + " Http server " + _http ?? "no"); return FixInit.start_acceptor(_config, (string.IsNullOrEmpty(_http) ? null : _http)); } else if (_initiator) From 24ae03a9f8563f848efef7bd9d14e98a9fb9212f Mon Sep 17 00:00:00 2001 From: Kevin Darby Date: Mon, 3 Dec 2018 18:19:20 -0500 Subject: [PATCH 04/28] access permissions api so fix session can report fills and orders --- src/client/spark/Admin/AdminModel.cs | 1 + src/client/spark/Orders/OrdersModel.cs | 6 +- .../admin}/AdminModelWrapper.cs | 4 +- .../admin}/PermissionFilters.cs | 24 ++-- src/client/spark_fix/DropCopySession.cs | 119 ++++++++++++++++++ src/client/spark_fix/FixInit.cs | 4 +- src/client/spark_fix/Initiator.cs | 0 .../{Acceptor.cs => OrderSession.cs} | 3 +- src/client/spark_fix/spark_fix.cfg | 6 +- src/client/spark_fix/spark_fix.csproj | 1 + src/client/sparkcmd/Cmd/ConsoleCommandEx.cs | 2 +- src/client/sparkcmd/Cmd/FIXCommand.cs | 28 +++-- src/client/sparkcmd/Cmd/ServiceTail.cs | 2 +- src/lib/CMakeDeps.cmake | 2 +- .../api/service_helpers/AdminServiceUtils.cpp | 1 + 15 files changed, 169 insertions(+), 34 deletions(-) rename src/client/{spark/Admin => spark_core/admin}/AdminModelWrapper.cs (97%) rename src/client/{spark/Admin => spark_core/admin}/PermissionFilters.cs (66%) create mode 100644 src/client/spark_fix/DropCopySession.cs delete mode 100644 src/client/spark_fix/Initiator.cs rename src/client/spark_fix/{Acceptor.cs => OrderSession.cs} (95%) diff --git a/src/client/spark/Admin/AdminModel.cs b/src/client/spark/Admin/AdminModel.cs index da1ae42f4..1b6ed064e 100644 --- a/src/client/spark/Admin/AdminModel.cs +++ b/src/client/spark/Admin/AdminModel.cs @@ -1,5 +1,6 @@ using bts; using bts.api.admin; +using bts.api.core; using System; using System.Collections.Generic; using System.ComponentModel.Composition; diff --git a/src/client/spark/Orders/OrdersModel.cs b/src/client/spark/Orders/OrdersModel.cs index 7e470f842..bf24da63c 100644 --- a/src/client/spark/Orders/OrdersModel.cs +++ b/src/client/spark/Orders/OrdersModel.cs @@ -44,8 +44,8 @@ namespace mbts.spark { _dynamic_helper = dynamic_helper; var scheduler = ThreadPoolScheduler.Instance; var interval = TimeSpan.FromMilliseconds(100); - on_orders = _service.subscribei_orders().Naggle(interval, scheduler).PermissionFilter(admin_model).Table().Cache(); - on_positions = _position_service.subscribei_position_data().Naggle(interval, scheduler).PermissionFilter(admin_model).Table().Cache(); + on_orders = _service.subscribei_orders().Naggle(interval, scheduler).PermissionFilter(admin_model.on_admin_data).Table().Cache(); + on_positions = _position_service.subscribei_position_data().Naggle(interval, scheduler).PermissionFilter(admin_model.on_admin_data).Table().Cache(); working_orders = on_orders.Scan( ImmutableDictionary.Empty, @@ -55,7 +55,7 @@ namespace mbts.spark { on_order_tuples = order_record_tuple_source.subscribe_incremental_update(); on_order_tuples_table = order_record_tuple_source.subscribe_incremental_table_update(); on_order_securities = order_record_tuple_source.subscribe_order_securities(); - on_fills = _service.subscribei_fills().Naggle(interval, scheduler).PermissionFilter(admin_model).Table().Cache(); + on_fills = _service.subscribei_fills().Naggle(interval, scheduler).PermissionFilter(admin_model.on_admin_data).Table().Cache(); _activity = new OrderActivitySummarizer(bus, on_orders); on_fill_tuples = FillTupleSource.create_observable(bus.subscribe(SparkTags.SecuritiesTag), on_orders, on_fills); _security_orders_demuxer = new TableUpdateDemuxer(o => o.Key, o => o.security_key()); diff --git a/src/client/spark/Admin/AdminModelWrapper.cs b/src/client/spark_core/admin/AdminModelWrapper.cs similarity index 97% rename from src/client/spark/Admin/AdminModelWrapper.cs rename to src/client/spark_core/admin/AdminModelWrapper.cs index 62895933c..f52f016c5 100644 --- a/src/client/spark/Admin/AdminModelWrapper.cs +++ b/src/client/spark_core/admin/AdminModelWrapper.cs @@ -4,9 +4,9 @@ using System; using System.Collections.Generic; using System.Linq; -namespace mbts.spark +namespace bts.api.core { - class AdminModelWrapper + public class AdminModelWrapper { readonly AdminDataImmutable? _admin_data; readonly string _user_name; diff --git a/src/client/spark/Admin/PermissionFilters.cs b/src/client/spark_core/admin/PermissionFilters.cs similarity index 66% rename from src/client/spark/Admin/PermissionFilters.cs rename to src/client/spark_core/admin/PermissionFilters.cs index 115187a45..3da6a137c 100644 --- a/src/client/spark/Admin/PermissionFilters.cs +++ b/src/client/spark_core/admin/PermissionFilters.cs @@ -4,10 +4,6 @@ using bts.api.core; using bts.api.orderman; using bts.api.position; using bts.spark; -using mbts.collections; -using mbts.spark; -using mbts.spark.utilities; -using mbts.utils; using System; using System.Collections.Generic; using System.Collections.Immutable; @@ -18,14 +14,14 @@ using System.Reactive.Linq; namespace bts.api.core { - - static class PermissionFilters + public static class PermissionFilters { - public static IObservable> PermissionFilter(this IObservable> source, AdminModel am) + public static IObservable> + PermissionFilter(this IObservable> source, IObservable am) { var pred = Observable.Create>( observer => { - return am.on_admin_data.Subscribe(x => + return am.Subscribe(x => { Func filter = (z => x.can_view_account(z.Account)); observer.OnNext(filter); @@ -35,13 +31,14 @@ namespace bts.api.core return source.Filter(pred); } - public static IObservable> PermissionFilter(this IObservable> source, AdminModel am) + public static IObservable> + PermissionFilter(this IObservable> source, IObservable am) { var pred = Observable.Create>(observer => { - return am.on_admin_data.Subscribe(x => + return am.Subscribe(x => { - Func filter = (z => x.can_view_account(z.account())); + Func filter = (z => x.can_view_account(z.Def.Account ?? string.Empty)); observer.OnNext(filter); }); }); @@ -49,11 +46,12 @@ namespace bts.api.core return source.Filter(pred); } - public static IObservable> PermissionFilter(this IObservable> source, AdminModel am) + public static IObservable> + PermissionFilter(this IObservable> source, IObservable am) { var pred = Observable.Create>(observer => { - return am.on_admin_data.Subscribe(x => + return am.Subscribe(x => { Func filter = (z => x.can_view_account(z.Account)); observer.OnNext(filter); diff --git a/src/client/spark_fix/DropCopySession.cs b/src/client/spark_fix/DropCopySession.cs new file mode 100644 index 000000000..2d0567005 --- /dev/null +++ b/src/client/spark_fix/DropCopySession.cs @@ -0,0 +1,119 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reactive.Linq; +using System.Reactive.Concurrency; +using System.Text; + +using QuickFix; +using QuickFix.Fields; + + +using bts.api.core; +using bts.api.orderman; +using bts.api.user; +using bts.api.admin; + +namespace bts.fix +{ + + public class DropCopySession : QuickFix.MessageCracker, QuickFix.IApplication + { + static OrderService _orders = bts.api.Locator.locate(); + static UserService _users = bts.api.Locator.locate(); + static AdminService _admin = bts.api.Locator.locate(); + + private string _user_name; + private AuthToken _token; + private IDisposable _fillsdisp, _ordersdisp; + + public DropCopySession() + { + } + + virtual public async void FromAdmin(Message message, SessionID sessionID) + { + MsgType type = Message.IdentifyType(message.ToString()); + switch (type.Obj) + { + case MsgType.LOGON: + { + QuickFix.FIX44.Logon msg = (QuickFix.FIX44.Logon)message; + _user_name = msg.Username.getValue(); + var resp = await _users.authenticate_login_async(new AuthenticateLoginRequest { Login = msg.Username.getValue(), Password = msg.Password.getValue() }); + if (resp.success && resp.value.IsValid) + _token = resp.value.Token; + else + throw new RejectLogon("Logon rejected " + resp.error_message + resp.value?.Reason ?? string.Empty); + } + break; + default: + Console.WriteLine("ADMININ: " + message); + break; + } + } + + virtual public void ToAdmin(Message message, SessionID sessionID) + { + Console.WriteLine("ADMINOUT: " + message); + } + + virtual protected void subscribe_fills_and_orders() + { + var adm = _admin.subscribei_admin_data().Select(x => new AdminModelWrapper(mbts.GlobalExtensions.TryFirst(x.all), _user_name)); + + var scheduler = TaskPoolScheduler.Default; + var interval = TimeSpan.FromMilliseconds(500); + var on_orders = _orders.subscribei_orders().Naggle(interval, scheduler).PermissionFilter(adm).Table().Cache(); + var on_fills = _orders.subscribei_fills().Naggle(interval, scheduler).PermissionFilter(adm).Table().Cache(); + + _ordersdisp = on_orders.Subscribe(o => + { + }); + + _fillsdisp = on_fills.Subscribe(o => + { + }); + } + + virtual public void OnLogon(SessionID sessionID) + { + var msg = sessionID.ToString() + " Logged on"; + Console.WriteLine(msg); + Log.FIX.info(msg); + } + virtual public void OnLogout(SessionID sessionID) + { + var msg = sessionID.ToString() + " Logged out"; + Console.WriteLine(msg); + Log.FIX.info(msg); + } + + virtual public void FromApp(Message message, SessionID sessionID) + { + MsgType type = Message.IdentifyType(message.ToString()); + switch (type.Obj) + { + case MsgType.ORDER_STATUS_REQUEST: + Crack(message, sessionID); + break; + default: + Console.WriteLine("IN: " + message); + throw new UnsupportedMessageType(); + } + } + + virtual public void ToApp(Message message, SessionID sessionID) + { + Console.WriteLine("OUT: " + message); + } + + virtual public void OnCreate(SessionID sessionID) + { + + } + + virtual public void OnMessage(QuickFix.FIX44.BusinessMessageReject n, SessionID s) { } + virtual public void OnMessage(QuickFix.FIX44.News n, SessionID s) { } + } +} \ No newline at end of file diff --git a/src/client/spark_fix/FixInit.cs b/src/client/spark_fix/FixInit.cs index 2191a7d53..715e6bbae 100644 --- a/src/client/spark_fix/FixInit.cs +++ b/src/client/spark_fix/FixInit.cs @@ -10,12 +10,12 @@ namespace bts.fix { public class FixInit { - public static int start_acceptor(string settings_file, string http_address = null) + public static int start_acceptor(string settings_file, bool orders_allowed, string http_address = null) { try { SessionSettings settings = new SessionSettings(settings_file); - IApplication app = new Acceptor(); + IApplication app = (orders_allowed ? new OrderSession() as IApplication : new DropCopySession() as IApplication); IMessageStoreFactory storeFactory = new FileStoreFactory(settings); ILogFactory logFactory = new FileLogFactory(settings); IAcceptor acceptor = new ThreadedSocketAcceptor(app, storeFactory, settings, logFactory); diff --git a/src/client/spark_fix/Initiator.cs b/src/client/spark_fix/Initiator.cs deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/client/spark_fix/Acceptor.cs b/src/client/spark_fix/OrderSession.cs similarity index 95% rename from src/client/spark_fix/Acceptor.cs rename to src/client/spark_fix/OrderSession.cs index ee06dd3ae..653c75113 100644 --- a/src/client/spark_fix/Acceptor.cs +++ b/src/client/spark_fix/OrderSession.cs @@ -14,8 +14,9 @@ namespace bts.fix /// Note that this app is *NOT* a message cracker. /// - public class Acceptor : QuickFix.MessageCracker, QuickFix.IApplication + public class OrderSession : QuickFix.MessageCracker, QuickFix.IApplication { + static readonly decimal DEFAULT_MARKET_PRICE = 10; int orderID = 0; diff --git a/src/client/spark_fix/spark_fix.cfg b/src/client/spark_fix/spark_fix.cfg index a1318b449..71211dc5b 100644 --- a/src/client/spark_fix/spark_fix.cfg +++ b/src/client/spark_fix/spark_fix.cfg @@ -1,3 +1,5 @@ +#http://www.quickfixengine.org/quickfix/doc/html/configuration.html + [DEFAULT] ConnectionType=acceptor SocketAcceptPort=5001 @@ -9,8 +11,10 @@ UseDataDictionary=Y ResetOnLogon=Y ResetOnLogout=Y ResetOnDisconnect=Y -SSLEnable=N +LogonTimeout=30 + +SSLEnable=N # SSLEnable=Y # # It is recommended to install the certificate and refer to it by name instead of using filename + password # SSLCertificate=QuickFixn-TestServer.pfx diff --git a/src/client/spark_fix/spark_fix.csproj b/src/client/spark_fix/spark_fix.csproj index 96a9a9789..9f297b151 100644 --- a/src/client/spark_fix/spark_fix.csproj +++ b/src/client/spark_fix/spark_fix.csproj @@ -25,6 +25,7 @@ + diff --git a/src/client/sparkcmd/Cmd/ConsoleCommandEx.cs b/src/client/sparkcmd/Cmd/ConsoleCommandEx.cs index 18c73075d..1f731b6d9 100644 --- a/src/client/sparkcmd/Cmd/ConsoleCommandEx.cs +++ b/src/client/sparkcmd/Cmd/ConsoleCommandEx.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace ManyConsole { +namespace ManyConsole.CommandLineUtils { public static class ConsoleCommandEx { public static string get_argument(this ConsoleCommand _, string arg_name) { var arg = Environment.GetCommandLineArgs().FirstOrDefault(str => str.StartsWith("--"+arg_name)); diff --git a/src/client/sparkcmd/Cmd/FIXCommand.cs b/src/client/sparkcmd/Cmd/FIXCommand.cs index e6ce5d572..3427de8f4 100644 --- a/src/client/sparkcmd/Cmd/FIXCommand.cs +++ b/src/client/sparkcmd/Cmd/FIXCommand.cs @@ -8,27 +8,37 @@ namespace bts { public class FIXCommand : ConsoleCommand { - bool _acceptor, _initiator; + bool _initiator, _orders, _dropcopy; string _config, _http; public FIXCommand() { - IsCommand("fix", "start a fix acceptor or initiator session"); - HasOption("a|acceptor", "Start a FIX Acceptor", h => _acceptor = true); - HasOption("i|initiator", "Start a FIX Initiator", h => _initiator = true); + 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); - HasAdditionalArguments(null, " [other params]"); + + 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); + + //HasAdditionalArguments(null, " [other params]"); } public override int Run(string[] remaining_args) { - if (_acceptor) + if (_orders) { - Console.WriteLine("Starting FIX Acceptor using " + _config + " Http server " + _http ?? "no"); - return FixInit.start_acceptor(_config, (string.IsNullOrEmpty(_http) ? null : _http)); + Console.WriteLine("Starting FIX ORDERS Acceptor using " + _config + " Http server " + _http ?? "no"); + return FixInit.start_acceptor(_config, true, (string.IsNullOrEmpty(_http) ? null : _http)); + } + else if (_dropcopy) + { + Console.WriteLine("Starting FIX DROP Acceptor using " + _config + " Http server " + _http ?? "no"); + return FixInit.start_acceptor(_config, false, (string.IsNullOrEmpty(_http) ? null : _http)); } else if (_initiator) - { + { + Console.WriteLine("Initiator not supported yet"); } + Console.WriteLine("Must select either orders or dropcopy session"); return -1; } } diff --git a/src/client/sparkcmd/Cmd/ServiceTail.cs b/src/client/sparkcmd/Cmd/ServiceTail.cs index 316d52071..2ff2e3aac 100644 --- a/src/client/sparkcmd/Cmd/ServiceTail.cs +++ b/src/client/sparkcmd/Cmd/ServiceTail.cs @@ -1,6 +1,6 @@ using bts.api.core; using bts.test; -using ManyConsole; +using ManyConsole.CommandLineUtils; using System; using System.Collections.Generic; using System.Linq; diff --git a/src/lib/CMakeDeps.cmake b/src/lib/CMakeDeps.cmake index cd221187f..20657086a 100644 --- a/src/lib/CMakeDeps.cmake +++ b/src/lib/CMakeDeps.cmake @@ -1 +1 @@ -set(sources api/apicore.proto;api/apigateway.proto;api/apioptions.proto;api/core/ApiClientInterop.cpp;api/core/ApiServerInterop.cpp;api/public/ApiServer.cpp;api/public/ClientChannel.cpp;api/public/QuickbusClientChannel.cpp;api/public/ServerChannel.cpp;api/public/ServiceContext.cpp;api/service_helpers/AdminServiceUtils.cpp;api/services/AdminService.proto;api/services/ApiUnitTestService.proto;api/services/ErrorReportService.proto;api/services/HelloService.proto;api/services/MarketDataAuxiliaryService.proto;api/services/MarketDataRelay.proto;api/services/OrderService.proto;api/services/OutOfProcessURLListener.proto;api/services/PersistenceService.proto;api/services/PositionService.proto;api/services/ShellDiagnosticService.proto;api/services/ShellLatencyService.proto;api/services/SyntheticSecurityService.proto;api/services/UserService.proto;api/test/ApiTests.cpp;api/test/HelloServiceServer.cpp;config/ConfigCheck.cpp;config/ConfigDownloader.cpp;config/ConfigErrorCollector.cpp;config/ConfigLog.cpp;config/ConfigPropertyEvaluator.cpp;config/ConfigValueQueue.cpp;config/ConfigurationException.cpp;config/ConfigurationState.cpp;config/PreprocessInputStream.cpp;config/config.cpp;config/defaults/Executor.conf;config/defaults/MarketData.conf;config/defaults/Ports.conf;config/defaults/Symbols.conf;config/defaults/cme_reference_data.conf;config/defaults/edge.conf;config/defaults/jetfix.conf;config/defaults/logging.conf;config/defaults/orderman_cfg.conf;config/defaults/orders_fills_cleanup.conf;config/defaults/spreader.conf;config/defaults/testkeys.conf;config/defaults/threads.conf;config/defaults/toggles.conf;config/extensions/extensions.proto;config/invalid/invalid.proto;config/protos/ExchangeSimCfg.proto;config/protos/MarketData.proto;config/protos/Ports.proto;config/protos/Symbols.proto;config/protos/UI.proto;config/protos/cme_reference_data.proto;config/protos/jetfix.proto;config/protos/logging.proto;config/protos/mercury_cfg.proto;config/protos/orderman_cfg.proto;config/protos/orders_fills_cleanup.proto;config/protos/quickbus_cfg.proto;config/protos/spreader.proto;config/protos/system.proto;config/protos/testkeys.proto;config/protos/threads.proto;config/protos/toggles.proto;config/tests/HTTPServer.cpp;config/tests/config_ref_tests.cpp;config/tests/config_tests.cpp;config/text_format/text_format.cpp;domain_model/Security.cpp;domain_model/Security.proto;domain_model/SecurityTests.cpp;domain_model/tests/domain_tests.cpp;expression/BooleanGrammar.cpp;expression/ExpressionEvaluator.cpp;expression/ParserExceptions.cpp;expression/Value.cpp;expression/tests/expression_parser_tests.cpp;jetfix/codec/FIXArray.cpp;jetfix/common/OutFIX.cpp;jetfix/connection/AsyncReader.cpp;jetfix/connection/IConnection.cpp;jetfix/connection/SocketConnection.cpp;jetfix/gateway/CoreGateway.cpp;jetfix/gateway/JetFIXGateway.cpp;jetfix/gateway/Session.cpp;jetfix/store/FIXFileStore.cpp;jetfix/store/session_name.cpp;jetfix/tests/async_reader_tests.cpp;jetfix/tests/decoding_tests.cpp;jetfix/tests/fix_encoding_stream_tests.cpp;jetfix/tests/fix_fragment_tests.cpp;jetfix/tests/jetfix_performance_tests.cpp;jetfix/tests/sample_fix.cpp;jetfix/tests/store_tests.cpp;logging/LoggerHub.cpp;logging/Sink.cpp;logging/logging.cpp;logging/tests/logging_tests.cpp;md/Diag/MDPeriodicDumper.cpp;md/Diag/ShmDumper.cpp;md/MDConsumer.cpp;md/MDConsumerHandle.cpp;md/MDConsumerInterop.cpp;md/MDProducer.cpp;md/MDProducerHandle.cpp;md/MDRecoverableConsumer.cpp;md/MemorySegmentUtils.cpp;md/PlatformLoader.cpp;md/PriceSize.cpp;md/SecurityDB.cpp;md/SecurityIDRecorder.cpp;md/SettlementRecorder.cpp;md/Shm/FixedSecurity.cpp;md/SyntheticSecurityService.cpp;md/cme/MDP3Utils.cpp;md/common.cpp;md/protos/co2.proto;md/relay/QueryServer.cpp;md/relay/RelayClient.cpp;md/relay/RelayRecorder.cpp;md/test/Co2ManagedTestHelper.cpp;md/test/Co2TestInstrument.cpp;md/test/md2_tests.cpp;md/test/synthetic_book_merge_tests.cpp;mercury/actors/IPollableActor.cpp;mercury/broker/Broker.cpp;mercury/broker/BrokerProxy.cpp;mercury/broker/ILocalBroker.cpp;mercury/broker/IRemoteBroker.cpp;mercury/common/mercury_common.cpp;mercury/events/TimerEvent.cpp;mercury/executor/Executor.cpp;mercury/topics/Topic.cpp;metrics/metrics.cpp;metrics/system_metrics.cpp;orderman/actors/AsyncFactory.cpp;orderman/actors/ExecutionGateway.cpp;orderman/actors/FillStore.cpp;orderman/actors/MDSupplementarySource.cpp;orderman/actors/OrderStore.cpp;orderman/actors/SODPosition.cpp;orderman/actors/SecuritySrc.cpp;orderman/actors/ServiceBridge.cpp;orderman/actors/order_manager/OrderBuilder.cpp;orderman/actors/order_manager/OrderManager.cpp;orderman/actors/order_manager/OrderServicesData.cpp;orderman/events/CancelRejectEvent.cpp;orderman/events/NewExecutionReportEvent.cpp;orderman/limiter/LimitStore.cpp;orderman/limiter/Limiter.cpp;orderman/limiter/ProductLimitNode.cpp;orderman/limiter/ProductLimitTree.cpp;orderman/limiter/SecurityLimitNode.cpp;orderman/limiter/SecurityLimitTree.cpp;orderman/limiter/tests/limit_tests.cpp;orderman/order_factory/DynamicOrderRegistry.cpp;orderman/order_factory/OrderFactory.cpp;orderman/order_router/OrderRouter.cpp;orderman/orderman_utils/PerfTraceLog.cpp;orderman/orderman_utils/fix_order_codec.cpp;orderman/orders/DynamicOrder.cpp;orderman/orders/IcebergOrder.cpp;orderman/orders/NativeOrder.cpp;orderman/orders/Order.cpp;orderman/orders/TimeBoxOrder.cpp;orderman/orders/TriggerOrder.cpp;orderman/orders/book_algos/BookAlgo.cpp;orderman/orders/book_algos/CoverOrder.cpp;orderman/orders/book_algos/JoinOrder.cpp;orderman/orders/book_algos/LeanOrder.cpp;orderman/orders/book_algos/OffsetOrder.cpp;orderman/orders/book_algos/TickOrder.cpp;orderman/orders/book_algos/TopOrder.cpp;orderman/orders/spreader_orders/SpreaderOrder.cpp;orderman/orders/spreader_orders/spreader/LegPropertyData.cpp;orderman/orders/spreader_orders/spreader/QuoteLegPriceQuantityState.cpp;orderman/orders/spreader_orders/spreader/SingleFillHedger.cpp;orderman/orders/spreader_orders/spreader/SingleLegQuoter.cpp;orderman/orders/spreader_orders/spreader/SpreaderBookkeepingData.cpp;orderman/orders/spreader_orders/spreader/SpreaderChildOrderState.cpp;orderman/orders/spreader_orders/spreader/SpreaderLegData.cpp;orderman/orders/spreader_orders/spreader/SpreaderUtils.cpp;orderman/orders/spreader_orders/spreader/external_interfacing/SpreaderOrderBuilder.cpp;orderman/orders/spreader_orders/spreader/external_interfacing/SpreaderOrderServices.cpp;orderman/orders/spreader_orders/spreader/external_interfacing/SpreaderPreActivationOrderServices.cpp;orderman/orders/spreader_orders/spreader/hedger/UnhedgedDelta.cpp;orderman/orders/spreader_orders/spreader/hedger/hedger_states/HedgerEndStateWorker.cpp;orderman/orders/spreader_orders/spreader/hedger/hedger_states/HedgerStartStateWorker.cpp;orderman/orders/spreader_orders/spreader/hedger/hedger_states/HedgerWaitingForCancelAckStateWorker.cpp;orderman/orders/spreader_orders/spreader/hedger/hedger_states/HedgerWaitingForFirstAckCancelledStateWorker.cpp;orderman/orders/spreader_orders/spreader/hedger/hedger_states/HedgerWaitingForFirstAckStateWorker.cpp;orderman/orders/spreader_orders/spreader/hedger/hedger_states/HedgerWorkingStateWorker.cpp;orderman/orders/spreader_orders/spreader/quoter/QuoteDriverSet.cpp;orderman/orders/spreader_orders/spreader/quoter/QuoteDriverSetHistory.cpp;orderman/orders/spreader_orders/spreader/quoter/QuoteLegDriver.cpp;orderman/orders/spreader_orders/spreader/quoter/quoter_states/QuoterEndStateWorker.cpp;orderman/orders/spreader_orders/spreader/quoter/quoter_states/QuoterStartStateWorker.cpp;orderman/orders/spreader_orders/spreader/quoter/quoter_states/QuoterWaitingForCancelAckStateWorker.cpp;orderman/orders/spreader_orders/spreader/quoter/quoter_states/QuoterWaitingForFirstAckCancelledWorker.cpp;orderman/orders/spreader_orders/spreader/quoter/quoter_states/QuoterWaitingForFirstAckWorker.cpp;orderman/orders/spreader_orders/spreader/quoter/quoter_states/QuoterWaitingForIOCWorker.cpp;orderman/orders/spreader_orders/spreader/quoter/quoter_states/QuoterWaitingForSizeStateWorker.cpp;orderman/orders/spreader_orders/spreader/quoter/quoter_states/QuoterWorkingStateWorker.cpp;orderman/orders/spreader_orders/spreader_states/SpreaderEndStateWorker.cpp;orderman/orders/spreader_orders/spreader_states/SpreaderStartStateWorker.cpp;orderman/orders/spreader_orders/spreader_states/SpreaderWaitingForCancelAllStateWorker.cpp;orderman/orders/spreader_orders/spreader_states/SpreaderWaitingForInitialDataStateWorker.cpp;orderman/orders/spreader_orders/spreader_states/SpreaderWorkingStateWorker.cpp;orderman/orders/spreader_orders/tests/spreader_tests.cpp;orderman/server/OrderServiceServer.cpp;orderman/tests/fat_wrapper_tests.cpp;orderman2/OrderManager2.cpp;os/os.cpp;os/tests/os_tests.cpp;persistence/IStore.cpp;persistence/PersistenceServiceServer.cpp;persistence/SqliteStore.cpp;persistence/persistence_utils.cpp;persistence/tests/PersistenceServiceTests.cpp;plugin/SparkServices.cpp;plugin/plugin.cpp;quickbus/core/LocalNode.cpp;quickbus/core/Quickbus.cpp;quickbus/core/SubscriptionID.cpp;quickbus/core/TableID.cpp;quickbus/message_model/Update.cpp;quickbus/message_model/merge_updates.cpp;quickbus/network/QBConnection.cpp;quickbus/network/QBConnectionManager.cpp;quickbus/network/endpoint_description.cpp;quickbus/network/quickbus_msgs.proto;quickbus/pubsub/TablePublisher.cpp;quickbus/pubsub/TableSubscriber.cpp;quickbus/pubsub/tests/qb_pubsub_tests.cpp;quickbus/routing/INode.cpp;quickbus/routing/NodeID.cpp;quickbus/routing/Router.cpp;quickbus/rpc/RPCClient.cpp;quickbus/rpc/RPCServer.cpp;quickbus/rpc/RPCSessionID.cpp;quickbus/rpc/rpc_utils.cpp;quickbus/rpc/tests/qb_rpc_tests.cpp;quickbus/tests/quickbus_tests.cpp;sparkproto/SparkProtos.proto;testing/catch_test_runner.cpp;utils/AuthToken.cpp;utils/Dispatcher.cpp;utils/GrowableSPSCQueue.cpp;utils/HTTPStream.cpp;utils/PBUtils.cpp;utils/Puid.cpp;utils/SecureLogon.cpp;utils/SharedMemory.cpp;utils/Sqlite_utils.cpp;utils/Uuid.cpp;utils/datetime.cpp;utils/download.cpp;utils/file_utils.cpp;utils/init_spark_lib.cpp;utils/is_unittest_environment.cpp;utils/stats.cpp;utils/thread_manager.cpp) \ No newline at end of file +set(sources api/apicore.proto;api/apigateway.proto;api/apioptions.proto;api/core/ApiClientInterop.cpp;api/core/ApiServerInterop.cpp;api/public/ApiServer.cpp;api/public/ClientChannel.cpp;api/public/QuickbusClientChannel.cpp;api/public/ServerChannel.cpp;api/public/ServiceContext.cpp;api/service_helpers/AdminServiceUtils.cpp;api/services/AdminService.proto;api/services/ApiUnitTestService.proto;api/services/ErrorReportService.proto;api/services/HelloService.proto;api/services/MarketDataAuxiliaryService.proto;api/services/MarketDataRelay.proto;api/services/OrderService.proto;api/services/OutOfProcessURLListener.proto;api/services/PersistenceService.proto;api/services/PositionService.proto;api/services/ShellDiagnosticService.proto;api/services/ShellLatencyService.proto;api/services/SyntheticSecurityService.proto;api/services/UserService.proto;api/test/ApiTests.cpp;api/test/HelloServiceServer.cpp;config/ConfigCheck.cpp;config/ConfigDownloader.cpp;config/ConfigErrorCollector.cpp;config/ConfigLog.cpp;config/ConfigPropertyEvaluator.cpp;config/ConfigValueQueue.cpp;config/ConfigurationException.cpp;config/ConfigurationState.cpp;config/PreprocessInputStream.cpp;config/config.cpp;config/defaults/MarketData.conf;config/defaults/Ports.conf;config/defaults/Symbols.conf;config/defaults/cme_reference_data.conf;config/defaults/edge.conf;config/defaults/jetfix.conf;config/defaults/logging.conf;config/defaults/orderman_cfg.conf;config/defaults/orders_fills_cleanup.conf;config/defaults/spreader.conf;config/defaults/testkeys.conf;config/defaults/threads.conf;config/defaults/toggles.conf;config/extensions/extensions.proto;config/invalid/invalid.proto;config/protos/ExchangeSimCfg.proto;config/protos/MarketData.proto;config/protos/Ports.proto;config/protos/Symbols.proto;config/protos/UI.proto;config/protos/cme_reference_data.proto;config/protos/jetfix.proto;config/protos/logging.proto;config/protos/mercury_cfg.proto;config/protos/orderman_cfg.proto;config/protos/orders_fills_cleanup.proto;config/protos/quickbus_cfg.proto;config/protos/spreader.proto;config/protos/system.proto;config/protos/testkeys.proto;config/protos/threads.proto;config/protos/toggles.proto;config/tests/HTTPServer.cpp;config/tests/config_ref_tests.cpp;config/tests/config_tests.cpp;config/text_format/text_format.cpp;domain_model/Security.cpp;domain_model/Security.proto;domain_model/SecurityTests.cpp;domain_model/tests/domain_tests.cpp;expression/BooleanGrammar.cpp;expression/ExpressionEvaluator.cpp;expression/ParserExceptions.cpp;expression/Value.cpp;expression/tests/expression_parser_tests.cpp;logging/LoggerHub.cpp;logging/Sink.cpp;logging/logging.cpp;logging/tests/logging_tests.cpp;md/Diag/MDPeriodicDumper.cpp;md/Diag/ShmDumper.cpp;md/MDConsumer.cpp;md/MDConsumerHandle.cpp;md/MDConsumerInterop.cpp;md/MDProducer.cpp;md/MDProducerHandle.cpp;md/MDRecoverableConsumer.cpp;md/MemorySegmentUtils.cpp;md/PlatformLoader.cpp;md/PriceSize.cpp;md/SecurityDB.cpp;md/SecurityIDRecorder.cpp;md/SettlementRecorder.cpp;md/Shm/FixedSecurity.cpp;md/SyntheticSecurityService.cpp;md/cme/MDP3Utils.cpp;md/common.cpp;md/protos/co2.proto;md/relay/QueryServer.cpp;md/relay/RelayClient.cpp;md/relay/RelayRecorder.cpp;md/test/Co2ManagedTestHelper.cpp;md/test/Co2TestInstrument.cpp;md/test/md2_tests.cpp;md/test/synthetic_book_merge_tests.cpp;os/os.cpp;os/tests/os_tests.cpp;quickbus/core/LocalNode.cpp;quickbus/core/Quickbus.cpp;quickbus/core/SubscriptionID.cpp;quickbus/core/TableID.cpp;quickbus/message_model/Update.cpp;quickbus/message_model/merge_updates.cpp;quickbus/network/QBConnection.cpp;quickbus/network/QBConnectionManager.cpp;quickbus/network/endpoint_description.cpp;quickbus/network/quickbus_msgs.proto;quickbus/pubsub/TablePublisher.cpp;quickbus/pubsub/TableSubscriber.cpp;quickbus/pubsub/tests/qb_pubsub_tests.cpp;quickbus/routing/INode.cpp;quickbus/routing/NodeID.cpp;quickbus/routing/Router.cpp;quickbus/rpc/RPCClient.cpp;quickbus/rpc/RPCServer.cpp;quickbus/rpc/RPCSessionID.cpp;quickbus/rpc/rpc_utils.cpp;quickbus/rpc/tests/qb_rpc_tests.cpp;quickbus/tests/quickbus_tests.cpp;sparkproto/SparkProtos.proto;testing/catch_test_runner.cpp;utils/AuthToken.cpp;utils/Dispatcher.cpp;utils/GrowableSPSCQueue.cpp;utils/HTTPStream.cpp;utils/PBUtils.cpp;utils/Puid.cpp;utils/SecureLogon.cpp;utils/SharedMemory.cpp;utils/Sqlite_utils.cpp;utils/Uuid.cpp;utils/datetime.cpp;utils/download.cpp;utils/file_utils.cpp;utils/init_spark_lib.cpp;utils/is_unittest_environment.cpp;utils/stats.cpp;utils/thread_manager.cpp) \ No newline at end of file diff --git a/src/lib/api/service_helpers/AdminServiceUtils.cpp b/src/lib/api/service_helpers/AdminServiceUtils.cpp index ae6641719..ca30f9f61 100644 --- a/src/lib/api/service_helpers/AdminServiceUtils.cpp +++ b/src/lib/api/service_helpers/AdminServiceUtils.cpp @@ -1303,6 +1303,7 @@ void AdminServiceUtils::bootstrap_data (bts::api::admin::AdminData& data){ //associate users bts::api::admin::UserAccountPermissionUnit permission_unit; permission_unit.mutable_trading_permission()->set_submit_market_orders(true); + permission_unit.mutable_trading_permission()->set_has_permissions(true); permission_unit.mutable_admin_permission()->set_has_permissions(true); bts::api::admin::UserAccountPermissions account_permissions; account_permissions.mutable_account_permissions()->insert(google::protobuf::MapPair(parent_account->id(), permission_unit)); From 6e188b4f739666cabc45b29ee285c28c350e530e Mon Sep 17 00:00:00 2001 From: Kevin Darby Date: Tue, 4 Dec 2018 16:37:41 -0500 Subject: [PATCH 05/28] shaping up --- src/client/spark_api/md/MarketDataClient.cs | 28 +- src/client/spark_fix/DropCopySession.cs | 290 ++++++++++++++++---- src/client/spark_fix/FixInit.cs | 10 +- src/client/spark_fix/FixRouter.cs | 97 +++++++ src/client/spark_fix/OrderSession.cs | 142 +--------- src/client/spark_fix/spark_fix.csproj | 1 + 6 files changed, 380 insertions(+), 188 deletions(-) create mode 100644 src/client/spark_fix/FixRouter.cs diff --git a/src/client/spark_api/md/MarketDataClient.cs b/src/client/spark_api/md/MarketDataClient.cs index 9f06f6aeb..61d62672e 100644 --- a/src/client/spark_api/md/MarketDataClient.cs +++ b/src/client/spark_api/md/MarketDataClient.cs @@ -75,7 +75,12 @@ namespace bts.api.md return req; } - public Security lookup(security_key key) + public IEnumerable get_securities() + { + return _data.Values.Select(x => new SecurityImmutable(x.data.Security)); + } + + public SecurityImmutable? lookup(security_key key) { Data value; if(_data.TryGetValue(key, out value)) @@ -233,6 +238,11 @@ namespace bts.api.md /// /// public async Task start_pump(TimeSpan? interval = null) + { + await _start_pump(interval); + } + + async Task _start_pump(TimeSpan? interval = null, int num_pumps = -1) { var rep = await _md.Value.request_names_async(new VoidMessage()); int count = 0; @@ -248,7 +258,8 @@ namespace bts.api.md } } while (!rep.success && count++ < 5); - while (true) + count = 0; + while (num_pumps < 0 || count++ < num_pumps) { var reply = await _md.Value.requestmd_async(_subscription); if (reply.success) @@ -298,6 +309,19 @@ namespace bts.api.md await this.start_pump(interval); } + public void pump_once() + { + if (_pump_task == null) + { + _pump_task = this._start_pump(null, 1) + .ContinueWith(ex => + { + System.Diagnostics.Debug.Assert(ex == null, ex.ToString()); + } + , TaskContinuationOptions.OnlyOnFaulted); + } + } + readonly CancellationTokenSource _cts = new CancellationTokenSource(); public void Dispose() diff --git a/src/client/spark_fix/DropCopySession.cs b/src/client/spark_fix/DropCopySession.cs index 2d0567005..eeed4e6b3 100644 --- a/src/client/spark_fix/DropCopySession.cs +++ b/src/client/spark_fix/DropCopySession.cs @@ -13,26 +13,35 @@ using bts.api.core; using bts.api.orderman; using bts.api.user; using bts.api.admin; +using System.Collections.Concurrent; +using System.Runtime.CompilerServices; namespace bts.fix { - - public class DropCopySession : QuickFix.MessageCracker, QuickFix.IApplication + class DropCopySession : QuickFix.MessageCracker, QuickFix.IApplication { - static OrderService _orders = bts.api.Locator.locate(); - static UserService _users = bts.api.Locator.locate(); - static AdminService _admin = bts.api.Locator.locate(); + protected static OrderService _orders = bts.api.Locator.locate(); + protected static UserService _users = bts.api.Locator.locate(); + protected static AdminService _admin = bts.api.Locator.locate(); - private string _user_name; - private AuthToken _token; - private IDisposable _fillsdisp, _ordersdisp; + protected string _user_name; + protected AuthToken _token; + protected IDisposable _fillsdisp; + protected IDisposable _ordersdisp; - public DropCopySession() + protected readonly ConcurrentDictionary _cache = new ConcurrentDictionary(); + protected readonly IFixRouter _router; + protected readonly SessionID _sess; + public DropCopySession(IFixRouter router, SessionID sess) { + _router = router; + _sess = sess; } virtual public async void FromAdmin(Message message, SessionID sessionID) - { + { + Log.assert_d(sessionID.Equals(_sess)); + MsgType type = Message.IdentifyType(message.ToString()); switch (type.Obj) { @@ -48,17 +57,217 @@ namespace bts.fix } break; default: - Console.WriteLine("ADMININ: " + message); + log_info("ADMININ: " + message); break; } } virtual public void ToAdmin(Message message, SessionID sessionID) { - Console.WriteLine("ADMINOUT: " + message); + Log.assert_d(sessionID.Equals(_sess)); + log_info("ADMINOUT: " + message); } - virtual protected void subscribe_fills_and_orders() + virtual public void OnLogon(SessionID sessionID) + { + Log.assert_d(sessionID.Equals(_sess)); + var msg = sessionID.ToString() + " Logged on"; + log_info(msg); + + subscribe_fills_and_orders(sessionID); + } + virtual public void OnLogout(SessionID sessionID) + { + Log.assert_d(sessionID.Equals(_sess)); + var msg = sessionID.ToString() + " Logged out"; + log_info(msg); + + if(_ordersdisp != null) + _ordersdisp.Dispose(); + if(_fillsdisp != null) + _fillsdisp.Dispose(); + } + + virtual public void FromApp(Message message, SessionID sessionID) + { + Log.assert_d(sessionID.Equals(_sess)); + MsgType type = Message.IdentifyType(message.ToString()); + switch (type.getValue()) + { + case MsgType.ORDER_STATUS_REQUEST: + case MsgType.SECURITYDEFINITIONREQUEST: + log_info("IN: " + message); + Crack(message, sessionID); + break; + default: + log_info("UNSUPPORTED MESSAGE IN: " + type.getValue()); + throw new UnsupportedMessageType(); + } + } + + virtual public void ToApp(Message message, SessionID sessionID) + { + Log.assert_d(sessionID.Equals(_sess)); + log_info("OUT: " + message); + } + + virtual public void OnCreate(SessionID sessionID) + { + log_info("CREATE"); + } + + virtual public void OnMessage(QuickFix.FIX44.BusinessMessageReject n, SessionID s) + { + Log.assert(false, "biz reject wtf " + n.EncodedText.getValue()); + } + virtual public void OnMessage(QuickFix.FIX44.News n, SessionID s) + { + log_info("news " + n.EncodedHeadline.getValue()); + } + + protected void log_info(string message, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0) + { + Log.FIX.info(_sess.ToString() + " " + message, file, line); + } + + #region status stuff + + QuickFix.Fields.OrdStatus translate_status(in bts.api.orderman.OrderStateImmutable state) + { + if (state.HasMarket) + { + return new OrdStatus((char)state.Market.NativeState.NativeStatus); + } + else if (state.HasLimit) + { + return new OrdStatus((char)state.Limit.NativeState.NativeStatus); + } + else if (state.HasStop) + { + return new OrdStatus((char)state.Stop.NativeState.NativeStatus); + } + else if (state.HasStopLimit) + { + return new OrdStatus((char)state.StopLimit.NativeState.NativeStatus); + } + else + { + switch (state.Status) + { + case OrderStatus.Canceled: + return new OrdStatus(OrdStatus.CANCELED); + case OrderStatus.Completed: + return new OrdStatus(OrdStatus.FILLED); + case OrderStatus.Disconnected: + return new OrdStatus(OrdStatus.STOPPED); + case OrderStatus.Error: + return new OrdStatus(OrdStatus.REJECTED); + case OrderStatus.Inactive: + return new OrdStatus(OrdStatus.PENDING_NEW); + case OrderStatus.PendingWorking: + return new OrdStatus(OrdStatus.PENDING_NEW); + case OrderStatus.RejectedBySpark: + return new OrdStatus(OrdStatus.REJECTED); + case OrderStatus.Working: + { + if(state.FilledQuantity < state.Quantity) + return new OrdStatus(OrdStatus.PARTIALLY_FILLED); + else + return new OrdStatus(OrdStatus.NEW); + } + default: + return new OrdStatus(); + } + } + } + + virtual protected void process_order_state(in OrderStateImmutable state, ref uint filled, ref uint leaves, ref double avgprx, + ref QuickFix.Fields.OrdStatus fstatus) + { + filled = state.FilledQuantity; + leaves = state.Quantity - state.FilledQuantity; + avgprx = state.AvgPrice; + fstatus = translate_status(state); + } + + #endregion + + protected void send(Message mess, SessionID sess) + { + try + { + Session.SendToTarget(mess, sess); + } + catch (SessionNotFound ex) + { + Log.FIX.error("==session not found exception!=="); + Log.FIX.fatal(ex.ToString()); + Log.assert(false, "session not found " + sess); + } + catch (Exception ex) + { + Log.FIX.error("==exception sending to " + sess + " " + ex.ToString()); + } + } + + virtual protected void send_fill(SessionID sess, in FillImmutable fill, bool change = false) + { + var exec = new QuickFix.Fields.ExecType(QuickFix.Fields.ExecType.FILL); + QuickFix.Fields.OrdStatus status = new QuickFix.Fields.OrdStatus(); + uint filled = 0; uint leaves = 0; double prx = 0.0; + OrderStateImmutable state; + if (_cache.TryGetValue(fill.OrderKey, out state)) + { + process_order_state(state, ref filled, ref leaves, ref prx, ref status); + if (leaves > 0) + exec = new QuickFix.Fields.ExecType(QuickFix.Fields.ExecType.PARTIAL_FILL); + } + if (change) + exec = new QuickFix.Fields.ExecType(QuickFix.Fields.ExecType.TRADE_CORRECT); + + var sec = _router.lookup(fill.SecurityKey); + QuickFix.FIX44.ExecutionReport report = new QuickFix.FIX44.ExecutionReport( + new OrderID(fill.OrderKey.ToString()), + new ExecID(fill.FillKey.ToString()), + exec, + status, + new Symbol(sec?.Symbol ?? string.Empty), + new Side(fill.Side == bts.api.Side.Buy ? Side.BUY : Side.SELL), + new LeavesQty(leaves), + new CumQty(filled), + new AvgPx(Convert.ToDecimal(prx))); + if (sec?.HasGlbx ?? false) + report.SecurityDesc = new SecurityDesc(sec.Value.Glbx.SecurityDesc); + send(report, sess); + } + + virtual protected void send_order(SessionID sess, in OrderRecordImmutable order, bool change = false) + { + var exec = new QuickFix.Fields.ExecType(QuickFix.Fields.ExecType.NEW); + if (_cache.TryGetValue(order.Key, out OrderStateImmutable _)) + exec = new QuickFix.Fields.ExecType(QuickFix.Fields.ExecType.ORDER_STATUS); + + QuickFix.Fields.OrdStatus status = new QuickFix.Fields.OrdStatus(); + uint filled = 0; uint leaves = 0; double prx = 0.0; + process_order_state(order.State, ref filled, ref leaves, ref prx, ref status); + + var sec = _router.lookup(order.Def.SecurityKey); + QuickFix.FIX44.ExecutionReport report = new QuickFix.FIX44.ExecutionReport( + new OrderID(order.Key.ToString()), + new ExecID("0"), + exec, + status, + new Symbol(sec?.Symbol ?? string.Empty), + new Side(order.Def.Side == bts.api.Side.Buy ? Side.BUY : Side.SELL), + new LeavesQty(leaves), + new CumQty(filled), + new AvgPx(Convert.ToDecimal(prx))); + if (sec?.HasGlbx ?? false) + report.SecurityDesc = new SecurityDesc(sec.Value.Glbx.SecurityDesc); + send(report, sess); + } + + virtual protected void subscribe_fills_and_orders(SessionID sessionID) { var adm = _admin.subscribei_admin_data().Select(x => new AdminModelWrapper(mbts.GlobalExtensions.TryFirst(x.all), _user_name)); @@ -69,51 +278,22 @@ namespace bts.fix _ordersdisp = on_orders.Subscribe(o => { + foreach (var order in o.added) + { + send_order(sessionID, order); + _cache[order.Key] = order.State; + } + foreach (var order in o.changed) + send_order(sessionID, order, true); }); - - _fillsdisp = on_fills.Subscribe(o => + + _fillsdisp = on_fills.Subscribe(f => { + foreach (var fill in f.added) + send_fill(sessionID, fill); + foreach (var fill in f.changed) + send_fill(sessionID, fill); }); - } - - virtual public void OnLogon(SessionID sessionID) - { - var msg = sessionID.ToString() + " Logged on"; - Console.WriteLine(msg); - Log.FIX.info(msg); - } - virtual public void OnLogout(SessionID sessionID) - { - var msg = sessionID.ToString() + " Logged out"; - Console.WriteLine(msg); - Log.FIX.info(msg); - } - - virtual public void FromApp(Message message, SessionID sessionID) - { - MsgType type = Message.IdentifyType(message.ToString()); - switch (type.Obj) - { - case MsgType.ORDER_STATUS_REQUEST: - Crack(message, sessionID); - break; - default: - Console.WriteLine("IN: " + message); - throw new UnsupportedMessageType(); - } - } - - virtual public void ToApp(Message message, SessionID sessionID) - { - Console.WriteLine("OUT: " + message); - } - - virtual public void OnCreate(SessionID sessionID) - { - } - - virtual public void OnMessage(QuickFix.FIX44.BusinessMessageReject n, SessionID s) { } - virtual public void OnMessage(QuickFix.FIX44.News n, SessionID s) { } } } \ No newline at end of file diff --git a/src/client/spark_fix/FixInit.cs b/src/client/spark_fix/FixInit.cs index 715e6bbae..bd0250b2e 100644 --- a/src/client/spark_fix/FixInit.cs +++ b/src/client/spark_fix/FixInit.cs @@ -10,12 +10,18 @@ namespace bts.fix { public class FixInit { - public static int start_acceptor(string settings_file, bool orders_allowed, string http_address = null) + public static int start_acceptor(string settings_file, bool orders_allowed, string http_address = null) { try { SessionSettings settings = new SessionSettings(settings_file); - IApplication app = (orders_allowed ? new OrderSession() as IApplication : new DropCopySession() as IApplication); + IApplication app = new FixRouter( (th, sess) => + { + if(orders_allowed) + return new OrderSession(th, sess); + else + return new DropCopySession(th, sess); + }); IMessageStoreFactory storeFactory = new FileStoreFactory(settings); ILogFactory logFactory = new FileLogFactory(settings); IAcceptor acceptor = new ThreadedSocketAcceptor(app, storeFactory, settings, logFactory); diff --git a/src/client/spark_fix/FixRouter.cs b/src/client/spark_fix/FixRouter.cs new file mode 100644 index 000000000..a05841ed3 --- /dev/null +++ b/src/client/spark_fix/FixRouter.cs @@ -0,0 +1,97 @@ +using System; +using System.Collections.Generic; +using System.Collections.Concurrent; +using System.Linq; +using System.Reactive.Linq; +using System.Reactive.Concurrency; +using System.Text; + +using QuickFix; +using QuickFix.Fields; + +using bts.api; +using bts.api.core; +using bts.api.orderman; +using bts.api.user; +using bts.api.md; +using bts.api.admin; + +using security_key = System.UInt32; + +namespace bts.fix +{ + interface IFixRouter + { + IEnumerable get_securities(); + SecurityImmutable? lookup(security_key key); + } + + class FixRouter : QuickFix.MessageCracker, QuickFix.IApplication, IFixRouter + { + readonly ConcurrentDictionary _sessions = new ConcurrentDictionary(); + readonly Func _factory; + readonly MarketDataClient _mdglobal = new MarketDataClient(); + + public FixRouter(Func factory) + { + _factory = factory; + _mdglobal.pump_once(); //get securities + } + + public IApplication session(SessionID sessionID) + { + IApplication app; + if (!_sessions.TryGetValue(sessionID, out app)) + { + app = _factory(this, sessionID); + _sessions[sessionID] = app; + } + return app; + } + + public void FromAdmin(Message message, SessionID sessionID) + { + session(sessionID).FromAdmin(message, sessionID); + } + + public void FromApp(Message message, SessionID sessionID) + { + session(sessionID).FromApp(message, sessionID); + } + + public void OnCreate(SessionID sessionID) + { + session(sessionID).OnCreate(sessionID); + } + + public void OnLogon(SessionID sessionID) + { + session(sessionID).OnLogon(sessionID); + } + + public void OnLogout(SessionID sessionID) + { + session(sessionID).OnLogout(sessionID); + } + + public void ToAdmin(Message message, SessionID sessionID) + { + session(sessionID).ToAdmin(message, sessionID); + } + + public void ToApp(Message message, SessionID sessionID) + { + session(sessionID).ToApp(message, sessionID); + } + + IEnumerable IFixRouter.get_securities() + { + return _mdglobal.get_securities(); + } + + SecurityImmutable? IFixRouter.lookup(uint key) + { + return _mdglobal.lookup(key); + } + } +} diff --git a/src/client/spark_fix/OrderSession.cs b/src/client/spark_fix/OrderSession.cs index 653c75113..323e290a0 100644 --- a/src/client/spark_fix/OrderSession.cs +++ b/src/client/spark_fix/OrderSession.cs @@ -8,143 +8,27 @@ using QuickFix.Fields; namespace bts.fix { - /// - /// Just a simple server that will let you connect to it and ignore any - /// application-level messages you send to it. - /// Note that this app is *NOT* a message cracker. - /// - - public class OrderSession : QuickFix.MessageCracker, QuickFix.IApplication + class OrderSession : DropCopySession, QuickFix.IApplication { - - static readonly decimal DEFAULT_MARKET_PRICE = 10; - - int orderID = 0; - int execID = 0; - - private string GenOrderID() { return (++orderID).ToString(); } - private string GenExecID() { return (++execID).ToString(); } - - #region QuickFix.Application Methods - - public void FromApp(Message message, SessionID sessionID) + public OrderSession(IFixRouter router, SessionID sess) : base(router, sess) { - Console.WriteLine("IN: " + message); - Crack(message, sessionID); } - public void ToApp(Message message, SessionID sessionID) + override public void FromApp(Message message, SessionID sessionID) { - Console.WriteLine("OUT: " + message); - } - - public void FromAdmin(Message message, SessionID sessionID) - { - Console.WriteLine("ADMININ: " + message); - } - - public void ToAdmin(Message message, SessionID sessionID) - { - Console.WriteLine("ADMINOUT: " + message); - } - - public void OnCreate(SessionID sessionID) { } - public void OnLogout(SessionID sessionID) { } - public void OnLogon(SessionID sessionID) { } - #endregion - - public void OnMessage(QuickFix.FIX44.BusinessMessageReject n, SessionID s) { } - public void OnMessage(QuickFix.FIX44.News n, SessionID s) { } - - public void OnMessage(QuickFix.FIX44.NewOrderSingle n, SessionID s) - { - Symbol symbol = n.Symbol; - Side side = n.Side; - OrdType ordType = n.OrdType; - OrderQty orderQty = n.OrderQty; - Price price = new Price(DEFAULT_MARKET_PRICE); - ClOrdID clOrdID = n.ClOrdID; - - switch (ordType.getValue()) + Log.assert_d(sessionID.Equals(_sess)); + MsgType type = Message.IdentifyType(message.ToString()); + switch (type.getValue()) { - case OrdType.LIMIT: - price = n.Price; - if (price.Obj == 0) - throw new IncorrectTagValue(price.Tag); + case MsgType.ORDER_STATUS_REQUEST: + case MsgType.SECURITYDEFINITIONREQUEST: + log_info("IN: " + message); + Crack(message, sessionID); break; - case OrdType.MARKET: break; - default: throw new IncorrectTagValue(ordType.Tag); - } - - QuickFix.FIX44.ExecutionReport exReport = new QuickFix.FIX44.ExecutionReport( - new OrderID(GenOrderID()), - new ExecID(GenExecID()), - new ExecType(ExecType.FILL), - new OrdStatus(OrdStatus.FILLED), - symbol, //shouldn't be here? - side, - new LeavesQty(0), - new CumQty(orderQty.getValue()), - new AvgPx(price.getValue())); - - exReport.Set(clOrdID); - exReport.Set(symbol); - exReport.Set(orderQty); - exReport.Set(new LastQty(orderQty.getValue())); - exReport.Set(new LastPx(price.getValue())); - - if (n.IsSetAccount()) - exReport.SetField(n.Account); - - try - { - Session.SendToTarget(exReport, s); - } - catch (SessionNotFound ex) - { - Console.WriteLine("==session not found exception!=="); - Console.WriteLine(ex.ToString()); - } - catch (Exception ex) - { - Console.WriteLine(ex.ToString()); - } - } - - public void OnMessage(QuickFix.FIX44.OrderCancelRequest msg, SessionID s) - { - string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Obj : "unknown orderID"; - QuickFix.FIX44.OrderCancelReject ocj = new QuickFix.FIX44.OrderCancelReject( - new OrderID(orderid), msg.ClOrdID, msg.OrigClOrdID, new OrdStatus(OrdStatus.REJECTED), new CxlRejResponseTo(CxlRejResponseTo.ORDER_CANCEL_REQUEST)); - ocj.CxlRejReason = new CxlRejReason(CxlRejReason.OTHER); - ocj.Text = new Text("Executor does not support order cancels"); - - try - { - Session.SendToTarget(ocj, s); - } - catch (Exception ex) - { - Console.WriteLine(ex.ToString()); + default: + log_info("UNSUPPORTED MESSAGE IN: " + type.getValue()); + throw new UnsupportedMessageType(); } } - - public void OnMessage(QuickFix.FIX44.OrderCancelReplaceRequest msg, SessionID s) - { - string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Obj : "unknown orderID"; - QuickFix.FIX44.OrderCancelReject ocj = new QuickFix.FIX44.OrderCancelReject( - new OrderID(orderid), msg.ClOrdID, msg.OrigClOrdID, new OrdStatus(OrdStatus.REJECTED), new CxlRejResponseTo(CxlRejResponseTo.ORDER_CANCEL_REPLACE_REQUEST)); - ocj.CxlRejReason = new CxlRejReason(CxlRejReason.OTHER); - ocj.Text = new Text("Executor does not support order cancel/replaces"); - - try - { - Session.SendToTarget(ocj, s); - } - catch (Exception ex) - { - Console.WriteLine(ex.ToString()); - } - } } } \ No newline at end of file diff --git a/src/client/spark_fix/spark_fix.csproj b/src/client/spark_fix/spark_fix.csproj index 9f297b151..bcc342f02 100644 --- a/src/client/spark_fix/spark_fix.csproj +++ b/src/client/spark_fix/spark_fix.csproj @@ -10,6 +10,7 @@ AnyCPU true + 7.2 1.0.0 From 7789f39c9d0a9c5e684f682579442ac4068091ea Mon Sep 17 00:00:00 2001 From: Kevin Darby Date: Tue, 4 Dec 2018 18:20:23 -0500 Subject: [PATCH 06/28] handle some messages --- src/client/spark_fix/DropCopySession.cs | 47 +++++++++++++++++++------ 1 file changed, 37 insertions(+), 10 deletions(-) diff --git a/src/client/spark_fix/DropCopySession.cs b/src/client/spark_fix/DropCopySession.cs index eeed4e6b3..add22f91a 100644 --- a/src/client/spark_fix/DropCopySession.cs +++ b/src/client/spark_fix/DropCopySession.cs @@ -29,7 +29,7 @@ namespace bts.fix protected IDisposable _fillsdisp; protected IDisposable _ordersdisp; - protected readonly ConcurrentDictionary _cache = new ConcurrentDictionary(); + protected readonly ConcurrentDictionary _cache = new ConcurrentDictionary(); protected readonly IFixRouter _router; protected readonly SessionID _sess; public DropCopySession(IFixRouter router, SessionID sess) @@ -118,13 +118,28 @@ namespace bts.fix virtual public void OnMessage(QuickFix.FIX44.BusinessMessageReject n, SessionID s) { - Log.assert(false, "biz reject wtf " + n.EncodedText.getValue()); + //Log.assert(false, "biz reject wtf " + n.EncodedText.getValue()); + Log.FIX.warn(_sess.ToString() + " Business Reject " + n.BusinessRejectReason.getValue() + " " + n.Text.getValue()); } virtual public void OnMessage(QuickFix.FIX44.News n, SessionID s) { log_info("news " + n.EncodedHeadline.getValue()); } + virtual public void OnMessage(QuickFix.FIX44.OrderStatusRequest n, SessionID s) + { + if (!string.IsNullOrEmpty(n.ClOrdID.getValue())) + { + uint oid = uint.Parse(n.ClOrdID.getValue()); + if (_cache.TryGetValue(oid, out OrderRecordImmutable order)) + send_order_status(s, order); + else + send_reject(s, "Can't find order " + oid, n); + } + else + send_reject(s, "clorderid null", n); + } + protected void log_info(string message, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0) { Log.FIX.info(_sess.ToString() + " " + message, file, line); @@ -132,6 +147,18 @@ namespace bts.fix #region status stuff + protected void send_reject(SessionID sess, string text, Message refmessage = null) + { + int refseqnum = refmessage.Header.GetField(new QuickFix.Fields.MsgSeqNum()).getValue(); + QuickFix.FIX44.Reject rej = null; + if(refseqnum > 0) + rej = new QuickFix.FIX44.Reject(new QuickFix.Fields.RefSeqNum(refseqnum)); + else + rej = new QuickFix.FIX44.Reject(); + rej.Text = new Text(text); + send(rej, sess); + } + QuickFix.Fields.OrdStatus translate_status(in bts.api.orderman.OrderStateImmutable state) { if (state.HasMarket) @@ -215,10 +242,10 @@ namespace bts.fix var exec = new QuickFix.Fields.ExecType(QuickFix.Fields.ExecType.FILL); QuickFix.Fields.OrdStatus status = new QuickFix.Fields.OrdStatus(); uint filled = 0; uint leaves = 0; double prx = 0.0; - OrderStateImmutable state; - if (_cache.TryGetValue(fill.OrderKey, out state)) + OrderRecordImmutable order; + if (_cache.TryGetValue(fill.OrderKey, out order)) { - process_order_state(state, ref filled, ref leaves, ref prx, ref status); + process_order_state(order.State, ref filled, ref leaves, ref prx, ref status); if (leaves > 0) exec = new QuickFix.Fields.ExecType(QuickFix.Fields.ExecType.PARTIAL_FILL); } @@ -241,10 +268,10 @@ namespace bts.fix send(report, sess); } - virtual protected void send_order(SessionID sess, in OrderRecordImmutable order, bool change = false) + virtual protected void send_order_status(SessionID sess, in OrderRecordImmutable order, bool change = false) { var exec = new QuickFix.Fields.ExecType(QuickFix.Fields.ExecType.NEW); - if (_cache.TryGetValue(order.Key, out OrderStateImmutable _)) + if (_cache.TryGetValue(order.Key, out OrderRecordImmutable _)) exec = new QuickFix.Fields.ExecType(QuickFix.Fields.ExecType.ORDER_STATUS); QuickFix.Fields.OrdStatus status = new QuickFix.Fields.OrdStatus(); @@ -280,11 +307,11 @@ namespace bts.fix { foreach (var order in o.added) { - send_order(sessionID, order); - _cache[order.Key] = order.State; + send_order_status(sessionID, order); + _cache[order.Key] = order; } foreach (var order in o.changed) - send_order(sessionID, order, true); + send_order_status(sessionID, order, true); }); _fillsdisp = on_fills.Subscribe(f => From edbaa9c435a96d47da199065097368c17d7e9fad Mon Sep 17 00:00:00 2001 From: Kevin Darby Date: Wed, 5 Dec 2018 15:35:49 -0500 Subject: [PATCH 07/28] looks like we have dropcopy --- .../spark_api/security/SecurityFormatter.cs | 2 +- .../spark_api/security/SecurityHelper.cs | 4 +- src/client/spark_fix/DropCopySession.cs | 326 ------------------ src/client/spark_fix/OrderSession.cs | 34 -- 4 files changed, 3 insertions(+), 363 deletions(-) delete mode 100644 src/client/spark_fix/DropCopySession.cs delete mode 100644 src/client/spark_fix/OrderSession.cs diff --git a/src/client/spark_api/security/SecurityFormatter.cs b/src/client/spark_api/security/SecurityFormatter.cs index c03482ef1..d13dfd227 100644 --- a/src/client/spark_api/security/SecurityFormatter.cs +++ b/src/client/spark_api/security/SecurityFormatter.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using static bts.api.Security; namespace bts.api { - struct FutureLeg { + public struct FutureLeg { public readonly Venue exchange; public readonly string symbol, exchange_desc; public readonly FutureContractImmutable future; diff --git a/src/client/spark_api/security/SecurityHelper.cs b/src/client/spark_api/security/SecurityHelper.cs index af11abc23..b1580c0d2 100644 --- a/src/client/spark_api/security/SecurityHelper.cs +++ b/src/client/spark_api/security/SecurityHelper.cs @@ -4,7 +4,7 @@ using System.Linq; using static bts.api.Security; namespace bts.api { - internal static class SecurityHelper { + public static class SecurityHelper { public static IEnumerable get_flat_future_legs(SecurityImmutable sec) { switch (sec.ContractCase) { case ContractOneofCase.Spread: return _get_flat_future_legs(sec.Spread.Legs, 1); @@ -37,7 +37,7 @@ namespace bts.api { public static DateTime expiration_date(this FutureContract future) { return new DateTime((int)future.ExpirationYear, (int)future.ExpirationMonth, (int)future.ExpirationDay); } public static DateTime expiration_date(this FutureContractImmutable future) { return new DateTime((int)future.ExpirationYear, (int)future.ExpirationMonth, (int)future.ExpirationDay); } - internal static DateTime EarliestExpiration(this SecurityImmutable security) { + public static DateTime EarliestExpiration(this SecurityImmutable security) { switch (security.ContractCase) { case ContractOneofCase.Synthetic: return security.Synthetic.Legs.First().Security.EarliestExpiration(); case ContractOneofCase.Spread: return security.Spread.Legs.First().Security.EarliestExpiration(); diff --git a/src/client/spark_fix/DropCopySession.cs b/src/client/spark_fix/DropCopySession.cs deleted file mode 100644 index add22f91a..000000000 --- a/src/client/spark_fix/DropCopySession.cs +++ /dev/null @@ -1,326 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reactive.Linq; -using System.Reactive.Concurrency; -using System.Text; - -using QuickFix; -using QuickFix.Fields; - - -using bts.api.core; -using bts.api.orderman; -using bts.api.user; -using bts.api.admin; -using System.Collections.Concurrent; -using System.Runtime.CompilerServices; - -namespace bts.fix -{ - class DropCopySession : QuickFix.MessageCracker, QuickFix.IApplication - { - protected static OrderService _orders = bts.api.Locator.locate(); - protected static UserService _users = bts.api.Locator.locate(); - protected static AdminService _admin = bts.api.Locator.locate(); - - protected string _user_name; - protected AuthToken _token; - protected IDisposable _fillsdisp; - protected IDisposable _ordersdisp; - - protected readonly ConcurrentDictionary _cache = new ConcurrentDictionary(); - protected readonly IFixRouter _router; - protected readonly SessionID _sess; - public DropCopySession(IFixRouter router, SessionID sess) - { - _router = router; - _sess = sess; - } - - virtual public async void FromAdmin(Message message, SessionID sessionID) - { - Log.assert_d(sessionID.Equals(_sess)); - - MsgType type = Message.IdentifyType(message.ToString()); - switch (type.Obj) - { - case MsgType.LOGON: - { - QuickFix.FIX44.Logon msg = (QuickFix.FIX44.Logon)message; - _user_name = msg.Username.getValue(); - var resp = await _users.authenticate_login_async(new AuthenticateLoginRequest { Login = msg.Username.getValue(), Password = msg.Password.getValue() }); - if (resp.success && resp.value.IsValid) - _token = resp.value.Token; - else - throw new RejectLogon("Logon rejected " + resp.error_message + resp.value?.Reason ?? string.Empty); - } - break; - default: - log_info("ADMININ: " + message); - break; - } - } - - virtual public void ToAdmin(Message message, SessionID sessionID) - { - Log.assert_d(sessionID.Equals(_sess)); - log_info("ADMINOUT: " + message); - } - - virtual public void OnLogon(SessionID sessionID) - { - Log.assert_d(sessionID.Equals(_sess)); - var msg = sessionID.ToString() + " Logged on"; - log_info(msg); - - subscribe_fills_and_orders(sessionID); - } - virtual public void OnLogout(SessionID sessionID) - { - Log.assert_d(sessionID.Equals(_sess)); - var msg = sessionID.ToString() + " Logged out"; - log_info(msg); - - if(_ordersdisp != null) - _ordersdisp.Dispose(); - if(_fillsdisp != null) - _fillsdisp.Dispose(); - } - - virtual public void FromApp(Message message, SessionID sessionID) - { - Log.assert_d(sessionID.Equals(_sess)); - MsgType type = Message.IdentifyType(message.ToString()); - switch (type.getValue()) - { - case MsgType.ORDER_STATUS_REQUEST: - case MsgType.SECURITYDEFINITIONREQUEST: - log_info("IN: " + message); - Crack(message, sessionID); - break; - default: - log_info("UNSUPPORTED MESSAGE IN: " + type.getValue()); - throw new UnsupportedMessageType(); - } - } - - virtual public void ToApp(Message message, SessionID sessionID) - { - Log.assert_d(sessionID.Equals(_sess)); - log_info("OUT: " + message); - } - - virtual public void OnCreate(SessionID sessionID) - { - log_info("CREATE"); - } - - virtual public void OnMessage(QuickFix.FIX44.BusinessMessageReject n, SessionID s) - { - //Log.assert(false, "biz reject wtf " + n.EncodedText.getValue()); - Log.FIX.warn(_sess.ToString() + " Business Reject " + n.BusinessRejectReason.getValue() + " " + n.Text.getValue()); - } - virtual public void OnMessage(QuickFix.FIX44.News n, SessionID s) - { - log_info("news " + n.EncodedHeadline.getValue()); - } - - virtual public void OnMessage(QuickFix.FIX44.OrderStatusRequest n, SessionID s) - { - if (!string.IsNullOrEmpty(n.ClOrdID.getValue())) - { - uint oid = uint.Parse(n.ClOrdID.getValue()); - if (_cache.TryGetValue(oid, out OrderRecordImmutable order)) - send_order_status(s, order); - else - send_reject(s, "Can't find order " + oid, n); - } - else - send_reject(s, "clorderid null", n); - } - - protected void log_info(string message, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0) - { - Log.FIX.info(_sess.ToString() + " " + message, file, line); - } - - #region status stuff - - protected void send_reject(SessionID sess, string text, Message refmessage = null) - { - int refseqnum = refmessage.Header.GetField(new QuickFix.Fields.MsgSeqNum()).getValue(); - QuickFix.FIX44.Reject rej = null; - if(refseqnum > 0) - rej = new QuickFix.FIX44.Reject(new QuickFix.Fields.RefSeqNum(refseqnum)); - else - rej = new QuickFix.FIX44.Reject(); - rej.Text = new Text(text); - send(rej, sess); - } - - QuickFix.Fields.OrdStatus translate_status(in bts.api.orderman.OrderStateImmutable state) - { - if (state.HasMarket) - { - return new OrdStatus((char)state.Market.NativeState.NativeStatus); - } - else if (state.HasLimit) - { - return new OrdStatus((char)state.Limit.NativeState.NativeStatus); - } - else if (state.HasStop) - { - return new OrdStatus((char)state.Stop.NativeState.NativeStatus); - } - else if (state.HasStopLimit) - { - return new OrdStatus((char)state.StopLimit.NativeState.NativeStatus); - } - else - { - switch (state.Status) - { - case OrderStatus.Canceled: - return new OrdStatus(OrdStatus.CANCELED); - case OrderStatus.Completed: - return new OrdStatus(OrdStatus.FILLED); - case OrderStatus.Disconnected: - return new OrdStatus(OrdStatus.STOPPED); - case OrderStatus.Error: - return new OrdStatus(OrdStatus.REJECTED); - case OrderStatus.Inactive: - return new OrdStatus(OrdStatus.PENDING_NEW); - case OrderStatus.PendingWorking: - return new OrdStatus(OrdStatus.PENDING_NEW); - case OrderStatus.RejectedBySpark: - return new OrdStatus(OrdStatus.REJECTED); - case OrderStatus.Working: - { - if(state.FilledQuantity < state.Quantity) - return new OrdStatus(OrdStatus.PARTIALLY_FILLED); - else - return new OrdStatus(OrdStatus.NEW); - } - default: - return new OrdStatus(); - } - } - } - - virtual protected void process_order_state(in OrderStateImmutable state, ref uint filled, ref uint leaves, ref double avgprx, - ref QuickFix.Fields.OrdStatus fstatus) - { - filled = state.FilledQuantity; - leaves = state.Quantity - state.FilledQuantity; - avgprx = state.AvgPrice; - fstatus = translate_status(state); - } - - #endregion - - protected void send(Message mess, SessionID sess) - { - try - { - Session.SendToTarget(mess, sess); - } - catch (SessionNotFound ex) - { - Log.FIX.error("==session not found exception!=="); - Log.FIX.fatal(ex.ToString()); - Log.assert(false, "session not found " + sess); - } - catch (Exception ex) - { - Log.FIX.error("==exception sending to " + sess + " " + ex.ToString()); - } - } - - virtual protected void send_fill(SessionID sess, in FillImmutable fill, bool change = false) - { - var exec = new QuickFix.Fields.ExecType(QuickFix.Fields.ExecType.FILL); - QuickFix.Fields.OrdStatus status = new QuickFix.Fields.OrdStatus(); - uint filled = 0; uint leaves = 0; double prx = 0.0; - OrderRecordImmutable order; - if (_cache.TryGetValue(fill.OrderKey, out order)) - { - process_order_state(order.State, ref filled, ref leaves, ref prx, ref status); - if (leaves > 0) - exec = new QuickFix.Fields.ExecType(QuickFix.Fields.ExecType.PARTIAL_FILL); - } - if (change) - exec = new QuickFix.Fields.ExecType(QuickFix.Fields.ExecType.TRADE_CORRECT); - - var sec = _router.lookup(fill.SecurityKey); - QuickFix.FIX44.ExecutionReport report = new QuickFix.FIX44.ExecutionReport( - new OrderID(fill.OrderKey.ToString()), - new ExecID(fill.FillKey.ToString()), - exec, - status, - new Symbol(sec?.Symbol ?? string.Empty), - new Side(fill.Side == bts.api.Side.Buy ? Side.BUY : Side.SELL), - new LeavesQty(leaves), - new CumQty(filled), - new AvgPx(Convert.ToDecimal(prx))); - if (sec?.HasGlbx ?? false) - report.SecurityDesc = new SecurityDesc(sec.Value.Glbx.SecurityDesc); - send(report, sess); - } - - virtual protected void send_order_status(SessionID sess, in OrderRecordImmutable order, bool change = false) - { - var exec = new QuickFix.Fields.ExecType(QuickFix.Fields.ExecType.NEW); - if (_cache.TryGetValue(order.Key, out OrderRecordImmutable _)) - exec = new QuickFix.Fields.ExecType(QuickFix.Fields.ExecType.ORDER_STATUS); - - QuickFix.Fields.OrdStatus status = new QuickFix.Fields.OrdStatus(); - uint filled = 0; uint leaves = 0; double prx = 0.0; - process_order_state(order.State, ref filled, ref leaves, ref prx, ref status); - - var sec = _router.lookup(order.Def.SecurityKey); - QuickFix.FIX44.ExecutionReport report = new QuickFix.FIX44.ExecutionReport( - new OrderID(order.Key.ToString()), - new ExecID("0"), - exec, - status, - new Symbol(sec?.Symbol ?? string.Empty), - new Side(order.Def.Side == bts.api.Side.Buy ? Side.BUY : Side.SELL), - new LeavesQty(leaves), - new CumQty(filled), - new AvgPx(Convert.ToDecimal(prx))); - if (sec?.HasGlbx ?? false) - report.SecurityDesc = new SecurityDesc(sec.Value.Glbx.SecurityDesc); - send(report, sess); - } - - virtual protected void subscribe_fills_and_orders(SessionID sessionID) - { - var adm = _admin.subscribei_admin_data().Select(x => new AdminModelWrapper(mbts.GlobalExtensions.TryFirst(x.all), _user_name)); - - var scheduler = TaskPoolScheduler.Default; - var interval = TimeSpan.FromMilliseconds(500); - var on_orders = _orders.subscribei_orders().Naggle(interval, scheduler).PermissionFilter(adm).Table().Cache(); - var on_fills = _orders.subscribei_fills().Naggle(interval, scheduler).PermissionFilter(adm).Table().Cache(); - - _ordersdisp = on_orders.Subscribe(o => - { - foreach (var order in o.added) - { - send_order_status(sessionID, order); - _cache[order.Key] = order; - } - foreach (var order in o.changed) - send_order_status(sessionID, order, true); - }); - - _fillsdisp = on_fills.Subscribe(f => - { - foreach (var fill in f.added) - send_fill(sessionID, fill); - foreach (var fill in f.changed) - send_fill(sessionID, fill); - }); - } - } -} \ No newline at end of file diff --git a/src/client/spark_fix/OrderSession.cs b/src/client/spark_fix/OrderSession.cs deleted file mode 100644 index 323e290a0..000000000 --- a/src/client/spark_fix/OrderSession.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -using QuickFix; -using QuickFix.Fields; - -namespace bts.fix -{ - class OrderSession : DropCopySession, QuickFix.IApplication - { - public OrderSession(IFixRouter router, SessionID sess) : base(router, sess) - { - } - - override public void FromApp(Message message, SessionID sessionID) - { - Log.assert_d(sessionID.Equals(_sess)); - MsgType type = Message.IdentifyType(message.ToString()); - switch (type.getValue()) - { - case MsgType.ORDER_STATUS_REQUEST: - case MsgType.SECURITYDEFINITIONREQUEST: - log_info("IN: " + message); - Crack(message, sessionID); - break; - default: - log_info("UNSUPPORTED MESSAGE IN: " + type.getValue()); - throw new UnsupportedMessageType(); - } - } - } -} \ No newline at end of file From 7bf50415cae953c69db369ea14ec39e29e7d94f4 Mon Sep 17 00:00:00 2001 From: Kevin Darby Date: Wed, 5 Dec 2018 17:55:06 -0500 Subject: [PATCH 08/28] nearly ready for testing --- src/client/spark_api/utils/APIExtensions.cs | 15 + .../spark_core/admin/AdminModelWrapper.cs | 1 + .../spark_core/utils/GlobalExtensions.cs | 7 - src/client/spark_fix/FixRouter.cs | 9 + .../spark_fix/session/DropCopySession.cs | 261 +++++++++++++++ src/client/spark_fix/session/OrderSession.cs | 99 ++++++ src/client/spark_fix/session/SessionBase.cs | 315 ++++++++++++++++++ src/client/spark_fix/spark_fix.cfg | 1 + 8 files changed, 701 insertions(+), 7 deletions(-) create mode 100644 src/client/spark_api/utils/APIExtensions.cs create mode 100644 src/client/spark_fix/session/DropCopySession.cs create mode 100644 src/client/spark_fix/session/OrderSession.cs create mode 100644 src/client/spark_fix/session/SessionBase.cs diff --git a/src/client/spark_api/utils/APIExtensions.cs b/src/client/spark_api/utils/APIExtensions.cs new file mode 100644 index 000000000..e8ff8ddde --- /dev/null +++ b/src/client/spark_api/utils/APIExtensions.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; + +namespace bts +{ + public static class APIExtensions + { + public static T? TryFirst(this IEnumerable src) where T : struct + { + foreach (var v in src) + return v; + return null; + } + } +} \ No newline at end of file diff --git a/src/client/spark_core/admin/AdminModelWrapper.cs b/src/client/spark_core/admin/AdminModelWrapper.cs index f52f016c5..25b88ddf5 100644 --- a/src/client/spark_core/admin/AdminModelWrapper.cs +++ b/src/client/spark_core/admin/AdminModelWrapper.cs @@ -9,6 +9,7 @@ namespace bts.api.core public class AdminModelWrapper { readonly AdminDataImmutable? _admin_data; + public AdminDataImmutable? admin_data => _admin_data; readonly string _user_name; readonly List _allowed_accounts; readonly Dictionary _allowed_account_dict = new Dictionary(); diff --git a/src/client/spark_core/utils/GlobalExtensions.cs b/src/client/spark_core/utils/GlobalExtensions.cs index 0f231a633..d1065aea7 100644 --- a/src/client/spark_core/utils/GlobalExtensions.cs +++ b/src/client/spark_core/utils/GlobalExtensions.cs @@ -69,12 +69,5 @@ namespace mbts { } } } - - public static T? TryFirst(this IEnumerable src) where T : struct - { - foreach(var v in src) - return v; - return null; - } } } \ No newline at end of file diff --git a/src/client/spark_fix/FixRouter.cs b/src/client/spark_fix/FixRouter.cs index a05841ed3..cba291708 100644 --- a/src/client/spark_fix/FixRouter.cs +++ b/src/client/spark_fix/FixRouter.cs @@ -24,6 +24,7 @@ namespace bts.fix { IEnumerable get_securities(); SecurityImmutable? lookup(security_key key); + SecurityImmutable? lookup(string desc); } class FixRouter : QuickFix.MessageCracker, QuickFix.IApplication, IFixRouter @@ -93,5 +94,13 @@ namespace bts.fix { return _mdglobal.lookup(key); } + + SecurityImmutable? IFixRouter.lookup(string desc) + { + if (_mdglobal.lookup_security_key_from_desc(desc, out uint key)) + return _mdglobal.lookup(key); + else + return null; + } } } diff --git a/src/client/spark_fix/session/DropCopySession.cs b/src/client/spark_fix/session/DropCopySession.cs new file mode 100644 index 000000000..1343e94d9 --- /dev/null +++ b/src/client/spark_fix/session/DropCopySession.cs @@ -0,0 +1,261 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reactive.Linq; +using System.Reactive.Concurrency; +using System.Text; + +using QuickFix; +using QuickFix.Fields; + +using bts.api.core; +using bts.api.orderman; +using bts.api.user; +using bts.api.admin; +using System.Collections.Concurrent; +using System.Runtime.CompilerServices; + +namespace bts.fix +{ + class DropCopySession : SessionBase, QuickFix.IApplication + { + protected IDisposable _fillsdisp; + protected IDisposable _ordersdisp; + + + protected readonly ConcurrentDictionary _order_cache = new ConcurrentDictionary(); + protected readonly ConcurrentDictionary _fix_clorderids = new ConcurrentDictionary(); + public DropCopySession(IFixRouter router, SessionID sess) : base(router, sess) + { + } + + override public void OnLogon(SessionID sessionID) + { + Log.assert_d(sessionID.Equals(_sess)); + var msg = sessionID.ToString() + " Logged on"; + log_info(msg); + + subscribe_fills_and_orders(sessionID); + } + override public void OnLogout(SessionID sessionID) + { + Log.assert_d(sessionID.Equals(_sess)); + var msg = sessionID.ToString() + " Logged out"; + log_info(msg); + + if (_ordersdisp != null) + _ordersdisp.Dispose(); + if (_fillsdisp != null) + _fillsdisp.Dispose(); + } + + override public void FromApp(Message message, SessionID sessionID) + { + Log.assert_d(sessionID.Equals(_sess)); + MsgType type = Message.IdentifyType(message.ToString()); + switch (type.getValue()) + { + case MsgType.ORDER_STATUS_REQUEST: + case MsgType.SECURITYDEFINITIONREQUEST: + log_info("IN: " + message); + Crack(message, sessionID); + break; + default: + log_info("UNSUPPORTED MESSAGE IN: " + type.getValue()); + throw new UnsupportedMessageType(); + } + } + + virtual public void OnMessage(QuickFix.FIX44.OrderStatusRequest req, SessionID s) + { + if (req.IsSetField(req.OrderID) && req.IsSetField(req.OrdStatusReqID)) + { + uint oid = uint.Parse(req.OrderID.getValue()); + if (_order_cache.TryGetValue(oid, out OrderRecordImmutable order)) + { + var ostat = build_order_status(s, order); + ostat.OrdStatusReqID = new OrdStatusReqID(req.OrdStatusReqID.getValue()); + send(ostat, s); + } + else + send_reject(s, "Can't find order " + oid, req); + } + else + send_reject(s, "clorderid null", req); + } + + virtual public void OnMessage(QuickFix.FIX44.SecurityDefinitionRequest req, SessionID s) + { + if (req.IsSetField(req.SecurityReqID) && req.IsSetField(req.SecurityRequestType) && + req.SecurityRequestType.getValue() == SecurityRequestType.REQUEST_LIST_SECURITIES) + { + var secs = _router.get_securities(); + if (req.IsSetField(req.Symbol)) + secs = secs.Where(x => x.Symbol.ToLower() == req.Symbol.getValue().ToLower()); + if (req.IsSetField(req.SecurityType)) + secs = secs.Where(x => security_types_equal(x.security_type(), req.SecurityType)); + if (req.IsSetField(req.SecurityExchange)) + secs = secs.Where(x => exchanges_equal(x.Exchange, req.SecurityExchange)); + + var def = new QuickFix.FIX44.SecurityDefinition(req.SecurityReqID, + new SecurityResponseID(Guid.NewGuid().ToString()), + new SecurityResponseType(SecurityResponseType.LIST_OF_SECURITIES_RETURNED_PER_REQUEST)); + send(def, s); + } + else + send_reject(s, "Can't parse secdef request", req); + } + + + + virtual protected void subscribe_fills_and_orders(SessionID sessionID) + { + + + var scheduler = TaskPoolScheduler.Default; + var interval = TimeSpan.FromMilliseconds(500); + var on_orders = _orderservice.subscribei_orders().Naggle(interval, scheduler).PermissionFilter(_adminobservable).Table().Cache(); + var on_fills = _orderservice.subscribei_fills().Naggle(interval, scheduler).PermissionFilter(_adminobservable).Table().Cache(); + + _ordersdisp = on_orders.Subscribe(o => + { + foreach (var order in o.added) + { + var ostat = build_order_status(sessionID, order); + _order_cache[order.Key] = order; + send(ostat, sessionID); + } + foreach (var order in o.changed) + { + var ostat = build_order_status(sessionID, order, true); + send(ostat, sessionID); + } + }); + + _fillsdisp = on_fills.Subscribe(f => + { + foreach (var fill in f.added) + { + var fi = build_fill(sessionID, fill); + send(fi, sessionID); + } + foreach (var fill in f.changed) + { + var fi = build_fill(sessionID, fill); + send(fi, sessionID); + } + }); + } + + + virtual protected void process_order_state(in OrderStateImmutable state, ref uint filled, ref uint leaves, ref double avgprx, + ref QuickFix.Fields.OrdStatus fstatus, ref NativeOrderStateImmutable? native) + { + filled = state.FilledQuantity; + leaves = state.Quantity - state.FilledQuantity; + avgprx = state.AvgPrice; + fstatus = translate_status(state, ref native); + } + + protected void set_execution_report_security(bts.api.SecurityImmutable? sec, QuickFix.FIX44.ExecutionReport report) + { + report.SecurityExchange = convert_exchange(sec.Value.Exchange); + report.SecurityType = convert_security_type(sec.Value.security_type()); + report.MaturityMonthYear = new MaturityMonthYear(bts.api.SecurityHelper.EarliestExpiration(sec.Value).ToString("YYYYMMDD")); + if (sec.Value.HasGlbx) + report.SecurityDesc = new SecurityDesc(sec.Value.Glbx.SecurityDesc); + } + + virtual protected QuickFix.FIX44.ExecutionReport build_fill(SessionID sess, in FillImmutable fill, bool change = false) + { + var exec = new QuickFix.Fields.ExecType(QuickFix.Fields.ExecType.FILL); + QuickFix.Fields.OrdStatus status = new QuickFix.Fields.OrdStatus(); + uint filled = 0; uint leaves = 0; double prx = 0.0; + OrderRecordImmutable order; NativeOrderStateImmutable? native = null; + if (_order_cache.TryGetValue(fill.OrderKey, out order)) + { + process_order_state(order.State, ref filled, ref leaves, ref prx, ref status, ref native); + if (leaves > 0) + exec = new QuickFix.Fields.ExecType(QuickFix.Fields.ExecType.PARTIAL_FILL); + } + if (change) + exec = new QuickFix.Fields.ExecType(QuickFix.Fields.ExecType.TRADE_CORRECT); + + var sec = _router.lookup(fill.SecurityKey); + QuickFix.FIX44.ExecutionReport report = new QuickFix.FIX44.ExecutionReport( + new OrderID(fill.OrderKey.ToString()), + new ExecID(fill.FillKey.ToString()), + exec, + status, + new Symbol(sec?.Symbol ?? string.Empty), + new Side(fill.Side == bts.api.Side.Buy ? Side.BUY : Side.SELL), + new LeavesQty(leaves), + new CumQty(filled), + new AvgPx(Convert.ToDecimal(prx))); + + report.Account = new Account(fill.Account); + report.LastQty = new LastQty(Convert.ToDecimal(fill.LastShares)); + report.LastPx = new LastPx(Convert.ToDecimal(fill.LastPrice)); + var ts = fill.HasTimestamp ? fill.Timestamp.ToDateTime() : DateTime.MinValue; + report.TransactTime = new TransactTime(ts, true); + report.TradeDate = new TradeDate(ts.ToString("YYYYMMDD")); + set_execution_report_security(sec, report); + if (native.HasValue) + report.SecondaryOrderID = new SecondaryOrderID(native.Value.ExchangeOrderId); + + if (sec.HasValue && sec.Value.security_type() == bts.api.SecurityType.Spread || sec.Value.security_type() == bts.api.SecurityType.Synthetic) + { + if (fill.FillKind == bts.api.orderman.Fill.Types.FillKind.Leg) + report.MultiLegReportingType = new MultiLegReportingType('2'); + else + report.MultiLegReportingType = new MultiLegReportingType('3'); + } + return report; + } + + virtual protected QuickFix.FIX44.ExecutionReport build_order_status(SessionID sess, in OrderRecordImmutable order, bool change = false) + { + var exec = new QuickFix.Fields.ExecType(QuickFix.Fields.ExecType.NEW); + if (_order_cache.TryGetValue(order.Key, out OrderRecordImmutable _)) + exec = new QuickFix.Fields.ExecType(QuickFix.Fields.ExecType.ORDER_STATUS); + + QuickFix.Fields.OrdStatus status = new QuickFix.Fields.OrdStatus(); + uint filled = 0; uint leaves = 0; double prx = 0.0; NativeOrderStateImmutable? native = null; + process_order_state(order.State, ref filled, ref leaves, ref prx, ref status, ref native); + + var sec = _router.lookup(order.Def.SecurityKey); + QuickFix.FIX44.ExecutionReport report = new QuickFix.FIX44.ExecutionReport( + new OrderID(order.Key.ToString()), + new ExecID("0"), + exec, + status, + new Symbol(sec?.Symbol ?? string.Empty), + new Side(order.Def.Side == bts.api.Side.Buy ? Side.BUY : Side.SELL), + new LeavesQty(leaves), + new CumQty(filled), + new AvgPx(Convert.ToDecimal(prx))); + + report.Account = new Account(order.Def.Account); + report.OrderQty = new OrderQty(order.State.Quantity); + report.Price = new Price(Convert.ToDecimal(order.State.Price)); + report.TimeInForce = new QuickFix.Fields.TimeInForce((char)order.Def.TimeInForce); + var ts = order.State.LastChange.ToDateTime(); + report.TransactTime = new TransactTime(ts, true); + report.Text = new Text(order.State.LastMsg); + + set_execution_report_security(sec, report); + if (native.HasValue) + { + report.SecondaryOrderID = new SecondaryOrderID(native.Value.ExchangeOrderId); + report.OrdType = new OrdType((char)native.Value.NativeType); + } + //TODO Big race here, we need a correlation id of some sort + if (_fix_clorderids.TryGetValue(order.Key, out string clorderid)) + { + report.ClOrdID = new ClOrdID(clorderid); + } + return report; + } + + } +} \ No newline at end of file diff --git a/src/client/spark_fix/session/OrderSession.cs b/src/client/spark_fix/session/OrderSession.cs new file mode 100644 index 000000000..b235bf3bf --- /dev/null +++ b/src/client/spark_fix/session/OrderSession.cs @@ -0,0 +1,99 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using QuickFix; +using QuickFix.Fields; + +using bts.api; +using bts.api.orderman; + +namespace bts.fix +{ + class OrderSession : DropCopySession, QuickFix.IApplication + { + public OrderSession(IFixRouter router, SessionID sess) : base(router, sess) + { + } + + override public void FromApp(Message message, SessionID sessionID) + { + Log.assert_d(sessionID.Equals(_sess)); + MsgType type = Message.IdentifyType(message.ToString()); + switch (type.getValue()) + { + case MsgType.ORDER_STATUS_REQUEST: + case MsgType.SECURITYDEFINITIONREQUEST: + + case MsgType.NEWORDERSINGLE: + case MsgType.ORDERCANCELREPLACEREQUEST: + case MsgType.ORDERCANCELREQUEST: + log_info("IN: " + message); + Crack(message, sessionID); + break; + default: + log_info("UNSUPPORTED MESSAGE IN: " + type.getValue()); + throw new UnsupportedMessageType(); + } + } + + virtual public void OnMessage(QuickFix.FIX44.NewOrderSingle req, SessionID s) + { + Venue ven = convert_exchange(req.SecurityExchange); + if(ven != Venue.Glbx) + throw new IncorrectTagValue(req.SecurityExchange.Tag); + + var sec = _router.lookup(req.Symbol.getValue()); + if(sec == null) + sec = _router.lookup(req.SecurityDesc.getValue()); + if(!sec.HasValue) + throw new IncorrectTagValue(req.SecurityDesc.Tag); + + OrderDefinition def = new OrderDefinition() + { + Account = req.Account.getValue(), + AccountId = lookup_account(req.Account.getValue()), + SecurityKey = sec.Value.Id, + Side = (api.Side)int.Parse(req.Side.getValue().ToString()), + TimeInForce = (api.orderman.TimeInForce)int.Parse(req.TimeInForce.getValue().ToString()), + User = _user_name, + UserId = lookup_user(_user_name), + ManualOrderIndicator = bts.api.orderman.ManualOrderIndicator.Yes, + }; + + set_ordertype(def, req, out bool price_req); + Create cr = new Create(); + if(price_req) + cr.Price = Convert.ToDouble(req.Price.getValue()); + cr.NewOrder = def; + cr.Quantity = Convert.ToUInt32(Math.Abs(req.OrderQty.getValue())); + + _orderservice.create_order_async(cr); + } + + private void set_ordertype(OrderDefinition def, QuickFix.FIX44.NewOrderSingle req, out bool price_req) + { + price_req = false; + switch (req.OrdType.getValue()) + { + case '1': + def.CustomDef = new CustomOrderDefinition { Market = new MarketOrderDefinition() }; + break; + case '2': + def.CustomDef = new CustomOrderDefinition { Limit = new LimitOrderDefinition() }; + price_req = true; + break; + case '3': + def.CustomDef = new CustomOrderDefinition { Stop = new StopOrderDefinition() {StopPrice = Convert.ToDouble(req.StopPx.getValue()) } }; + break; + case '4': + def.CustomDef = new CustomOrderDefinition { StopLimit = new StopLimitOrderDefinition() { StopPrice = Convert.ToDouble(req.StopPx.getValue()) } }; + price_req = true; + break; + default: + throw new IncorrectTagValue(req.OrdType.Tag); + } + } + } +} \ No newline at end of file diff --git a/src/client/spark_fix/session/SessionBase.cs b/src/client/spark_fix/session/SessionBase.cs new file mode 100644 index 000000000..bd5304742 --- /dev/null +++ b/src/client/spark_fix/session/SessionBase.cs @@ -0,0 +1,315 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reactive.Linq; +using System.Reactive.Concurrency; +using System.Text; + +using QuickFix; +using QuickFix.Fields; + + +using bts.api.core; +using bts.api.orderman; +using bts.api.user; +using bts.api.admin; +using System.Collections.Concurrent; +using System.Runtime.CompilerServices; + + +namespace bts.fix +{ + abstract class SessionBase : QuickFix.MessageCracker, QuickFix.IApplication + { + protected static UserService _userservice = bts.api.Locator.locate(); + protected static OrderService _orderservice = bts.api.Locator.locate(); + protected static AdminService _adminservice = bts.api.Locator.locate(); + protected static bts.metrics.ShellLatencyService _latencyservice = bts.api.Locator.locate(); + + protected string _user_name; + protected AuthToken _token; + + protected IDisposable _admindisp; + protected IObservable _adminobservable; + protected AdminDataImmutable? _admin_data; + + protected readonly IFixRouter _router; + protected readonly SessionID _sess; + + public SessionBase(IFixRouter router, SessionID sess) + { + _router = router; + _sess = sess; + + _clockdisp = _latencyservice.subscribe_clock().Subscribe(x => + { + var t = x.all.FirstOrDefault(); + if(t != null) + _clock = t.Timestamp; + }); + + _adminobservable = _adminservice.subscribei_admin_data().Select(x => + { + return new AdminModelWrapper(x.all.TryFirst(), _user_name); + }); + _admindisp = _adminobservable.Subscribe(x => _admin_data = x.admin_data); + } + + abstract public void FromApp(Message message, SessionID sessionID); + abstract public void OnLogon(SessionID sessionID); //subscribe to your stuff + abstract public void OnLogout(SessionID sessionID); //unsub + + virtual public void ToApp(Message message, SessionID sessionID) + { + Log.assert_d(sessionID.Equals(_sess)); + log_info("OUT: " + message); + } + + readonly IDisposable _clockdisp; ulong _clock = 0; + virtual public async void FromAdmin(Message message, SessionID sessionID) + { + Log.assert_d(sessionID.Equals(_sess)); + + MsgType type = Message.IdentifyType(message.ToString()); + switch (type.getValue()) + { + case MsgType.LOGON: + { + QuickFix.FIX44.Logon msg = (QuickFix.FIX44.Logon)message; + _user_name = msg.Username.getValue(); + var resp = await _userservice.authenticate_login_async(new AuthenticateLoginRequest { Login = msg.Username.getValue(), Password = msg.Password.getValue() }); + if (resp.success && resp.value.IsValid) + _token = resp.value.Token; + else + throw new RejectLogon("Logon rejected " + resp.error_message + resp.value?.Reason ?? string.Empty); + } + break; + case MsgType.HEARTBEAT: + { + QuickFix.FIX44.Heartbeat hb = (QuickFix.FIX44.Heartbeat)message; + var resp = await _latencyservice.report_async(new bts.metrics.Report { HostName = "BTSFIX_" + sessionID.ToString(), + Timestamp = _clock, User = _user_name }); + if (resp.success) + send(hb, sessionID); + } + break; + default: + log_info("ADMININ: " + message); + break; + } + } + + virtual public void ToAdmin(Message message, SessionID sessionID) + { + Log.assert_d(sessionID.Equals(_sess)); + log_info("ADMINOUT: " + message); + } + + virtual public void OnCreate(SessionID sessionID) + { + log_info("CREATE"); + } + + virtual public void OnMessage(QuickFix.FIX44.BusinessMessageReject n, SessionID s) + { + //Log.assert(false, "biz reject wtf " + n.EncodedText.getValue()); + Log.FIX.warn(_sess.ToString() + " Business Reject " + n.BusinessRejectReason.getValue() + " " + n.Text.getValue()); + } + virtual public void OnMessage(QuickFix.FIX44.News n, SessionID s) + { + log_info("news " + n.EncodedHeadline.getValue()); + } + + + protected void log_info(string message, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0) + { + Log.FIX.info(_sess.ToString() + " " + message, file, line); + } + + protected void log_error(string message, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0) + { + Log.FIX.error(_sess.ToString() + " " + message, file, line); + } + + protected void send(Message mess, SessionID sess) + { + try + { + Session.SendToTarget(mess, sess); + } + catch (SessionNotFound ex) + { + log_error("==session not found exception!=="); + log_error(ex.ToString()); + Log.assert(false, "session not found " + sess); + } + catch (Exception ex) + { + log_error("==exception sending to " + sess + " " + ex.ToString()); + } + } + + + protected void send_reject(SessionID sess, string text, Message refmessage = null) + { + var seq = new QuickFix.Fields.MsgSeqNum(); + QuickFix.FIX44.Reject rej = null; + if (refmessage.Header.IsSetField(seq)) + rej = new QuickFix.FIX44.Reject(new QuickFix.Fields.RefSeqNum(seq.getValue())); + else + rej = new QuickFix.FIX44.Reject(); + rej.Text = new Text(text); + send(rej, sess); + } + + protected bool security_types_equal(bts.api.SecurityType btstype, QuickFix.Fields.SecurityType fixtype) + { + return btstype == convert_security_type(fixtype); + } + + protected QuickFix.Fields.SecurityType convert_security_type(bts.api.SecurityType btstype) + { + switch (btstype) + { + case bts.api.SecurityType.Future: + return new QuickFix.Fields.SecurityType("FUT"); + case bts.api.SecurityType.Option: + return new QuickFix.Fields.SecurityType("OPT"); + case bts.api.SecurityType.Spread: + return new QuickFix.Fields.SecurityType("MLEG"); + default: + return new QuickFix.Fields.SecurityType(); + } + } + + protected bts.api.SecurityType convert_security_type(QuickFix.Fields.SecurityType fixtype) + { + switch (fixtype.getValue()) + { + case "FUT": + return bts.api.SecurityType.Future; + case "OPT": + return bts.api.SecurityType.Option; + case "MLEG": + return bts.api.SecurityType.Spread; + default: + return bts.api.SecurityType.Unset; + } + } + + protected bool exchanges_equal(bts.api.Venue btstype, QuickFix.Fields.SecurityExchange fixtype) + { + return btstype == convert_exchange(fixtype); + } + + protected QuickFix.Fields.SecurityExchange convert_exchange(bts.api.Venue btstype) + { + switch (btstype) + { + case bts.api.Venue.Glbx: + return new QuickFix.Fields.SecurityExchange("XCME"); + case bts.api.Venue.Ice: + return new QuickFix.Fields.SecurityExchange("IEPA"); + default: + return new QuickFix.Fields.SecurityExchange(); + } + } + + protected bts.api.Venue convert_exchange(QuickFix.Fields.SecurityExchange fixtype) + { + switch (fixtype.getValue()) + { + case "XCME": + case "XCBT": + case "XCEC": + case "XNYM": + return bts.api.Venue.Glbx; + case "IEPA": + case "IFUS": + case "IFEU": + case "IFLL": + return bts.api.Venue.Ice; + default: + return bts.api.Venue.Unset; + } + } + + protected QuickFix.Fields.OrdStatus translate_status(in bts.api.orderman.OrderStateImmutable state, + ref bts.api.orderman.NativeOrderStateImmutable? native) + { + native = null; + if (state.HasMarket) + { + native = state.Market.NativeState; + return new OrdStatus((char)native?.NativeStatus); + } + else if (state.HasLimit) + { + native = state.Limit.NativeState; + return new OrdStatus((char)native?.NativeStatus); + } + else if (state.HasStop) + { + native = state.Stop.NativeState; + return new OrdStatus((char)native?.NativeStatus); + } + else if (state.HasStopLimit) + { + native = state.StopLimit.NativeState; + return new OrdStatus((char)native?.NativeStatus); + } + else + { + switch (state.Status) + { + case OrderStatus.Canceled: + return new OrdStatus(OrdStatus.CANCELED); + case OrderStatus.Completed: + return new OrdStatus(OrdStatus.FILLED); + case OrderStatus.Disconnected: + return new OrdStatus(OrdStatus.STOPPED); + case OrderStatus.Error: + return new OrdStatus(OrdStatus.REJECTED); + case OrderStatus.Inactive: + return new OrdStatus(OrdStatus.PENDING_NEW); + case OrderStatus.PendingWorking: + return new OrdStatus(OrdStatus.PENDING_NEW); + case OrderStatus.RejectedBySpark: + return new OrdStatus(OrdStatus.REJECTED); + case OrderStatus.Working: + { + if (state.FilledQuantity < state.Quantity) + return new OrdStatus(OrdStatus.PARTIALLY_FILLED); + else + return new OrdStatus(OrdStatus.NEW); + } + default: + return new OrdStatus(); + } + } + } + + protected uint lookup_account(string acct) + { + if (_admin_data.HasValue) + { + var ac = _admin_data.Value.Accounts.Where(x => x.Name == acct).TryFirst(); + if(ac.HasValue) + return ac.Value.Id; + } + throw new IncorrectTagValue(new Account().Tag); + } + + protected uint lookup_user(string user) + { + if (_admin_data.HasValue) + { + var ac = _admin_data.Value.Users.Where(x => x.Name == user).TryFirst(); + if (ac.HasValue) + return ac.Value.Id; + } + throw new IncorrectTagValue(new Username().Tag); + } + + } +} \ No newline at end of file diff --git a/src/client/spark_fix/spark_fix.cfg b/src/client/spark_fix/spark_fix.cfg index 71211dc5b..e6c1315bf 100644 --- a/src/client/spark_fix/spark_fix.cfg +++ b/src/client/spark_fix/spark_fix.cfg @@ -12,6 +12,7 @@ ResetOnLogon=Y ResetOnLogout=Y ResetOnDisconnect=Y +HeartBtInt=30 LogonTimeout=30 SSLEnable=N From ba633532ebd952d6cde8830d589d53ef7315ba05 Mon Sep 17 00:00:00 2001 From: Kevin Darby Date: Thu, 6 Dec 2018 12:55:21 -0500 Subject: [PATCH 09/28] hit a wall here with MDClient, going to refactor --- .vscode/launch.json | 8 +-- .../spark_api/security/SecurityHelper.cs | 2 +- .../spark_fix/session/DropCopySession.cs | 48 +++++++++---- src/client/spark_fix/session/SessionBase.cs | 68 +++++++++++++++---- src/client/spark_fix/spark_fix.cfg | 1 + src/client/spark_fix/spec/fix/FIX44.xml | 2 + src/client/sparkcmd/Cmd/FIXCommand.cs | 8 ++- 7 files changed, 104 insertions(+), 33 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 163cad3eb..d9f8b2753 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -33,12 +33,12 @@ "requireExactSource": false }, { - "name": "SDK Launch", + "name": "FIX Launch", "type": "clr", "request": "launch", - "program": "${workspaceRoot}/build/Debug/bin/net471/spark_sdk.exe", - "args": ["md","GLBX","Future","ZN", "ZNU8"], - "cwd": "${workspaceRoot}", + "program": "${workspaceRoot}/build/Debug/bin/net471/sparkcmd.exe", + "args": ["fix","-f","spark_fix.cfg","-d"], + "cwd": "${workspaceRoot}/build/Debug/bin/net471/", "stopAtEntry": false, "externalConsole": true, "requireExactSource": false diff --git a/src/client/spark_api/security/SecurityHelper.cs b/src/client/spark_api/security/SecurityHelper.cs index b1580c0d2..e9542f4a0 100644 --- a/src/client/spark_api/security/SecurityHelper.cs +++ b/src/client/spark_api/security/SecurityHelper.cs @@ -37,7 +37,7 @@ namespace bts.api { public static DateTime expiration_date(this FutureContract future) { return new DateTime((int)future.ExpirationYear, (int)future.ExpirationMonth, (int)future.ExpirationDay); } public static DateTime expiration_date(this FutureContractImmutable future) { return new DateTime((int)future.ExpirationYear, (int)future.ExpirationMonth, (int)future.ExpirationDay); } - public static DateTime EarliestExpiration(this SecurityImmutable security) { + internal static DateTime EarliestExpiration(this SecurityImmutable security) { switch (security.ContractCase) { case ContractOneofCase.Synthetic: return security.Synthetic.Legs.First().Security.EarliestExpiration(); case ContractOneofCase.Spread: return security.Spread.Legs.First().Security.EarliestExpiration(); diff --git a/src/client/spark_fix/session/DropCopySession.cs b/src/client/spark_fix/session/DropCopySession.cs index 1343e94d9..1a5978036 100644 --- a/src/client/spark_fix/session/DropCopySession.cs +++ b/src/client/spark_fix/session/DropCopySession.cs @@ -68,7 +68,7 @@ namespace bts.fix virtual public void OnMessage(QuickFix.FIX44.OrderStatusRequest req, SessionID s) { - if (req.IsSetField(req.OrderID) && req.IsSetField(req.OrdStatusReqID)) + if (req.IsSetOrderID() && req.IsSetOrdStatusReqID()) { uint oid = uint.Parse(req.OrderID.getValue()); if (_order_cache.TryGetValue(oid, out OrderRecordImmutable order)) @@ -86,15 +86,15 @@ namespace bts.fix virtual public void OnMessage(QuickFix.FIX44.SecurityDefinitionRequest req, SessionID s) { - if (req.IsSetField(req.SecurityReqID) && req.IsSetField(req.SecurityRequestType) && + if (req.IsSetSecurityReqID() && req.IsSetSecurityRequestType() && req.SecurityRequestType.getValue() == SecurityRequestType.REQUEST_LIST_SECURITIES) { var secs = _router.get_securities(); - if (req.IsSetField(req.Symbol)) + if (req.IsSetSymbol()) secs = secs.Where(x => x.Symbol.ToLower() == req.Symbol.getValue().ToLower()); - if (req.IsSetField(req.SecurityType)) + if (req.IsSetSecurityType()) secs = secs.Where(x => security_types_equal(x.security_type(), req.SecurityType)); - if (req.IsSetField(req.SecurityExchange)) + if (req.IsSetSecurityExchange()) secs = secs.Where(x => exchanges_equal(x.Exchange, req.SecurityExchange)); var def = new QuickFix.FIX44.SecurityDefinition(req.SecurityReqID, @@ -157,13 +157,31 @@ namespace bts.fix fstatus = translate_status(state, ref native); } - protected void set_execution_report_security(bts.api.SecurityImmutable? sec, QuickFix.FIX44.ExecutionReport report) + protected bts.api.SecurityImmutable? resolve_execution_report_security(bts.api.SecurityImmutable? sec, QuickFix.FIX44.ExecutionReport report) { report.SecurityExchange = convert_exchange(sec.Value.Exchange); - report.SecurityType = convert_security_type(sec.Value.security_type()); - report.MaturityMonthYear = new MaturityMonthYear(bts.api.SecurityHelper.EarliestExpiration(sec.Value).ToString("YYYYMMDD")); + var sectype = sec.Value.security_type(); + report.SecurityType = convert_security_type(sectype); if (sec.Value.HasGlbx) - report.SecurityDesc = new SecurityDesc(sec.Value.Glbx.SecurityDesc); + report.SecurityDesc = new SecurityDesc(sec.Value.Glbx.SecurityDesc); + + switch (sectype) + { + case bts.api.SecurityType.Future: + report.MaturityMonthYear = new MaturityMonthYear(bts.api.SecurityHelper.expiration_date(sec.Value.Future).ToString("yyyyMMdd")); + break; + case bts.api.SecurityType.Option: + throw new NotSupportedException("No options yet"); + case bts.api.SecurityType.Spread: + //report.MaturityMonthYear = new MaturityMonthYear(bts.api.SecurityHelper.EarliestExpiration(sec.Value).ToString("yyyyMMdd")); + //TODO + //bug here need to kill MDCLIENT + break; + default: + report.MaturityMonthYear = new MaturityMonthYear(bts.api.SecurityHelper.EarliestExpiration(sec.Value).ToString("yyyyMMdd")); + break; + } + return sec; } virtual protected QuickFix.FIX44.ExecutionReport build_fill(SessionID sess, in FillImmutable fill, bool change = false) @@ -198,12 +216,13 @@ namespace bts.fix report.LastPx = new LastPx(Convert.ToDecimal(fill.LastPrice)); var ts = fill.HasTimestamp ? fill.Timestamp.ToDateTime() : DateTime.MinValue; report.TransactTime = new TransactTime(ts, true); - report.TradeDate = new TradeDate(ts.ToString("YYYYMMDD")); - set_execution_report_security(sec, report); + report.TradeDate = new TradeDate(ts.ToString("yyyyMMdd")); + sec = resolve_execution_report_security(sec, report); if (native.HasValue) report.SecondaryOrderID = new SecondaryOrderID(native.Value.ExchangeOrderId); - if (sec.HasValue && sec.Value.security_type() == bts.api.SecurityType.Spread || sec.Value.security_type() == bts.api.SecurityType.Synthetic) + if (sec.HasValue && sec.Value.security_type() == bts.api.SecurityType.Spread || + sec.Value.security_type() == bts.api.SecurityType.Synthetic) { if (fill.FillKind == bts.api.orderman.Fill.Types.FillKind.Leg) report.MultiLegReportingType = new MultiLegReportingType('2'); @@ -241,9 +260,10 @@ namespace bts.fix report.TimeInForce = new QuickFix.Fields.TimeInForce((char)order.Def.TimeInForce); var ts = order.State.LastChange.ToDateTime(); report.TransactTime = new TransactTime(ts, true); - report.Text = new Text(order.State.LastMsg); + if(!string.IsNullOrEmpty(order.State.LastMsg)) + report.Text = new Text(order.State.LastMsg); - set_execution_report_security(sec, report); + sec = resolve_execution_report_security(sec, report); if (native.HasValue) { report.SecondaryOrderID = new SecondaryOrderID(native.Value.ExchangeOrderId); diff --git a/src/client/spark_fix/session/SessionBase.cs b/src/client/spark_fix/session/SessionBase.cs index bd5304742..34febe17a 100644 --- a/src/client/spark_fix/session/SessionBase.cs +++ b/src/client/spark_fix/session/SessionBase.cs @@ -66,7 +66,7 @@ namespace bts.fix } readonly IDisposable _clockdisp; ulong _clock = 0; - virtual public async void FromAdmin(Message message, SessionID sessionID) + virtual public void FromAdmin(Message message, SessionID sessionID) { Log.assert_d(sessionID.Equals(_sess)); @@ -75,22 +75,34 @@ namespace bts.fix { case MsgType.LOGON: { - QuickFix.FIX44.Logon msg = (QuickFix.FIX44.Logon)message; - _user_name = msg.Username.getValue(); - var resp = await _userservice.authenticate_login_async(new AuthenticateLoginRequest { Login = msg.Username.getValue(), Password = msg.Password.getValue() }); - if (resp.success && resp.value.IsValid) - _token = resp.value.Token; - else - throw new RejectLogon("Logon rejected " + resp.error_message + resp.value?.Reason ?? string.Empty); + try + { + QuickFix.FIX44.Logon msg = (QuickFix.FIX44.Logon)message; + _user_name = msg.Username.getValue(); + string pass = string.Empty; + if(msg.IsSetPassword()) + pass = msg.Password.getValue(); + var resp = _userservice.authenticate_login(new AuthenticateLoginRequest { + Login = msg.Username.getValue(), Password = pass}); + if (resp != null && resp.IsValid) + _token = resp.Token; + else + throw new RejectLogon("Logon rejected " + resp?.Reason ?? string.Empty); + } + catch (RejectLogon) + { + throw; + } + catch (Exception ex) + { + throw new RejectLogon("Logon rejected " + ex.ToString()); + } } break; case MsgType.HEARTBEAT: { QuickFix.FIX44.Heartbeat hb = (QuickFix.FIX44.Heartbeat)message; - var resp = await _latencyservice.report_async(new bts.metrics.Report { HostName = "BTSFIX_" + sessionID.ToString(), - Timestamp = _clock, User = _user_name }); - if (resp.success) - send(hb, sessionID); + handle_heartbeat(hb, sessionID); } break; default: @@ -99,6 +111,14 @@ namespace bts.fix } } + async protected void handle_heartbeat(QuickFix.FIX44.Heartbeat hb, SessionID sessionID) + { + var resp = await _latencyservice.report_async(new bts.metrics.Report { HostName = "BTSFIX_" + sessionID.ToString(), + Timestamp = _clock, User = _user_name }); + if (resp.success) + send(hb, sessionID); + } + virtual public void ToAdmin(Message message, SessionID sessionID) { Log.assert_d(sessionID.Equals(_sess)); @@ -177,6 +197,10 @@ namespace bts.fix return new QuickFix.Fields.SecurityType("OPT"); case bts.api.SecurityType.Spread: return new QuickFix.Fields.SecurityType("MLEG"); + case bts.api.SecurityType.Stock: + return new QuickFix.Fields.SecurityType("CS"); + case bts.api.SecurityType.Synthetic: + return new QuickFix.Fields.SecurityType("SYNTH"); default: return new QuickFix.Fields.SecurityType(); } @@ -192,6 +216,10 @@ namespace bts.fix return bts.api.SecurityType.Option; case "MLEG": return bts.api.SecurityType.Spread; + case "CS": + return bts.api.SecurityType.Stock; + case "SYNTH": + return bts.api.SecurityType.Synthetic; default: return bts.api.SecurityType.Unset; } @@ -206,10 +234,18 @@ namespace bts.fix { switch (btstype) { + case bts.api.Venue.Bts: + return new QuickFix.Fields.SecurityExchange("BTS"); + case bts.api.Venue.Cboe: + return new QuickFix.Fields.SecurityExchange("XCBO"); + case bts.api.Venue.Cboecfe: + return new QuickFix.Fields.SecurityExchange("XCBF"); case bts.api.Venue.Glbx: return new QuickFix.Fields.SecurityExchange("XCME"); case bts.api.Venue.Ice: return new QuickFix.Fields.SecurityExchange("IEPA"); + case bts.api.Venue.Sim: + return new QuickFix.Fields.SecurityExchange("SIM"); default: return new QuickFix.Fields.SecurityExchange(); } @@ -219,6 +255,12 @@ namespace bts.fix { switch (fixtype.getValue()) { + case "BTS": + return bts.api.Venue.Bts; + case "XCBO": + return bts.api.Venue.Cboe; + case "XCBF": + return bts.api.Venue.Cboecfe; case "XCME": case "XCBT": case "XCEC": @@ -229,6 +271,8 @@ namespace bts.fix case "IFEU": case "IFLL": return bts.api.Venue.Ice; + case "SIM": + return bts.api.Venue.Sim; default: return bts.api.Venue.Unset; } diff --git a/src/client/spark_fix/spark_fix.cfg b/src/client/spark_fix/spark_fix.cfg index e6c1315bf..b4350efb2 100644 --- a/src/client/spark_fix/spark_fix.cfg +++ b/src/client/spark_fix/spark_fix.cfg @@ -1,4 +1,5 @@ #http://www.quickfixengine.org/quickfix/doc/html/configuration.html +#https://www.onixs.biz/fix-dictionary.html [DEFAULT] ConnectionType=acceptor diff --git a/src/client/spark_fix/spec/fix/FIX44.xml b/src/client/spark_fix/spec/fix/FIX44.xml index f889ddb4c..69b89c401 100644 --- a/src/client/spark_fix/spec/fix/FIX44.xml +++ b/src/client/spark_fix/spec/fix/FIX44.xml @@ -1,3 +1,5 @@ + +
diff --git a/src/client/sparkcmd/Cmd/FIXCommand.cs b/src/client/sparkcmd/Cmd/FIXCommand.cs index 3427de8f4..2517708c6 100644 --- a/src/client/sparkcmd/Cmd/FIXCommand.cs +++ b/src/client/sparkcmd/Cmd/FIXCommand.cs @@ -26,12 +26,16 @@ namespace bts { if (_orders) { - Console.WriteLine("Starting FIX ORDERS Acceptor using " + _config + " Http server " + _http ?? "no"); + 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)); } else if (_dropcopy) { - Console.WriteLine("Starting FIX DROP Acceptor using " + _config + " Http server " + _http ?? "no"); + 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)); } else if (_initiator) From 0d83f28cbca915c90fb5d68e10a2ac7796afdeaf Mon Sep 17 00:00:00 2001 From: Kevin Darby Date: Wed, 12 Dec 2018 14:26:03 -0500 Subject: [PATCH 10/28] fix lives --- src/client/spark_api/utils/Locator.cs | 4 +++ src/client/spark_fix/FixRouter.cs | 11 ++++---- .../spark_fix/session/DropCopySession.cs | 6 ++--- src/client/spark_fix/session/OrderSession.cs | 2 +- src/client/spark_fix/session/SessionBase.cs | 25 ++++++++++--------- 5 files changed, 26 insertions(+), 22 deletions(-) diff --git a/src/client/spark_api/utils/Locator.cs b/src/client/spark_api/utils/Locator.cs index 64bbe1711..3d7b3d3aa 100644 --- a/src/client/spark_api/utils/Locator.cs +++ b/src/client/spark_api/utils/Locator.cs @@ -16,6 +16,10 @@ namespace bts.api { return await _context.Value.login(username, password); } + static public void login_with_token(AuthTokenImmutable token) + { + _context.Value.login(token); + } static public AuthTokenImmutable? token => _context.Value.token; } } diff --git a/src/client/spark_fix/FixRouter.cs b/src/client/spark_fix/FixRouter.cs index 670e17fb4..3b06fab04 100644 --- a/src/client/spark_fix/FixRouter.cs +++ b/src/client/spark_fix/FixRouter.cs @@ -31,12 +31,11 @@ namespace bts.fix { readonly ConcurrentDictionary _sessions = new ConcurrentDictionary(); readonly Func _factory; - readonly MarketDataClient _mdglobal = new MarketDataClient(); + readonly MarketDataClient _md = new MarketDataClient(); public FixRouter(Func factory) { _factory = factory; - _mdglobal.pump_once(); //get securities } public IApplication session(SessionID sessionID) @@ -87,18 +86,18 @@ namespace bts.fix IEnumerable IFixRouter.get_securities() { - return _mdglobal.get_securities(); + return _md.securities; } SecurityImmutable? IFixRouter.lookup(uint key) { - return _mdglobal.lookup(key); + return _md.lookup(key); } SecurityImmutable? IFixRouter.lookup(string desc) { - if (_mdglobal.lookup_security_key_from_desc(desc, out uint key)) - return _mdglobal.lookup(key); + if (_md.lookup_security_key_from_desc(desc, out uint key)) + return _md.lookup(key); else return null; } diff --git a/src/client/spark_fix/session/DropCopySession.cs b/src/client/spark_fix/session/DropCopySession.cs index 1a5978036..3de5a9194 100644 --- a/src/client/spark_fix/session/DropCopySession.cs +++ b/src/client/spark_fix/session/DropCopySession.cs @@ -21,7 +21,7 @@ namespace bts.fix { protected IDisposable _fillsdisp; protected IDisposable _ordersdisp; - + protected static Lazy _orderservice = new Lazy(() => bts.api.Locator.locate(), true); protected readonly ConcurrentDictionary _order_cache = new ConcurrentDictionary(); protected readonly ConcurrentDictionary _fix_clorderids = new ConcurrentDictionary(); @@ -114,8 +114,8 @@ namespace bts.fix var scheduler = TaskPoolScheduler.Default; var interval = TimeSpan.FromMilliseconds(500); - var on_orders = _orderservice.subscribei_orders().Naggle(interval, scheduler).PermissionFilter(_adminobservable).Table().Cache(); - var on_fills = _orderservice.subscribei_fills().Naggle(interval, scheduler).PermissionFilter(_adminobservable).Table().Cache(); + var on_orders = _orderservice.Value.subscribei_orders().Naggle(interval, scheduler).PermissionFilter(_adminobservable).Table().Cache(); + var on_fills = _orderservice.Value.subscribei_fills().Naggle(interval, scheduler).PermissionFilter(_adminobservable).Table().Cache(); _ordersdisp = on_orders.Subscribe(o => { diff --git a/src/client/spark_fix/session/OrderSession.cs b/src/client/spark_fix/session/OrderSession.cs index b235bf3bf..58835fffe 100644 --- a/src/client/spark_fix/session/OrderSession.cs +++ b/src/client/spark_fix/session/OrderSession.cs @@ -69,7 +69,7 @@ namespace bts.fix cr.NewOrder = def; cr.Quantity = Convert.ToUInt32(Math.Abs(req.OrderQty.getValue())); - _orderservice.create_order_async(cr); + _orderservice.Value.create_order_async(cr); } private void set_ordertype(OrderDefinition def, QuickFix.FIX44.NewOrderSingle req, out bool price_req) diff --git a/src/client/spark_fix/session/SessionBase.cs b/src/client/spark_fix/session/SessionBase.cs index 34febe17a..31006229f 100644 --- a/src/client/spark_fix/session/SessionBase.cs +++ b/src/client/spark_fix/session/SessionBase.cs @@ -4,27 +4,28 @@ using System.Linq; using System.Reactive.Linq; using System.Reactive.Concurrency; using System.Text; +using System.Collections.Concurrent; +using System.Runtime.CompilerServices; using QuickFix; using QuickFix.Fields; - +using mbts; +using bts.api; using bts.api.core; using bts.api.orderman; using bts.api.user; using bts.api.admin; -using System.Collections.Concurrent; -using System.Runtime.CompilerServices; namespace bts.fix { abstract class SessionBase : QuickFix.MessageCracker, QuickFix.IApplication { - protected static UserService _userservice = bts.api.Locator.locate(); - protected static OrderService _orderservice = bts.api.Locator.locate(); - protected static AdminService _adminservice = bts.api.Locator.locate(); - protected static bts.metrics.ShellLatencyService _latencyservice = bts.api.Locator.locate(); + protected static AuthService _authservice = bts.api.Locator.locate(); + protected static Lazy _adminservice = new Lazy(() => bts.api.Locator.locate(), true); + protected static Lazy _latencyservice = + new Lazy(() => bts.api.Locator.locate(), true); protected string _user_name; protected AuthToken _token; @@ -41,14 +42,14 @@ namespace bts.fix _router = router; _sess = sess; - _clockdisp = _latencyservice.subscribe_clock().Subscribe(x => + _clockdisp = _latencyservice.Value.subscribe_clock().Subscribe(x => { var t = x.all.FirstOrDefault(); if(t != null) _clock = t.Timestamp; }); - _adminobservable = _adminservice.subscribei_admin_data().Select(x => + _adminobservable = _adminservice.Value.subscribei_admin_data().Select(x => { return new AdminModelWrapper(x.all.TryFirst(), _user_name); }); @@ -82,7 +83,7 @@ namespace bts.fix string pass = string.Empty; if(msg.IsSetPassword()) pass = msg.Password.getValue(); - var resp = _userservice.authenticate_login(new AuthenticateLoginRequest { + var resp = _authservice.authenticate_login(new AuthenticateLoginRequest { Login = msg.Username.getValue(), Password = pass}); if (resp != null && resp.IsValid) _token = resp.Token; @@ -113,8 +114,8 @@ namespace bts.fix async protected void handle_heartbeat(QuickFix.FIX44.Heartbeat hb, SessionID sessionID) { - var resp = await _latencyservice.report_async(new bts.metrics.Report { HostName = "BTSFIX_" + sessionID.ToString(), - Timestamp = _clock, User = _user_name }); + var resp = await _latencyservice.Value.report_async(new bts.metrics.Report { HostName = "BTSFIX_" + sessionID.ToString(), + Timestamp = _clock, User = _user_name }); if (resp.success) send(hb, sessionID); } From 8cac406547355a9a8f88daacc1b9a75b5f74fa5f Mon Sep 17 00:00:00 2001 From: Kevin Darby Date: Wed, 12 Dec 2018 17:33:25 -0500 Subject: [PATCH 11/28] fix error handling --- src/client/spark_api/md/MarketDataClient.cs | 12 ++- src/client/spark_fix/FixInit.cs | 72 +++++++------ src/client/spark_fix/FixRouter.cs | 84 +++++++++++++-- .../spark_fix/session/DropCopySession.cs | 47 +++----- src/client/spark_fix/session/IFIXSession.cs | 8 ++ src/client/spark_fix/session/OrderSession.cs | 100 ++++++++++++------ src/client/spark_fix/session/SessionBase.cs | 56 ++++++++-- 7 files changed, 266 insertions(+), 113 deletions(-) create mode 100644 src/client/spark_fix/session/IFIXSession.cs diff --git a/src/client/spark_api/md/MarketDataClient.cs b/src/client/spark_api/md/MarketDataClient.cs index 34909805d..49fa13cbb 100644 --- a/src/client/spark_api/md/MarketDataClient.cs +++ b/src/client/spark_api/md/MarketDataClient.cs @@ -198,12 +198,16 @@ namespace bts.md public bool lookup_security_key_from_desc(string security_desc, out SecurityKey key) { key = 0; - var fnd = find(x => x.glbx_desc() == security_desc).TryFirst(); - if (fnd.HasValue) + try { - key = fnd.Value.security.Id; - return true; + var fnd = find(x => x.glbx_desc() == security_desc).TryFirst(); + if (fnd.HasValue) + { + key = fnd.Value.security.Id; + return true; + } } + catch { } return false; } diff --git a/src/client/spark_fix/FixInit.cs b/src/client/spark_fix/FixInit.cs index bd0250b2e..b9ca12b4c 100644 --- a/src/client/spark_fix/FixInit.cs +++ b/src/client/spark_fix/FixInit.cs @@ -10,45 +10,51 @@ namespace bts.fix { public class FixInit { + static FixInit() + { + AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; + } + + static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) + { + var exception = e.ExceptionObject as Exception; + Log.FIX.error($"Unhandled Exception: {e.ExceptionObject} {exception?.StackTrace}"); + if (e.IsTerminating) + { + Log.system_is_crashing("Unhandled exception", e.ExceptionObject); + } + } + public static int start_acceptor(string settings_file, bool orders_allowed, string http_address = null) { - try + SessionSettings settings = new SessionSettings(settings_file); + IApplication app = new FixRouter( (th, sess) => { - SessionSettings settings = new SessionSettings(settings_file); - IApplication app = new FixRouter( (th, sess) => - { - if(orders_allowed) - return new OrderSession(th, sess); - else - return new DropCopySession(th, sess); - }); - IMessageStoreFactory storeFactory = new FileStoreFactory(settings); - ILogFactory logFactory = new FileLogFactory(settings); - IAcceptor acceptor = new ThreadedSocketAcceptor(app, storeFactory, settings, logFactory); + if(orders_allowed) + return new OrderSession(th, sess); + else + return new DropCopySession(th, sess); + }); + IMessageStoreFactory storeFactory = new FileStoreFactory(settings); + ILogFactory logFactory = new FileLogFactory(settings); + IAcceptor acceptor = new ThreadedSocketAcceptor(app, storeFactory, settings, logFactory); - acceptor.Start(); - HttpServer srv = null; - if (!string.IsNullOrEmpty(http_address)) - { - if(!http_address.StartsWith("http")) - http_address = "http://127.0.0.1:5080/"; - srv = new HttpServer(http_address, settings); - srv.Start(); - } - Console.WriteLine("press to quit"); - while (Console.Read() != 'q') { } - acceptor.Stop(); - if(srv != null) - srv.Stop(); - return 0; - } - catch (System.Exception e) + acceptor.Start(); + HttpServer srv = null; + if (!string.IsNullOrEmpty(http_address)) { - bts.Log.FIX.fatal(e.ToString()); - Console.WriteLine("==FATAL ERROR=="); - Console.WriteLine(e.ToString()); - return -1; + if(!http_address.StartsWith("http")) + http_address = "http://127.0.0.1:5080/"; + srv = new HttpServer(http_address, settings); + srv.Start(); } + Console.WriteLine("press to quit"); + while (Console.Read() != 'q') { } + acceptor.Stop(); + if(srv != null) + srv.Stop(); + return 0; + } } } diff --git a/src/client/spark_fix/FixRouter.cs b/src/client/spark_fix/FixRouter.cs index 3b06fab04..f3d4fd545 100644 --- a/src/client/spark_fix/FixRouter.cs +++ b/src/client/spark_fix/FixRouter.cs @@ -38,7 +38,7 @@ namespace bts.fix _factory = factory; } - public IApplication session(SessionID sessionID) + IApplication session(SessionID sessionID) { IApplication app; if (!_sessions.TryGetValue(sessionID, out app)) @@ -49,39 +49,107 @@ namespace bts.fix return app; } + void handle_session_exception(Exception ex, SessionID sessionID, Message message = null) + { + string msg = "==ERROR in session " + sessionID.ToString() + "== "; + msg += message?.GetType().Name ?? string.Empty; + msg += ex?.ToString() ?? string.Empty; + + bts.Log.FIX.error(msg); + Console.WriteLine(msg); + //now shut this fucker down + try + { + var sess = Session.LookupSession(sessionID); + if(sess != null) + sess.Disconnect(msg); + } + catch { } + } + public void FromAdmin(Message message, SessionID sessionID) { - session(sessionID).FromAdmin(message, sessionID); + try + { + session(sessionID).FromAdmin(message, sessionID); + } + catch (Exception ex) + { + handle_session_exception(ex, sessionID, message); + } } public void FromApp(Message message, SessionID sessionID) { - session(sessionID).FromApp(message, sessionID); + try + { + session(sessionID).FromApp(message, sessionID); + } + catch (Exception ex) + { + handle_session_exception(ex, sessionID, message); + } } public void OnCreate(SessionID sessionID) { - session(sessionID).OnCreate(sessionID); + try + { + session(sessionID).OnCreate(sessionID); + } + catch (Exception ex) + { + handle_session_exception(ex, sessionID); + } } public void OnLogon(SessionID sessionID) { - session(sessionID).OnLogon(sessionID); + try + { + session(sessionID).OnLogon(sessionID); + } + catch (Exception ex) + { + handle_session_exception(ex, sessionID); + } } public void OnLogout(SessionID sessionID) { - session(sessionID).OnLogout(sessionID); + try + { + //TODO stackoverflow? + session(sessionID).OnLogout(sessionID); + } + catch (Exception ex) + { + handle_session_exception(ex, sessionID); + } } public void ToAdmin(Message message, SessionID sessionID) { - session(sessionID).ToAdmin(message, sessionID); + try + { + session(sessionID).ToAdmin(message, sessionID); + } + catch (Exception ex) + { + handle_session_exception(ex, sessionID, message); + } } public void ToApp(Message message, SessionID sessionID) { - session(sessionID).ToApp(message, sessionID); + try + { + session(sessionID).ToApp(message, sessionID); + } + catch (Exception ex) + { + handle_session_exception(ex, sessionID, message); + } } IEnumerable IFixRouter.get_securities() diff --git a/src/client/spark_fix/session/DropCopySession.cs b/src/client/spark_fix/session/DropCopySession.cs index 3de5a9194..2548d48cf 100644 --- a/src/client/spark_fix/session/DropCopySession.cs +++ b/src/client/spark_fix/session/DropCopySession.cs @@ -8,6 +8,7 @@ using System.Text; using QuickFix; using QuickFix.Fields; +using bts.api; using bts.api.core; using bts.api.orderman; using bts.api.user; @@ -17,7 +18,7 @@ using System.Runtime.CompilerServices; namespace bts.fix { - class DropCopySession : SessionBase, QuickFix.IApplication + class DropCopySession : SessionBase { protected IDisposable _fillsdisp; protected IDisposable _ordersdisp; @@ -68,26 +69,18 @@ namespace bts.fix virtual public void OnMessage(QuickFix.FIX44.OrderStatusRequest req, SessionID s) { - if (req.IsSetOrderID() && req.IsSetOrdStatusReqID()) + uint oid = uint.Parse(req.OrderID.getValue()); + if (_order_cache.TryGetValue(oid, out OrderRecordImmutable order)) { - uint oid = uint.Parse(req.OrderID.getValue()); - if (_order_cache.TryGetValue(oid, out OrderRecordImmutable order)) - { - var ostat = build_order_status(s, order); - ostat.OrdStatusReqID = new OrdStatusReqID(req.OrdStatusReqID.getValue()); - send(ostat, s); - } - else - send_reject(s, "Can't find order " + oid, req); + var ostat = build_order_status(s, order); + ostat.OrdStatusReqID = new OrdStatusReqID(req.OrdStatusReqID.getValue()); + send(ostat, s); } - else - send_reject(s, "clorderid null", req); } virtual public void OnMessage(QuickFix.FIX44.SecurityDefinitionRequest req, SessionID s) { - if (req.IsSetSecurityReqID() && req.IsSetSecurityRequestType() && - req.SecurityRequestType.getValue() == SecurityRequestType.REQUEST_LIST_SECURITIES) + if (req.SecurityRequestType.getValue() == SecurityRequestType.REQUEST_LIST_SECURITIES) { var secs = _router.get_securities(); if (req.IsSetSymbol()) @@ -103,15 +96,13 @@ namespace bts.fix send(def, s); } else - send_reject(s, "Can't parse secdef request", req); + throw new IncorrectTagValue(req.SecurityRequestType.Tag); } virtual protected void subscribe_fills_and_orders(SessionID sessionID) { - - var scheduler = TaskPoolScheduler.Default; var interval = TimeSpan.FromMilliseconds(500); var on_orders = _orderservice.Value.subscribei_orders().Naggle(interval, scheduler).PermissionFilter(_adminobservable).Table().Cache(); @@ -141,7 +132,7 @@ namespace bts.fix } foreach (var fill in f.changed) { - var fi = build_fill(sessionID, fill); + var fi = build_fill(sessionID, fill, true); send(fi, sessionID); } }); @@ -168,18 +159,14 @@ namespace bts.fix switch (sectype) { case bts.api.SecurityType.Future: - report.MaturityMonthYear = new MaturityMonthYear(bts.api.SecurityHelper.expiration_date(sec.Value.Future).ToString("yyyyMMdd")); + report.MaturityMonthYear = new MaturityMonthYear(sec.Value.EarliestExpiration().ToString("yyyyMMdd")); break; - case bts.api.SecurityType.Option: - throw new NotSupportedException("No options yet"); - case bts.api.SecurityType.Spread: - //report.MaturityMonthYear = new MaturityMonthYear(bts.api.SecurityHelper.EarliestExpiration(sec.Value).ToString("yyyyMMdd")); - //TODO - //bug here need to kill MDCLIENT + case bts.api.SecurityType.Spread: //TODO this is not quite right for spreads of spreads + var leg = sec.Value.Spread.Legs.OrderBy(x => x.Security.EarliestExpiration()).First(); + report.MaturityMonthYear = new MaturityMonthYear(leg.Security.EarliestExpiration().ToString("yyyyMMdd")); break; default: - report.MaturityMonthYear = new MaturityMonthYear(bts.api.SecurityHelper.EarliestExpiration(sec.Value).ToString("yyyyMMdd")); - break; + throw new UnsupportedMessageType(); } return sec; } @@ -206,7 +193,7 @@ namespace bts.fix exec, status, new Symbol(sec?.Symbol ?? string.Empty), - new Side(fill.Side == bts.api.Side.Buy ? Side.BUY : Side.SELL), + new QuickFix.Fields.Side(fill.Side == bts.api.Side.Buy ? QuickFix.Fields.Side.BUY : QuickFix.Fields.Side.SELL), new LeavesQty(leaves), new CumQty(filled), new AvgPx(Convert.ToDecimal(prx))); @@ -249,7 +236,7 @@ namespace bts.fix exec, status, new Symbol(sec?.Symbol ?? string.Empty), - new Side(order.Def.Side == bts.api.Side.Buy ? Side.BUY : Side.SELL), + new QuickFix.Fields.Side(order.Def.Side == bts.api.Side.Buy ? QuickFix.Fields.Side.BUY : QuickFix.Fields.Side.SELL), new LeavesQty(leaves), new CumQty(filled), new AvgPx(Convert.ToDecimal(prx))); diff --git a/src/client/spark_fix/session/IFIXSession.cs b/src/client/spark_fix/session/IFIXSession.cs new file mode 100644 index 000000000..ca70a23f8 --- /dev/null +++ b/src/client/spark_fix/session/IFIXSession.cs @@ -0,0 +1,8 @@ +using System; + +namespace bts.fix +{ + interface IFIXSession : QuickFix.IApplication + { + } +} \ No newline at end of file diff --git a/src/client/spark_fix/session/OrderSession.cs b/src/client/spark_fix/session/OrderSession.cs index 58835fffe..94d0b2d1d 100644 --- a/src/client/spark_fix/session/OrderSession.cs +++ b/src/client/spark_fix/session/OrderSession.cs @@ -11,7 +11,7 @@ using bts.api.orderman; namespace bts.fix { - class OrderSession : DropCopySession, QuickFix.IApplication + class OrderSession : DropCopySession { public OrderSession(IFixRouter router, SessionID sess) : base(router, sess) { @@ -23,8 +23,8 @@ namespace bts.fix MsgType type = Message.IdentifyType(message.ToString()); switch (type.getValue()) { - case MsgType.ORDER_STATUS_REQUEST: - case MsgType.SECURITYDEFINITIONREQUEST: + case MsgType.ORDER_STATUS_REQUEST: //handled in DropCopySession + case MsgType.SECURITYDEFINITIONREQUEST: //handled in DropCopySession case MsgType.NEWORDERSINGLE: case MsgType.ORDERCANCELREPLACEREQUEST: @@ -38,38 +38,78 @@ namespace bts.fix } } - virtual public void OnMessage(QuickFix.FIX44.NewOrderSingle req, SessionID s) + virtual public void OnMessage(QuickFix.FIX44.OrderCancelRequest cancel, SessionID s) { - Venue ven = convert_exchange(req.SecurityExchange); - if(ven != Venue.Glbx) - throw new IncorrectTagValue(req.SecurityExchange.Tag); - - var sec = _router.lookup(req.Symbol.getValue()); - if(sec == null) - sec = _router.lookup(req.SecurityDesc.getValue()); - if(!sec.HasValue) - throw new IncorrectTagValue(req.SecurityDesc.Tag); - - OrderDefinition def = new OrderDefinition() + var id = cancel.OrderID.getValue(); + if(!uint.TryParse(id, out uint key)) + throw new IncorrectTagValue(cancel.OrderID.Tag); + var resp = _orderservice.Value.cancel_order(new Cancel { OrderKey = key }); + if (resp.ErrorCode != OrderError.Ok) { - Account = req.Account.getValue(), - AccountId = lookup_account(req.Account.getValue()), - SecurityKey = sec.Value.Id, - Side = (api.Side)int.Parse(req.Side.getValue().ToString()), - TimeInForce = (api.orderman.TimeInForce)int.Parse(req.TimeInForce.getValue().ToString()), - User = _user_name, - UserId = lookup_user(_user_name), - ManualOrderIndicator = bts.api.orderman.ManualOrderIndicator.Yes, - }; + send_cancel_reject(s, "Cancel Rejected: " + resp.ErrorCode.ToString() + " - " + resp.Msg, cancel); + } + } - set_ordertype(def, req, out bool price_req); + virtual public void OnMessage(QuickFix.FIX44.NewOrderSingle create, SessionID s) + { + Venue ven = convert_exchange(create.SecurityExchange); + if (ven != Venue.Glbx) + throw new IncorrectTagValue(create.SecurityExchange.Tag); + + var sec = _router.lookup(create.Symbol.getValue()); + if (!sec.HasValue) + sec = _router.lookup(create.SecurityDesc.getValue()); + if (!sec.HasValue) + throw new IncorrectTagValue(create.SecurityDesc.Tag); + + OrderDefinition def = null; + try + { + string manual = "Y"; + if(create.IsSetField(Tags.ManualOrderIndicator)) + manual = create.GetField(Tags.ManualOrderIndicator); + def = new OrderDefinition() + { + Account = create.Account.getValue(), + AccountId = lookup_account(create.Account.getValue()), + SecurityKey = sec.Value.Id, + Side = (api.Side)(int)create.Side.getValue(), + TimeInForce = (api.orderman.TimeInForce)(int)create.TimeInForce.getValue(), + User = _user_name, + UserId = lookup_user(_user_name), + ManualOrderIndicator = manual == "Y" ? bts.api.orderman.ManualOrderIndicator.Yes : bts.api.orderman.ManualOrderIndicator.No, + }; + } + catch + { + throw new IncorrectTagValue(create.TimeInForce.Tag); + } + + set_ordertype(def, create, out bool price_req); Create cr = new Create(); - if(price_req) - cr.Price = Convert.ToDouble(req.Price.getValue()); cr.NewOrder = def; - cr.Quantity = Convert.ToUInt32(Math.Abs(req.OrderQty.getValue())); - - _orderservice.Value.create_order_async(cr); + try + { + if (price_req) + cr.Price = Convert.ToDouble(create.Price.getValue()); + } + catch + { + throw new IncorrectTagValue(create.Price.Tag); + } + try + { + cr.Quantity = Convert.ToUInt32(Math.Abs(create.OrderQty.getValue())); + } + catch + { + throw new IncorrectTagValue(create.OrderQty.Tag); + } + var resp = _orderservice.Value.create_order(cr); + if (resp.ErrorCode != OrderError.Ok) + { + send_biz_reject(s, "Order Rejected: " + resp.ErrorCode.ToString() + " - " + resp.Msg, create); + } } private void set_ordertype(OrderDefinition def, QuickFix.FIX44.NewOrderSingle req, out bool price_req) diff --git a/src/client/spark_fix/session/SessionBase.cs b/src/client/spark_fix/session/SessionBase.cs index 31006229f..5bbc37728 100644 --- a/src/client/spark_fix/session/SessionBase.cs +++ b/src/client/spark_fix/session/SessionBase.cs @@ -20,7 +20,7 @@ using bts.api.admin; namespace bts.fix { - abstract class SessionBase : QuickFix.MessageCracker, QuickFix.IApplication + abstract class SessionBase : QuickFix.MessageCracker, IFIXSession { protected static AuthService _authservice = bts.api.Locator.locate(); protected static Lazy _adminservice = new Lazy(() => bts.api.Locator.locate(), true); @@ -170,19 +170,60 @@ namespace bts.fix } } - - protected void send_reject(SessionID sess, string text, Message refmessage = null) + protected void send_session_reject(SessionID sess, string text, Message refmessage = null) { - var seq = new QuickFix.Fields.MsgSeqNum(); QuickFix.FIX44.Reject rej = null; - if (refmessage.Header.IsSetField(seq)) - rej = new QuickFix.FIX44.Reject(new QuickFix.Fields.RefSeqNum(seq.getValue())); + if (refmessage != null && refmessage.Header.IsSetField(Tags.MsgSeqNum)) + rej = new QuickFix.FIX44.Reject( new QuickFix.Fields.RefSeqNum( refmessage.Header.GetInt(Tags.MsgSeqNum) )); else rej = new QuickFix.FIX44.Reject(); rej.Text = new Text(text); send(rej, sess); } + protected void send_biz_reject(SessionID sess, string text, Message refmessage) + { + QuickFix.FIX44.BusinessMessageReject rej = new QuickFix.FIX44.BusinessMessageReject(); + + rej.RefMsgType = new QuickFix.Fields.RefMsgType(refmessage.Header.GetString(Tags.MsgType)); + rej.RefSeqNum = new QuickFix.Fields.RefSeqNum(refmessage.Header.GetInt(Tags.MsgSeqNum)); + rej.BusinessRejectReason = new QuickFix.Fields.BusinessRejectReason(0); + rej.Text = new Text(text); + send(rej, sess); + } + + protected void send_cancel_reject(SessionID sess, string text, Message refmessage) + { + QuickFix.FIX44.OrderCancelReject rej = new QuickFix.FIX44.OrderCancelReject(); + if (refmessage is QuickFix.FIX44.OrderCancelRequest cancel) + { + if (cancel.IsSetClOrdID()) + rej.SetField(cancel.ClOrdID); + if (cancel.IsSetOrigClOrdID()) + rej.SetField(cancel.OrigClOrdID); + if (cancel.IsSetOrderID()) + rej.SetField(cancel.OrderID); + rej.CxlRejResponseTo = new CxlRejResponseTo('1'); + rej.Text = new Text(text); + send(rej, sess); + } + else if (refmessage is QuickFix.FIX44.OrderCancelReplaceRequest replace) + { + if (replace.IsSetClOrdID()) + rej.SetField(replace.ClOrdID); + if (replace.IsSetOrigClOrdID()) + rej.SetField(replace.OrigClOrdID); + if (replace.IsSetOrderID()) + rej.SetField(replace.OrderID); + rej.CxlRejResponseTo = new CxlRejResponseTo('2'); + rej.Text = new Text(text); + send(rej, sess); + } + else + throw new UnsupportedMessageType(); + + } + protected bool security_types_equal(bts.api.SecurityType btstype, QuickFix.Fields.SecurityType fixtype) { return btstype == convert_security_type(fixtype); @@ -354,7 +395,6 @@ namespace bts.fix return ac.Value.Id; } throw new IncorrectTagValue(new Username().Tag); - } - + } } } \ No newline at end of file From 6e7fa91718a1ca79c2e2c379c946ce025f90790b Mon Sep 17 00:00:00 2001 From: Kevin Darby Date: Fri, 14 Dec 2018 10:39:34 -0500 Subject: [PATCH 12/28] ready for testing --- src/client/spark_api/md/MarketDataClient.cs | 10 +- .../rtd/subscriptions/MDSubscribe.cs | 2 +- src/client/spark_fix/FixRouter.cs | 92 +++++++++++++++---- .../spark_fix/session/DropCopySession.cs | 29 +++--- src/client/spark_fix/session/OrderSession.cs | 32 ++++++- src/client/spark_fix/session/SessionBase.cs | 55 ++--------- 6 files changed, 135 insertions(+), 85 deletions(-) diff --git a/src/client/spark_api/md/MarketDataClient.cs b/src/client/spark_api/md/MarketDataClient.cs index 49fa13cbb..b8b0eeec0 100644 --- a/src/client/spark_api/md/MarketDataClient.cs +++ b/src/client/spark_api/md/MarketDataClient.cs @@ -183,11 +183,11 @@ namespace bts.md return null; } - public bool lookup_security_desc(SecurityKey key, out string security_desc) + public bool lookup_security_desc_glbx(SecurityKey key, out string security_desc) { security_desc = null; var sec = lookup(key); - if (sec.HasValue) + if (sec.HasValue && sec.Value.HasGlbx) { security_desc = sec.Value.glbx_desc(); return true; @@ -200,7 +200,8 @@ namespace bts.md key = 0; try { - var fnd = find(x => x.glbx_desc() == security_desc).TryFirst(); + var fnd = find( + x => x.glbx_desc() == security_desc).TryFirst(); if (fnd.HasValue) { key = fnd.Value.security.Id; @@ -214,7 +215,8 @@ namespace bts.md IEnumerable find(Func filter) { Func filt = (SecurityMD secmd) => filter(secmd.security); - return _data.Values.Where(filt); + var found = _data.Values.Where(filt); + return found; } public SecurityImmutable? find_security(Func filter) diff --git a/src/client/spark_excel/rtd/subscriptions/MDSubscribe.cs b/src/client/spark_excel/rtd/subscriptions/MDSubscribe.cs index a96272d2a..b2db0617d 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((uint)security_key, out string desc); + MDSubscribe.market_data(ven).lookup_security_desc_glbx((uint)security_key, out string desc); return desc ?? string.Empty; } diff --git a/src/client/spark_fix/FixRouter.cs b/src/client/spark_fix/FixRouter.cs index f3d4fd545..cb441780a 100644 --- a/src/client/spark_fix/FixRouter.cs +++ b/src/client/spark_fix/FixRouter.cs @@ -25,13 +25,18 @@ namespace bts.fix IEnumerable get_securities(); SecurityImmutable? lookup(security_key key); SecurityImmutable? lookup(string desc); + + void send(Message mess, SessionID sess); + void send_session_reject(SessionID sess, string text, Message refmessage = null); + void send_biz_reject(SessionID sess, string text, Message refmessage, int reason_code = 0); } - class FixRouter : QuickFix.MessageCracker, QuickFix.IApplication, IFixRouter + class FixRouter : QuickFix.MessageCracker, IFIXSession, IFixRouter { readonly ConcurrentDictionary _sessions = new ConcurrentDictionary(); readonly Func _factory; readonly MarketDataClient _md = new MarketDataClient(); + readonly object _lock = new object(); public FixRouter(Func factory) { @@ -49,11 +54,54 @@ namespace bts.fix return app; } + public void send(Message mess, SessionID sess) + { + lock (_lock) + { + try + { + Session.SendToTarget(mess, sess); + } + catch (SessionNotFound) + { + Log.assert(false, "session not found " + sess); + } + catch (Exception ex) + { + Log.FIX.error(sess.ToString() + " " + ex.Message + " " + sess); + } + } + } + + public void send_session_reject(SessionID sess, string text, Message refmessage = null) + { + QuickFix.FIX44.Reject rej = null; + if (refmessage != null && refmessage.Header.IsSetField(Tags.MsgSeqNum)) + rej = new QuickFix.FIX44.Reject(new QuickFix.Fields.RefSeqNum(refmessage.Header.GetInt(Tags.MsgSeqNum))); + else + rej = new QuickFix.FIX44.Reject(); + rej.Text = new Text(text); + send(rej, sess); + } + + public void send_biz_reject(SessionID sess, string text, Message refmessage, int reason_code = 0) + { + QuickFix.FIX44.BusinessMessageReject rej = new QuickFix.FIX44.BusinessMessageReject(); + + rej.RefMsgType = new QuickFix.Fields.RefMsgType(refmessage.Header.GetString(Tags.MsgType)); + rej.RefSeqNum = new QuickFix.Fields.RefSeqNum(refmessage.Header.GetInt(Tags.MsgSeqNum)); + rej.BusinessRejectReason = new QuickFix.Fields.BusinessRejectReason(reason_code); + rej.Text = new Text(text); + send(rej, sess); + } + void handle_session_exception(Exception ex, SessionID sessionID, Message message = null) { string msg = "==ERROR in session " + sessionID.ToString() + "== "; msg += message?.GetType().Name ?? string.Empty; msg += ex?.ToString() ?? string.Empty; + if(!string.IsNullOrEmpty(ex.StackTrace)) + msg += Environment.NewLine + ex.StackTrace; bts.Log.FIX.error(msg); Console.WriteLine(msg); @@ -67,16 +115,26 @@ namespace bts.fix catch { } } + void handle_field_not_found(FieldNotFoundException ex, SessionID sess, Message message) + { + if(ex.Field > 0) + send_biz_reject(sess, $"Field {ex.Field} was expected but not found", message, 5 ); + //QF does not include the tag number.... + //throw new FieldNotFoundException($"Field {ex.Field} was expected but not found", ex); + else + throw ex; + } + public void FromAdmin(Message message, SessionID sessionID) { try { session(sessionID).FromAdmin(message, sessionID); } - catch (Exception ex) - { - handle_session_exception(ex, sessionID, message); - } + catch (FieldNotFoundException ex) { handle_field_not_found(ex, sessionID, message); } + catch (UnsupportedMessageType) { throw; } + catch (IncorrectTagValue) { throw; } + catch (Exception ex) { handle_session_exception(ex, sessionID, message); } } public void FromApp(Message message, SessionID sessionID) @@ -85,10 +143,10 @@ namespace bts.fix { session(sessionID).FromApp(message, sessionID); } - catch (Exception ex) - { - handle_session_exception(ex, sessionID, message); - } + catch (FieldNotFoundException ex) { handle_field_not_found(ex, sessionID, message); } + catch (UnsupportedMessageType) { throw; } + catch (IncorrectTagValue) { throw; } + catch (Exception ex) { handle_session_exception(ex, sessionID, message); } } public void OnCreate(SessionID sessionID) @@ -134,10 +192,10 @@ namespace bts.fix { session(sessionID).ToAdmin(message, sessionID); } - catch (Exception ex) - { - handle_session_exception(ex, sessionID, message); - } + catch (FieldNotFoundException ex) { handle_field_not_found(ex, sessionID, message); } + catch (UnsupportedMessageType) { throw; } + catch (IncorrectTagValue) { throw; } + catch (Exception ex) { handle_session_exception(ex, sessionID, message); } } public void ToApp(Message message, SessionID sessionID) @@ -146,10 +204,10 @@ namespace bts.fix { session(sessionID).ToApp(message, sessionID); } - catch (Exception ex) - { - handle_session_exception(ex, sessionID, message); - } + catch (FieldNotFoundException ex) { handle_field_not_found(ex, sessionID, message); } + catch (UnsupportedMessageType) { throw; } + catch (IncorrectTagValue) { throw; } + catch (Exception ex) { handle_session_exception(ex, sessionID, message); } } IEnumerable IFixRouter.get_securities() diff --git a/src/client/spark_fix/session/DropCopySession.cs b/src/client/spark_fix/session/DropCopySession.cs index 2548d48cf..7229f2f3c 100644 --- a/src/client/spark_fix/session/DropCopySession.cs +++ b/src/client/spark_fix/session/DropCopySession.cs @@ -74,7 +74,7 @@ namespace bts.fix { var ostat = build_order_status(s, order); ostat.OrdStatusReqID = new OrdStatusReqID(req.OrdStatusReqID.getValue()); - send(ostat, s); + _router.send(ostat, s); } } @@ -93,7 +93,7 @@ namespace bts.fix var def = new QuickFix.FIX44.SecurityDefinition(req.SecurityReqID, new SecurityResponseID(Guid.NewGuid().ToString()), new SecurityResponseType(SecurityResponseType.LIST_OF_SECURITIES_RETURNED_PER_REQUEST)); - send(def, s); + _router.send(def, s); } else throw new IncorrectTagValue(req.SecurityRequestType.Tag); @@ -114,12 +114,12 @@ namespace bts.fix { var ostat = build_order_status(sessionID, order); _order_cache[order.Key] = order; - send(ostat, sessionID); + _router.send(ostat, sessionID); } foreach (var order in o.changed) { var ostat = build_order_status(sessionID, order, true); - send(ostat, sessionID); + _router.send(ostat, sessionID); } }); @@ -128,19 +128,19 @@ namespace bts.fix foreach (var fill in f.added) { var fi = build_fill(sessionID, fill); - send(fi, sessionID); + _router.send(fi, sessionID); } foreach (var fill in f.changed) { var fi = build_fill(sessionID, fill, true); - send(fi, sessionID); + _router.send(fi, sessionID); } }); } virtual protected void process_order_state(in OrderStateImmutable state, ref uint filled, ref uint leaves, ref double avgprx, - ref QuickFix.Fields.OrdStatus fstatus, ref NativeOrderStateImmutable? native) + ref QuickFix.Fields.OrdStatus fstatus, ref NativeOrderStateImmutable? native, FillImmutable? fill = null) { filled = state.FilledQuantity; leaves = state.Quantity - state.FilledQuantity; @@ -173,15 +173,15 @@ namespace bts.fix virtual protected QuickFix.FIX44.ExecutionReport build_fill(SessionID sess, in FillImmutable fill, bool change = false) { - var exec = new QuickFix.Fields.ExecType(QuickFix.Fields.ExecType.FILL); + var exec = new QuickFix.Fields.ExecType(QuickFix.Fields.ExecType.PARTIAL_FILL); QuickFix.Fields.OrdStatus status = new QuickFix.Fields.OrdStatus(); uint filled = 0; uint leaves = 0; double prx = 0.0; OrderRecordImmutable order; NativeOrderStateImmutable? native = null; if (_order_cache.TryGetValue(fill.OrderKey, out order)) { process_order_state(order.State, ref filled, ref leaves, ref prx, ref status, ref native); - if (leaves > 0) - exec = new QuickFix.Fields.ExecType(QuickFix.Fields.ExecType.PARTIAL_FILL); + if(Convert.ToDouble(order.State.Quantity) == fill.LastShares) + exec = new QuickFix.Fields.ExecType(QuickFix.Fields.ExecType.FILL); } if (change) exec = new QuickFix.Fields.ExecType(QuickFix.Fields.ExecType.TRADE_CORRECT); @@ -205,7 +205,7 @@ namespace bts.fix report.TransactTime = new TransactTime(ts, true); report.TradeDate = new TradeDate(ts.ToString("yyyyMMdd")); sec = resolve_execution_report_security(sec, report); - if (native.HasValue) + if (native.HasValue && !string.IsNullOrEmpty(native.Value.ExchangeOrderId)) report.SecondaryOrderID = new SecondaryOrderID(native.Value.ExchangeOrderId); if (sec.HasValue && sec.Value.security_type() == bts.api.SecurityType.Spread || @@ -252,9 +252,10 @@ namespace bts.fix sec = resolve_execution_report_security(sec, report); if (native.HasValue) - { - report.SecondaryOrderID = new SecondaryOrderID(native.Value.ExchangeOrderId); - report.OrdType = new OrdType((char)native.Value.NativeType); + { + report.OrdType = new OrdType((char)native.Value.NativeType); + if(!string.IsNullOrEmpty(native.Value.ExchangeOrderId)) + report.SecondaryOrderID = new SecondaryOrderID(native.Value.ExchangeOrderId); } //TODO Big race here, we need a correlation id of some sort if (_fix_clorderids.TryGetValue(order.Key, out string clorderid)) diff --git a/src/client/spark_fix/session/OrderSession.cs b/src/client/spark_fix/session/OrderSession.cs index 94d0b2d1d..786c470a5 100644 --- a/src/client/spark_fix/session/OrderSession.cs +++ b/src/client/spark_fix/session/OrderSession.cs @@ -11,6 +11,15 @@ using bts.api.orderman; namespace bts.fix { + /* Some test fix + order for 4 lot CLZ8 + 8=FIX.4.49=15635=D49=SPARK56=CLIENT134=150=3073797=Y52=20000809-20:20:5011=900010081=ACC A21=255=SIM:CLZ854=138=440=259=044=7460=20000809-18:20:32207=SIM10=045 + + order for 4 lot CLZ8-CLH9 + 8=FIX.4.49=15635=D49=SPARK56=CLIENT134=150=3073797=Y52=20000809-20:20:5011=900010081=ACC A21=255=SIM:CLZ8-CLH954=138=440=259=044=7460=20000809-18:20:32207=SIM10=045 + + */ + class OrderSession : DropCopySession { public OrderSession(IFixRouter router, SessionID sess) : base(router, sess) @@ -50,10 +59,29 @@ namespace bts.fix } } + virtual public void OnMessage(QuickFix.FIX44.OrderCancelReplaceRequest replace, SessionID s) + { + var id = replace.OrderID.getValue(); + if (!uint.TryParse(id, out uint key)) + throw new IncorrectTagValue(replace.OrderID.Tag); + double price = Convert.ToDouble(replace.Price.getValue()); + uint sz = Convert.ToUInt32(Math.Abs(replace.OrderQty.getValue())); + var resp = _orderservice.Value.update_order(new Update + { + OrderKey = key, + Price = price, + Quantity = sz, + }); + if (resp.ErrorCode != OrderError.Ok) + { + send_cancel_reject(s, "Cancel Rejected: " + resp.ErrorCode.ToString() + " - " + resp.Msg, replace); + } + } + virtual public void OnMessage(QuickFix.FIX44.NewOrderSingle create, SessionID s) { Venue ven = convert_exchange(create.SecurityExchange); - if (ven != Venue.Glbx) + if (ven == bts.api.Venue.Unset) throw new IncorrectTagValue(create.SecurityExchange.Tag); var sec = _router.lookup(create.Symbol.getValue()); @@ -108,7 +136,7 @@ namespace bts.fix var resp = _orderservice.Value.create_order(cr); if (resp.ErrorCode != OrderError.Ok) { - send_biz_reject(s, "Order Rejected: " + resp.ErrorCode.ToString() + " - " + resp.Msg, create); + _router.send_biz_reject(s, "Order Rejected: " + resp.ErrorCode.ToString() + " - " + resp.Msg, create); } } diff --git a/src/client/spark_fix/session/SessionBase.cs b/src/client/spark_fix/session/SessionBase.cs index 5bbc37728..406525cc3 100644 --- a/src/client/spark_fix/session/SessionBase.cs +++ b/src/client/spark_fix/session/SessionBase.cs @@ -117,7 +117,7 @@ namespace bts.fix var resp = await _latencyservice.Value.report_async(new bts.metrics.Report { HostName = "BTSFIX_" + sessionID.ToString(), Timestamp = _clock, User = _user_name }); if (resp.success) - send(hb, sessionID); + _router.send(hb, sessionID); } virtual public void ToAdmin(Message message, SessionID sessionID) @@ -152,46 +152,6 @@ namespace bts.fix Log.FIX.error(_sess.ToString() + " " + message, file, line); } - protected void send(Message mess, SessionID sess) - { - try - { - Session.SendToTarget(mess, sess); - } - catch (SessionNotFound ex) - { - log_error("==session not found exception!=="); - log_error(ex.ToString()); - Log.assert(false, "session not found " + sess); - } - catch (Exception ex) - { - log_error("==exception sending to " + sess + " " + ex.ToString()); - } - } - - protected void send_session_reject(SessionID sess, string text, Message refmessage = null) - { - QuickFix.FIX44.Reject rej = null; - if (refmessage != null && refmessage.Header.IsSetField(Tags.MsgSeqNum)) - rej = new QuickFix.FIX44.Reject( new QuickFix.Fields.RefSeqNum( refmessage.Header.GetInt(Tags.MsgSeqNum) )); - else - rej = new QuickFix.FIX44.Reject(); - rej.Text = new Text(text); - send(rej, sess); - } - - protected void send_biz_reject(SessionID sess, string text, Message refmessage) - { - QuickFix.FIX44.BusinessMessageReject rej = new QuickFix.FIX44.BusinessMessageReject(); - - rej.RefMsgType = new QuickFix.Fields.RefMsgType(refmessage.Header.GetString(Tags.MsgType)); - rej.RefSeqNum = new QuickFix.Fields.RefSeqNum(refmessage.Header.GetInt(Tags.MsgSeqNum)); - rej.BusinessRejectReason = new QuickFix.Fields.BusinessRejectReason(0); - rej.Text = new Text(text); - send(rej, sess); - } - protected void send_cancel_reject(SessionID sess, string text, Message refmessage) { QuickFix.FIX44.OrderCancelReject rej = new QuickFix.FIX44.OrderCancelReject(); @@ -205,7 +165,7 @@ namespace bts.fix rej.SetField(cancel.OrderID); rej.CxlRejResponseTo = new CxlRejResponseTo('1'); rej.Text = new Text(text); - send(rej, sess); + _router.send(rej, sess); } else if (refmessage is QuickFix.FIX44.OrderCancelReplaceRequest replace) { @@ -217,7 +177,7 @@ namespace bts.fix rej.SetField(replace.OrderID); rej.CxlRejResponseTo = new CxlRejResponseTo('2'); rej.Text = new Text(text); - send(rej, sess); + _router.send(rej, sess); } else throw new UnsupportedMessageType(); @@ -303,6 +263,7 @@ namespace bts.fix return bts.api.Venue.Cboe; case "XCBF": return bts.api.Venue.Cboecfe; + case "GLBX": case "XCME": case "XCBT": case "XCEC": @@ -324,22 +285,22 @@ namespace bts.fix ref bts.api.orderman.NativeOrderStateImmutable? native) { native = null; - if (state.HasMarket) + if (state.HasMarket && state.Market.HasNativeState && state.Market.NativeState.NativeStatus != NativeOrderStatus.Unacknowledged) { native = state.Market.NativeState; return new OrdStatus((char)native?.NativeStatus); } - else if (state.HasLimit) + else if (state.HasLimit && state.Limit.HasNativeState && state.Limit.NativeState.NativeStatus != NativeOrderStatus.Unacknowledged) { native = state.Limit.NativeState; return new OrdStatus((char)native?.NativeStatus); } - else if (state.HasStop) + else if (state.HasStop && state.Stop.HasNativeState && state.Stop.NativeState.NativeStatus != NativeOrderStatus.Unacknowledged) { native = state.Stop.NativeState; return new OrdStatus((char)native?.NativeStatus); } - else if (state.HasStopLimit) + else if (state.HasStopLimit && state.StopLimit.HasNativeState && state.StopLimit.NativeState.NativeStatus != NativeOrderStatus.Unacknowledged) { native = state.StopLimit.NativeState; return new OrdStatus((char)native?.NativeStatus); From 005c0f9a5d752919564c4b182cfe1b43e3af4e19 Mon Sep 17 00:00:00 2001 From: Kevin Darby Date: Mon, 23 Sep 2019 16:59:39 -0400 Subject: [PATCH 13/28] c++ fix --- src/server/sparkd/fix/DropCopySession.cpp | 0 src/server/sparkd/fix/DropCopySession.h | 0 src/server/sparkd/fix/FixRouter.cpp | 0 src/server/sparkd/fix/FixRouter.h | 0 src/server/sparkd/fix/IFixSession.h | 0 src/server/sparkd/fix/OrderSession.cpp | 0 src/server/sparkd/fix/OrderSession.h | 0 src/server/sparkd/fix/SessionBase.cpp | 0 src/server/sparkd/fix/SessionBase.h | 0 9 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/server/sparkd/fix/DropCopySession.cpp create mode 100644 src/server/sparkd/fix/DropCopySession.h create mode 100644 src/server/sparkd/fix/FixRouter.cpp create mode 100644 src/server/sparkd/fix/FixRouter.h create mode 100644 src/server/sparkd/fix/IFixSession.h create mode 100644 src/server/sparkd/fix/OrderSession.cpp create mode 100644 src/server/sparkd/fix/OrderSession.h create mode 100644 src/server/sparkd/fix/SessionBase.cpp create mode 100644 src/server/sparkd/fix/SessionBase.h diff --git a/src/server/sparkd/fix/DropCopySession.cpp b/src/server/sparkd/fix/DropCopySession.cpp new file mode 100644 index 000000000..e69de29bb diff --git a/src/server/sparkd/fix/DropCopySession.h b/src/server/sparkd/fix/DropCopySession.h new file mode 100644 index 000000000..e69de29bb diff --git a/src/server/sparkd/fix/FixRouter.cpp b/src/server/sparkd/fix/FixRouter.cpp new file mode 100644 index 000000000..e69de29bb diff --git a/src/server/sparkd/fix/FixRouter.h b/src/server/sparkd/fix/FixRouter.h new file mode 100644 index 000000000..e69de29bb diff --git a/src/server/sparkd/fix/IFixSession.h b/src/server/sparkd/fix/IFixSession.h new file mode 100644 index 000000000..e69de29bb diff --git a/src/server/sparkd/fix/OrderSession.cpp b/src/server/sparkd/fix/OrderSession.cpp new file mode 100644 index 000000000..e69de29bb diff --git a/src/server/sparkd/fix/OrderSession.h b/src/server/sparkd/fix/OrderSession.h new file mode 100644 index 000000000..e69de29bb diff --git a/src/server/sparkd/fix/SessionBase.cpp b/src/server/sparkd/fix/SessionBase.cpp new file mode 100644 index 000000000..e69de29bb diff --git a/src/server/sparkd/fix/SessionBase.h b/src/server/sparkd/fix/SessionBase.h new file mode 100644 index 000000000..e69de29bb From ddfb6d11058879688b8505b29a488f4f1ce84e4e Mon Sep 17 00:00:00 2001 From: Kevin Darby Date: Mon, 23 Sep 2019 17:03:49 -0400 Subject: [PATCH 14/28] update externals --- externals | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/externals b/externals index 69f863923..6d8f64ca5 160000 --- a/externals +++ b/externals @@ -1 +1 @@ -Subproject commit 69f863923502b11c8d7fde491e4b5aec5b705e97 +Subproject commit 6d8f64ca5cee3acbf9addb51428f25d54b9f906a From aa8a56787bdc1388edccaccc44bda5155ac13ff9 Mon Sep 17 00:00:00 2001 From: Kevin Darby Date: Mon, 23 Sep 2019 18:16:05 -0400 Subject: [PATCH 15/28] fix fix fix --- .../rtd/subscriptions/MDSubscribe.cs | 2 +- src/client/spark_fix/spark_fix.csproj | 2 +- src/client/sparkcmd/Cmd/FIXCommand.cs | 65 +++++++++++-------- src/client/sparkcmd/Program.cs | 5 +- src/client/sparkcmd/sparkcmd.csproj | 1 + src/server/sparkd/fix/FixInit.cpp | 42 ++++++++++++ src/server/sparkd/fix/FixInit.h | 14 ++++ src/server/sparkd/fix/FixRouter.cpp | 42 ++++++++++++ src/server/sparkd/fix/FixRouter.h | 19 ++++++ src/server/sparkd/fix/IFixRouter.h | 38 +++++++++++ src/server/sparkd/fix/IFixSession.h | 10 +++ 11 files changed, 209 insertions(+), 31 deletions(-) create mode 100644 src/server/sparkd/fix/FixInit.cpp create mode 100644 src/server/sparkd/fix/FixInit.h create mode 100644 src/server/sparkd/fix/IFixRouter.h 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 From f66004b46560b2e2feca4fbf8a650b0e8217c7d2 Mon Sep 17 00:00:00 2001 From: Kevin Darby Date: Tue, 24 Sep 2019 14:37:30 -0400 Subject: [PATCH 16/28] fix port --- src/lib/md/HandleIndex.h | 89 +++++++++++++++++++++++++++++ src/lib/md/MBOServiceServer.cpp | 59 ++----------------- src/server/sparkd/fix/FixInit.cpp | 3 + src/server/sparkd/fix/FixRouter.cpp | 3 + src/server/sparkd/fix/FixRouter.h | 46 ++++++++++++++- src/server/sparkd/fix/IFixSession.h | 8 ++- 6 files changed, 150 insertions(+), 58 deletions(-) create mode 100644 src/lib/md/HandleIndex.h diff --git a/src/lib/md/HandleIndex.h b/src/lib/md/HandleIndex.h new file mode 100644 index 000000000..ec3ea60fd --- /dev/null +++ b/src/lib/md/HandleIndex.h @@ -0,0 +1,89 @@ +#pragma once +#ifndef _WIN32 + +#include "lib/domain_model/Security.h" +#include "lib/md/MDConsumerHandle.h" +#include "lib/md/MDClient.h" +#include "lib/md/ExchangeOrderKey.h" + +#include "lib/utils/LockBox.h" + +#include +#include +#include +#include +#include + + +namespace bts { +namespace md { + +SecurityKey default_key(const MDConsumerHandle& h) { return SecurityKey( h.key() ); } + +template +class HandleIndex +{ + MDClient& _client; + int _sub; + std::optional _consumer; + +public: + typedef decltype( Key_Func(std::declval()) ) KeyType; + utils::LockBox> index; + + + HandleIndex(md::MDClient& client) : + _client(client), + _sub(0), + _consumer(std::nullopt), + index() + { + _sub = _client.on_consumer().subscribe([=](const MDConsumer& c) { on_consumer(c); }); + on_consumer( _client.current_consumer() ); + } + virtual ~HandleIndex() + { + _client.on_consumer().unsubscribe(_sub); + } + +private: + void on_consumer(const MDConsumer& c) + { + MDConsumer temp(c); + if (temp.all_heartbeats_ok()) + { + auto existing = _consumer ? _consumer->id() : 0; + LOG(md,Info, "Updating HandleIndex MDConsumer. Old {} new {}", existing, temp.id()); + // clear the index + index.lock([](auto& index) { index.clear(); }); + // Swap to new consumer + if (_consumer) + { + _consumer->swap(temp); + } + else + { + _consumer = temp; + } + // Subscribe to on_security + auto id = _consumer->id(); + _consumer->on_security([this,id](const SecurityPtr&, MDConsumerHandle handle) + { + if (_consumer->id() == id) + { + index.lock([this, handle](auto& index) + { + index[ Key_Func(handle) ] = handle; + }); + } + }); + } + } +}; + +typedef HandleIndex KeyHandleIndex; + +}} + + +#endif \ No newline at end of file diff --git a/src/lib/md/MBOServiceServer.cpp b/src/lib/md/MBOServiceServer.cpp index 16b8175fa..ac6d4cc2b 100644 --- a/src/lib/md/MBOServiceServer.cpp +++ b/src/lib/md/MBOServiceServer.cpp @@ -8,6 +8,8 @@ #include "MDClient.h" #include "ExchangeOrderKey.h" #include "MBOProcessor.h" +#include "MDClient.h" +#include "HandleIndex.h" #include "lib/utils/LockBox.h" @@ -21,55 +23,6 @@ using namespace bts::api::orderman; namespace bts { namespace md { -// -// Simple class to handle MD recovery and maintain an index of SecurityKey=>MDConsumerHandle - -class HandleIndex { - MDClient& _client; - int _sub; - std::optional _consumer; - -public: - utils::LockBox> index; - - HandleIndex(md::MDClient& client): - _client(client), - _sub(0), - _consumer(std::nullopt), - index() { - _sub = _client.on_consumer().subscribe([=](const MDConsumer& c) { on_consumer(c); }); - on_consumer(_client.current_consumer()); - } - - ~HandleIndex() { _client.on_consumer().unsubscribe(_sub); } - - -private: - void on_consumer(const MDConsumer& c) { - MDConsumer temp(c); - if (temp.all_heartbeats_ok()) { - auto existing = _consumer ? _consumer->id() : 0; - LOG(md,Info, "Updateing MBOService MDConsumer. Old {} new {}", existing, temp.id()); - // clear the index - index.lock([](auto& index) { index.clear(); }); - // Swap to new consumer - if (_consumer) { - _consumer->swap(temp); - } - else { _consumer = temp; } - // Subscribe to on_security - auto id = _consumer->id(); - _consumer->on_security([this,id](const SecurityPtr&, MDConsumerHandle handle) { - if (_consumer->id() == id) { - index.lock([handle](auto& index) { - index[SecurityKey(handle.key())] = handle; - }); - } - }); - } - } -}; - class ActiveOrder { SecurityKey _security; SparkOrderKey _id; @@ -111,7 +64,7 @@ struct MBOServiceImpl { MBOServiceImpl( api::ServiceContext& ctx, utils::Dispatcher& d, - md::MDClient& c, + MDClient& c, MBOServiceBase::PiqPublisher&& pub ): dispatcher(d), @@ -124,10 +77,10 @@ struct MBOServiceImpl { {} utils::Dispatcher& dispatcher; - md::MDClient& client; + MDClient& client; OrderService orders; - HandleIndex handle_index; + KeyHandleIndex handle_index; MBOServiceBase::PiqPublisher publish; utils::DispatcherTimer timer; @@ -162,7 +115,7 @@ std::optional search_orders(const ExchangeOrderKey oid, const std::vec return std::nullopt; } -bool update_position(const HandleIndex& handles, ActiveOrder& order) { +bool update_position(const KeyHandleIndex& handles, ActiveOrder& order) { const auto& index = handles.index; auto handle = index.lock([id=order.security_id()](const auto& index) { auto iter = index.find(id); diff --git a/src/server/sparkd/fix/FixInit.cpp b/src/server/sparkd/fix/FixInit.cpp index 608208bfc..1016afeb4 100644 --- a/src/server/sparkd/fix/FixInit.cpp +++ b/src/server/sparkd/fix/FixInit.cpp @@ -21,6 +21,9 @@ namespace bts namespace fix { +GCC_DIAG_OFF("-Wdeprecated") +GCC_DIAG_OFF("-Wignored-qualifiers") + int FixInit::start_acceptor(const std::string& settings_file, bool orders_allowed) { std::ifstream str{settings_file}; diff --git a/src/server/sparkd/fix/FixRouter.cpp b/src/server/sparkd/fix/FixRouter.cpp index cca79f1c0..29241ec69 100644 --- a/src/server/sparkd/fix/FixRouter.cpp +++ b/src/server/sparkd/fix/FixRouter.cpp @@ -21,6 +21,9 @@ namespace bts namespace fix { +GCC_DIAG_OFF("-Wdeprecated") +GCC_DIAG_OFF("-Wignored-qualifiers") + int FixRouter::start_acceptor(const std::string& settings_file, bool orders_allowed) { std::ifstream str{settings_file}; diff --git a/src/server/sparkd/fix/FixRouter.h b/src/server/sparkd/fix/FixRouter.h index b244c7c33..8f44205d8 100644 --- a/src/server/sparkd/fix/FixRouter.h +++ b/src/server/sparkd/fix/FixRouter.h @@ -1,19 +1,61 @@ #pragma once #include "IFixSession.h" +#include "IFixRouter.h" +#include "lib/md/HandleIndex.h" #include +#include +#include +#include #include +#include +#include + +#include "lib/utils/warn_ctrl.h" + +GCC_DIAG_OFF("-Woverloaded-virtual") +GCC_DIAG_OFF("-Wdeprecated") +GCC_DIAG_OFF("-Wignored-qualifiers") + namespace bts { +namespace md { class MDClient; } namespace fix { -class FixRouter : public IFixSession, public FIX::MessageCracker +class FixRouter : public IFixSession, public FIX::MessageCracker, public IFixRouter { public: + FixRouter(const md::MDClient&); + ~FixRouter(); + + void send(const FIX::Message&, const FIX::SessionID&); + 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); + +public: + void fromAdmin(const FIX::Message& message, const FIX::SessionID& sessionID) + throw(FIX::FieldNotFound, FIX::IncorrectDataFormat, FIX::IncorrectTagValue, FIX::RejectLogon); + void fromApp(const FIX::Message &message,const FIX::SessionID &sessionID) + throw(FIX::FieldNotFound, FIX::IncorrectDataFormat, FIX::IncorrectTagValue, FIX::UnsupportedMessageType); + + +void onCreate(const FIX::SessionID&); +void onLogon(const FIX::SessionID&); +void onLogout(const FIX::SessionID&); +void toAdmin(FIX::Message&, const FIX::SessionID&); +void toApp(FIX::Message&, const FIX::SessionID&) throw(FIX::DoNotSend); + +private: + IFixSession& session(const FIX::SessionID&); + void handle_session_exception(const std::exception& ex, const FIX::SessionID& sessionID, const FIX::Message* message = nullptr); + void handle_field_not_found(const FIX::FieldNotFound& ex, const FIX::SessionID& sess, const FIX::Message& message); - +private: + boost::container::flat_map< FIX::SessionID, std::shared_ptr > _sessions; + const md::MDClient& _md; + std::mutex _lock; }; }} \ No newline at end of file diff --git a/src/server/sparkd/fix/IFixSession.h b/src/server/sparkd/fix/IFixSession.h index 462af6b20..f8f973a3c 100644 --- a/src/server/sparkd/fix/IFixSession.h +++ b/src/server/sparkd/fix/IFixSession.h @@ -4,7 +4,9 @@ namespace bts { namespace fix { - class IFIXSession : public FIX::Application - { - }; + +class IFIXSession : public FIX::Application +{ +}; + }} \ No newline at end of file From d436dae7cd6d1321b1f06ad4b9d1b3d9eafda1e9 Mon Sep 17 00:00:00 2001 From: Kevin Darby Date: Tue, 24 Sep 2019 18:22:09 -0400 Subject: [PATCH 17/28] more fix --- src/lib/md/HandleIndex.h | 12 ++- src/server/sparkd/fix/FixInit.cpp | 17 ++- src/server/sparkd/fix/FixInit.h | 4 +- src/server/sparkd/fix/FixRouter.cpp | 77 +++++++++++--- src/server/sparkd/fix/FixRouter.h | 33 +++--- src/server/sparkd/fix/IFixRouter.h | 15 +-- src/server/sparkd/fix/IFixSession.h | 2 +- src/server/sparkd/fix/SessionBase.cpp | 146 ++++++++++++++++++++++++++ src/server/sparkd/fix/SessionBase.h | 88 ++++++++++++++++ 9 files changed, 353 insertions(+), 41 deletions(-) diff --git a/src/lib/md/HandleIndex.h b/src/lib/md/HandleIndex.h index ec3ea60fd..495998ab8 100644 --- a/src/lib/md/HandleIndex.h +++ b/src/lib/md/HandleIndex.h @@ -18,7 +18,16 @@ namespace bts { namespace md { -SecurityKey default_key(const MDConsumerHandle& h) { return SecurityKey( h.key() ); } +SecurityKey default_key(const MDConsumerHandle& h) +{ + return SecurityKey( h.key() ); +} + +std::string desc_key(const MDConsumerHandle& h) +{ + auto sec = h.get_normalized_security(); + return securities::descriptor(sec); +} template class HandleIndex @@ -82,6 +91,7 @@ private: }; typedef HandleIndex KeyHandleIndex; +typedef HandleIndex DescHandleIndex; }} diff --git a/src/server/sparkd/fix/FixInit.cpp b/src/server/sparkd/fix/FixInit.cpp index 1016afeb4..40bd37b9d 100644 --- a/src/server/sparkd/fix/FixInit.cpp +++ b/src/server/sparkd/fix/FixInit.cpp @@ -1,6 +1,9 @@ #include "FixInit.h" #include "IFixSession.h" +#include "FixRouter.h" +#include "OrderSession.h" +#include "DropCopySession.h" #include #include @@ -20,19 +23,23 @@ namespace bts { namespace fix { + GCC_DIAG_OFF("-Wdeprecated") GCC_DIAG_OFF("-Wignored-qualifiers") -int FixInit::start_acceptor(const std::string& settings_file, bool orders_allowed) +int FixInit::start_acceptor(bts::api::ServiceContext& sc, const md::MDClient& md, 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); + FixRouter application(md, [=](IFixRouter& router, const auto& id) + { + if(orders_allowed) + return std::shared_ptr(new OrderSession(sc, router, id)); + else + return std::shared_ptr(new DropCopySession(sc, router, id)); + }); FIX::FileStoreFactory storeFactory( settings ); FIX::FileLogFactory logFactory( settings ); FIX::SocketAcceptor acceptor( application, storeFactory, settings, logFactory ); diff --git a/src/server/sparkd/fix/FixInit.h b/src/server/sparkd/fix/FixInit.h index 1d30df552..0273a7a6c 100644 --- a/src/server/sparkd/fix/FixInit.h +++ b/src/server/sparkd/fix/FixInit.h @@ -3,12 +3,14 @@ #include namespace bts { +namespace api { class ServiceContext; } +namespace md { class MDClient; } namespace fix { class FixInit { public: - static int start_acceptor(const std::string& settings_file, bool orders_allowed); + static int start_acceptor(bts::api::ServiceContext& sc, const md::MDClient& md, 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 29241ec69..26488aaee 100644 --- a/src/server/sparkd/fix/FixRouter.cpp +++ b/src/server/sparkd/fix/FixRouter.cpp @@ -24,22 +24,73 @@ namespace fix GCC_DIAG_OFF("-Wdeprecated") GCC_DIAG_OFF("-Wignored-qualifiers") -int FixRouter::start_acceptor(const std::string& settings_file, bool orders_allowed) +FixRouter::FixRouter(const md::MDClient& md, + std::function< std::shared_ptr (IFixRouter&, const FIX::SessionID&) > factory) : + _sessions(), + _index(md), + _sc(sc), + _lock() { - 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 ); +FixRouter::~FixRouter() +{ +} + +void FixRouter::send(const FIX::Message&, const FIX::SessionID&) +{ +} + +void FixRouter::send_session_reject(const FIX::SessionID& sess, const std::string& text, const FIX::Message* refmessage) +{ +} + +void FixRouter::send_biz_reject(const FIX::SessionID sess, const std::string& text, const FIX::Message& refmessage, int reason_code) +{ +} + +void FixRouter::fromAdmin(const FIX::Message& message, const FIX::SessionID& sessionID) + throw(FIX::FieldNotFound, FIX::IncorrectDataFormat, FIX::IncorrectTagValue, FIX::RejectLogon) +{ +} + +void FixRouter::fromApp(const FIX::Message &message,const FIX::SessionID &sessionID) + throw(FIX::FieldNotFound, FIX::IncorrectDataFormat, FIX::IncorrectTagValue, FIX::UnsupportedMessageType) +{ +} + +void FixRouter::onCreate(const FIX::SessionID&) +{ +} + +void FixRouter::onLogon(const FIX::SessionID&) +{ +} + +void onLogout(const FIX::SessionID&) +{ +} + +void FixRouter::toAdmin(FIX::Message&, const FIX::SessionID&) +{ +} + +void FixRouter::toApp(FIX::Message&, const FIX::SessionID&) throw(FIX::DoNotSend) +{ +} - acceptor.start(); - -} +IFixSession& FixRouter::session(const FIX::SessionID&) +{ +} +void FixRouter::handle_session_exception(const std::exception& ex, const FIX::SessionID& sessionID, const FIX::Message* message) +{ +} + +void FixRouter::handle_field_not_found(const FIX::FieldNotFound& ex, const FIX::SessionID& sess, const FIX::Message& message) +{ +} + + } } \ No newline at end of file diff --git a/src/server/sparkd/fix/FixRouter.h b/src/server/sparkd/fix/FixRouter.h index 8f44205d8..93947f7c5 100644 --- a/src/server/sparkd/fix/FixRouter.h +++ b/src/server/sparkd/fix/FixRouter.h @@ -3,6 +3,7 @@ #include "IFixSession.h" #include "IFixRouter.h" #include "lib/md/HandleIndex.h" +#include "lib/md/MDConsumerHandle.h" #include #include @@ -11,6 +12,7 @@ #include #include #include +#include #include "lib/utils/warn_ctrl.h" @@ -20,41 +22,46 @@ GCC_DIAG_OFF("-Wignored-qualifiers") namespace bts { +namespace api { class ServiceContext; } namespace md { class MDClient; } namespace fix { class FixRouter : public IFixSession, public FIX::MessageCracker, public IFixRouter { public: - FixRouter(const md::MDClient&); + FixRouter(const md::MDClient&, + std::function< std::shared_ptr (IFixRouter&, const FIX::SessionID&) > factory); ~FixRouter(); - void send(const FIX::Message&, const FIX::SessionID&); - 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); + void send(const FIX::Message&, const FIX::SessionID&) override; + void send_session_reject(const FIX::SessionID& sess, const std::string& text, const FIX::Message* refmessage = nullptr) override; + void send_biz_reject(const FIX::SessionID sess, const std::string& text, const FIX::Message& refmessage, int reason_code = 0) override; public: void fromAdmin(const FIX::Message& message, const FIX::SessionID& sessionID) throw(FIX::FieldNotFound, FIX::IncorrectDataFormat, FIX::IncorrectTagValue, FIX::RejectLogon); void fromApp(const FIX::Message &message,const FIX::SessionID &sessionID) throw(FIX::FieldNotFound, FIX::IncorrectDataFormat, FIX::IncorrectTagValue, FIX::UnsupportedMessageType); - - -void onCreate(const FIX::SessionID&); -void onLogon(const FIX::SessionID&); -void onLogout(const FIX::SessionID&); -void toAdmin(FIX::Message&, const FIX::SessionID&); -void toApp(FIX::Message&, const FIX::SessionID&) throw(FIX::DoNotSend); + void toAdmin(FIX::Message&, const FIX::SessionID&); + void toApp(FIX::Message&, const FIX::SessionID&) throw(FIX::DoNotSend); + + void onCreate(const FIX::SessionID&); + void onLogon(const FIX::SessionID&); + void onLogout(const FIX::SessionID&); private: IFixSession& session(const FIX::SessionID&); void handle_session_exception(const std::exception& ex, const FIX::SessionID& sessionID, const FIX::Message* message = nullptr); void handle_field_not_found(const FIX::FieldNotFound& ex, const FIX::SessionID& sess, const FIX::Message& message); - + +private: + std::vector get_securities() override; + const api::Security* lookup(security_key key) override; + const api::Security* lookup(const std::string& desc) override; private: boost::container::flat_map< FIX::SessionID, std::shared_ptr > _sessions; - const md::MDClient& _md; + md::DescHandleIndex _index; std::mutex _lock; }; diff --git a/src/server/sparkd/fix/IFixRouter.h b/src/server/sparkd/fix/IFixRouter.h index ce9c279b2..6fb043fd5 100644 --- a/src/server/sparkd/fix/IFixRouter.h +++ b/src/server/sparkd/fix/IFixRouter.h @@ -26,13 +26,14 @@ namespace fix class IFixRouter { - std::vector get_securities(); - const api::Security* lookup(security_key key); - const api::Security* lookup(const std::string& desc); + public: + virtual std::vector get_securities() = 0; + virtual const api::Security* lookup(security_key key) = 0; + virtual const api::Security* lookup(const std::string& desc) = 0; - 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); - } + virtual void send(const FIX::Message& mess, const FIX::SessionID& sess) = 0; + virtual void send_session_reject(const FIX::SessionID& sess, const std::string& text, const FIX::Message* refmessage = nullptr) = 0; + virtual void send_biz_reject(const FIX::SessionID sess, const std::string& text, const FIX::Message& refmessage, int reason_code = 0) = 0; + }; } } diff --git a/src/server/sparkd/fix/IFixSession.h b/src/server/sparkd/fix/IFixSession.h index f8f973a3c..f086e4126 100644 --- a/src/server/sparkd/fix/IFixSession.h +++ b/src/server/sparkd/fix/IFixSession.h @@ -5,7 +5,7 @@ namespace bts { namespace fix { -class IFIXSession : public FIX::Application +class IFixSession : public FIX::Application { }; diff --git a/src/server/sparkd/fix/SessionBase.cpp b/src/server/sparkd/fix/SessionBase.cpp index e69de29bb..572d1af62 100644 --- a/src/server/sparkd/fix/SessionBase.cpp +++ b/src/server/sparkd/fix/SessionBase.cpp @@ -0,0 +1,146 @@ +#include "SessionBase.h" + +#include "IFixRouter.h" + +#include "lib/api/public/ServiceContext.h" +#include "lib/utils/AuthToken.h" +#include "lib/logging/logging.h" +#include "lib/utils/bts_assert.h" + + +#include +#include +#include +#include +#include +#include +#include + + +namespace bts { +namespace fix { + +SessionBase::SessionBase(bts::api::ServiceContext& sc, IFixRouter& router, const FIX::SessionID& sess) : + _auth_service( sc.locate() ), + _admin_service( sc.locate() ), + _user_name(), + _token(), + _router(router), + _sess(sess), + _admin_data(), + _lock() +{ + _admin_service.get_admin_data(api::VoidMessage(), [this] (auto& result) + { + std::lock_guard guard(_lock); + if(result.success()) + _admin_data = *result.value(); + }); +} + +SessionBase::~SessionBase() +{ +} + +void SessionBase::fromAdmin(const FIX::Message& message, const FIX::SessionID& sessionID) + throw(FIX::FieldNotFound, FIX::IncorrectDataFormat, FIX::IncorrectTagValue, FIX::RejectLogon) +{ + bts_assert_msg(sessionID == _sess, "invalid session"); +} + +void SessionBase::fromApp(const FIX::Message&,const FIX::SessionID&) + throw(FIX::FieldNotFound, FIX::IncorrectDataFormat, FIX::IncorrectTagValue, FIX::UnsupportedMessageType) +{ +} + +void SessionBase::toAdmin(FIX::Message&, const FIX::SessionID&) +{ +} + +void SessionBase::toApp(FIX::Message& m, const FIX::SessionID&) throw(FIX::DoNotSend) +{ + LOG(Fix, Info, "OUT: {}", m.toString()); +} + +void SessionBase::onMessage(const FIX44::BusinessMessageReject& n, const FIX::SessionID& s) +{ + LOG(Fix, Warn, "{} Business Reject: {} {}", s.toString(), n.getField(FIX::FIELD::BusinessRejectReason), n.getField(FIX::FIELD::Text) ); +} + +void SessionBase::send_cancel_reject(const FIX::SessionID& sess, const std::string& text, const FIX::Message& refmessage) +{ + FIX44::OrderCancelReject rej; + if(refmessage.isSetField(FIX::FIELD::ClOrdID)) + rej.setField(FIX::FIELD::ClOrdID, refmessage.getField(FIX::FIELD::ClOrdID)); + if(refmessage.isSetField(FIX::FIELD::OrigClOrdID)) + rej.setField(FIX::FIELD::OrigClOrdID, refmessage.getField(FIX::FIELD::OrigClOrdID)); + if(refmessage.isSetField(FIX::FIELD::OrderID)) + rej.setField(FIX::FIELD::OrderID, refmessage.getField(FIX::FIELD::OrderID)); + rej.setField(FIX::FIELD::Text, text); + + if(refmessage.getField(FIX::FIELD::MsgType) == FIX44::OrderCancelRequest::MsgType()) + { + rej.setField(FIX::FIELD::CxlRejResponseTo, "1"); + } + else if(refmessage.getField(FIX::FIELD::MsgType) == FIX44::OrderCancelReplaceRequest::MsgType()) + { + rej.setField(FIX::FIELD::CxlRejResponseTo, "2"); + } + _router.send(rej, sess); +} + +bool SessionBase::security_types_equal(bts::api::SecurityType btstype, FIX::SecurityType fixtype) +{ + return btstype == convert_security_type(fixtype); +} + +FIX::SecurityType SessionBase::convert_security_type(bts::api::SecurityType btstype) +{ + switch (btstype) + { + case bts::api::SecurityType::SECURITYTYPE_FUTURE: + return new QuickFix.Fields.SecurityType("FUT"); + case bts.api.SecurityType.Option: + return new QuickFix.Fields.SecurityType("OPT"); + case bts.api.SecurityType.Spread: + return new QuickFix.Fields.SecurityType("MLEG"); + case bts.api.SecurityType.Stock: + return new QuickFix.Fields.SecurityType("CS"); + case bts.api.SecurityType.Synthetic: + return new QuickFix.Fields.SecurityType("SYNTH"); + default: + return new QuickFix.Fields.SecurityType(); + } +} + +bts::api::SecurityType SessionBase::convert_security_type(FIX::SecurityType fixtype) +{ +} + +bool SessionBase::exchanges_equal(bts::api::Venue btstype, FIX::SecurityExchange fixtype) +{ +} + +FIX::SecurityExchange SessionBase::convert_exchange(bts::api::Venue btstype) +{ +} + +bts::api::Venue SessionBase::convert_exchange(FIX::SecurityExchange fixtype) +{ +} + +FIX::OrdStatus SessionBase::translate_status(const bts::api::orderman::OrderStateImmutable& state, + bts::api::orderman::NativeOrderStateImmutable* native) +{ +} + +uint SessionBase::lookup_account(const std::string& acct) +{ +} + +uint SessionBase::lookup_user(const std::string& user) +{ +} + + +}} \ No newline at end of file diff --git a/src/server/sparkd/fix/SessionBase.h b/src/server/sparkd/fix/SessionBase.h index e69de29bb..63e402e6e 100644 --- a/src/server/sparkd/fix/SessionBase.h +++ b/src/server/sparkd/fix/SessionBase.h @@ -0,0 +1,88 @@ +#pragma once + +#include "IFixSession.h" + +#include "lib/api/public/ServiceContext.h" +#include "lib/api/services/AuthService.pb.h" +#include "lib/api/services/AuthService.client.pb.h" +#include "lib/api/services/AdminService.pb.h" +#include "lib/api/services/AdminService.client.pb.h" + +#include "lib/domain_model/Security.pb.h" + +#include +#include +#include +#include +#include + +#include "lib/utils/warn_ctrl.h" + +GCC_DIAG_OFF("-Woverloaded-virtual") +GCC_DIAG_OFF("-Wdeprecated") +GCC_DIAG_OFF("-Wignored-qualifiers") + +namespace FIX +{ + class Message; + class SessionID; +} + +namespace bts { +namespace api { + namespace orderman { + class OrderStateImmutable; + class NativeOrderStateImmutable; + } +} + +namespace fix { + +class IFixRouter; + +class SessionBase : public IFixSession, public FIX::MessageCracker +{ +public: + SessionBase(bts::api::ServiceContext&, IFixRouter&, const FIX::SessionID&); + virtual ~SessionBase(); + + void fromAdmin(const FIX::Message& message, const FIX::SessionID& sessionID) + throw(FIX::FieldNotFound, FIX::IncorrectDataFormat, FIX::IncorrectTagValue, FIX::RejectLogon); + void fromApp(const FIX::Message &message,const FIX::SessionID &sessionID) + throw(FIX::FieldNotFound, FIX::IncorrectDataFormat, FIX::IncorrectTagValue, FIX::UnsupportedMessageType); + void toAdmin(FIX::Message&, const FIX::SessionID&); + void toApp(FIX::Message&, const FIX::SessionID&) throw(FIX::DoNotSend); + + void onMessage(const FIX44::BusinessMessageReject& n, const FIX::SessionID& s); + +protected: + void send_cancel_reject(const FIX::SessionID& sess, const std::string& text, const FIX::Message& refmessage); + + bool security_types_equal(bts::api::SecurityType btstype, FIX::SecurityType fixtype); + FIX::SecurityType convert_security_type(bts::api::SecurityType btstype); + bts::api::SecurityType convert_security_type(FIX::SecurityType fixtype); + + bool exchanges_equal(bts::api::Venue btstype, FIX::SecurityExchange fixtype); + FIX::SecurityExchange convert_exchange(bts::api::Venue btstype); + bts::api::Venue convert_exchange(FIX::SecurityExchange fixtype); + + FIX::OrdStatus translate_status(const bts::api::orderman::OrderStateImmutable& state, + bts::api::orderman::NativeOrderStateImmutable* native); + + + uint lookup_account(const std::string& acct); + uint lookup_user(const std::string& user); + +protected: + bts::api::user::AuthService _auth_service; + bts::api::admin::AdminService _admin_service; + + std::string _user_name; + bts::api::AuthToken _token; + IFixRouter& _router; + const FIX::SessionID& _sess; + bts::api::admin::AdminData _admin_data; + std::mutex _lock; +}; + +}} From 719fd030638ebe69f15bcffec647c5ef7f80c48c Mon Sep 17 00:00:00 2001 From: Kevin Darby Date: Thu, 26 Sep 2019 11:45:08 -0400 Subject: [PATCH 18/28] nothing builds --- src/lib/md/HandleIndex.h | 17 ++++-- src/lib/md/MBOServiceServer.cpp | 4 +- src/server/sparkd/CMakeLists.txt | 5 ++ src/server/sparkd/fix/FixInit.cpp | 14 ++--- src/server/sparkd/fix/FixRouter.cpp | 2 - src/server/sparkd/fix/FixRouter.h | 12 ++-- src/server/sparkd/fix/IFixRouter.h | 9 +-- src/server/sparkd/fix/IFixSession.h | 10 +++- src/server/sparkd/fix/SecurityIndex.cpp | 49 +++++++++++++++ src/server/sparkd/fix/SecurityIndex.h | 28 +++++++++ src/server/sparkd/fix/SessionBase.cpp | 79 +++++++++++++++++++++---- src/server/sparkd/fix/SessionBase.h | 4 +- 12 files changed, 191 insertions(+), 42 deletions(-) create mode 100644 src/server/sparkd/fix/SecurityIndex.cpp create mode 100644 src/server/sparkd/fix/SecurityIndex.h diff --git a/src/lib/md/HandleIndex.h b/src/lib/md/HandleIndex.h index 495998ab8..c8656b9a9 100644 --- a/src/lib/md/HandleIndex.h +++ b/src/lib/md/HandleIndex.h @@ -38,14 +38,16 @@ class HandleIndex public: typedef decltype( Key_Func(std::declval()) ) KeyType; - utils::LockBox> index; + utils::LockBox> handle_index; + utils::LockBox> security_index; HandleIndex(md::MDClient& client) : _client(client), _sub(0), _consumer(std::nullopt), - index() + handle_index(), + security_index() { _sub = _client.on_consumer().subscribe([=](const MDConsumer& c) { on_consumer(c); }); on_consumer( _client.current_consumer() ); @@ -64,7 +66,8 @@ private: auto existing = _consumer ? _consumer->id() : 0; LOG(md,Info, "Updating HandleIndex MDConsumer. Old {} new {}", existing, temp.id()); // clear the index - index.lock([](auto& index) { index.clear(); }); + handle_index.lock([](auto& index) { index.clear(); }); + security_index.lock([](auto& index) { index.clear(); }); // Swap to new consumer if (_consumer) { @@ -76,14 +79,18 @@ private: } // Subscribe to on_security auto id = _consumer->id(); - _consumer->on_security([this,id](const SecurityPtr&, MDConsumerHandle handle) + _consumer->on_security([this,id](const SecurityPtr& sec, MDConsumerHandle handle) { if (_consumer->id() == id) { - index.lock([this, handle](auto& index) + handle_index.lock([this, handle](auto& index) { index[ Key_Func(handle) ] = handle; }); + security_index.lock([this, handle, sec](auto& index) + { + index[ Key_Func(handle) ] = sec; + }); } }); } diff --git a/src/lib/md/MBOServiceServer.cpp b/src/lib/md/MBOServiceServer.cpp index ac6d4cc2b..dc468f671 100644 --- a/src/lib/md/MBOServiceServer.cpp +++ b/src/lib/md/MBOServiceServer.cpp @@ -116,7 +116,7 @@ std::optional search_orders(const ExchangeOrderKey oid, const std::vec } bool update_position(const KeyHandleIndex& handles, ActiveOrder& order) { - const auto& index = handles.index; + const auto& index = handles.handle_index; auto handle = index.lock([id=order.security_id()](const auto& index) { auto iter = index.find(id); return iter != index.end() ? iter->second : MDConsumerHandle {}; @@ -253,7 +253,7 @@ MBOServiceServer::~MBOServiceServer() { } void MBOServiceServer::get_orders_for_security(const MBOSecurityQuery& request, const api::Response& reply) { PositionData response; response.set_security_id(request.security_id()); - auto handle = _me->handle_index.index.lock([id=request.security_id()](const auto& index) { + auto handle = _me->handle_index.handle_index.lock([id=request.security_id()](const auto& index) { auto iter = index.find(SecurityKey(id)); return iter != index.end() ? iter->second : MDConsumerHandle {}; }); diff --git a/src/server/sparkd/CMakeLists.txt b/src/server/sparkd/CMakeLists.txt index 802ffd19b..d06d32218 100644 --- a/src/server/sparkd/CMakeLists.txt +++ b/src/server/sparkd/CMakeLists.txt @@ -18,6 +18,11 @@ target_include_directories( sparkd PUBLIC ${CMAKE_SOURCE_DIR}/src ${CMAKE_BINARY set_source_files_properties(exchange_sim/ExchangeSim.cpp PROPERTIES COMPILE_FLAGS --std=c++14) set_source_files_properties(exchange_sim/ExchangeSimApplication.cpp PROPERTIES COMPILE_FLAGS --std=c++14) +set_source_files_properties(fix/FixInit.cpp PROPERTIES COMPILE_FLAGS --std=c++14) +set_source_files_properties(fix/FixRouter.cpp PROPERTIES COMPILE_FLAGS --std=c++14) +set_source_files_properties(fix/SessionBase.cpp PROPERTIES COMPILE_FLAGS --std=c++14) +set_source_files_properties(fix/OrderSession.cpp PROPERTIES COMPILE_FLAGS --std=c++14) +set_source_files_properties(fix/DropCopySession.cpp PROPERTIES COMPILE_FLAGS --std=c++14) # linking target_link_libraries( sparkd diff --git a/src/server/sparkd/fix/FixInit.cpp b/src/server/sparkd/fix/FixInit.cpp index 40bd37b9d..d902bd5d9 100644 --- a/src/server/sparkd/fix/FixInit.cpp +++ b/src/server/sparkd/fix/FixInit.cpp @@ -23,22 +23,22 @@ namespace bts { namespace fix { - GCC_DIAG_OFF("-Wdeprecated") GCC_DIAG_OFF("-Wignored-qualifiers") - -int FixInit::start_acceptor(bts::api::ServiceContext& sc, const md::MDClient& md, const std::string& settings_file, bool orders_allowed) + +int FixInit::start_acceptor(bts::api::ServiceContext&, const md::MDClient& md, const std::string& settings_file, bool orders_allowed) { std::ifstream str{settings_file}; FIX::SessionSettings settings( str ); FixRouter application(md, [=](IFixRouter& router, const auto& id) { - if(orders_allowed) - return std::shared_ptr(new OrderSession(sc, router, id)); - else - return std::shared_ptr(new DropCopySession(sc, router, id)); + return std::shared_ptr(); + // if(orders_allowed) + // return std::shared_ptr(new OrderSession(sc, router, id)); + // else + // return std::shared_ptr(new DropCopySession(sc, router, id)); }); FIX::FileStoreFactory storeFactory( settings ); FIX::FileLogFactory logFactory( settings ); diff --git a/src/server/sparkd/fix/FixRouter.cpp b/src/server/sparkd/fix/FixRouter.cpp index 26488aaee..a4e0a1637 100644 --- a/src/server/sparkd/fix/FixRouter.cpp +++ b/src/server/sparkd/fix/FixRouter.cpp @@ -21,8 +21,6 @@ namespace bts namespace fix { -GCC_DIAG_OFF("-Wdeprecated") -GCC_DIAG_OFF("-Wignored-qualifiers") FixRouter::FixRouter(const md::MDClient& md, std::function< std::shared_ptr (IFixRouter&, const FIX::SessionID&) > factory) : diff --git a/src/server/sparkd/fix/FixRouter.h b/src/server/sparkd/fix/FixRouter.h index 93947f7c5..1e64b1298 100644 --- a/src/server/sparkd/fix/FixRouter.h +++ b/src/server/sparkd/fix/FixRouter.h @@ -2,12 +2,13 @@ #include "IFixSession.h" #include "IFixRouter.h" -#include "lib/md/HandleIndex.h" +#include "SecurityIndex.h" #include "lib/md/MDConsumerHandle.h" #include #include #include + #include #include #include @@ -16,16 +17,15 @@ #include "lib/utils/warn_ctrl.h" -GCC_DIAG_OFF("-Woverloaded-virtual") -GCC_DIAG_OFF("-Wdeprecated") -GCC_DIAG_OFF("-Wignored-qualifiers") - - namespace bts { namespace api { class ServiceContext; } namespace md { class MDClient; } namespace fix { +GCC_DIAG_OFF("-Wdeprecated") +GCC_DIAG_OFF("-Wignored-qualifiers") + + class FixRouter : public IFixSession, public FIX::MessageCracker, public IFixRouter { public: diff --git a/src/server/sparkd/fix/IFixRouter.h b/src/server/sparkd/fix/IFixRouter.h index 6fb043fd5..da04963ce 100644 --- a/src/server/sparkd/fix/IFixRouter.h +++ b/src/server/sparkd/fix/IFixRouter.h @@ -1,6 +1,6 @@ #pragma once -#include "lib/domain_model/Security.pb.h" +#include "lib/md/common.h" #include #include @@ -20,15 +20,12 @@ namespace api } namespace fix -{ - typedef uint32_t security_key; - const security_key invalid_security_key = 0; - +{ class IFixRouter { public: virtual std::vector get_securities() = 0; - virtual const api::Security* lookup(security_key key) = 0; + virtual const api::Security* lookup(md::security_key key) = 0; virtual const api::Security* lookup(const std::string& desc) = 0; virtual void send(const FIX::Message& mess, const FIX::SessionID& sess) = 0; diff --git a/src/server/sparkd/fix/IFixSession.h b/src/server/sparkd/fix/IFixSession.h index f086e4126..e92c8f4b8 100644 --- a/src/server/sparkd/fix/IFixSession.h +++ b/src/server/sparkd/fix/IFixSession.h @@ -1,12 +1,20 @@ #pragma once +#include "lib/utils/warn_ctrl.h" +GCC_DIAG_OFF("-Woverloaded-virtual") +GCC_DIAG_OFF("-Wdeprecated") +GCC_DIAG_OFF("-Wignored-qualifiers") + #include namespace bts { namespace fix { +GCC_DIAG_OFF("-Wdeprecated") +GCC_DIAG_OFF("-Wignored-qualifiers") + class IFixSession : public FIX::Application { }; -}} \ No newline at end of file +}} diff --git a/src/server/sparkd/fix/SecurityIndex.cpp b/src/server/sparkd/fix/SecurityIndex.cpp new file mode 100644 index 000000000..cb12bf92c --- /dev/null +++ b/src/server/sparkd/fix/SecurityIndex.cpp @@ -0,0 +1,49 @@ +#include "SecurityIndex.h" + +#include "lib/md/HandleIndex.h" + + +namespace bts { +namespace fix { + +struct SecurityIndex::PImpl +{ + md::DescHandleIndex index; + PImpl(const md::MDClient& md) : index(md) + { + } +}; + + +SecurityIndex::SecurityIndex(const md::MDClient& md) : me(new PImpl(md)) +{ +} + +std::vector SecurityIndex::get_securities() +{ + std::vector list; + me->index.security_index.lock([&list] (const auto& secmap) + { + for(const auto& s : secmap) + list.push_back(s.second); + }); + return list; +} + + +md::SecurityPtr SecurityIndex::lookup(const std::string& desc) +{ + md::SecurityPtr ptr = nullptr; + me->index.security_index.lock([&ptr, &desc] (const auto& secmap) + { + auto it = secmap.find(desc); + if(it != secmap.end()) + ptr = it->second; + }); + return ptr; +} + + +}} + + \ No newline at end of file diff --git a/src/server/sparkd/fix/SecurityIndex.h b/src/server/sparkd/fix/SecurityIndex.h new file mode 100644 index 000000000..f366d87fa --- /dev/null +++ b/src/server/sparkd/fix/SecurityIndex.h @@ -0,0 +1,28 @@ +#pragma once + +#include "lib/md/common.h" +#include "lib/md/SecurityPtr.h" +#include +#include +#include + +namespace bts { +namespace api { class Security; } +namespace md { class MDClient; } +namespace fix { + +//A Wrapper for HandleIndex that compiles in c++14 (because of Fix dynamic exception stuff) +class SecurityIndex +{ +public: + SecurityIndex(const md::MDClient&); + + std::vector get_securities(); + md::SecurityPtr lookup(const std::string& desc); + +private: + struct PImpl; + std::unique_ptr me; +}; + +}} diff --git a/src/server/sparkd/fix/SessionBase.cpp b/src/server/sparkd/fix/SessionBase.cpp index 572d1af62..3646403f6 100644 --- a/src/server/sparkd/fix/SessionBase.cpp +++ b/src/server/sparkd/fix/SessionBase.cpp @@ -6,6 +6,7 @@ #include "lib/utils/AuthToken.h" #include "lib/logging/logging.h" #include "lib/utils/bts_assert.h" +#include "lib/api/service_helpers/AdminServiceUtils.h" #include @@ -99,47 +100,105 @@ FIX::SecurityType SessionBase::convert_security_type(bts::api::SecurityType btst switch (btstype) { case bts::api::SecurityType::SECURITYTYPE_FUTURE: - return new QuickFix.Fields.SecurityType("FUT"); - case bts.api.SecurityType.Option: - return new QuickFix.Fields.SecurityType("OPT"); - case bts.api.SecurityType.Spread: - return new QuickFix.Fields.SecurityType("MLEG"); - case bts.api.SecurityType.Stock: - return new QuickFix.Fields.SecurityType("CS"); - case bts.api.SecurityType.Synthetic: - return new QuickFix.Fields.SecurityType("SYNTH"); + return FIX::SecurityType("FUT"); + case bts::api::SecurityType::SECURITYTYPE_OPTION: + return FIX::SecurityType("OPT"); + case bts::api::SecurityType::SECURITYTYPE_SPREAD: + return FIX::SecurityType("MLEG"); + case bts::api::SecurityType::SECURITYTYPE_STOCK: + return FIX::SecurityType("CS"); + case bts::api::SecurityType::SECURITYTYPE_SYNTHETIC: + return FIX::SecurityType("SYNTH"); default: - return new QuickFix.Fields.SecurityType(); + return FIX::SecurityType(); } } bts::api::SecurityType SessionBase::convert_security_type(FIX::SecurityType fixtype) { + std::string s = std::string(fixtype.getValue()); + if(s == "FUT") + return bts::api::SecurityType::SECURITYTYPE_FUTURE; + else if(s == "OPT") + return bts::api::SecurityType::SECURITYTYPE_OPTION; + else if(s == "MLEG")) + return bts::api::SecurityType::SECURITYTYPE_SPREAD; + else if(s == "CS") + return bts::api::SecurityType::SECURITYTYPE_STOCK; + else if("SYNTH" == s) + return bts::api::SecurityType::SECURITYTYPE_SYNTHETIC; + else + return bts::api::SecurityType::SECURITYTYPE_UNSET; } bool SessionBase::exchanges_equal(bts::api::Venue btstype, FIX::SecurityExchange fixtype) { + return btstype == convert_exchange(fixtype); } FIX::SecurityExchange SessionBase::convert_exchange(bts::api::Venue btstype) { + switch (btstype) + { + case bts::api::Venue::VENUE_BTS: + return FIX::SecurityExchange("BTS"); + case bts::api::Venue::VENUE_CBOE: + return FIX::SecurityExchange("XCBO"); + case bts::api::Venue::VENUE_CBOECFE: + return FIX::SecurityExchange("XCBF"); + case bts::api::Venue::VENUE_GLBX: + return FIX::SecurityExchange("XCME"); + case bts::api::Venue::VENUE_ICE: + return FIX::SecurityExchange("IFUS"); + case bts::api::Venue::VENUE_SIM: + return FIX::SecurityExchange("SIM"); + default: + return FIX::SecurityExchange(); + } } bts::api::Venue SessionBase::convert_exchange(FIX::SecurityExchange fixtype) { + std::string s = std::string(fixtype.getValue()); + if("BTS" == s) + return bts::api::Venue::VENUE_BTS; + else if("XCBO" == s) + return bts::api::Venue::VENUE_CBOE; + else if("XCBF" == s) + return bts::api::Venue::VENUE_CBOECFE; + else if("GLBX" == s || "XCME" == s || "XCBT" == s || "XCEC" == s || "XNYM" == s) + return bts::api::Venue::VENUE_GLBX; + else if("IEPA" == s || "IFUS" == s || "IFEU" == s || "IFLL" == s || "IFCA" == s) + return bts::api::Venue::VENUE_ICE; + else if("SIM" == s) + return bts::api::Venue::VENUE_SIM; + else + return bts::api::Venue::VENUE_UNSET; + } } FIX::OrdStatus SessionBase::translate_status(const bts::api::orderman::OrderStateImmutable& state, bts::api::orderman::NativeOrderStateImmutable* native) { + return FIX::OrdStatus(); } uint SessionBase::lookup_account(const std::string& acct) { + auto a = admin::AdminServiceUtils::find_account(_admin_data, acct); + if(a) + return a->id(); + else + throw FIX::IncorrectTagValue(FIX::FIEILD::Account); } uint SessionBase::lookup_user(const std::string& user) { + auto u = admin::AdminServiceUtils::find_user(_admin_data, user); + if(u) + return u->id(); + else + throw FIX::IncorrectTagValue(FIX::FIEILD::Username); } diff --git a/src/server/sparkd/fix/SessionBase.h b/src/server/sparkd/fix/SessionBase.h index 63e402e6e..fce203fd4 100644 --- a/src/server/sparkd/fix/SessionBase.h +++ b/src/server/sparkd/fix/SessionBase.h @@ -11,6 +11,7 @@ #include "lib/domain_model/Security.pb.h" #include + #include #include #include @@ -18,9 +19,6 @@ #include "lib/utils/warn_ctrl.h" -GCC_DIAG_OFF("-Woverloaded-virtual") -GCC_DIAG_OFF("-Wdeprecated") -GCC_DIAG_OFF("-Wignored-qualifiers") namespace FIX { From e1c2d8aaafb02f2b2e0a95cf7ebb0d769b5645fb Mon Sep 17 00:00:00 2001 From: Kevin Darby Date: Thu, 26 Sep 2019 12:33:42 -0400 Subject: [PATCH 19/28] it builds, ship it --- src/lib/logging/logging.h | 2 +- src/server/sparkd/fix/FixInit.cpp | 4 +- src/server/sparkd/fix/FixInit.h | 2 +- src/server/sparkd/fix/FixRouter.cpp | 53 +++++++++++++++++++++---- src/server/sparkd/fix/FixRouter.h | 23 ++++------- src/server/sparkd/fix/IFixRouter.h | 7 ++-- src/server/sparkd/fix/IFixSession.h | 6 +-- src/server/sparkd/fix/SecurityIndex.cpp | 16 +++++++- src/server/sparkd/fix/SecurityIndex.h | 5 ++- src/server/sparkd/fix/SessionBase.cpp | 9 ++--- 10 files changed, 84 insertions(+), 43 deletions(-) diff --git a/src/lib/logging/logging.h b/src/lib/logging/logging.h index 5539dc7a3..9b7fa89c2 100644 --- a/src/lib/logging/logging.h +++ b/src/lib/logging/logging.h @@ -46,7 +46,7 @@ constexpr log::Subsystem DataFlow {Latency.ordinal+1 }; constexpr log::Subsystem Plugin {DataFlow.ordinal+1 }; constexpr log::Subsystem ClientSdk {Plugin.ordinal+1 }; constexpr log::Subsystem Http {ClientSdk.ordinal+1 }; -constexpr log::Subsystem FIX {Http.ordinal+1 }; +constexpr log::Subsystem Fix {Http.ordinal+1 }; struct LoggerHandle { LoggerHandle(LoggerHandle const&) = delete; diff --git a/src/server/sparkd/fix/FixInit.cpp b/src/server/sparkd/fix/FixInit.cpp index d902bd5d9..a42919c7d 100644 --- a/src/server/sparkd/fix/FixInit.cpp +++ b/src/server/sparkd/fix/FixInit.cpp @@ -27,7 +27,7 @@ namespace fix GCC_DIAG_OFF("-Wdeprecated") GCC_DIAG_OFF("-Wignored-qualifiers") -int FixInit::start_acceptor(bts::api::ServiceContext&, const md::MDClient& md, const std::string& settings_file, bool orders_allowed) +int FixInit::start_acceptor(bts::api::ServiceContext&, md::MDClient& md, const std::string& settings_file, bool orders_allowed) { std::ifstream str{settings_file}; FIX::SessionSettings settings( str ); @@ -45,7 +45,7 @@ int FixInit::start_acceptor(bts::api::ServiceContext&, const md::MDClient& md, c FIX::SocketAcceptor acceptor( application, storeFactory, settings, logFactory ); acceptor.start(); - + return 0; } } diff --git a/src/server/sparkd/fix/FixInit.h b/src/server/sparkd/fix/FixInit.h index 0273a7a6c..93401429f 100644 --- a/src/server/sparkd/fix/FixInit.h +++ b/src/server/sparkd/fix/FixInit.h @@ -10,7 +10,7 @@ namespace fix { class FixInit { public: - static int start_acceptor(bts::api::ServiceContext& sc, const md::MDClient& md, const std::string& settings_file, bool orders_allowed); + static int start_acceptor(bts::api::ServiceContext& sc, md::MDClient& md, 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 a4e0a1637..c56e9f7ac 100644 --- a/src/server/sparkd/fix/FixRouter.cpp +++ b/src/server/sparkd/fix/FixRouter.cpp @@ -1,6 +1,8 @@ #include "FixRouter.h" #include "IFixSession.h" +#include "SecurityIndex.h" +#include "lib/md/MDConsumerHandle.h" #include #include @@ -20,14 +22,24 @@ namespace bts { namespace fix { + +struct FixRouter::PImpl +{ + boost::container::flat_map< FIX::SessionID, std::shared_ptr > sessions; + SecurityIndex index; + std::mutex lock; + Factory factory; + PImpl(md::MDClient& md, Factory factory) : + sessions(), + index(md), + lock(), + factory(factory) + { + } +}; -FixRouter::FixRouter(const md::MDClient& md, - std::function< std::shared_ptr (IFixRouter&, const FIX::SessionID&) > factory) : - _sessions(), - _index(md), - _sc(sc), - _lock() +FixRouter::FixRouter(md::MDClient& md, Factory factory) : me(new PImpl(md, factory)) { } @@ -65,7 +77,7 @@ void FixRouter::onLogon(const FIX::SessionID&) { } -void onLogout(const FIX::SessionID&) +void FixRouter::onLogout(const FIX::SessionID&) { } @@ -77,8 +89,18 @@ void FixRouter::toApp(FIX::Message&, const FIX::SessionID&) throw(FIX::DoNotSend { } -IFixSession& FixRouter::session(const FIX::SessionID&) +IFixSession& FixRouter::session(const FIX::SessionID& sid) { + std::lock_guard guard(me->lock); + auto it = me->sessions.find(sid); + if(it == me->sessions.end()) + { + auto ptr = me->factory(*this, sid); + me->sessions[sid] = ptr; + return *ptr; + } + else + return *it->second; } void FixRouter::handle_session_exception(const std::exception& ex, const FIX::SessionID& sessionID, const FIX::Message* message) @@ -89,6 +111,21 @@ void FixRouter::handle_field_not_found(const FIX::FieldNotFound& ex, const FIX:: { } +std::vector FixRouter::get_securities() +{ + return me->index.get_securities(); +} + +const md::SecurityPtr FixRouter::lookup(md::security_key key) +{ + return me->index.lookup(key); +} + +const md::SecurityPtr FixRouter::lookup(const std::string& desc) +{ + return me->index.lookup(desc); +} + } } \ No newline at end of file diff --git a/src/server/sparkd/fix/FixRouter.h b/src/server/sparkd/fix/FixRouter.h index 1e64b1298..7b12ee954 100644 --- a/src/server/sparkd/fix/FixRouter.h +++ b/src/server/sparkd/fix/FixRouter.h @@ -2,8 +2,6 @@ #include "IFixSession.h" #include "IFixRouter.h" -#include "SecurityIndex.h" -#include "lib/md/MDConsumerHandle.h" #include #include @@ -15,22 +13,18 @@ #include #include -#include "lib/utils/warn_ctrl.h" namespace bts { namespace api { class ServiceContext; } namespace md { class MDClient; } namespace fix { -GCC_DIAG_OFF("-Wdeprecated") -GCC_DIAG_OFF("-Wignored-qualifiers") - - class FixRouter : public IFixSession, public FIX::MessageCracker, public IFixRouter { public: - FixRouter(const md::MDClient&, - std::function< std::shared_ptr (IFixRouter&, const FIX::SessionID&) > factory); + typedef std::function< std::shared_ptr (IFixRouter&, const FIX::SessionID&) > Factory; + + FixRouter(md::MDClient&, Factory factory); ~FixRouter(); void send(const FIX::Message&, const FIX::SessionID&) override; @@ -55,14 +49,13 @@ private: void handle_field_not_found(const FIX::FieldNotFound& ex, const FIX::SessionID& sess, const FIX::Message& message); private: - std::vector get_securities() override; - const api::Security* lookup(security_key key) override; - const api::Security* lookup(const std::string& desc) override; + std::vector get_securities() override; + const md::SecurityPtr lookup(md::security_key key) override; + const md::SecurityPtr lookup(const std::string& desc) override; private: - boost::container::flat_map< FIX::SessionID, std::shared_ptr > _sessions; - md::DescHandleIndex _index; - std::mutex _lock; + struct PImpl; + std::unique_ptr me; }; }} \ No newline at end of file diff --git a/src/server/sparkd/fix/IFixRouter.h b/src/server/sparkd/fix/IFixRouter.h index da04963ce..191809b4e 100644 --- a/src/server/sparkd/fix/IFixRouter.h +++ b/src/server/sparkd/fix/IFixRouter.h @@ -1,6 +1,7 @@ #pragma once #include "lib/md/common.h" +#include "lib/md/SecurityPtr.h" #include #include @@ -24,9 +25,9 @@ namespace fix class IFixRouter { public: - virtual std::vector get_securities() = 0; - virtual const api::Security* lookup(md::security_key key) = 0; - virtual const api::Security* lookup(const std::string& desc) = 0; + virtual std::vector get_securities() = 0; + virtual const md::SecurityPtr lookup(md::security_key key) = 0; + virtual const md::SecurityPtr lookup(const std::string& desc) = 0; virtual void send(const FIX::Message& mess, const FIX::SessionID& sess) = 0; virtual void send_session_reject(const FIX::SessionID& sess, const std::string& text, const FIX::Message* refmessage = nullptr) = 0; diff --git a/src/server/sparkd/fix/IFixSession.h b/src/server/sparkd/fix/IFixSession.h index e92c8f4b8..8da871e19 100644 --- a/src/server/sparkd/fix/IFixSession.h +++ b/src/server/sparkd/fix/IFixSession.h @@ -4,15 +4,13 @@ GCC_DIAG_OFF("-Woverloaded-virtual") GCC_DIAG_OFF("-Wdeprecated") GCC_DIAG_OFF("-Wignored-qualifiers") +GCC_DIAG_OFF("-Wunused-parameter") #include namespace bts { namespace fix { - -GCC_DIAG_OFF("-Wdeprecated") -GCC_DIAG_OFF("-Wignored-qualifiers") - + class IFixSession : public FIX::Application { }; diff --git a/src/server/sparkd/fix/SecurityIndex.cpp b/src/server/sparkd/fix/SecurityIndex.cpp index cb12bf92c..855dc399d 100644 --- a/src/server/sparkd/fix/SecurityIndex.cpp +++ b/src/server/sparkd/fix/SecurityIndex.cpp @@ -9,13 +9,14 @@ namespace fix { struct SecurityIndex::PImpl { md::DescHandleIndex index; - PImpl(const md::MDClient& md) : index(md) + md::KeyHandleIndex key_index; + PImpl(md::MDClient& md) : index(md), key_index(md) { } }; -SecurityIndex::SecurityIndex(const md::MDClient& md) : me(new PImpl(md)) +SecurityIndex::SecurityIndex(md::MDClient& md) : me(new PImpl(md)) { } @@ -43,6 +44,17 @@ md::SecurityPtr SecurityIndex::lookup(const std::string& desc) return ptr; } +md::SecurityPtr SecurityIndex::lookup(md::security_key key) +{ + md::SecurityPtr ptr = nullptr; + me->key_index.security_index.lock([&ptr, &key] (const auto& secmap) + { + auto it = secmap.find( SecurityKey(key) ); + if(it != secmap.end()) + ptr = it->second; + }); + return ptr; +} }} diff --git a/src/server/sparkd/fix/SecurityIndex.h b/src/server/sparkd/fix/SecurityIndex.h index f366d87fa..e18b7189b 100644 --- a/src/server/sparkd/fix/SecurityIndex.h +++ b/src/server/sparkd/fix/SecurityIndex.h @@ -15,14 +15,15 @@ namespace fix { class SecurityIndex { public: - SecurityIndex(const md::MDClient&); + SecurityIndex(md::MDClient&); std::vector get_securities(); md::SecurityPtr lookup(const std::string& desc); + md::SecurityPtr lookup(md::security_key key); private: struct PImpl; - std::unique_ptr me; + std::shared_ptr me; }; }} diff --git a/src/server/sparkd/fix/SessionBase.cpp b/src/server/sparkd/fix/SessionBase.cpp index 3646403f6..bd22249a6 100644 --- a/src/server/sparkd/fix/SessionBase.cpp +++ b/src/server/sparkd/fix/SessionBase.cpp @@ -31,7 +31,7 @@ SessionBase::SessionBase(bts::api::ServiceContext& sc, IFixRouter& router, const _admin_data(), _lock() { - _admin_service.get_admin_data(api::VoidMessage(), [this] (auto& result) + _admin_service.get_admin_data(api::VoidMessage(), [this] (auto result) { std::lock_guard guard(_lock); if(result.success()) @@ -121,7 +121,7 @@ bts::api::SecurityType SessionBase::convert_security_type(FIX::SecurityType fixt return bts::api::SecurityType::SECURITYTYPE_FUTURE; else if(s == "OPT") return bts::api::SecurityType::SECURITYTYPE_OPTION; - else if(s == "MLEG")) + else if(s == "MLEG") return bts::api::SecurityType::SECURITYTYPE_SPREAD; else if(s == "CS") return bts::api::SecurityType::SECURITYTYPE_STOCK; @@ -174,7 +174,6 @@ bts::api::Venue SessionBase::convert_exchange(FIX::SecurityExchange fixtype) return bts::api::Venue::VENUE_SIM; else return bts::api::Venue::VENUE_UNSET; - } } FIX::OrdStatus SessionBase::translate_status(const bts::api::orderman::OrderStateImmutable& state, @@ -189,7 +188,7 @@ uint SessionBase::lookup_account(const std::string& acct) if(a) return a->id(); else - throw FIX::IncorrectTagValue(FIX::FIEILD::Account); + throw FIX::IncorrectTagValue(FIX::FIELD::Account); } uint SessionBase::lookup_user(const std::string& user) @@ -198,7 +197,7 @@ uint SessionBase::lookup_user(const std::string& user) if(u) return u->id(); else - throw FIX::IncorrectTagValue(FIX::FIEILD::Username); + throw FIX::IncorrectTagValue(FIX::FIELD::Username); } From 6ef0808f4963cc87995895993f9b3938f1dadcee Mon Sep 17 00:00:00 2001 From: Kevin Darby Date: Thu, 26 Sep 2019 18:16:48 -0400 Subject: [PATCH 20/28] never thought I'd use rxcpp...it's truly terrible; I feel physical pain --- src/server/sparkd/fix/AdminModelWrapper.cpp | 38 +++++ src/server/sparkd/fix/AdminModelWrapper.h | 28 ++++ src/server/sparkd/fix/DropCopySession.cpp | 156 ++++++++++++++++++++ src/server/sparkd/fix/DropCopySession.h | 52 +++++++ src/server/sparkd/fix/FixInit.cpp | 11 +- src/server/sparkd/fix/FixRouter.cpp | 118 ++++++++++++++- src/server/sparkd/fix/FixRouter.h | 2 +- src/server/sparkd/fix/IFixRouter.h | 2 +- src/server/sparkd/fix/SessionBase.cpp | 148 ++++++++++++++++--- src/server/sparkd/fix/SessionBase.h | 38 ++--- 10 files changed, 538 insertions(+), 55 deletions(-) create mode 100644 src/server/sparkd/fix/AdminModelWrapper.cpp create mode 100644 src/server/sparkd/fix/AdminModelWrapper.h diff --git a/src/server/sparkd/fix/AdminModelWrapper.cpp b/src/server/sparkd/fix/AdminModelWrapper.cpp new file mode 100644 index 000000000..c187a9860 --- /dev/null +++ b/src/server/sparkd/fix/AdminModelWrapper.cpp @@ -0,0 +1,38 @@ +#include "AdminModelWrapper.h" + +#include "lib/api/service_helpers/AdminServiceUtils.h" + +#include + +namespace bts +{ + +AdminModelWrapper::AdminModelWrapper(const bts::api::admin::AdminData& data, const std::string& user_name) : + data(data), + _user_name(user_name), + _allowed_accounts() +{ + auto user = bts::admin::AdminServiceUtils::find_user(data, _user_name); + if(user && user->has_user_data() && user->user_data().has_account_permissions()) + { + for(const auto& a : user->user_data().account_permissions().account_permissions()) + { + auto account = bts::admin::AdminServiceUtils::find_account(data, a.first); + if(account) + { + if(a.second.has_trading_permission() && a.second.trading_permission().has_permissions()) + _allowed_accounts[account->name()] = 0; + if(a.second.has_admin_permission() && a.second.admin_permission().has_permissions()) + _allowed_accounts[account->name()] = 0; + } + } + } +} + +bool AdminModelWrapper::can_view_account(const std::string& account) +{ + auto it = _allowed_accounts.find(account); + return it != _allowed_accounts.end() || _user_name == "bts"; +} + +} \ No newline at end of file diff --git a/src/server/sparkd/fix/AdminModelWrapper.h b/src/server/sparkd/fix/AdminModelWrapper.h new file mode 100644 index 000000000..74e0087f8 --- /dev/null +++ b/src/server/sparkd/fix/AdminModelWrapper.h @@ -0,0 +1,28 @@ +#pragma once + +#include "lib/api/services/AdminService.pb.h" +#include "lib/api/services/AdminService.client.pb.h" + +#include +#include + +namespace bts +{ + +//see AdminModelWrapper.cs + +namespace api { namespace admin { class AdminData; } } +class AdminModelWrapper +{ +public: + AdminModelWrapper(const bts::api::admin::AdminData& data, const std::string& user_name); + + bool can_view_account(const std::string& account); + const bts::api::admin::AdminData data; + +private: + std::string _user_name; + std::unordered_map _allowed_accounts; +}; + +} \ No newline at end of file diff --git a/src/server/sparkd/fix/DropCopySession.cpp b/src/server/sparkd/fix/DropCopySession.cpp index e69de29bb..4a8147fa7 100644 --- a/src/server/sparkd/fix/DropCopySession.cpp +++ b/src/server/sparkd/fix/DropCopySession.cpp @@ -0,0 +1,156 @@ +#include "DropCopySession.h" +#include "FixRouter.h" + +#include "lib/logging/logging.h" +#include "lib/utils/bts_assert.h" +#include "lib/utils/helper_macros.h" + +#include +#include +#include +#include + +namespace bts { +namespace fix { + +DropCopySession::DropCopySession(bts::api::ServiceContext& sc, IFixRouter& rt, const FIX::SessionID& id) : + SessionBase(sc, rt, id), + _orderservice( sc.locate() ), + _order_cache() +{ +} + +DropCopySession::~DropCopySession() +{ +} + +void DropCopySession::onLogon(const FIX::SessionID& sessionID) +{ + bts_assert(sessionID == _sess); + LOG(Fix, Info, "Logged on {}", sessionID.toString()); + subscribe_fills_and_orders(sessionID); +} + +void DropCopySession::onLogout(const FIX::SessionID& sessionID) +{ + bts_assert(sessionID == _sess); + LOG(Fix, Info, "Logged out {}", sessionID.toString()); + +} + +void DropCopySession::fromApp(const FIX::Message &message,const FIX::SessionID &sessionID) + throw(FIX::FieldNotFound, FIX::IncorrectDataFormat, FIX::IncorrectTagValue, FIX::UnsupportedMessageType) +{ + bts_assert(sessionID == _sess); + auto mt = message.getHeader().getField(FIX::FIELD::MsgType); + if(mt == FIX44::OrderStatusRequest::MsgType() || + mt == FIX44::SecurityDefinitionRequest::MsgType() + ) + { + LOG(Fix, Info, "DC IN: {}", message.toString() ); + crack(message, sessionID); + } + else + { + LOG(Fix, Info, "DC IN: Unsupported message in {}", mt ); + throw FIX::UnsupportedMessageType(mt); + } +} + +void DropCopySession::onMessage(const FIX44::OrderStatusRequest& req, const FIX::SessionID& s) +{ + uint oid = atoi(req.getField(FIX::FIELD::OrderID).c_str()); + auto it = _order_cache.find(oid); + if(it != _order_cache.end()) + { + auto&& ostat = build_order_status(s, *it->second); + ostat.setField(FIX::FIELD::OrdStatusReqID, req.getField(FIX::FIELD::OrdStatusReqID)); + _router.send(ostat, s); + } +} + +void DropCopySession::onMessage(const FIX44::SecurityDefinitionRequest& req, const FIX::SessionID& s) +{ + if (req.getField(FIX::FIELD::SecurityRequestType) == std::to_string(FIX::SecurityRequestType_ALL_SECURITIES)) + { + auto&& secs = _router.get_securities(); + // if (req.isSetField(FIX::FIELD::Symbol)) + // secs = secs.Where(x => x.Symbol.ToLower() == req.Symbol.getValue().ToLower()); + // if (req.IsSetSecurityType()) + // secs = secs.Where(x => security_types_equal(x.security_type(), req.SecurityType)); + // if (req.IsSetSecurityExchange()) + // secs = secs.Where(x => exchanges_equal(x.Exchange, req.SecurityExchange)); + + auto def = FIX44::SecurityDefinition(FIX::SecurityReqID(req.getField(FIX::FIELD::SecurityReqID)), + FIX::SecurityResponseID(""), + FIX::SecurityResponseType(FIX::SecurityResponseType_LIST_OF_SECURITIES_RETURNED_PER_REQUEST)); + _router.send(def, s); + } + else + throw FIX::IncorrectTagValue(FIX::FIELD::SecurityRequestType); +} + +void DropCopySession::subscribe_fills_and_orders(const FIX::SessionID sessionID) +{ + //TODO put this in our C++ pipe and smoke it + //var on_orders = _orderservice.Value.subscribei_orders().Naggle(interval, scheduler).PermissionFilter(_adminobservable).Table().Cache(); + //var on_fills = _orderservice.Value.subscribei_fills().Naggle(interval, scheduler).PermissionFilter(_adminobservable).Table().Cache(); + + // auto filter = rxcpp::observable<>::create([] (auto& observer) + // { + // return _adminobservable.subscribe([] (auto& x) + // { + // auto filter = [&x] (auto& z) + // { + // return x.can_view_account(z.def().account()); + // }; + // observer.on_next(filter); + // }); + // }); + + auto orders = _orderservice.subscribe_orders() | + rxcpp::operators::buffer_with_time( std::chrono::milliseconds(500) ); + + // auto admin = _adminobservable | + // rxcpp::operators::combine_latest([] (auto& admin, auto& order) + // { + // return std::make_pair(admin, order); + // }, orders) | + // rxcpp::operators::filter([] (const auto& pair) + // { + // //return pair.first.can_view_account(pair.second.def().account()); + // return true; + // }); + + orders.subscribe([this](const auto& update) + { + std::lock_guard l(_lock); + + }); +} + +void DropCopySession::process_order_state(const bts::api::orderman::OrderState& state, uint& filled, uint leaves, double& avgprx, + FIX::OrdStatus& fstatus, bts::api::orderman::NativeOrderState& native, const bts::api::orderman::Fill* fill) +{ +} + +const bts::api::Security* DropCopySession::resolve_execution_report_security(const bts::api::Security* sec, FIX44::ExecutionReport& report) +{ + return nullptr; +} + +FIX44::ExecutionReport DropCopySession::build_fill(const FIX::SessionID& sess, + const bts::api::orderman::Fill& fill, bool change) +{ + return FIX44::ExecutionReport(); +} + +FIX44::ExecutionReport DropCopySession::build_order_status(const FIX::SessionID& sess, + const bts::api::orderman::OrderRecord& order, bool change ) +{ + return FIX44::ExecutionReport(); +} + + + +}} diff --git a/src/server/sparkd/fix/DropCopySession.h b/src/server/sparkd/fix/DropCopySession.h index e69de29bb..9cb400d76 100644 --- a/src/server/sparkd/fix/DropCopySession.h +++ b/src/server/sparkd/fix/DropCopySession.h @@ -0,0 +1,52 @@ +#pragma once + +#include "SessionBase.h" + +#include +#include + +#include +#include +#include +#include +#include + +namespace FIX44 +{ + class OrderStatusRequest; + class SecurityDefinitionRequest; +} + +namespace bts { +namespace fix { + +class DropCopySession : public SessionBase +{ +public: + DropCopySession(bts::api::ServiceContext&, IFixRouter&, const FIX::SessionID&); + virtual ~DropCopySession(); + + void onLogon(const FIX::SessionID&); + void onLogout(const FIX::SessionID&); + + void fromApp(const FIX::Message &message,const FIX::SessionID &sessionID) + throw(FIX::FieldNotFound, FIX::IncorrectDataFormat, FIX::IncorrectTagValue, FIX::UnsupportedMessageType); + + void onMessage(const FIX44::OrderStatusRequest& m, const FIX::SessionID& s); + void onMessage(const FIX44::SecurityDefinitionRequest& m, const FIX::SessionID& s); + +protected: + virtual void subscribe_fills_and_orders(const FIX::SessionID sessionID); + virtual void process_order_state(const bts::api::orderman::OrderState& state, uint& filled, uint leaves, double& avgprx, + FIX::OrdStatus& fstatus, bts::api::orderman::NativeOrderState& native, const bts::api::orderman::Fill* fill = nullptr); + + const bts::api::Security* resolve_execution_report_security(const bts::api::Security* sec, FIX44::ExecutionReport& report); + virtual FIX44::ExecutionReport build_fill(const FIX::SessionID& sess, const bts::api::orderman::Fill& fill, bool change = false); + virtual FIX44::ExecutionReport build_order_status(const FIX::SessionID& sess, const bts::api::orderman::OrderRecord& order, bool change = false); + +protected: + bts::api::orderman::OrderService _orderservice; + std::unordered_map _order_cache; +}; + +}} diff --git a/src/server/sparkd/fix/FixInit.cpp b/src/server/sparkd/fix/FixInit.cpp index a42919c7d..27779b736 100644 --- a/src/server/sparkd/fix/FixInit.cpp +++ b/src/server/sparkd/fix/FixInit.cpp @@ -23,18 +23,15 @@ namespace bts { namespace fix { - -GCC_DIAG_OFF("-Wdeprecated") -GCC_DIAG_OFF("-Wignored-qualifiers") - -int FixInit::start_acceptor(bts::api::ServiceContext&, md::MDClient& md, const std::string& settings_file, bool orders_allowed) + +int FixInit::start_acceptor(bts::api::ServiceContext& sc, md::MDClient& md, const std::string& settings_file, bool orders_allowed) { std::ifstream str{settings_file}; FIX::SessionSettings settings( str ); - FixRouter application(md, [=](IFixRouter& router, const auto& id) + FixRouter application(md, [&](IFixRouter& router, const auto& id) { - return std::shared_ptr(); + return std::shared_ptr(new DropCopySession(sc, router, id)); // if(orders_allowed) // return std::shared_ptr(new OrderSession(sc, router, id)); // else diff --git a/src/server/sparkd/fix/FixRouter.cpp b/src/server/sparkd/fix/FixRouter.cpp index c56e9f7ac..d7a366b06 100644 --- a/src/server/sparkd/fix/FixRouter.cpp +++ b/src/server/sparkd/fix/FixRouter.cpp @@ -10,6 +10,8 @@ #include #include #include +#include +#include #include @@ -47,51 +49,131 @@ FixRouter::~FixRouter() { } -void FixRouter::send(const FIX::Message&, const FIX::SessionID&) +void FixRouter::send(FIX::Message& mess, const FIX::SessionID& sess) { +std::lock_guard guard(me->lock); + try + { + FIX::Session::sendToTarget(mess, sess); + } + catch(FIX::SessionNotFound) + { + bts_assert_msg(false, "session not found " + sess.toString()); + } + catch(std::exception ex) + { + LOG(Fix, Error, "session error {} {}", sess.toString(), std::string(ex.what())); + } } void FixRouter::send_session_reject(const FIX::SessionID& sess, const std::string& text, const FIX::Message* refmessage) { + FIX44::Reject rej; + if(refmessage && refmessage->getHeader().isSetField(FIX::FIELD::MsgSeqNum)) + rej.setField(FIX::FIELD::RefSeqNum, refmessage->getHeader().getField(FIX::FIELD::MsgSeqNum)); + rej.setField(FIX::FIELD::Text, text); + send(rej, sess); } void FixRouter::send_biz_reject(const FIX::SessionID sess, const std::string& text, const FIX::Message& refmessage, int reason_code) { + FIX44::BusinessMessageReject rej; + rej.setField(FIX::FIELD::RefMsgType, refmessage.getHeader().getField(FIX::FIELD::MsgType)); + rej.setField(FIX::FIELD::RefSeqNum, refmessage.getHeader().getField(FIX::FIELD::MsgSeqNum)); + rej.setField(FIX::FIELD::BusinessRejectReason, std::to_string(reason_code)); + rej.setField(FIX::FIELD::Text, text); } void FixRouter::fromAdmin(const FIX::Message& message, const FIX::SessionID& sessionID) throw(FIX::FieldNotFound, FIX::IncorrectDataFormat, FIX::IncorrectTagValue, FIX::RejectLogon) { + try + { + session(sessionID).fromAdmin(message, sessionID); + } + catch (FIX::FieldNotFound ex) { handle_field_not_found(ex, sessionID, message); } + catch (FIX::UnsupportedMessageType) { throw; } + catch (FIX::IncorrectTagValue) { throw; } + catch (std::exception ex) { handle_session_exception(ex, sessionID, &message); } } void FixRouter::fromApp(const FIX::Message &message,const FIX::SessionID &sessionID) throw(FIX::FieldNotFound, FIX::IncorrectDataFormat, FIX::IncorrectTagValue, FIX::UnsupportedMessageType) { + try + { + session(sessionID).fromApp(message, sessionID); + } + catch (FIX::FieldNotFound ex) { handle_field_not_found(ex, sessionID, message); } + catch (FIX::UnsupportedMessageType) { throw; } + catch (FIX::IncorrectTagValue) { throw; } + catch (std::exception ex) { handle_session_exception(ex, sessionID, &message); } } -void FixRouter::onCreate(const FIX::SessionID&) +void FixRouter::onCreate(const FIX::SessionID& sessionID) { + try + { + session(sessionID).onCreate(sessionID); + } + catch(std::exception ex) + { + handle_session_exception(ex, sessionID); + } } -void FixRouter::onLogon(const FIX::SessionID&) +void FixRouter::onLogon(const FIX::SessionID& sessionID) { + try + { + session(sessionID).onLogon(sessionID); + } + catch (std::exception ex) + { + handle_session_exception(ex, sessionID); + } } -void FixRouter::onLogout(const FIX::SessionID&) +void FixRouter::onLogout(const FIX::SessionID& sessionID) { + try + { + //TODO stackoverflow? + session(sessionID).onLogout(sessionID); + } + catch (std::exception ex) + { + handle_session_exception(ex, sessionID); + } } -void FixRouter::toAdmin(FIX::Message&, const FIX::SessionID&) +void FixRouter::toAdmin(FIX::Message& message, const FIX::SessionID& sessionID) { + try + { + session(sessionID).toAdmin(message, sessionID); + } + catch (FIX::FieldNotFound ex) { handle_field_not_found(ex, sessionID, message); } + catch (FIX::UnsupportedMessageType) { throw; } + catch (FIX::IncorrectTagValue) { throw; } + catch (std::exception ex) { handle_session_exception(ex, sessionID, &message); } } -void FixRouter::toApp(FIX::Message&, const FIX::SessionID&) throw(FIX::DoNotSend) +void FixRouter::toApp(FIX::Message& message, const FIX::SessionID& sessionID) throw(FIX::DoNotSend) { + try + { + session(sessionID).toApp(message, sessionID); + } + catch (FIX::FieldNotFound ex) { handle_field_not_found(ex, sessionID, message); } + catch (FIX::UnsupportedMessageType) { throw FIX::DoNotSend() ; } + catch (FIX::IncorrectTagValue) { throw FIX::DoNotSend() ; } + catch (std::exception ex) { handle_session_exception(ex, sessionID, &message); } } IFixSession& FixRouter::session(const FIX::SessionID& sid) { - std::lock_guard guard(me->lock); +std::lock_guard guard(me->lock); auto it = me->sessions.find(sid); if(it == me->sessions.end()) { @@ -105,10 +187,32 @@ IFixSession& FixRouter::session(const FIX::SessionID& sid) void FixRouter::handle_session_exception(const std::exception& ex, const FIX::SessionID& sessionID, const FIX::Message* message) { + std::string msg = "==ERROR in session " + sessionID.toString() + "== "; + msg += (message ? message->getHeader().getField(FIX::FIELD::MsgType) : ""); + msg += std::string(ex.what()); + + LOG(Fix, Error, msg.c_str()); + //now shut this fucker down + try + { + auto sess = FIX::Session::lookupSession(sessionID); + if(sess != nullptr) + sess->disconnect(); + } + catch(...) { } } void FixRouter::handle_field_not_found(const FIX::FieldNotFound& ex, const FIX::SessionID& sess, const FIX::Message& message) { + if(ex.field > 0) + { + std::string text = "Field " + std::to_string(ex.field) + " was expected but not found"; + send_biz_reject(sess, text, message, 5 ); + } + //QF does not include the tag number.... + //throw new FieldNotFoundException($"Field {ex.Field} was expected but not found", ex); + else + throw ex; } std::vector FixRouter::get_securities() diff --git a/src/server/sparkd/fix/FixRouter.h b/src/server/sparkd/fix/FixRouter.h index 7b12ee954..0edc0f770 100644 --- a/src/server/sparkd/fix/FixRouter.h +++ b/src/server/sparkd/fix/FixRouter.h @@ -27,7 +27,7 @@ public: FixRouter(md::MDClient&, Factory factory); ~FixRouter(); - void send(const FIX::Message&, const FIX::SessionID&) override; + void send(FIX::Message&, const FIX::SessionID&) override; void send_session_reject(const FIX::SessionID& sess, const std::string& text, const FIX::Message* refmessage = nullptr) override; void send_biz_reject(const FIX::SessionID sess, const std::string& text, const FIX::Message& refmessage, int reason_code = 0) override; diff --git a/src/server/sparkd/fix/IFixRouter.h b/src/server/sparkd/fix/IFixRouter.h index 191809b4e..925338c69 100644 --- a/src/server/sparkd/fix/IFixRouter.h +++ b/src/server/sparkd/fix/IFixRouter.h @@ -29,7 +29,7 @@ namespace fix virtual const md::SecurityPtr lookup(md::security_key key) = 0; virtual const md::SecurityPtr lookup(const std::string& desc) = 0; - virtual void send(const FIX::Message& mess, const FIX::SessionID& sess) = 0; + virtual void send(FIX::Message& mess, const FIX::SessionID& sess) = 0; virtual void send_session_reject(const FIX::SessionID& sess, const std::string& text, const FIX::Message* refmessage = nullptr) = 0; virtual void send_biz_reject(const FIX::SessionID sess, const std::string& text, const FIX::Message& refmessage, int reason_code = 0) = 0; }; diff --git a/src/server/sparkd/fix/SessionBase.cpp b/src/server/sparkd/fix/SessionBase.cpp index bd22249a6..0f9f63523 100644 --- a/src/server/sparkd/fix/SessionBase.cpp +++ b/src/server/sparkd/fix/SessionBase.cpp @@ -3,14 +3,17 @@ #include "IFixRouter.h" #include "lib/api/public/ServiceContext.h" +#include "lib/api/service_helpers/AdminServiceUtils.h" #include "lib/utils/AuthToken.h" #include "lib/logging/logging.h" #include "lib/utils/bts_assert.h" -#include "lib/api/service_helpers/AdminServiceUtils.h" - +#include "lib/utils/helper_macros.h" #include +#include #include +#include +#include #include #include #include @@ -22,40 +25,92 @@ namespace bts { namespace fix { SessionBase::SessionBase(bts::api::ServiceContext& sc, IFixRouter& router, const FIX::SessionID& sess) : - _auth_service( sc.locate() ), - _admin_service( sc.locate() ), + _authservice( sc.locate() ), + _adminservice( sc.locate() ), + _admin_data(), + _user_name(), _token(), _router(router), - _sess(sess), - _admin_data(), + _sess(sess), _lock() { - _admin_service.get_admin_data(api::VoidMessage(), [this] (auto result) - { - std::lock_guard guard(_lock); - if(result.success()) - _admin_data = *result.value(); - }); + _adminobservable = _adminservice.subscribe_admin_data() | + rxcpp::operators::map( + [this](const auto& update) + { + std::lock_guard l(_lock); + bts_assert(update.all().size() == 1); + _admin_data = *update.all()[0]; + return std::shared_ptr(new AdminModelWrapper(_admin_data, _user_name) ); + }); + } SessionBase::~SessionBase() { } + void SessionBase::fromAdmin(const FIX::Message& message, const FIX::SessionID& sessionID) throw(FIX::FieldNotFound, FIX::IncorrectDataFormat, FIX::IncorrectTagValue, FIX::RejectLogon) { bts_assert_msg(sessionID == _sess, "invalid session"); -} -void SessionBase::fromApp(const FIX::Message&,const FIX::SessionID&) - throw(FIX::FieldNotFound, FIX::IncorrectDataFormat, FIX::IncorrectTagValue, FIX::UnsupportedMessageType) -{ + FIX::MsgType type; + message.getHeader().getField(type); + if(type.getString() == FIX44::Logon::MsgType()) + { + try + { + FIX44::Logon msg = (FIX44::Logon)message; + _user_name = msg.getField(FIX::FIELD::Username); + std::string pass; + if(msg.isSetField(FIX::FIELD::Password)) + pass = msg.getField(FIX::FIELD::Password); + + bts::api::user::AuthenticateLoginRequest auth; + auth.set_login(_user_name); + auth.set_password(pass); + _authservice.authenticate_login(auth, [this] (auto resp) + { + if (resp.success() && resp.value()->is_valid()) + _token = resp.value()->token(); + else + throw FIX::RejectLogon("Logon rejected " + resp.value()->reason()); + }); + } + catch (FIX::RejectLogon) + { + throw; + } + catch (std::exception ex) + { + throw FIX::RejectLogon("Logon rejected " + std::string(ex.what())); + } + } + else if(type.getString() == FIX44::Heartbeat::MsgType()) + { + FIX44::Heartbeat hb = (FIX44::Heartbeat)message; + handle_heartbeat(hb, sessionID); + } + else + { + LOG(Fix, Info, "ADMININ: {}", message.toString() ); + } } -void SessionBase::toAdmin(FIX::Message&, const FIX::SessionID&) +void SessionBase::handle_heartbeat(const FIX44::Heartbeat& hb, const FIX::SessionID& sessionID) { + //TODO I'd previously sent this to the latency service when it was out of process, not sure what to do now + UNUSED(hb); + UNUSED(sessionID); +} + +void SessionBase::toAdmin(FIX::Message& m, const FIX::SessionID& sessionID) +{ + bts_assert_msg(sessionID == _sess, "invalid session"); + LOG(Fix, Info, "ADMINOUT: {}", m.toString()); } void SessionBase::toApp(FIX::Message& m, const FIX::SessionID&) throw(FIX::DoNotSend) @@ -63,6 +118,11 @@ void SessionBase::toApp(FIX::Message& m, const FIX::SessionID&) throw(FIX::DoNot LOG(Fix, Info, "OUT: {}", m.toString()); } +void SessionBase::onCreate(const FIX::SessionID& s) +{ + LOG(Fix, Info, "CREATE: {}", s.toString()); +} + void SessionBase::onMessage(const FIX44::BusinessMessageReject& n, const FIX::SessionID& s) { LOG(Fix, Warn, "{} Business Reject: {} {}", s.toString(), n.getField(FIX::FIELD::BusinessRejectReason), n.getField(FIX::FIELD::Text) ); @@ -176,10 +236,58 @@ bts::api::Venue SessionBase::convert_exchange(FIX::SecurityExchange fixtype) return bts::api::Venue::VENUE_UNSET; } -FIX::OrdStatus SessionBase::translate_status(const bts::api::orderman::OrderStateImmutable& state, - bts::api::orderman::NativeOrderStateImmutable* native) +FIX::OrdStatus SessionBase::translate_status(const bts::api::orderman::OrderState& state, + bts::api::orderman::NativeOrderState* native) { - return FIX::OrdStatus(); + if (state.has_market() && state.market().has_native_state() && state.market().native_state().native_status() != bts::api::orderman::NativeOrderStatus::NATIVE_ORDER_STATUS_UNACKNOWLEDGED) + { + *native = state.market().native_state(); + return FIX::OrdStatus((char)native->native_status()); + } + else if (state.has_limit() && state.limit().has_native_state() && state.limit().native_state().native_status() != bts::api::orderman::NativeOrderStatus::NATIVE_ORDER_STATUS_UNACKNOWLEDGED) + { + *native = state.limit().native_state(); + return FIX::OrdStatus((char)native->native_status()); + } + else if (state.has_stop() && state.stop().has_native_state() && state.stop().native_state().native_status() != bts::api::orderman::NativeOrderStatus::NATIVE_ORDER_STATUS_UNACKNOWLEDGED) + { + *native = state.stop().native_state(); + return FIX::OrdStatus((char)native->native_status()); + } + else if (state.has_stop_limit() && state.stop_limit().has_native_state() && state.stop_limit().native_state().native_status() != bts::api::orderman::NativeOrderStatus::NATIVE_ORDER_STATUS_UNACKNOWLEDGED) + { + *native = state.stop_limit().native_state(); + return FIX::OrdStatus((char)native->native_status()); + } + else + { + switch (state.status()) + { + case bts::api::orderman::OrderStatus::ORDER_STATUS_CANCELED: + return FIX::OrdStatus(FIX::OrdStatus_CANCELED); + case bts::api::orderman::OrderStatus::ORDER_STATUS_COMPLETED: + return FIX::OrdStatus(FIX::OrdStatus_FILLED); + case bts::api::orderman::OrderStatus::ORDER_STATUS_DISCONNECTED: + return FIX::OrdStatus(FIX::OrdStatus_STOPPED); + case bts::api::orderman::OrderStatus::ORDER_STATUS_ERROR: + return FIX::OrdStatus(FIX::OrdStatus_REJECTED); + case bts::api::orderman::OrderStatus::ORDER_STATUS_INACTIVE: + return FIX::OrdStatus(FIX::OrdStatus_PENDING_NEW); + case bts::api::orderman::OrderStatus::ORDER_STATUS_PENDING_WORKING: + return FIX::OrdStatus(FIX::OrdStatus_PENDING_NEW); + case bts::api::orderman::OrderStatus::ORDER_STATUS_REJECTED_BY_SPARK: + return FIX::OrdStatus(FIX::OrdStatus_REJECTED); + case bts::api::orderman::OrderStatus::ORDER_STATUS_WORKING: + { + if (state.filled_quantity() < state.quantity()) + return FIX::OrdStatus(FIX::OrdStatus_PARTIALLY_FILLED); + else + return FIX::OrdStatus(FIX::OrdStatus_NEW); + } + default: + return FIX::OrdStatus(); + } + } } uint SessionBase::lookup_account(const std::string& acct) diff --git a/src/server/sparkd/fix/SessionBase.h b/src/server/sparkd/fix/SessionBase.h index fce203fd4..771344929 100644 --- a/src/server/sparkd/fix/SessionBase.h +++ b/src/server/sparkd/fix/SessionBase.h @@ -1,12 +1,15 @@ #pragma once #include "IFixSession.h" +#include "AdminModelWrapper.h" #include "lib/api/public/ServiceContext.h" #include "lib/api/services/AuthService.pb.h" #include "lib/api/services/AuthService.client.pb.h" #include "lib/api/services/AdminService.pb.h" #include "lib/api/services/AdminService.client.pb.h" +#include "lib/api/services/OrderService.pb.h" +#include "lib/api/services/OrderService.client.pb.h" #include "lib/domain_model/Security.pb.h" @@ -17,23 +20,19 @@ #include #include -#include "lib/utils/warn_ctrl.h" - - namespace FIX { class Message; class SessionID; } -namespace bts { -namespace api { - namespace orderman { - class OrderStateImmutable; - class NativeOrderStateImmutable; - } +namespace FIX44 +{ + class Heartbeat; + class BusinessMessageReject; } +namespace bts { namespace fix { class IFixRouter; @@ -46,14 +45,14 @@ public: void fromAdmin(const FIX::Message& message, const FIX::SessionID& sessionID) throw(FIX::FieldNotFound, FIX::IncorrectDataFormat, FIX::IncorrectTagValue, FIX::RejectLogon); - void fromApp(const FIX::Message &message,const FIX::SessionID &sessionID) - throw(FIX::FieldNotFound, FIX::IncorrectDataFormat, FIX::IncorrectTagValue, FIX::UnsupportedMessageType); void toAdmin(FIX::Message&, const FIX::SessionID&); void toApp(FIX::Message&, const FIX::SessionID&) throw(FIX::DoNotSend); + void onCreate(const FIX::SessionID& s); void onMessage(const FIX44::BusinessMessageReject& n, const FIX::SessionID& s); protected: + void handle_heartbeat(const FIX44::Heartbeat& hb, const FIX::SessionID& sessionID); void send_cancel_reject(const FIX::SessionID& sess, const std::string& text, const FIX::Message& refmessage); bool security_types_equal(bts::api::SecurityType btstype, FIX::SecurityType fixtype); @@ -64,23 +63,24 @@ protected: FIX::SecurityExchange convert_exchange(bts::api::Venue btstype); bts::api::Venue convert_exchange(FIX::SecurityExchange fixtype); - FIX::OrdStatus translate_status(const bts::api::orderman::OrderStateImmutable& state, - bts::api::orderman::NativeOrderStateImmutable* native); - + FIX::OrdStatus translate_status(const bts::api::orderman::OrderState& state, + bts::api::orderman::NativeOrderState* native); uint lookup_account(const std::string& acct); uint lookup_user(const std::string& user); protected: - bts::api::user::AuthService _auth_service; - bts::api::admin::AdminService _admin_service; + bts::api::user::AuthService _authservice; + bts::api::admin::AdminService _adminservice; + + bts::api::admin::AdminData _admin_data; + rxcpp::observable> _adminobservable; std::string _user_name; bts::api::AuthToken _token; IFixRouter& _router; - const FIX::SessionID& _sess; - bts::api::admin::AdminData _admin_data; - std::mutex _lock; + const FIX::SessionID& _sess; + std::recursive_mutex _lock; }; }} From d23a072ad6d835a23aaaa3ec246415582b97d2ba Mon Sep 17 00:00:00 2001 From: Kevin Darby Date: Thu, 26 Sep 2019 18:27:41 -0400 Subject: [PATCH 21/28] rx --- src/server/sparkd/fix/DropCopySession.cpp | 26 +++++++++++++---------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/server/sparkd/fix/DropCopySession.cpp b/src/server/sparkd/fix/DropCopySession.cpp index 4a8147fa7..cc9c527d7 100644 --- a/src/server/sparkd/fix/DropCopySession.cpp +++ b/src/server/sparkd/fix/DropCopySession.cpp @@ -111,18 +111,22 @@ void DropCopySession::subscribe_fills_and_orders(const FIX::SessionID sessionID) auto orders = _orderservice.subscribe_orders() | rxcpp::operators::buffer_with_time( std::chrono::milliseconds(500) ); - // auto admin = _adminobservable | - // rxcpp::operators::combine_latest([] (auto& admin, auto& order) - // { - // return std::make_pair(admin, order); - // }, orders) | - // rxcpp::operators::filter([] (const auto& pair) - // { - // //return pair.first.can_view_account(pair.second.def().account()); - // return true; - // }); + auto admin = _adminobservable.combine_latest(orders) + .filter( [] (auto& tuple) + { + return true; + }); + // rxcpp::operators::combine_latest([] (auto& admin, auto& order) + // { + // return std::make_pair(admin, order); + // }, orders); + // rxcpp::operators::filter([] (auto& pair) + // { + // return pair.first->can_view_account(pair.second.def().account()); + // //return true; + // }); - orders.subscribe([this](const auto& update) + admin.subscribe([this](const auto& update) { std::lock_guard l(_lock); From 9850d6bde0f57d131d6040f2fa40999e9ea90f98 Mon Sep 17 00:00:00 2001 From: Kevin Darby Date: Fri, 27 Sep 2019 14:29:22 -0400 Subject: [PATCH 22/28] rx-cpp requires concurrent use with prescription medicine --- src/server/sparkd/fix/DropCopySession.cpp | 209 ++++++++++++++++++---- src/server/sparkd/fix/DropCopySession.h | 10 +- src/server/sparkd/fix/SessionBase.cpp | 1 + 3 files changed, 181 insertions(+), 39 deletions(-) diff --git a/src/server/sparkd/fix/DropCopySession.cpp b/src/server/sparkd/fix/DropCopySession.cpp index cc9c527d7..e171f832b 100644 --- a/src/server/sparkd/fix/DropCopySession.cpp +++ b/src/server/sparkd/fix/DropCopySession.cpp @@ -1,6 +1,8 @@ #include "DropCopySession.h" #include "FixRouter.h" +#include "lib/api/service_helpers/AdminServiceUtils.h" +#include "lib/domain_model/Security.h" #include "lib/logging/logging.h" #include "lib/utils/bts_assert.h" #include "lib/utils/helper_macros.h" @@ -10,6 +12,10 @@ #include #include +#include +#include +#include + namespace bts { namespace fix { @@ -90,63 +96,196 @@ void DropCopySession::onMessage(const FIX44::SecurityDefinitionRequest& req, con throw FIX::IncorrectTagValue(FIX::FIELD::SecurityRequestType); } + + void DropCopySession::subscribe_fills_and_orders(const FIX::SessionID sessionID) { //TODO put this in our C++ pipe and smoke it //var on_orders = _orderservice.Value.subscribei_orders().Naggle(interval, scheduler).PermissionFilter(_adminobservable).Table().Cache(); //var on_fills = _orderservice.Value.subscribei_fills().Naggle(interval, scheduler).PermissionFilter(_adminobservable).Table().Cache(); - // auto filter = rxcpp::observable<>::create([] (auto& observer) - // { - // return _adminobservable.subscribe([] (auto& x) - // { - // auto filter = [&x] (auto& z) - // { - // return x.can_view_account(z.def().account()); - // }; - // observer.on_next(filter); - // }); - // }); - - auto orders = _orderservice.subscribe_orders() | - rxcpp::operators::buffer_with_time( std::chrono::milliseconds(500) ); - - auto admin = _adminobservable.combine_latest(orders) - .filter( [] (auto& tuple) + auto&& filtered_orders = _adminobservable.combine_latest(_orderservice.subscribe_orders()) + .map( [] (auto& tuple) -> auto { - return true; - }); - // rxcpp::operators::combine_latest([] (auto& admin, auto& order) - // { - // return std::make_pair(admin, order); - // }, orders); - // rxcpp::operators::filter([] (auto& pair) - // { - // return pair.first->can_view_account(pair.second.def().account()); - // //return true; - // }); + std::shared_ptr admin = std::get<0>(tuple); + auto&& update = std::get<1>(tuple); + + auto all = update.all(); + all.erase(std::remove_if(all.begin(), all.end(), + [admin](auto& i) -> bool { return !admin->can_view_account(i->def().account()); }), all.end()); + + auto added = update.added(); + added.erase(std::remove_if(added.begin(), added.end(), + [admin](auto& i) -> bool { return !admin->can_view_account(i->def().account()); }), added.end()); + + auto changed = update.changed(); + changed.erase(std::remove_if(changed.begin(), changed.end(), + [admin](auto& i) -> bool { return !admin->can_view_account(i.current()->def().account()); }), changed.end()); + + auto removed = update.removed(); + removed.erase(std::remove_if(removed.begin(), removed.end(), + [admin](auto& i) -> bool { return !admin->can_view_account(i->def().account()); }), removed.end()); + + bts::api::orderman::OrdersUpdate newupdate(all, added, changed, removed); + return newupdate; + }).buffer_with_time( std::chrono::milliseconds(500) ); - admin.subscribe([this](const auto& update) + filtered_orders.subscribe([this, &sessionID](const auto& updatevec) { std::lock_guard l(_lock); - - }); + for(auto& update : updatevec) + { + for(auto& order : update.added()) + { + auto&& ostat = build_order_status(sessionID, *order); + _order_cache[order->key()] = order; + _router.send(ostat, sessionID); + } + for(auto& order : update.changed()) + { + auto&& ostat = build_order_status(sessionID, *order.current(), true); + _router.send(ostat, sessionID); + } + } + }); + + auto&& filtered_fills = _adminobservable.combine_latest(_orderservice.subscribe_fills()) + .map( [] (auto& tuple) -> auto + { + std::shared_ptr admin = std::get<0>(tuple); + auto&& update = std::get<1>(tuple); + + auto all = update.all(); + all.erase(std::remove_if(all.begin(), all.end(), + [admin](auto& i) -> bool { return !admin->can_view_account(i->account()); }), all.end()); + + auto added = update.added(); + added.erase(std::remove_if(added.begin(), added.end(), + [admin](auto& i) -> bool { return !admin->can_view_account(i->account()); }), added.end()); + + auto changed = update.changed(); + changed.erase(std::remove_if(changed.begin(), changed.end(), + [admin](auto& i) -> bool { return !admin->can_view_account(i.current()->account()); }), changed.end()); + + auto removed = update.removed(); + removed.erase(std::remove_if(removed.begin(), removed.end(), + [admin](auto& i) -> bool { return !admin->can_view_account(i->account()); }), removed.end()); + + bts::api::orderman::FillsUpdate newupdate(all, added, changed, removed); + return newupdate; + }).buffer_with_time( std::chrono::milliseconds(500) ); + + filtered_fills.subscribe([this, &sessionID](const auto& updatevec) + { + std::lock_guard l(_lock); + for(auto& update : updatevec) + { + for(auto& fill : update.added()) + { + auto&& fi = build_fill(sessionID, *fill); + _router.send(fi, sessionID); + } + for(auto& fill : update.changed()) + { + auto&& fi = build_fill(sessionID, *fill.current(), true); + _router.send(fi, sessionID); + } + } + }); } -void DropCopySession::process_order_state(const bts::api::orderman::OrderState& state, uint& filled, uint leaves, double& avgprx, +void DropCopySession::process_order_state(const bts::api::orderman::OrderState& state, uint& filled, uint& leaves, double& avgprx, FIX::OrdStatus& fstatus, bts::api::orderman::NativeOrderState& native, const bts::api::orderman::Fill* fill) { + filled = state.filled_quantity(); + leaves = state.quantity() - filled; + avgprx = state.avg_price();; + fstatus = translate_status(state, &native); } -const bts::api::Security* DropCopySession::resolve_execution_report_security(const bts::api::Security* sec, FIX44::ExecutionReport& report) +md::SecurityPtr DropCopySession::resolve_execution_report_security(md::SecurityPtr sec, FIX44::ExecutionReport& report) { - return nullptr; + if(!sec) + return nullptr; + auto sectype = bts::admin::AdminServiceUtils::security_type(*sec); + report.setField(FIX::FIELD::SecurityExchange, convert_exchange(sec->exchange()).getString()); + report.setField(FIX::FIELD::SecurityType, convert_security_type(sectype).getString()); + if(sec->has_glbx() || sec->has_ice()) + report.setField(FIX::FIELD::SecurityDesc, securities::descriptor(*sec)); + + if(sectype == bts::api::SecurityType::SECURITYTYPE_FUTURE) + { + auto dt = securities::expiration(*sec); + report.setField(FIX::FIELD::MaturityMonthYear, boost::gregorian::to_iso_string(dt)); + } + else if(sectype == bts::api::SecurityType::SECURITYTYPE_SPREAD) + { + //TODO this is not quite right for spreads of spreads + auto dt = securities::expiration(*sec); //smallest + report.setField(FIX::FIELD::MaturityMonthYear, boost::gregorian::to_iso_string(dt)); + } + else + throw FIX::UnsupportedMessageType(); + return sec; } FIX44::ExecutionReport DropCopySession::build_fill(const FIX::SessionID& sess, const bts::api::orderman::Fill& fill, bool change) { - return FIX44::ExecutionReport(); + auto exec = FIX::ExecType(FIX::ExecType_PARTIAL_FILL); + FIX::OrdStatus status; + uint filled = 0; uint leaves = 0; double prx = 0.0; + api::orderman::NativeOrderState native; + auto orderit = _order_cache.find(fill.order_key()); + if(orderit != _order_cache.end()) + { + const api::orderman::OrderRecord& order = *orderit->second; + process_order_state(order.state(), filled, leaves, prx, status, native); + if( ((double)order.state().quantity()) == fill.last_shares()) + exec = FIX::ExecType(FIX::ExecType_FILL); + } + if (change) + exec = FIX::ExecType(FIX::ExecType_TRADE_CORRECT); + + auto sec = _router.lookup(fill.security_key()); + FIX44::ExecutionReport report ( + FIX::OrderID(std::to_string(fill.order_key())), + FIX::ExecID(fill.fill_key()), + exec, + status, + FIX::Side(fill.side() == bts::api::SIDE_BUY ? FIX::Side_BUY : FIX::Side_SELL), + FIX::LeavesQty(leaves), + FIX::CumQty(filled), + FIX::AvgPx(prx) + ); + + if(sec) + report.setField(FIX::FIELD::Symbol, sec->symbol()); + report.setField(FIX::FIELD::Account, FIX::Account(fill.account()).getString() ); + report.setField(FIX::FIELD::LastQty, FIX::LastQty(fill.last_shares()).getString() ); + report.setField(FIX::FIELD::LastPx, FIX::LastPx(fill.last_price()).getString() ); + + auto ts = fill.has_timestamp() ? fill.timestamp() : google::protobuf::Timestamp(); + //report.setField(FIX::FIELD::TransactTime, FIX::TransactTime(ts, true).getString()); + //report.setField(FIX::FIELD::TradeDate, FIX::TradeDate(ts.ToString("yyyyMMdd")); + report.setField(FIX::FIELD::TransactTime, google::protobuf::util::TimeUtil::ToString(ts)); + report.setField(FIX::FIELD::TradeDate, google::protobuf::util::TimeUtil::ToString(ts)); + + sec = resolve_execution_report_security(sec, report); + + if (native.exchange_order_id() != "") + report.setField(FIX::FIELD::SecondaryOrderID, FIX::SecondaryOrderID(native.exchange_order_id()).getString()); + + if (sec && (bts::admin::AdminServiceUtils::security_type(*sec) == bts::api::SECURITYTYPE_SPREAD || + bts::admin::AdminServiceUtils::security_type(*sec) == bts::api::SECURITYTYPE_SYNTHETIC) ) + { + if (fill.fill_kind() == bts::api::orderman::Fill::FILL_KIND_LEG) + report.setField(FIX::FIELD::MultiLegReportingType, FIX::MultiLegReportingType('2').getString()); + else + report.setField(FIX::FIELD::MultiLegReportingType, FIX::MultiLegReportingType('3').getString()); + } + return report; + } FIX44::ExecutionReport DropCopySession::build_order_status(const FIX::SessionID& sess, diff --git a/src/server/sparkd/fix/DropCopySession.h b/src/server/sparkd/fix/DropCopySession.h index 9cb400d76..0f077f74b 100644 --- a/src/server/sparkd/fix/DropCopySession.h +++ b/src/server/sparkd/fix/DropCopySession.h @@ -1,6 +1,7 @@ #pragma once #include "SessionBase.h" +#include "lib/md/SecurityPtr.h" #include #include @@ -18,6 +19,7 @@ namespace FIX44 } namespace bts { + namespace fix { class DropCopySession : public SessionBase @@ -35,18 +37,18 @@ public: void onMessage(const FIX44::OrderStatusRequest& m, const FIX::SessionID& s); void onMessage(const FIX44::SecurityDefinitionRequest& m, const FIX::SessionID& s); -protected: +protected: virtual void subscribe_fills_and_orders(const FIX::SessionID sessionID); - virtual void process_order_state(const bts::api::orderman::OrderState& state, uint& filled, uint leaves, double& avgprx, + virtual void process_order_state(const bts::api::orderman::OrderState& state, uint& filled, uint& leaves, double& avgprx, FIX::OrdStatus& fstatus, bts::api::orderman::NativeOrderState& native, const bts::api::orderman::Fill* fill = nullptr); - const bts::api::Security* resolve_execution_report_security(const bts::api::Security* sec, FIX44::ExecutionReport& report); + md::SecurityPtr resolve_execution_report_security(md::SecurityPtr sec, FIX44::ExecutionReport& report); virtual FIX44::ExecutionReport build_fill(const FIX::SessionID& sess, const bts::api::orderman::Fill& fill, bool change = false); virtual FIX44::ExecutionReport build_order_status(const FIX::SessionID& sess, const bts::api::orderman::OrderRecord& order, bool change = false); protected: bts::api::orderman::OrderService _orderservice; - std::unordered_map _order_cache; + std::unordered_map> _order_cache; }; }} diff --git a/src/server/sparkd/fix/SessionBase.cpp b/src/server/sparkd/fix/SessionBase.cpp index 0f9f63523..253ae439f 100644 --- a/src/server/sparkd/fix/SessionBase.cpp +++ b/src/server/sparkd/fix/SessionBase.cpp @@ -239,6 +239,7 @@ bts::api::Venue SessionBase::convert_exchange(FIX::SecurityExchange fixtype) FIX::OrdStatus SessionBase::translate_status(const bts::api::orderman::OrderState& state, bts::api::orderman::NativeOrderState* native) { + native->Clear(); if (state.has_market() && state.market().has_native_state() && state.market().native_state().native_status() != bts::api::orderman::NativeOrderStatus::NATIVE_ORDER_STATUS_UNACKNOWLEDGED) { *native = state.market().native_state(); From 4351d6e66a8b68426e338ed633c3d408ea79cf53 Mon Sep 17 00:00:00 2001 From: Kevin Darby Date: Fri, 27 Sep 2019 17:04:42 -0400 Subject: [PATCH 23/28] drop copy session code complete --- src/server/sparkd/fix/DropCopySession.cpp | 90 ++++++++++++++++++----- src/server/sparkd/fix/DropCopySession.h | 4 +- src/server/sparkd/fix/SessionBase.cpp | 31 +++++--- src/server/sparkd/fix/SessionBase.h | 12 ++- 4 files changed, 102 insertions(+), 35 deletions(-) diff --git a/src/server/sparkd/fix/DropCopySession.cpp b/src/server/sparkd/fix/DropCopySession.cpp index e171f832b..448bb20b2 100644 --- a/src/server/sparkd/fix/DropCopySession.cpp +++ b/src/server/sparkd/fix/DropCopySession.cpp @@ -66,13 +66,16 @@ void DropCopySession::fromApp(const FIX::Message &message,const FIX::SessionID & void DropCopySession::onMessage(const FIX44::OrderStatusRequest& req, const FIX::SessionID& s) { uint oid = atoi(req.getField(FIX::FIELD::OrderID).c_str()); - auto it = _order_cache.find(oid); - if(it != _order_cache.end()) + _order_cache.lock([&] (auto& order_cache) { - auto&& ostat = build_order_status(s, *it->second); - ostat.setField(FIX::FIELD::OrdStatusReqID, req.getField(FIX::FIELD::OrdStatusReqID)); - _router.send(ostat, s); - } + auto it = order_cache.find(oid); + if(it != order_cache.end()) + { + auto&& ostat = build_order_status(s, *it->second); + ostat.setField(FIX::FIELD::OrdStatusReqID, req.getField(FIX::FIELD::OrdStatusReqID)); + _router.send(ostat, s); + } + }); } void DropCopySession::onMessage(const FIX44::SecurityDefinitionRequest& req, const FIX::SessionID& s) @@ -132,13 +135,15 @@ void DropCopySession::subscribe_fills_and_orders(const FIX::SessionID sessionID) filtered_orders.subscribe([this, &sessionID](const auto& updatevec) { - std::lock_guard l(_lock); for(auto& update : updatevec) { for(auto& order : update.added()) { auto&& ostat = build_order_status(sessionID, *order); - _order_cache[order->key()] = order; + _order_cache.lock( [&order] (auto& order_cache) + { + order_cache[order->key()] = order; + }); _router.send(ostat, sessionID); } for(auto& order : update.changed()) @@ -177,7 +182,6 @@ void DropCopySession::subscribe_fills_and_orders(const FIX::SessionID sessionID) filtered_fills.subscribe([this, &sessionID](const auto& updatevec) { - std::lock_guard l(_lock); for(auto& update : updatevec) { for(auto& fill : update.added()) @@ -236,14 +240,18 @@ FIX44::ExecutionReport DropCopySession::build_fill(const FIX::SessionID& sess, FIX::OrdStatus status; uint filled = 0; uint leaves = 0; double prx = 0.0; api::orderman::NativeOrderState native; - auto orderit = _order_cache.find(fill.order_key()); - if(orderit != _order_cache.end()) + + _order_cache.lock([&] (auto& order_cache) { - const api::orderman::OrderRecord& order = *orderit->second; - process_order_state(order.state(), filled, leaves, prx, status, native); - if( ((double)order.state().quantity()) == fill.last_shares()) - exec = FIX::ExecType(FIX::ExecType_FILL); - } + auto orderit = order_cache.find(fill.order_key()); + if(orderit != order_cache.end()) + { + const api::orderman::OrderRecord& order = *orderit->second; + process_order_state(order.state(), filled, leaves, prx, status, native); + if( ((double)order.state().quantity()) == fill.last_shares()) + exec = FIX::ExecType(FIX::ExecType_FILL); + } + }); if (change) exec = FIX::ExecType(FIX::ExecType_TRADE_CORRECT); @@ -291,7 +299,55 @@ FIX44::ExecutionReport DropCopySession::build_fill(const FIX::SessionID& sess, FIX44::ExecutionReport DropCopySession::build_order_status(const FIX::SessionID& sess, const bts::api::orderman::OrderRecord& order, bool change ) { - return FIX44::ExecutionReport(); + auto exec = FIX::ExecType(FIX::ExecType_NEW); + _order_cache.lock( [&exec, &order] (auto& order_cache) + { + auto it = order_cache.find(order.key()); + if(it != order_cache.end()) + exec = FIX::ExecType(FIX::ExecType_ORDER_STATUS); + }); + + FIX::OrdStatus status; + uint filled = 0; uint leaves = 0; double prx = 0.0; + api::orderman::NativeOrderState native; + process_order_state(order.state(), filled, leaves, prx, status, native); + + auto sec = _router.lookup(order.def().security_key()); + FIX44::ExecutionReport report( + FIX::OrderID(std::to_string(order.key())), + FIX::ExecID("0"), + exec, + status, + FIX::Side(order.def().side() == bts::api::SIDE_BUY ? FIX::Side_BUY : FIX::Side_SELL), + FIX::LeavesQty(leaves), + FIX::CumQty(filled), + FIX::AvgPx(prx)); + + if(sec) + report.setField(FIX::Symbol(sec->symbol())); + report.setField(FIX::FIELD::Account, FIX::Account(order.def().account()).getString() ); + report.setField(FIX::FIELD::OrderQty, FIX::OrderQty(order.state().quantity()).getString() ); + report.setField(FIX::FIELD::Price, FIX::Price(order.state().price()).getString() ); + report.setField(FIX::FIELD::TimeInForce, FIX::TimeInForce((char)order.def().time_in_force()).getString() ); + auto ts = order.state().last_change(); + report.setField(FIX::FIELD::TransactTime, google::protobuf::util::TimeUtil::ToString(ts)); + + report.setField(FIX::FIELD::Text, FIX::Text(order.state().last_msg())); + sec = resolve_execution_report_security(sec, report); + if (native.exchange_order_id() != "") + { + report.setField(FIX::FIELD::OrdType, FIX::OrdType((char)native.native_type()).getString());; + report.setField(FIX::FIELD::SecondaryOrderID, FIX::SecondaryOrderID(native.exchange_order_id()).getString());; + } + //TODO Big race here, we need a correlation id of some sort + _fix_clorderids.lock([&order, &report] (auto& fix_clorderids) + { + auto fixit = fix_clorderids.find(order.key()); + if(fixit != fix_clorderids.end()) + report.setField(FIX::FIELD::ClOrdID, FIX::ClOrdID(fixit->second).getString()); + }); + return report; + } diff --git a/src/server/sparkd/fix/DropCopySession.h b/src/server/sparkd/fix/DropCopySession.h index 0f077f74b..9a100463e 100644 --- a/src/server/sparkd/fix/DropCopySession.h +++ b/src/server/sparkd/fix/DropCopySession.h @@ -48,7 +48,9 @@ protected: protected: bts::api::orderman::OrderService _orderservice; - std::unordered_map> _order_cache; + + utils::LockBox< std::unordered_map> > _order_cache; + utils::LockBox< std::unordered_map > _fix_clorderids; }; }} diff --git a/src/server/sparkd/fix/SessionBase.cpp b/src/server/sparkd/fix/SessionBase.cpp index 253ae439f..cfd562554 100644 --- a/src/server/sparkd/fix/SessionBase.cpp +++ b/src/server/sparkd/fix/SessionBase.cpp @@ -27,22 +27,25 @@ namespace fix { SessionBase::SessionBase(bts::api::ServiceContext& sc, IFixRouter& router, const FIX::SessionID& sess) : _authservice( sc.locate() ), _adminservice( sc.locate() ), - _admin_data(), - - _user_name(), - _token(), _router(router), _sess(sess), - _lock() + + _admin_data(), + _user_name(), + _token() { _adminobservable = _adminservice.subscribe_admin_data() | rxcpp::operators::map( [this](const auto& update) { - std::lock_guard l(_lock); bts_assert(update.all().size() == 1); - _admin_data = *update.all()[0]; - return std::shared_ptr(new AdminModelWrapper(_admin_data, _user_name) ); + + auto adata = _admin_data.lock( [&update] (auto& ad) + { + ad = *update.all()[0]; + return ad; + } ); + return std::shared_ptr(new AdminModelWrapper(adata, _user_name) ); //TODO RACE }); } @@ -293,7 +296,11 @@ FIX::OrdStatus SessionBase::translate_status(const bts::api::orderman::OrderStat uint SessionBase::lookup_account(const std::string& acct) { - auto a = admin::AdminServiceUtils::find_account(_admin_data, acct); + bts::api::admin::BTSAccount* a = nullptr; + _admin_data.lock( [&] (auto& ad) + { + a = admin::AdminServiceUtils::find_account(ad, acct); + }); if(a) return a->id(); else @@ -302,7 +309,11 @@ uint SessionBase::lookup_account(const std::string& acct) uint SessionBase::lookup_user(const std::string& user) { - auto u = admin::AdminServiceUtils::find_user(_admin_data, user); + bts::api::admin::BTSUser* u = nullptr; + _admin_data.lock( [&] (auto& ad) + { + u = admin::AdminServiceUtils::find_user(ad, user); + }); if(u) return u->id(); else diff --git a/src/server/sparkd/fix/SessionBase.h b/src/server/sparkd/fix/SessionBase.h index 771344929..14e8fcf3d 100644 --- a/src/server/sparkd/fix/SessionBase.h +++ b/src/server/sparkd/fix/SessionBase.h @@ -10,8 +10,8 @@ #include "lib/api/services/AdminService.client.pb.h" #include "lib/api/services/OrderService.pb.h" #include "lib/api/services/OrderService.client.pb.h" - #include "lib/domain_model/Security.pb.h" +#include "lib/utils/LockBox.h" #include @@ -72,15 +72,13 @@ protected: protected: bts::api::user::AuthService _authservice; bts::api::admin::AdminService _adminservice; - - bts::api::admin::AdminData _admin_data; rxcpp::observable> _adminobservable; - - std::string _user_name; - bts::api::AuthToken _token; IFixRouter& _router; const FIX::SessionID& _sess; - std::recursive_mutex _lock; + + utils::LockBox _admin_data; + std::string _user_name; + bts::api::AuthToken _token; }; }} From d078e73179c597ee092ce7c4cbbf407d09235a8d Mon Sep 17 00:00:00 2001 From: Kevin Darby Date: Fri, 27 Sep 2019 17:58:36 -0400 Subject: [PATCH 24/28] order session --- src/server/sparkd/fix/DropCopySession.cpp | 4 + src/server/sparkd/fix/FixInit.cpp | 11 +- src/server/sparkd/fix/FixRouter.cpp | 1 + src/server/sparkd/fix/IFixSession.h | 2 +- src/server/sparkd/fix/OrderSession.cpp | 161 ++++++++++++++++++++++ src/server/sparkd/fix/OrderSession.h | 27 ++++ 6 files changed, 199 insertions(+), 7 deletions(-) diff --git a/src/server/sparkd/fix/DropCopySession.cpp b/src/server/sparkd/fix/DropCopySession.cpp index 448bb20b2..95642701d 100644 --- a/src/server/sparkd/fix/DropCopySession.cpp +++ b/src/server/sparkd/fix/DropCopySession.cpp @@ -201,6 +201,7 @@ void DropCopySession::subscribe_fills_and_orders(const FIX::SessionID sessionID) void DropCopySession::process_order_state(const bts::api::orderman::OrderState& state, uint& filled, uint& leaves, double& avgprx, FIX::OrdStatus& fstatus, bts::api::orderman::NativeOrderState& native, const bts::api::orderman::Fill* fill) { + UNUSED(fill); filled = state.filled_quantity(); leaves = state.quantity() - filled; avgprx = state.avg_price();; @@ -236,6 +237,7 @@ md::SecurityPtr DropCopySession::resolve_execution_report_security(md::SecurityP FIX44::ExecutionReport DropCopySession::build_fill(const FIX::SessionID& sess, const bts::api::orderman::Fill& fill, bool change) { + UNUSED(sess); auto exec = FIX::ExecType(FIX::ExecType_PARTIAL_FILL); FIX::OrdStatus status; uint filled = 0; uint leaves = 0; double prx = 0.0; @@ -299,6 +301,8 @@ FIX44::ExecutionReport DropCopySession::build_fill(const FIX::SessionID& sess, FIX44::ExecutionReport DropCopySession::build_order_status(const FIX::SessionID& sess, const bts::api::orderman::OrderRecord& order, bool change ) { + UNUSED(sess); + UNUSED(change); auto exec = FIX::ExecType(FIX::ExecType_NEW); _order_cache.lock( [&exec, &order] (auto& order_cache) { diff --git a/src/server/sparkd/fix/FixInit.cpp b/src/server/sparkd/fix/FixInit.cpp index 27779b736..34a724122 100644 --- a/src/server/sparkd/fix/FixInit.cpp +++ b/src/server/sparkd/fix/FixInit.cpp @@ -30,12 +30,11 @@ int FixInit::start_acceptor(bts::api::ServiceContext& sc, md::MDClient& md, cons FIX::SessionSettings settings( str ); FixRouter application(md, [&](IFixRouter& router, const auto& id) - { - return std::shared_ptr(new DropCopySession(sc, router, id)); - // if(orders_allowed) - // return std::shared_ptr(new OrderSession(sc, router, id)); - // else - // return std::shared_ptr(new DropCopySession(sc, router, id)); + { + if(orders_allowed) + return std::shared_ptr(new OrderSession(sc, router, id)); + else + return std::shared_ptr(new DropCopySession(sc, router, id)); }); FIX::FileStoreFactory storeFactory( settings ); FIX::FileLogFactory logFactory( settings ); diff --git a/src/server/sparkd/fix/FixRouter.cpp b/src/server/sparkd/fix/FixRouter.cpp index d7a366b06..3b91c4142 100644 --- a/src/server/sparkd/fix/FixRouter.cpp +++ b/src/server/sparkd/fix/FixRouter.cpp @@ -82,6 +82,7 @@ void FixRouter::send_biz_reject(const FIX::SessionID sess, const std::string& te rej.setField(FIX::FIELD::RefSeqNum, refmessage.getHeader().getField(FIX::FIELD::MsgSeqNum)); rej.setField(FIX::FIELD::BusinessRejectReason, std::to_string(reason_code)); rej.setField(FIX::FIELD::Text, text); + send(rej, sess); } void FixRouter::fromAdmin(const FIX::Message& message, const FIX::SessionID& sessionID) diff --git a/src/server/sparkd/fix/IFixSession.h b/src/server/sparkd/fix/IFixSession.h index 8da871e19..2faff444b 100644 --- a/src/server/sparkd/fix/IFixSession.h +++ b/src/server/sparkd/fix/IFixSession.h @@ -4,7 +4,7 @@ GCC_DIAG_OFF("-Woverloaded-virtual") GCC_DIAG_OFF("-Wdeprecated") GCC_DIAG_OFF("-Wignored-qualifiers") -GCC_DIAG_OFF("-Wunused-parameter") +//GCC_DIAG_OFF("-Wunused-parameter") #include diff --git a/src/server/sparkd/fix/OrderSession.cpp b/src/server/sparkd/fix/OrderSession.cpp index e69de29bb..17d68dab6 100644 --- a/src/server/sparkd/fix/OrderSession.cpp +++ b/src/server/sparkd/fix/OrderSession.cpp @@ -0,0 +1,161 @@ +#include "OrderSession.h" +#include "FixRouter.h" + +#include "lib/api/service_helpers/AdminServiceUtils.h" +#include "lib/domain_model/Security.h" +#include "lib/logging/logging.h" +#include "lib/utils/bts_assert.h" +#include "lib/utils/helper_macros.h" + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + + +namespace bts { +namespace fix { + +OrderSession::OrderSession(bts::api::ServiceContext& sc, IFixRouter& rt, const FIX::SessionID& id) : + DropCopySession(sc, rt, id) +{ +} + +OrderSession::~OrderSession() +{ +} + +void OrderSession::fromApp(const FIX::Message &message,const FIX::SessionID &sessionID) + throw(FIX::FieldNotFound, FIX::IncorrectDataFormat, FIX::IncorrectTagValue, FIX::UnsupportedMessageType) +{ + bts_assert_msg(sessionID == _sess, "invalid session"); + auto mt = message.getHeader().getField(FIX::FIELD::MsgType); + if(mt == FIX44::OrderStatusRequest::MsgType() || + mt == FIX44::SecurityDefinitionRequest::MsgType() || + mt == FIX44::NewOrderSingle::MsgType() || + mt == FIX44::OrderCancelReplaceRequest::MsgType() || + mt == FIX44::OrderCancelRequest::MsgType() + ) + { + LOG(Fix, Info, "IN: {}", message.toString()); + crack(message, sessionID); + } + else + { + LOG(Fix, Info, "UNSUPPORTED IN: {}", message.toString()); + throw FIX::UnsupportedMessageType(); + } +} + + +void OrderSession::onMessage(const FIX44::OrderCancelRequest& cancel, const FIX::SessionID& s) +{ + auto id = cancel.getField(FIX::FIELD::OrderID); + uint key = 0; + try + { + key = atoi(id.c_str()); + } + catch(...) + { + throw FIX::IncorrectTagValue(FIX::FIELD::OrderID); + } + api::orderman::Cancel can; + can.set_order_key(key); + _orderservice.cancel_order(can, [&] (const auto& resp) + { + if(!resp.success() || resp.value()->error_code() != bts::api::orderman::ORDER_ERROR_OK) + { + send_cancel_reject(s, "Cancel Rejected: " + resp.value()->msg(), cancel); + } + }); +} + +void OrderSession::onMessage(const FIX44::OrderCancelReplaceRequest& replace, const FIX::SessionID& s) +{ + auto id = replace.getField(FIX::FIELD::OrderID); + uint key = 0; + try + { + key = atoi(id.c_str()); + } + catch(...) { throw FIX::IncorrectTagValue(FIX::FIELD::OrderID); } + double price = 0.0; + try + { + price = atof(replace.getField(FIX::FIELD::Price).c_str()); + } + catch(...) { throw FIX::IncorrectTagValue(FIX::FIELD::Price); } + uint sz = 0; + try + { + sz = (uint) abs( atoi (replace.getField(FIX::FIELD::OrderQty).c_str()) ); + } + catch(...) { throw FIX::IncorrectTagValue(FIX::FIELD::OrderQty); } + api::orderman::Update upd; + upd.set_order_key(key); + upd.set_price(price); + upd.set_quantity(sz); + _orderservice.update_order(upd, [&] (const auto& resp) + { + if(!resp.success() || resp.value()->error_code() != bts::api::orderman::ORDER_ERROR_OK) + { + send_cancel_reject(s, "Cancel Rejected: " + resp.value()->msg(), replace); + } + }); +} + +void OrderSession::onMessage(const FIX44::NewOrderSingle& create, const FIX::SessionID& s) +{ + UNUSED(create); + UNUSED(s); +} + +void OrderSession::set_ordertype(api::orderman::OrderDefinition& def, const FIX44::NewOrderSingle& req, bool& price_req) +{ + price_req = false; + auto ot = req.getField(FIX::FIELD::OrdType); + if(ot == "1") + { + def.mutable_custom_def()->mutable_market(); + } + else if(ot == "2") + { + def.mutable_custom_def()->mutable_limit(); + } + else if(ot == "3") + { + auto s = def.mutable_custom_def()->mutable_stop(); + double stoppx = 0.0; + try + { + stoppx = atof(req.getField(FIX::FIELD::StopPx).c_str()); + } + catch(...) { throw FIX::IncorrectTagValue(FIX::FIELD::StopPx); } + s->set_stop_price(stoppx); + } + else if(ot == "4") + { + auto s = def.mutable_custom_def()->mutable_stop_limit(); + double stoppx = 0.0; + try + { + stoppx = atof(req.getField(FIX::FIELD::StopPx).c_str()); + } + catch(...) { throw FIX::IncorrectTagValue(FIX::FIELD::StopPx); } + s->set_stop_price(stoppx); + } + else + throw FIX::IncorrectTagValue(FIX::FIELD::OrdType); +} + + +}} + diff --git a/src/server/sparkd/fix/OrderSession.h b/src/server/sparkd/fix/OrderSession.h index e69de29bb..ab1275797 100644 --- a/src/server/sparkd/fix/OrderSession.h +++ b/src/server/sparkd/fix/OrderSession.h @@ -0,0 +1,27 @@ +#pragma once + +#include "DropCopySession.h" + +namespace bts { +namespace fix { + +class OrderSession : public DropCopySession +{ +public: + OrderSession(bts::api::ServiceContext&, IFixRouter&, const FIX::SessionID&); + virtual ~OrderSession(); + + void fromApp(const FIX::Message &message,const FIX::SessionID &sessionID) + throw(FIX::FieldNotFound, FIX::IncorrectDataFormat, FIX::IncorrectTagValue, FIX::UnsupportedMessageType); + + void onMessage(const FIX44::OrderCancelRequest& cancel, const FIX::SessionID& s); + void onMessage(const FIX44::OrderCancelReplaceRequest& replace, const FIX::SessionID& s); + void onMessage(const FIX44::NewOrderSingle& create, const FIX::SessionID& s); + +protected: + void set_ordertype(api::orderman::OrderDefinition& def, const FIX44::NewOrderSingle& req, bool& price_req); + +}; + +}} + From a8e9d0d7d8a30901a5bcb0e7fc70ed18785b0a17 Mon Sep 17 00:00:00 2001 From: Kevin Darby Date: Fri, 27 Sep 2019 18:21:35 -0400 Subject: [PATCH 25/28] ordersession and dropcopy session code complete for native orders, time to debug --- src/server/sparkd/fix/OrderSession.cpp | 59 ++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/src/server/sparkd/fix/OrderSession.cpp b/src/server/sparkd/fix/OrderSession.cpp index 17d68dab6..8f8b44d0c 100644 --- a/src/server/sparkd/fix/OrderSession.cpp +++ b/src/server/sparkd/fix/OrderSession.cpp @@ -116,6 +116,65 @@ void OrderSession::onMessage(const FIX44::NewOrderSingle& create, const FIX::Ses { UNUSED(create); UNUSED(s); + + api::Venue ven = convert_exchange(FIX::SecurityExchange(create.getField(FIX::FIELD::SecurityExchange))); + if (ven == bts::api::VENUE_UNSET) + throw FIX::IncorrectTagValue(FIX::FIELD::SecurityExchange); + + auto sec = _router.lookup(create.getField(FIX::FIELD::Symbol)); + if (!sec) + sec = _router.lookup(create.getField(FIX::FIELD::SecurityDesc)); + if (!sec) + throw FIX::IncorrectTagValue(FIX::FIELD::SecurityDesc); + + api::orderman::OrderDefinition def; + try + { + std::string manual = "Y"; + if(create.isSetField(FIX::FIELD::ManualOrderIndicator)) + manual = create.getField(FIX::FIELD::ManualOrderIndicator); + def.set_account(create.getField(FIX::FIELD::Account)); + def.set_account_id(lookup_account(def.account())); + def.set_security_key(sec->id()); + def.set_side(create.getField(FIX::FIELD::Side) == "1" ? api::SIDE_BUY : api::SIDE_SELL); + def.set_user(_user_name); + def.set_user_id(lookup_user(_user_name)); + def.set_manual_order_indicator(manual == "Y" ? bts::api::orderman::MANUAL_ORDER_INDICATOR_YES : bts::api::orderman::MANUAL_ORDER_INDICATOR_NO); + def.set_time_in_force( (api::orderman::TimeInForce) int(create.getField(FIX::FIELD::TimeInForce)[0] ) ); + } + catch(...) + { + throw FIX::IncorrectTagValue(FIX::FIELD::TimeInForce); + } + + bool price_req = false; + set_ordertype(def, create, price_req); + api::orderman::Create cr; + cr.mutable_new_order()->CopyFrom(def); + try + { + if (price_req) + cr.set_price( atof( create.getField(FIX::FIELD::Price).c_str() ) );; + } + catch(...) + { + throw FIX::IncorrectTagValue(FIX::FIELD::Price); + } + try + { + cr.set_quantity( (uint) abs(atoi( create.getField(FIX::FIELD::OrderQty).c_str() )) ); + } + catch(...) + { + throw FIX::IncorrectTagValue(FIX::FIELD::OrderQty); + } + _orderservice.create_order(cr, [&] (const auto& resp) + { + if(!resp.success() || resp.value()->error_code() != bts::api::orderman::ORDER_ERROR_OK) + { + _router.send_biz_reject(s, "Order Rejected: " + resp.value()->msg(), create); + } + }); } void OrderSession::set_ordertype(api::orderman::OrderDefinition& def, const FIX44::NewOrderSingle& req, bool& price_req) From 95c589f5948945a9a28d8edd1544c7a6f0faa0e2 Mon Sep 17 00:00:00 2001 From: Kevin Darby Date: Mon, 30 Sep 2019 15:00:30 -0400 Subject: [PATCH 26/28] hooking up to run this fix server --- src/data_files/files/fix/spark_fix.cfg | 41 + src/data_files/files/fix/spec/fix/FIX40.xml | 828 ++ src/data_files/files/fix/spec/fix/FIX41.xml | 1239 ++ src/data_files/files/fix/spec/fix/FIX42.xml | 2623 ++++ src/data_files/files/fix/spec/fix/FIX43.xml | 3996 ++++++ src/data_files/files/fix/spec/fix/FIX44.xml | 6783 ++++++++++ src/data_files/files/fix/spec/fix/FIX50.xml | 8272 ++++++++++++ .../files/fix/spec/fix/FIX50SP1.xml | 9629 ++++++++++++++ .../files/fix/spec/fix/FIX50SP2.xml | 10541 ++++++++++++++++ src/data_files/files/fix/spec/fix/FIXT11.xml | 313 + src/lib/CMakeDeps_win.cmake | 2 +- src/lib/CMakeLists.txt | 2 +- src/lib/config/defaults/fix.conf | 7 + src/lib/config/protos/fix.proto | 8 + src/lib/md/HandleIndex.h | 3 +- src/server/sparkd/cmds/Run.cpp | 7 +- src/server/sparkd/cmds/RunFix.cpp | 40 + src/server/sparkd/cmds/RunFix.h | 17 + src/server/sparkd/fix/FixInit.cpp | 30 +- src/server/sparkd/fix/FixInit.h | 2 +- src/server/sparkd/main.cpp | 2 + 21 files changed, 44377 insertions(+), 8 deletions(-) create mode 100644 src/data_files/files/fix/spark_fix.cfg create mode 100644 src/data_files/files/fix/spec/fix/FIX40.xml create mode 100644 src/data_files/files/fix/spec/fix/FIX41.xml create mode 100644 src/data_files/files/fix/spec/fix/FIX42.xml create mode 100644 src/data_files/files/fix/spec/fix/FIX43.xml create mode 100644 src/data_files/files/fix/spec/fix/FIX44.xml create mode 100644 src/data_files/files/fix/spec/fix/FIX50.xml create mode 100644 src/data_files/files/fix/spec/fix/FIX50SP1.xml create mode 100644 src/data_files/files/fix/spec/fix/FIX50SP2.xml create mode 100644 src/data_files/files/fix/spec/fix/FIXT11.xml create mode 100644 src/lib/config/defaults/fix.conf create mode 100644 src/lib/config/protos/fix.proto create mode 100644 src/server/sparkd/cmds/RunFix.cpp create mode 100644 src/server/sparkd/cmds/RunFix.h diff --git a/src/data_files/files/fix/spark_fix.cfg b/src/data_files/files/fix/spark_fix.cfg new file mode 100644 index 000000000..92cc433ef --- /dev/null +++ b/src/data_files/files/fix/spark_fix.cfg @@ -0,0 +1,41 @@ +#http://www.quickfixengine.org/quickfix/doc/html/configuration.html +#https://www.onixs.biz/fix-dictionary.html + +[DEFAULT] +ConnectionType=acceptor +SocketAcceptPort=5001 +SocketReuseAddress=Y +StartTime=00:00:00 +EndTime=00:00:00 +UseDataDictionary=Y +ResetOnLogon=Y +ResetOnLogout=Y +ResetOnDisconnect=Y +HeartBtInt=30 +LogonTimeout=30 +FileLogPath=./fix/log/ +FileStorePath=./fix/store/ + +SSLEnable=N +# SSLEnable=Y +# # It is recommended to install the certificate and refer to it by name instead of using filename + password +# SSLCertificate=QuickFixn-TestServer.pfx +# SSLCertificatePassword=QuickFixn-TestServer +# # For production refer to certificate by name instead: SSLCertificate=CN=QuickFixn-TestServer +# SSLCACertificate=QuickFixn-TestCA.cer +# SSLCheckCertificateRevocation=N + + +[SESSION] +BeginString=FIX.4.4 +SenderCompID=SPARK +TargetCompID=CLIENT1 +DataDictionary=data_files/fix/spec/fix/FIX44.xml + +[SESSION] +BeginString=FIX.4.4 +SenderCompID=SPARK +TargetCompID=CLIENT2 +DataDictionary=data_files/fix/spec/fix/FIX44.xml + + diff --git a/src/data_files/files/fix/spec/fix/FIX40.xml b/src/data_files/files/fix/spec/fix/FIX40.xml new file mode 100644 index 000000000..08bd0e7d9 --- /dev/null +++ b/src/data_files/files/fix/spec/fix/FIX40.xml @@ -0,0 +1,828 @@ + +
+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/data_files/files/fix/spec/fix/FIX41.xml b/src/data_files/files/fix/spec/fix/FIX41.xml new file mode 100644 index 000000000..d1d470eb1 --- /dev/null +++ b/src/data_files/files/fix/spec/fix/FIX41.xml @@ -0,0 +1,1239 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/data_files/files/fix/spec/fix/FIX42.xml b/src/data_files/files/fix/spec/fix/FIX42.xml new file mode 100644 index 000000000..d209e06d4 --- /dev/null +++ b/src/data_files/files/fix/spec/fix/FIX42.xml @@ -0,0 +1,2623 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/data_files/files/fix/spec/fix/FIX43.xml b/src/data_files/files/fix/spec/fix/FIX43.xml new file mode 100644 index 000000000..208187f50 --- /dev/null +++ b/src/data_files/files/fix/spec/fix/FIX43.xml @@ -0,0 +1,3996 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/data_files/files/fix/spec/fix/FIX44.xml b/src/data_files/files/fix/spec/fix/FIX44.xml new file mode 100644 index 000000000..69b89c401 --- /dev/null +++ b/src/data_files/files/fix/spec/fix/FIX44.xml @@ -0,0 +1,6783 @@ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/data_files/files/fix/spec/fix/FIX50.xml b/src/data_files/files/fix/spec/fix/FIX50.xml new file mode 100644 index 000000000..b4d5d5a8c --- /dev/null +++ b/src/data_files/files/fix/spec/fix/FIX50.xml @@ -0,0 +1,8272 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/data_files/files/fix/spec/fix/FIX50SP1.xml b/src/data_files/files/fix/spec/fix/FIX50SP1.xml new file mode 100644 index 000000000..6bde1468d --- /dev/null +++ b/src/data_files/files/fix/spec/fix/FIX50SP1.xml @@ -0,0 +1,9629 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/data_files/files/fix/spec/fix/FIX50SP2.xml b/src/data_files/files/fix/spec/fix/FIX50SP2.xml new file mode 100644 index 000000000..a97e87583 --- /dev/null +++ b/src/data_files/files/fix/spec/fix/FIX50SP2.xml @@ -0,0 +1,10541 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/data_files/files/fix/spec/fix/FIXT11.xml b/src/data_files/files/fix/spec/fix/FIXT11.xml new file mode 100644 index 000000000..15054a8a2 --- /dev/null +++ b/src/data_files/files/fix/spec/fix/FIXT11.xml @@ -0,0 +1,313 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/lib/CMakeDeps_win.cmake b/src/lib/CMakeDeps_win.cmake index 2c14978ea..ebc9c46fc 100644 --- a/src/lib/CMakeDeps_win.cmake +++ b/src/lib/CMakeDeps_win.cmake @@ -1 +1 @@ -set(sources api/apicore.proto;api/apigateway.proto;api/apioptions.proto;api/core/ApiClientInterop.cpp;api/core/ApiServerInterop.cpp;api/public/ApiServer.cpp;api/public/ClientChannel.cpp;api/public/QuickbusClientChannel.cpp;api/public/ServerChannel.cpp;api/public/ServiceContext.cpp;api/service_helpers/AdminServiceUtils.cpp;api/service_helpers/AlgoServiceUtils.cpp;api/service_helpers/PositionUtilities.cpp;api/services/AdminService.proto;api/services/AlgoDefinitionService.proto;api/services/AlgoService.proto;api/services/ApiUnitTestService.proto;api/services/AuthService.proto;api/services/BasePositionService.proto;api/services/ErrorReportService.proto;api/services/HelloService.proto;api/services/MBOService.proto;api/services/MarginService.proto;api/services/MarketDataAuxiliaryService.proto;api/services/MarketDataRelay.proto;api/services/MoneyFileService.proto;api/services/OrderService.proto;api/services/OutOfProcessURLListener.proto;api/services/PersistenceService.proto;api/services/PositionService.proto;api/services/ShellDiagnosticService.proto;api/services/ShellLatencyService.proto;api/services/SyntheticSecurityService.proto;api/test/ApiTests.cpp;api/test/HelloServiceServer.cpp;config/ConfigCheck.cpp;config/ConfigDownloader.cpp;config/ConfigErrorCollector.cpp;config/ConfigLog.cpp;config/ConfigPropertyEvaluator.cpp;config/ConfigValueQueue.cpp;config/ConfigurationException.cpp;config/ConfigurationState.cpp;config/PreprocessInputStream.cpp;config/config.cpp;config/defaults/MarketData.conf;config/defaults/Ports.conf;config/defaults/Symbols.conf;config/defaults/cme_reference_data.conf;config/defaults/edge.conf;config/defaults/jetfix.conf;config/defaults/keycode.conf;config/defaults/logging.conf;config/defaults/orderman_cfg.conf;config/defaults/orders_fills_cleanup.conf;config/defaults/position_cfg.conf;config/defaults/span.conf;config/defaults/spreader.conf;config/defaults/testkeys.conf;config/defaults/threads.conf;config/defaults/toggles.conf;config/extensions/extensions.proto;config/invalid/invalid.proto;config/protos/ExchangeSimCfg.proto;config/protos/MarketData.proto;config/protos/Ports.proto;config/protos/Symbols.proto;config/protos/UI.proto;config/protos/cme_reference_data.proto;config/protos/jetfix.proto;config/protos/keycode.proto;config/protos/logging.proto;config/protos/mercury_cfg.proto;config/protos/orderman_cfg.proto;config/protos/orders_fills_cleanup.proto;config/protos/perflog_cfg.proto;config/protos/position_cfg.proto;config/protos/quickbus_cfg.proto;config/protos/span.proto;config/protos/spreader.proto;config/protos/system.proto;config/protos/testkeys.proto;config/protos/threads.proto;config/protos/toggles.proto;config/tests/HTTPServer.cpp;config/tests/config_ref_tests.cpp;config/tests/config_tests.cpp;config/text_format/text_format.cpp;domain_model/Security.cpp;domain_model/Security.proto;domain_model/SecurityTests.cpp;domain_model/sod.cpp;domain_model/tests/domain_tests.cpp;expression/BooleanGrammar.cpp;expression/ExpressionEvaluator.cpp;expression/ParserExceptions.cpp;expression/Value.cpp;expression/tests/expression_parser_tests.cpp;logging/LoggerHub.cpp;logging/Sink.cpp;logging/logging.cpp;logging/tests/logging_tests.cpp;md/Diag/MDPeriodicDumper.cpp;md/Diag/ShmDumper.cpp;md/MBOProcessor.cpp;md/MBOServiceServer.cpp;md/MDClient.cpp;md/MDConsumer.cpp;md/MDConsumerHandle.cpp;md/MDConsumerInterop.cpp;md/MDProducer.cpp;md/MDProducerHandle.cpp;md/MemorySegmentUtils.cpp;md/PlatformLoader.cpp;md/PriceSize.cpp;md/SecurityCache.cpp;md/SecurityDB.cpp;md/SecurityIDRecorder.cpp;md/SecurityMapper.cpp;md/SecurityOracle.cpp;md/SettlementRecorder.cpp;md/Shm/FixedSecurity.cpp;md/SyntheticSecurityService.cpp;md/cme/MDP3Utils.cpp;md/common.cpp;md/ice/ICEUtils.cpp;md/protos/co2.proto;md/relay/QueryServer.cpp;md/relay/RelayClient.cpp;md/relay/RelayRecorder.cpp;md/test/Co2ManagedTestHelper.cpp;md/test/Co2TestInstrument.cpp;md/test/mbo_tests.cpp;md/test/md2_tests.cpp;md/test/md_test_utils.cpp;md/test/synthetic_book_merge_tests.cpp;md/vendor/OnixsUtils.cpp;os/os.cpp;os/tests/os_tests.cpp;quickbus/core/LocalNode.cpp;quickbus/core/Quickbus.cpp;quickbus/core/SubscriptionID.cpp;quickbus/core/TableID.cpp;quickbus/message_model/Update.cpp;quickbus/message_model/merge_updates.cpp;quickbus/network/QBConnection.cpp;quickbus/network/QBConnectionManager.cpp;quickbus/network/endpoint_description.cpp;quickbus/network/quickbus_msgs.proto;quickbus/pubsub/TablePublisher.cpp;quickbus/pubsub/TableSubscriber.cpp;quickbus/pubsub/tests/qb_pubsub_tests.cpp;quickbus/routing/INode.cpp;quickbus/routing/NodeID.cpp;quickbus/routing/Router.cpp;quickbus/rpc/RPCClient.cpp;quickbus/rpc/RPCServer.cpp;quickbus/rpc/RPCSessionID.cpp;quickbus/rpc/rpc_utils.cpp;quickbus/rpc/tests/qb_rpc_tests.cpp;quickbus/tests/quickbus_tests.cpp;sparkproto/SparkProtos.proto;testing/catch_test_runner.cpp;utils/AuthSessionManager.cpp;utils/AuthToken.cpp;utils/Dispatcher.cpp;utils/GrowableSPSCQueue.cpp;utils/HTTPStream.cpp;utils/PBUtils.cpp;utils/Puid.cpp;utils/SecureLogon.cpp;utils/SharedMemory.cpp;utils/Sqlite_utils.cpp;utils/Uuid.cpp;utils/crypto/CipherType.cpp;utils/crypto/CryptoInit.cpp;utils/crypto/Digest.cpp;utils/crypto/KeyCodeHelper.cpp;utils/crypto/PasswordCallback.cpp;utils/crypto/PrivateKey.cpp;utils/crypto/PublicKey.cpp;utils/crypto/iostreambio.cpp;utils/datetime.cpp;utils/download.cpp;utils/file_utils.cpp;utils/init_spark_lib.cpp;utils/is_unittest_environment.cpp;utils/sftp.cpp;utils/stats.cpp;utils/tests/AuthTokenTests.cpp;utils/tests/SingleWriterConcurrentVectorTests.cpp;utils/thread_manager.cpp) \ No newline at end of file +set(sources api/apicore.proto;api/apigateway.proto;api/apioptions.proto;api/core/ApiClientInterop.cpp;api/core/ApiServerInterop.cpp;api/public/ApiServer.cpp;api/public/ClientChannel.cpp;api/public/QuickbusClientChannel.cpp;api/public/ServerChannel.cpp;api/public/ServiceContext.cpp;api/service_helpers/AdminServiceUtils.cpp;api/service_helpers/AlgoServiceUtils.cpp;api/service_helpers/PositionUtilities.cpp;api/services/AdminService.proto;api/services/AlgoDefinitionService.proto;api/services/AlgoService.proto;api/services/ApiUnitTestService.proto;api/services/AuthService.proto;api/services/BasePositionService.proto;api/services/ErrorReportService.proto;api/services/HelloService.proto;api/services/MBOService.proto;api/services/MarginService.proto;api/services/MarketDataAuxiliaryService.proto;api/services/MarketDataRelay.proto;api/services/MoneyFileService.proto;api/services/OrderService.proto;api/services/OutOfProcessURLListener.proto;api/services/PersistenceService.proto;api/services/PositionService.proto;api/services/ShellDiagnosticService.proto;api/services/ShellLatencyService.proto;api/services/SyntheticSecurityService.proto;api/test/ApiTests.cpp;api/test/HelloServiceServer.cpp;config/ConfigCheck.cpp;config/ConfigDownloader.cpp;config/ConfigErrorCollector.cpp;config/ConfigLog.cpp;config/ConfigPropertyEvaluator.cpp;config/ConfigValueQueue.cpp;config/ConfigurationException.cpp;config/ConfigurationState.cpp;config/PreprocessInputStream.cpp;config/config.cpp;config/defaults/MarketData.conf;config/defaults/Ports.conf;config/defaults/Symbols.conf;config/defaults/cme_reference_data.conf;config/defaults/edge.conf;config/defaults/fix.conf;config/defaults/jetfix.conf;config/defaults/keycode.conf;config/defaults/logging.conf;config/defaults/orderman_cfg.conf;config/defaults/orders_fills_cleanup.conf;config/defaults/position_cfg.conf;config/defaults/span.conf;config/defaults/spreader.conf;config/defaults/testkeys.conf;config/defaults/threads.conf;config/defaults/toggles.conf;config/extensions/extensions.proto;config/invalid/invalid.proto;config/protos/ExchangeSimCfg.proto;config/protos/MarketData.proto;config/protos/Ports.proto;config/protos/Symbols.proto;config/protos/UI.proto;config/protos/cme_reference_data.proto;config/protos/fix.proto;config/protos/jetfix.proto;config/protos/keycode.proto;config/protos/logging.proto;config/protos/mercury_cfg.proto;config/protos/orderman_cfg.proto;config/protos/orders_fills_cleanup.proto;config/protos/perflog_cfg.proto;config/protos/position_cfg.proto;config/protos/quickbus_cfg.proto;config/protos/span.proto;config/protos/spreader.proto;config/protos/system.proto;config/protos/testkeys.proto;config/protos/threads.proto;config/protos/toggles.proto;config/tests/HTTPServer.cpp;config/tests/config_ref_tests.cpp;config/tests/config_tests.cpp;config/text_format/text_format.cpp;domain_model/Security.cpp;domain_model/Security.proto;domain_model/SecurityTests.cpp;domain_model/sod.cpp;domain_model/tests/domain_tests.cpp;expression/BooleanGrammar.cpp;expression/ExpressionEvaluator.cpp;expression/ParserExceptions.cpp;expression/Value.cpp;expression/tests/expression_parser_tests.cpp;logging/LoggerHub.cpp;logging/Sink.cpp;logging/logging.cpp;logging/tests/logging_tests.cpp;md/Diag/MDPeriodicDumper.cpp;md/Diag/ShmDumper.cpp;md/MBOProcessor.cpp;md/MBOServiceServer.cpp;md/MDClient.cpp;md/MDConsumer.cpp;md/MDConsumerHandle.cpp;md/MDConsumerInterop.cpp;md/MDProducer.cpp;md/MDProducerHandle.cpp;md/MemorySegmentUtils.cpp;md/PlatformLoader.cpp;md/PriceSize.cpp;md/SecurityCache.cpp;md/SecurityDB.cpp;md/SecurityIDRecorder.cpp;md/SecurityMapper.cpp;md/SecurityOracle.cpp;md/SettlementRecorder.cpp;md/Shm/FixedSecurity.cpp;md/SyntheticSecurityService.cpp;md/cme/MDP3Utils.cpp;md/common.cpp;md/ice/ICEUtils.cpp;md/protos/co2.proto;md/relay/QueryServer.cpp;md/relay/RelayClient.cpp;md/relay/RelayRecorder.cpp;md/test/Co2ManagedTestHelper.cpp;md/test/Co2TestInstrument.cpp;md/test/mbo_tests.cpp;md/test/md2_tests.cpp;md/test/md_test_utils.cpp;md/test/synthetic_book_merge_tests.cpp;md/vendor/OnixsUtils.cpp;os/os.cpp;os/tests/os_tests.cpp;quickbus/core/LocalNode.cpp;quickbus/core/Quickbus.cpp;quickbus/core/SubscriptionID.cpp;quickbus/core/TableID.cpp;quickbus/message_model/Update.cpp;quickbus/message_model/merge_updates.cpp;quickbus/network/QBConnection.cpp;quickbus/network/QBConnectionManager.cpp;quickbus/network/endpoint_description.cpp;quickbus/network/quickbus_msgs.proto;quickbus/pubsub/TablePublisher.cpp;quickbus/pubsub/TableSubscriber.cpp;quickbus/pubsub/tests/qb_pubsub_tests.cpp;quickbus/routing/INode.cpp;quickbus/routing/NodeID.cpp;quickbus/routing/Router.cpp;quickbus/rpc/RPCClient.cpp;quickbus/rpc/RPCServer.cpp;quickbus/rpc/RPCSessionID.cpp;quickbus/rpc/rpc_utils.cpp;quickbus/rpc/tests/qb_rpc_tests.cpp;quickbus/tests/quickbus_tests.cpp;sparkproto/SparkProtos.proto;testing/catch_test_runner.cpp;utils/AuthSessionManager.cpp;utils/AuthToken.cpp;utils/Dispatcher.cpp;utils/GrowableSPSCQueue.cpp;utils/HTTPStream.cpp;utils/PBUtils.cpp;utils/Puid.cpp;utils/SecureLogon.cpp;utils/SharedMemory.cpp;utils/Sqlite_utils.cpp;utils/Uuid.cpp;utils/crypto/CipherType.cpp;utils/crypto/CryptoInit.cpp;utils/crypto/Digest.cpp;utils/crypto/KeyCodeHelper.cpp;utils/crypto/PasswordCallback.cpp;utils/crypto/PrivateKey.cpp;utils/crypto/PublicKey.cpp;utils/crypto/iostreambio.cpp;utils/datetime.cpp;utils/download.cpp;utils/file_utils.cpp;utils/init_spark_lib.cpp;utils/is_unittest_environment.cpp;utils/sftp.cpp;utils/stats.cpp;utils/tests/AuthTokenTests.cpp;utils/tests/SingleWriterConcurrentVectorTests.cpp;utils/thread_manager.cpp) \ No newline at end of file diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index c255c0b57..00cf37f31 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -142,4 +142,4 @@ if (WIN32) include(${CMAKE_SOURCE_DIR}/tools/vs_filters.cmake) endif() - + \ No newline at end of file diff --git a/src/lib/config/defaults/fix.conf b/src/lib/config/defaults/fix.conf new file mode 100644 index 000000000..8c5e10626 --- /dev/null +++ b/src/lib/config/defaults/fix.conf @@ -0,0 +1,7 @@ + +Fix { + value { + allow_orders: true + fix_config_file: 'spark_fix.cfg' + } +} \ No newline at end of file diff --git a/src/lib/config/protos/fix.proto b/src/lib/config/protos/fix.proto new file mode 100644 index 000000000..c2225390d --- /dev/null +++ b/src/lib/config/protos/fix.proto @@ -0,0 +1,8 @@ +syntax='proto2'; + +package bts.config; + +message Fix { + optional bool allow_orders = 10 [default = false]; + optional string fix_config_file = 20; +} diff --git a/src/lib/md/HandleIndex.h b/src/lib/md/HandleIndex.h index c8656b9a9..7563929fe 100644 --- a/src/lib/md/HandleIndex.h +++ b/src/lib/md/HandleIndex.h @@ -20,7 +20,8 @@ namespace md { SecurityKey default_key(const MDConsumerHandle& h) { - return SecurityKey( h.key() ); + auto&& key = h.key(); + return SecurityKey( key ); } std::string desc_key(const MDConsumerHandle& h) diff --git a/src/server/sparkd/cmds/Run.cpp b/src/server/sparkd/cmds/Run.cpp index 1bbcbfa49..00c2fa0db 100644 --- a/src/server/sparkd/cmds/Run.cpp +++ b/src/server/sparkd/cmds/Run.cpp @@ -37,16 +37,18 @@ #include "server/sparkd/support/ShellLatencyServer.h" #include "server/sparkd/user/AdminServiceServer.h" #include "server/sparkd/user/AuthServiceServer.h" +#include "server/sparkd/fix/FixInit.h" #include "lib/orderman/orders/algo/algo_orders/ProRataAlgo.h" #include "lib/orderman/orders/algo/algo_orders/ScratchAlgo.h" #include +#include namespace bts { namespace cmd { -int Run::execute(std::vector const &) { +int Run::execute(std::vector const ¶ms) { using namespace bts; LOG(Gen, Warn, "------------------------------------ Sparkd launched " @@ -102,6 +104,9 @@ int Run::execute(std::vector const &) { position::MarginServiceServer margin_service(sc, mdclient); metrics::ShellLatencyServer shell_latency_service( sc, stats, utils::Dispatcher::background()); + + if(std::find(params.begin(), params.end(), "nofix") == params.end()) + fix::FixInit::start_acceptor(sc, mdclient); auto bg_health = std::make_shared("spark_background_thread"); diff --git a/src/server/sparkd/cmds/RunFix.cpp b/src/server/sparkd/cmds/RunFix.cpp new file mode 100644 index 000000000..549178bec --- /dev/null +++ b/src/server/sparkd/cmds/RunFix.cpp @@ -0,0 +1,40 @@ +#include "RunFix.h" +#include "server/sparkd/fix/FixInit.h" + +#include "lib/api/public/ServiceContext.h" +#include "lib/config/config.h" +#include "lib/config/protos/Ports.pb.h" +#include "lib/config/protos/quickbus_cfg.pb.h" +#include "lib/logging/logging.h" +#include "lib/os/os.h" +#include "lib/quickbus/quickbus.h" +#include "lib/utils/Dispatcher.h" + +#include "lib/config/protos/toggles.pb.h" +#include "lib/md/SyntheticSecurityService.h" +#include "lib/md/MDClient.h" + + +namespace bts { +namespace cmd { + +int RunFix::execute(std::vector const &) +{ + config::QuickbusNodeCfg qb_cfg; + auto &ports = config::get(); + qb_cfg.set_my_port(ports.qbus_port()); + qbus::Quickbus quickbus(qb_cfg, + qbus::Quickbus::ThreadOptions::deferred_start); + api::ServiceContext sc(&quickbus); + + api::synthetic::SyntheticSecurityService synthetic_service(sc); + md::MDClient mdclient(&utils::Dispatcher::background(), &synthetic_service); + + fix::FixInit::start_acceptor(sc, mdclient); + + return 0; +} + +std::string RunFix::help () {return "\t run fix acceptor";} + +}} diff --git a/src/server/sparkd/cmds/RunFix.h b/src/server/sparkd/cmds/RunFix.h new file mode 100644 index 000000000..b4b8a1f16 --- /dev/null +++ b/src/server/sparkd/cmds/RunFix.h @@ -0,0 +1,17 @@ +#pragma once + +#include "ICmd.h" + +namespace bts { +namespace cmd { + +class RunFix : public ICmd +{ +public: + int execute(std::vector const &args); + std::string help (); +}; + +}} + + diff --git a/src/server/sparkd/fix/FixInit.cpp b/src/server/sparkd/fix/FixInit.cpp index 34a724122..2b3c5ab9a 100644 --- a/src/server/sparkd/fix/FixInit.cpp +++ b/src/server/sparkd/fix/FixInit.cpp @@ -4,6 +4,14 @@ #include "FixRouter.h" #include "OrderSession.h" #include "DropCopySession.h" +#include "lib/config/config.h" +#include "lib/config/protos/fix.pb.h" +#include "lib/os/os.h" +#include "lib/utils/bts_assert.h" +#include "lib/utils/bts_chrono.h" +#include "lib/config/protos/logging.pb.h" +#include "lib/utils/file_utils.h" +#include "lib/utils/helper_macros.h" #include #include @@ -23,11 +31,27 @@ namespace bts { namespace fix { - -int FixInit::start_acceptor(bts::api::ServiceContext& sc, md::MDClient& md, const std::string& settings_file, bool orders_allowed) + +boost::filesystem::path fix_path () { + auto store_root = os::bts_data_path(); + std::string base_path = store_root; + boost::filesystem::path result = utils::normalize_data_path (base_path); + result /= "fix"; + return result; +} + +int FixInit::start_acceptor(bts::api::ServiceContext& sc, md::MDClient& md) +{ + std::string settings_file = os::sparkd_wd() + "/data_files/fix/"; + settings_file += config::get().fix_config_file(); + bool orders_allowed = config::get().allow_orders(); + std::ifstream str{settings_file}; FIX::SessionSettings settings( str ); + auto sess = settings.getSessions(); + int scount = sess.size(); + UNUSED(scount); FixRouter application(md, [&](IFixRouter& router, const auto& id) { @@ -35,7 +59,7 @@ int FixInit::start_acceptor(bts::api::ServiceContext& sc, md::MDClient& md, cons return std::shared_ptr(new OrderSession(sc, router, id)); else return std::shared_ptr(new DropCopySession(sc, router, id)); - }); + }); FIX::FileStoreFactory storeFactory( settings ); FIX::FileLogFactory logFactory( settings ); FIX::SocketAcceptor acceptor( application, storeFactory, settings, logFactory ); diff --git a/src/server/sparkd/fix/FixInit.h b/src/server/sparkd/fix/FixInit.h index 93401429f..2475c6f86 100644 --- a/src/server/sparkd/fix/FixInit.h +++ b/src/server/sparkd/fix/FixInit.h @@ -10,7 +10,7 @@ namespace fix { class FixInit { public: - static int start_acceptor(bts::api::ServiceContext& sc, md::MDClient& md, const std::string& settings_file, bool orders_allowed); + static int start_acceptor(bts::api::ServiceContext& sc, md::MDClient& md); }; }} \ No newline at end of file diff --git a/src/server/sparkd/main.cpp b/src/server/sparkd/main.cpp index 4e50a071c..20be7b634 100644 --- a/src/server/sparkd/main.cpp +++ b/src/server/sparkd/main.cpp @@ -16,6 +16,7 @@ #include "server/sparkd/cmds/QuickTest.h" #include "server/sparkd/cmds/Run.h" #include "server/sparkd/cmds/RunSim.h" +#include "server/sparkd/cmds/RunFix.h" #include "server/sparkd/cmds/Span.h" #include "server/sparkd/cmds/Test.h" #include "server/sparkd/cmds/TestCeloxica.h" @@ -35,6 +36,7 @@ int main(int argc, char **argv) { REGISTER(ConfigCheck); REGISTER(KeyCode); REGISTER(RunSim); + REGISTER(RunFix); REGISTER(Benchmark); REGISTER(QuickTest); REGISTER(AutoCert); From 6772c77e01323f5d06b971224d9810f54e7ec8e1 Mon Sep 17 00:00:00 2001 From: Kevin Darby Date: Mon, 7 Oct 2019 17:18:20 -0400 Subject: [PATCH 27/28] rudimentary fix orders seem to work --- src/data_files/files/fix/spark_fix.cfg | 8 ++-- src/lib/config/defaults/fix.conf | 1 + src/lib/config/protos/fix.proto | 1 + src/lib/md/HandleIndex.h | 17 ++++---- src/lib/md/MBOServiceServer.cpp | 4 +- src/server/sparkd/cmds/Run.cpp | 10 +++-- src/server/sparkd/cmds/RunFix.cpp | 5 ++- src/server/sparkd/fix/DropCopySession.cpp | 47 +++++++++++++++-------- src/server/sparkd/fix/DropCopySession.h | 7 +++- src/server/sparkd/fix/FixInit.cpp | 4 +- src/server/sparkd/fix/FixRouter.cpp | 28 ++++++++------ src/server/sparkd/fix/OrderSession.cpp | 18 ++++++--- src/server/sparkd/fix/SecurityIndex.cpp | 2 +- src/server/sparkd/fix/SessionBase.cpp | 25 ++++++++---- src/server/sparkd/fix/SessionBase.h | 2 +- 15 files changed, 116 insertions(+), 63 deletions(-) diff --git a/src/data_files/files/fix/spark_fix.cfg b/src/data_files/files/fix/spark_fix.cfg index 92cc433ef..6b4450867 100644 --- a/src/data_files/files/fix/spark_fix.cfg +++ b/src/data_files/files/fix/spark_fix.cfg @@ -13,8 +13,8 @@ ResetOnLogout=Y ResetOnDisconnect=Y HeartBtInt=30 LogonTimeout=30 -FileLogPath=./fix/log/ -FileStorePath=./fix/store/ +FileLogPath=data_files/fix/log/ +FileStorePath=data_files/fix/store/ SSLEnable=N # SSLEnable=Y @@ -28,13 +28,13 @@ SSLEnable=N [SESSION] BeginString=FIX.4.4 -SenderCompID=SPARK +SenderCompID=SPARKFIX TargetCompID=CLIENT1 DataDictionary=data_files/fix/spec/fix/FIX44.xml [SESSION] BeginString=FIX.4.4 -SenderCompID=SPARK +SenderCompID=SPARKFIX TargetCompID=CLIENT2 DataDictionary=data_files/fix/spec/fix/FIX44.xml diff --git a/src/lib/config/defaults/fix.conf b/src/lib/config/defaults/fix.conf index 8c5e10626..ff380bfba 100644 --- a/src/lib/config/defaults/fix.conf +++ b/src/lib/config/defaults/fix.conf @@ -1,6 +1,7 @@ Fix { value { + enable_acceptor: true allow_orders: true fix_config_file: 'spark_fix.cfg' } diff --git a/src/lib/config/protos/fix.proto b/src/lib/config/protos/fix.proto index c2225390d..024f22f2c 100644 --- a/src/lib/config/protos/fix.proto +++ b/src/lib/config/protos/fix.proto @@ -3,6 +3,7 @@ syntax='proto2'; package bts.config; message Fix { + optional bool enable_acceptor = 5 [default = false]; optional bool allow_orders = 10 [default = false]; optional string fix_config_file = 20; } diff --git a/src/lib/md/HandleIndex.h b/src/lib/md/HandleIndex.h index 7563929fe..61fb114d0 100644 --- a/src/lib/md/HandleIndex.h +++ b/src/lib/md/HandleIndex.h @@ -18,16 +18,17 @@ namespace bts { namespace md { -SecurityKey default_key(const MDConsumerHandle& h) +security_key default_key(const MDConsumerHandle& h) { auto&& key = h.key(); - return SecurityKey( key ); + return key; } std::string desc_key(const MDConsumerHandle& h) { - auto sec = h.get_normalized_security(); - return securities::descriptor(sec); + auto&& sec = h.get_normalized_security(); + auto&& desc = securities::descriptor(sec); + return desc; } template @@ -86,11 +87,13 @@ private: { handle_index.lock([this, handle](auto& index) { - index[ Key_Func(handle) ] = handle; + auto key = Key_Func(handle); + index[ key ] = handle; }); - security_index.lock([this, handle, sec](auto& index) + security_index.lock([this, handle, &sec](auto& index) { - index[ Key_Func(handle) ] = sec; + auto key = Key_Func(handle); + index[ key ] = sec; }); } }); diff --git a/src/lib/md/MBOServiceServer.cpp b/src/lib/md/MBOServiceServer.cpp index dc468f671..827fac229 100644 --- a/src/lib/md/MBOServiceServer.cpp +++ b/src/lib/md/MBOServiceServer.cpp @@ -118,7 +118,7 @@ std::optional search_orders(const ExchangeOrderKey oid, const std::vec bool update_position(const KeyHandleIndex& handles, ActiveOrder& order) { const auto& index = handles.handle_index; auto handle = index.lock([id=order.security_id()](const auto& index) { - auto iter = index.find(id); + auto iter = index.find(id.value()); return iter != index.end() ? iter->second : MDConsumerHandle {}; }); @@ -254,7 +254,7 @@ void MBOServiceServer::get_orders_for_security(const MBOSecurityQuery& request, PositionData response; response.set_security_id(request.security_id()); auto handle = _me->handle_index.handle_index.lock([id=request.security_id()](const auto& index) { - auto iter = index.find(SecurityKey(id)); + auto iter = index.find(id); return iter != index.end() ? iter->second : MDConsumerHandle {}; }); diff --git a/src/server/sparkd/cmds/Run.cpp b/src/server/sparkd/cmds/Run.cpp index 00c2fa0db..566fef69a 100644 --- a/src/server/sparkd/cmds/Run.cpp +++ b/src/server/sparkd/cmds/Run.cpp @@ -4,6 +4,7 @@ #include "lib/api/public/ServiceContext.h" #include "lib/config/config.h" #include "lib/config/protos/Ports.pb.h" +#include "lib/config/protos/fix.pb.h" #include "lib/config/protos/quickbus_cfg.pb.h" #include "lib/logging/logging.h" #include "lib/os/os.h" @@ -48,7 +49,7 @@ namespace bts { namespace cmd { -int Run::execute(std::vector const ¶ms) { +int Run::execute(std::vector const &) { using namespace bts; LOG(Gen, Warn, "------------------------------------ Sparkd launched " @@ -105,8 +106,11 @@ int Run::execute(std::vector const ¶ms) { metrics::ShellLatencyServer shell_latency_service( sc, stats, utils::Dispatcher::background()); - if(std::find(params.begin(), params.end(), "nofix") == params.end()) - fix::FixInit::start_acceptor(sc, mdclient); + if(config::get().enable_acceptor()) + { + threading::make_thread("SparkFix", [&sc, &mdclient]() { fix::FixInit::start_acceptor(sc, mdclient); }) + .detach(); + } auto bg_health = std::make_shared("spark_background_thread"); diff --git a/src/server/sparkd/cmds/RunFix.cpp b/src/server/sparkd/cmds/RunFix.cpp index 549178bec..b8073796e 100644 --- a/src/server/sparkd/cmds/RunFix.cpp +++ b/src/server/sparkd/cmds/RunFix.cpp @@ -9,6 +9,7 @@ #include "lib/os/os.h" #include "lib/quickbus/quickbus.h" #include "lib/utils/Dispatcher.h" +#include "lib/utils/thread_manager.h" #include "lib/config/protos/toggles.pb.h" #include "lib/md/SyntheticSecurityService.h" @@ -29,9 +30,9 @@ int RunFix::execute(std::vector const &) api::synthetic::SyntheticSecurityService synthetic_service(sc); md::MDClient mdclient(&utils::Dispatcher::background(), &synthetic_service); - - fix::FixInit::start_acceptor(sc, mdclient); + threading::make_thread("SparkFix", [&sc, &mdclient]() { fix::FixInit::start_acceptor(sc, mdclient); }) + .detach(); return 0; } diff --git a/src/server/sparkd/fix/DropCopySession.cpp b/src/server/sparkd/fix/DropCopySession.cpp index 95642701d..7ea15e14a 100644 --- a/src/server/sparkd/fix/DropCopySession.cpp +++ b/src/server/sparkd/fix/DropCopySession.cpp @@ -18,11 +18,21 @@ namespace bts { namespace fix { + +struct DropCopySession::PImpl +{ + rxcpp::observable filtered_orders; + rxcpp::observable filtered_fills; + PImpl() + { + } +}; DropCopySession::DropCopySession(bts::api::ServiceContext& sc, IFixRouter& rt, const FIX::SessionID& id) : - SessionBase(sc, rt, id), + SessionBase(sc, rt, id), _orderservice( sc.locate() ), - _order_cache() + _order_cache(), + me(new PImpl()) { } @@ -39,9 +49,11 @@ void DropCopySession::onLogon(const FIX::SessionID& sessionID) void DropCopySession::onLogout(const FIX::SessionID& sessionID) { + me->filtered_orders.finally([] () {} ); + me->filtered_fills.finally([] () {} ); + bts_assert(sessionID == _sess); LOG(Fix, Info, "Logged out {}", sessionID.toString()); - } void DropCopySession::fromApp(const FIX::Message &message,const FIX::SessionID &sessionID) @@ -107,7 +119,7 @@ void DropCopySession::subscribe_fills_and_orders(const FIX::SessionID sessionID) //var on_orders = _orderservice.Value.subscribei_orders().Naggle(interval, scheduler).PermissionFilter(_adminobservable).Table().Cache(); //var on_fills = _orderservice.Value.subscribei_fills().Naggle(interval, scheduler).PermissionFilter(_adminobservable).Table().Cache(); - auto&& filtered_orders = _adminobservable.combine_latest(_orderservice.subscribe_orders()) + me->filtered_orders = _adminobservable.combine_latest(_orderservice.subscribe_orders()) .map( [] (auto& tuple) -> auto { std::shared_ptr admin = std::get<0>(tuple); @@ -131,12 +143,13 @@ void DropCopySession::subscribe_fills_and_orders(const FIX::SessionID sessionID) bts::api::orderman::OrdersUpdate newupdate(all, added, changed, removed); return newupdate; - }).buffer_with_time( std::chrono::milliseconds(500) ); + }); + //.buffer_with_time( std::chrono::milliseconds(500) ); - filtered_orders.subscribe([this, &sessionID](const auto& updatevec) + me->filtered_orders.subscribe([this, sessionID](const auto& update) { - for(auto& update : updatevec) - { + // for(auto& update : updatevec) + // { for(auto& order : update.added()) { auto&& ostat = build_order_status(sessionID, *order); @@ -151,10 +164,10 @@ void DropCopySession::subscribe_fills_and_orders(const FIX::SessionID sessionID) auto&& ostat = build_order_status(sessionID, *order.current(), true); _router.send(ostat, sessionID); } - } + // } }); - auto&& filtered_fills = _adminobservable.combine_latest(_orderservice.subscribe_fills()) + me->filtered_fills = _adminobservable.combine_latest(_orderservice.subscribe_fills()) .map( [] (auto& tuple) -> auto { std::shared_ptr admin = std::get<0>(tuple); @@ -178,12 +191,13 @@ void DropCopySession::subscribe_fills_and_orders(const FIX::SessionID sessionID) bts::api::orderman::FillsUpdate newupdate(all, added, changed, removed); return newupdate; - }).buffer_with_time( std::chrono::milliseconds(500) ); + }); + //.buffer_with_time( std::chrono::milliseconds(500) ); - filtered_fills.subscribe([this, &sessionID](const auto& updatevec) + me->filtered_fills.subscribe([this, sessionID](const auto& update) { - for(auto& update : updatevec) - { + // for(auto& update : updatevec) + // { for(auto& fill : update.added()) { auto&& fi = build_fill(sessionID, *fill); @@ -194,7 +208,7 @@ void DropCopySession::subscribe_fills_and_orders(const FIX::SessionID sessionID) auto&& fi = build_fill(sessionID, *fill.current(), true); _router.send(fi, sessionID); } - } + // } }); } @@ -336,7 +350,8 @@ FIX44::ExecutionReport DropCopySession::build_order_status(const FIX::SessionID& auto ts = order.state().last_change(); report.setField(FIX::FIELD::TransactTime, google::protobuf::util::TimeUtil::ToString(ts)); - report.setField(FIX::FIELD::Text, FIX::Text(order.state().last_msg())); + if(order.state().last_msg() != "") + report.setField(FIX::FIELD::Text, FIX::Text(order.state().last_msg())); sec = resolve_execution_report_security(sec, report); if (native.exchange_order_id() != "") { diff --git a/src/server/sparkd/fix/DropCopySession.h b/src/server/sparkd/fix/DropCopySession.h index 9a100463e..1a5e5bfbb 100644 --- a/src/server/sparkd/fix/DropCopySession.h +++ b/src/server/sparkd/fix/DropCopySession.h @@ -46,11 +46,16 @@ protected: virtual FIX44::ExecutionReport build_fill(const FIX::SessionID& sess, const bts::api::orderman::Fill& fill, bool change = false); virtual FIX44::ExecutionReport build_order_status(const FIX::SessionID& sess, const bts::api::orderman::OrderRecord& order, bool change = false); -protected: +protected: bts::api::orderman::OrderService _orderservice; utils::LockBox< std::unordered_map> > _order_cache; utils::LockBox< std::unordered_map > _fix_clorderids; + +private: + struct PImpl; + std::shared_ptr me; + }; }} diff --git a/src/server/sparkd/fix/FixInit.cpp b/src/server/sparkd/fix/FixInit.cpp index 2b3c5ab9a..3465f271b 100644 --- a/src/server/sparkd/fix/FixInit.cpp +++ b/src/server/sparkd/fix/FixInit.cpp @@ -53,7 +53,7 @@ int FixInit::start_acceptor(bts::api::ServiceContext& sc, md::MDClient& md) int scount = sess.size(); UNUSED(scount); - FixRouter application(md, [&](IFixRouter& router, const auto& id) + FixRouter application(md, [&sc, orders_allowed](IFixRouter& router, const auto& id) { if(orders_allowed) return std::shared_ptr(new OrderSession(sc, router, id)); @@ -65,6 +65,8 @@ int FixInit::start_acceptor(bts::api::ServiceContext& sc, md::MDClient& md) FIX::SocketAcceptor acceptor( application, storeFactory, settings, logFactory ); acceptor.start(); + utils::Dispatcher::current().run(); + acceptor.stop(); return 0; } diff --git a/src/server/sparkd/fix/FixRouter.cpp b/src/server/sparkd/fix/FixRouter.cpp index 3b91c4142..3df80a461 100644 --- a/src/server/sparkd/fix/FixRouter.cpp +++ b/src/server/sparkd/fix/FixRouter.cpp @@ -3,6 +3,7 @@ #include "IFixSession.h" #include "SecurityIndex.h" #include "lib/md/MDConsumerHandle.h" +#include "lib/utils/LockBox.h" #include #include @@ -27,7 +28,7 @@ namespace fix struct FixRouter::PImpl { - boost::container::flat_map< FIX::SessionID, std::shared_ptr > sessions; + utils::LockBox< boost::container::flat_map< FIX::SessionID, std::shared_ptr > > sessions; SecurityIndex index; std::mutex lock; Factory factory; @@ -38,7 +39,7 @@ struct FixRouter::PImpl lock(), factory(factory) { - } + } }; FixRouter::FixRouter(md::MDClient& md, Factory factory) : me(new PImpl(md, factory)) @@ -51,9 +52,9 @@ FixRouter::~FixRouter() void FixRouter::send(FIX::Message& mess, const FIX::SessionID& sess) { -std::lock_guard guard(me->lock); try { + std::lock_guard guard(me->lock); FIX::Session::sendToTarget(mess, sess); } catch(FIX::SessionNotFound) @@ -174,16 +175,19 @@ void FixRouter::toApp(FIX::Message& message, const FIX::SessionID& sessionID) th IFixSession& FixRouter::session(const FIX::SessionID& sid) { -std::lock_guard guard(me->lock); - auto it = me->sessions.find(sid); - if(it == me->sessions.end()) + auto ptr = me->sessions.lock([this, sid] (auto& sessions) { - auto ptr = me->factory(*this, sid); - me->sessions[sid] = ptr; - return *ptr; - } - else - return *it->second; + auto it = sessions.find(sid); + if(it == sessions.end()) + { + auto ptr = me->factory(*this, sid); + sessions[sid] = ptr; + return ptr; + } + else + return it->second; + }); + return *ptr; } void FixRouter::handle_session_exception(const std::exception& ex, const FIX::SessionID& sessionID, const FIX::Message* message) diff --git a/src/server/sparkd/fix/OrderSession.cpp b/src/server/sparkd/fix/OrderSession.cpp index 8f8b44d0c..5418ad22e 100644 --- a/src/server/sparkd/fix/OrderSession.cpp +++ b/src/server/sparkd/fix/OrderSession.cpp @@ -19,6 +19,13 @@ #include #include +/* +order for 4 lot CLZ9 +8=FIX.4.49=15635=D49=SPARKFIX56=CLIENT134=150=3073797=Y52=20000809-20:20:5011=900010081=ACC A21=255=SIM:CLZ954=138=440=259=044=5060=20000809-18:20:32207=SIM10=045 + +order for 4 lot CLZ9-CLH0 +8=FIX.4.49=15635=D49=SPARKFIX56=CLIENT134=150=3073797=Y52=20000809-20:20:5011=900010081=ACC A21=255=SIM:CLZ9-CLH054=138=440=259=044=7460=20000809-18:20:32207=SIM10=045 +*/ namespace bts { namespace fix { @@ -69,7 +76,7 @@ void OrderSession::onMessage(const FIX44::OrderCancelRequest& cancel, const FIX: } api::orderman::Cancel can; can.set_order_key(key); - _orderservice.cancel_order(can, [&] (const auto& resp) + _orderservice.cancel_order(can, [this, s, cancel] (const auto& resp) { if(!resp.success() || resp.value()->error_code() != bts::api::orderman::ORDER_ERROR_OK) { @@ -103,7 +110,7 @@ void OrderSession::onMessage(const FIX44::OrderCancelReplaceRequest& replace, co upd.set_order_key(key); upd.set_price(price); upd.set_quantity(sz); - _orderservice.update_order(upd, [&] (const auto& resp) + _orderservice.update_order(upd, [this, s, replace] (const auto& resp) { if(!resp.success() || resp.value()->error_code() != bts::api::orderman::ORDER_ERROR_OK) { @@ -114,9 +121,6 @@ void OrderSession::onMessage(const FIX44::OrderCancelReplaceRequest& replace, co void OrderSession::onMessage(const FIX44::NewOrderSingle& create, const FIX::SessionID& s) { - UNUSED(create); - UNUSED(s); - api::Venue ven = convert_exchange(FIX::SecurityExchange(create.getField(FIX::FIELD::SecurityExchange))); if (ven == bts::api::VENUE_UNSET) throw FIX::IncorrectTagValue(FIX::FIELD::SecurityExchange); @@ -168,7 +172,7 @@ void OrderSession::onMessage(const FIX44::NewOrderSingle& create, const FIX::Ses { throw FIX::IncorrectTagValue(FIX::FIELD::OrderQty); } - _orderservice.create_order(cr, [&] (const auto& resp) + _orderservice.create_order(cr, [this, s, create] (const auto& resp) { if(!resp.success() || resp.value()->error_code() != bts::api::orderman::ORDER_ERROR_OK) { @@ -188,6 +192,7 @@ void OrderSession::set_ordertype(api::orderman::OrderDefinition& def, const FIX4 else if(ot == "2") { def.mutable_custom_def()->mutable_limit(); + price_req = true; } else if(ot == "3") { @@ -202,6 +207,7 @@ void OrderSession::set_ordertype(api::orderman::OrderDefinition& def, const FIX4 } else if(ot == "4") { + price_req = true; auto s = def.mutable_custom_def()->mutable_stop_limit(); double stoppx = 0.0; try diff --git a/src/server/sparkd/fix/SecurityIndex.cpp b/src/server/sparkd/fix/SecurityIndex.cpp index 855dc399d..5919385e1 100644 --- a/src/server/sparkd/fix/SecurityIndex.cpp +++ b/src/server/sparkd/fix/SecurityIndex.cpp @@ -49,7 +49,7 @@ md::SecurityPtr SecurityIndex::lookup(md::security_key key) md::SecurityPtr ptr = nullptr; me->key_index.security_index.lock([&ptr, &key] (const auto& secmap) { - auto it = secmap.find( SecurityKey(key) ); + auto it = secmap.find( key ); if(it != secmap.end()) ptr = it->second; }); diff --git a/src/server/sparkd/fix/SessionBase.cpp b/src/server/sparkd/fix/SessionBase.cpp index cfd562554..1be9bd3b9 100644 --- a/src/server/sparkd/fix/SessionBase.cpp +++ b/src/server/sparkd/fix/SessionBase.cpp @@ -66,8 +66,10 @@ void SessionBase::fromAdmin(const FIX::Message& message, const FIX::SessionID& s { try { + LOG(Fix, Info, "LOGIN: {}", message.toString() ); FIX44::Logon msg = (FIX44::Logon)message; - _user_name = msg.getField(FIX::FIELD::Username); + if(msg.isSetField(FIX::FIELD::Username)) + _user_name = msg.getField(FIX::FIELD::Username); std::string pass; if(msg.isSetField(FIX::FIELD::Password)) pass = msg.getField(FIX::FIELD::Password); @@ -75,18 +77,27 @@ void SessionBase::fromAdmin(const FIX::Message& message, const FIX::SessionID& s bts::api::user::AuthenticateLoginRequest auth; auth.set_login(_user_name); auth.set_password(pass); - _authservice.authenticate_login(auth, [this] (auto resp) + _authservice.authenticate_login(auth, [this, sessionID] (auto resp) { if (resp.success() && resp.value()->is_valid()) + { _token = resp.value()->token(); + } else - throw FIX::RejectLogon("Logon rejected " + resp.value()->reason()); + { + //I can't just throw here cuz c++ + std::string reason = "LOGIN FAILED " + resp.value()->reason(); + LOG(Fix, Error, reason.c_str()); + try + { + auto sess = FIX::Session::lookupSession(sessionID); + if(sess != nullptr) + sess->disconnect(); + } + catch(...) {} + } }); } - catch (FIX::RejectLogon) - { - throw; - } catch (std::exception ex) { throw FIX::RejectLogon("Logon rejected " + std::string(ex.what())); diff --git a/src/server/sparkd/fix/SessionBase.h b/src/server/sparkd/fix/SessionBase.h index 14e8fcf3d..74d7d4cf5 100644 --- a/src/server/sparkd/fix/SessionBase.h +++ b/src/server/sparkd/fix/SessionBase.h @@ -74,7 +74,7 @@ protected: bts::api::admin::AdminService _adminservice; rxcpp::observable> _adminobservable; IFixRouter& _router; - const FIX::SessionID& _sess; + FIX::SessionID _sess; utils::LockBox _admin_data; std::string _user_name; From 193f248f06b825b70cdd936ca8b57859fda5b4f8 Mon Sep 17 00:00:00 2001 From: Kevin Darby Date: Mon, 7 Oct 2019 17:40:01 -0400 Subject: [PATCH 28/28] merge deleted some of my files --- .../spark_core/admin/AdminModelWrapper.cs | 64 +++++++++++++++++++ .../spark_core/admin/PermissionFilters.cs | 64 +++++++++++++++++++ 2 files changed, 128 insertions(+) create mode 100644 src/client/spark_core/admin/AdminModelWrapper.cs create mode 100644 src/client/spark_core/admin/PermissionFilters.cs diff --git a/src/client/spark_core/admin/AdminModelWrapper.cs b/src/client/spark_core/admin/AdminModelWrapper.cs new file mode 100644 index 000000000..33e70a26b --- /dev/null +++ b/src/client/spark_core/admin/AdminModelWrapper.cs @@ -0,0 +1,64 @@ +using bts; +using bts.api.admin; +using System; +using System.Collections.Generic; +using System.Linq; + +namespace bts.api.core +{ + public class AdminModelWrapper + { + readonly AdminDataImmutable? _admin_data; + public AdminDataImmutable? admin_data => _admin_data; + readonly string _user_name; + readonly List _allowed_accounts; + readonly Dictionary _allowed_account_dict = new Dictionary(); + public AdminModelWrapper(AdminDataImmutable? admin_data = null, string user_name = null) + { + _admin_data = admin_data; + _user_name = user_name ?? string.Empty; + _allowed_accounts = search_admin(u => u.Name == _user_name).Where(x => + { + return (x.Item2 != null && x.Item2.HasPermissions) || (x.Item3 != null && x.Item3.HasPermissions); + }).Select(xx => xx.Item1).ToList(); + foreach (var val in _allowed_accounts) + _allowed_account_dict[val.Name] = val.Name; + } + public IEnumerable viewable_accounts() + { + return _allowed_accounts; + } + public bool can_view_account(string account) + { + return _allowed_account_dict.ContainsKey(account) || _user_name.ToLower().Equals("bts"); + } + + IEnumerable> + search_admin(Func predicate) + { + var rv = new List>(); + if (_admin_data.HasValue) + { + var users = _admin_data.Value.Users.Where(predicate); + if (users != null && users.Count() == 1) + { + var user = users.ElementAt(0); + if (user.HasUserData && user.UserData.HasAccountPermissions) + { + foreach (var kv in user.UserData.AccountPermissions.AccountPermissions) + { + var account_id = kv.Key; + var accounts = _admin_data.Value.Accounts.Where(a => a.Id == account_id); + if (accounts != null && accounts.Count() == 1) + { + var account = accounts.ElementAt(0); + rv.Add(Tuple.Create(account, kv.Value.TradingPermission, kv.Value.AdminPermission)); + } + } + } + } + } + return rv; + } + } +} \ No newline at end of file diff --git a/src/client/spark_core/admin/PermissionFilters.cs b/src/client/spark_core/admin/PermissionFilters.cs new file mode 100644 index 000000000..ac33a370b --- /dev/null +++ b/src/client/spark_core/admin/PermissionFilters.cs @@ -0,0 +1,64 @@ +using bts; +using bts.api; +using bts.api.core; +using bts.api.orderman; +using bts.api.position; +using bts.spark; +using System; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Collections.Specialized; +using System.Linq; +using System.Reactive.Concurrency; +using System.Reactive.Linq; + +namespace bts.api.core +{ + public static class PermissionFilters + { + public static IObservable> + PermissionFilter(this IObservable> source, IObservable am) + { + var pred = Observable.Create>(observer => + { + return am.Subscribe(x => + { + Func filter = (z => x.can_view_account(z.Account)); + observer.OnNext(filter); + }); + }); + + return source.Filter(pred); + } + + public static IObservable> + PermissionFilter(this IObservable> source, IObservable am) + { + var pred = Observable.Create>(observer => + { + return am.Subscribe(x => + { + Func filter = (z => x.can_view_account(z.Def.Account ?? string.Empty)); + observer.OnNext(filter); + }); + }); + + return source.Filter(pred); + } + + public static IObservable> + PermissionFilter(this IObservable> source, IObservable am) + { + var pred = Observable.Create>(observer => + { + return am.Subscribe(x => + { + Func filter = (z => x.can_view_account(z.Account)); + observer.OnNext(filter); + }); + }); + + return source.Filter(pred); + } + } +} \ No newline at end of file