Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into ordinal
Browse files Browse the repository at this point in the history
  • Loading branch information
Rob-Hague committed Jan 19, 2024
2 parents db18330 + cf2e3f9 commit 04bbbc4
Show file tree
Hide file tree
Showing 27 changed files with 372 additions and 269 deletions.
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
blank_issues_enabled: false
19 changes: 19 additions & 0 deletions .github/ISSUE_TEMPLATE/new-issue-template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
name: New issue template
about: You should choose this one
title: ''
labels: ''
assignees: ''

---

**DO NOT ASK FOR USAGE HELP HERE.**
Please see [this page](https://quickfixengine.org/n/support/)
to learn where you should ask for help.

Github issues are **only** for engine bugs and feature requests,
and only a couple people are notified. If you ask for regular usage help here,
we will close your issue without helping.

Ok? If you have an engine bug or feature request,
then please delete this message and proceed with your report. Thanks!
31 changes: 31 additions & 0 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This workflow will build a .NET project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net

name: .NET

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Unit Test
run: dotnet test --no-build --verbosity normal UnitTests
- name: Acceptance
run: dotnet test --no-build --verbosity normal AcceptanceTest

2 changes: 1 addition & 1 deletion Examples/Executor/Examples.Executor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net6.0</TargetFrameworks>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>Executor</RootNamespace>
<AssemblyName>Executor</AssemblyName>
<Copyright>Copyright © Connamara Systems, LLC 2011</Copyright>
Expand Down
Empty file modified Examples/Executor/Executor.cs
100755 → 100644
Empty file.
Empty file modified Examples/Executor/executor.cfg
100755 → 100644
Empty file.
2 changes: 1 addition & 1 deletion Examples/FixToJson/Examples.FixToJson.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net6.0</TargetFrameworks>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>FixToJson</RootNamespace>
<AssemblyName>FixToJson</AssemblyName>
<Copyright>Copyright © Connamara Systems, LLC 2022</Copyright>
Expand Down
66 changes: 34 additions & 32 deletions Examples/README.txt → Examples/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
Example Applications
====================

These example applications demonstrate how to use the QuickFIX/n library to
build your own FIX applications. There are 3 QuickFIX/N example applications:
How-to Examples
---------------
Three of these example applications demonstrate how to use the QuickFIX/n library to
build your own FIX applications. They are:

1. The SimpleAcceptor demonstrates a barebones acceptor application.
2. The Executor takes orders over a FIX session and executes them.
3. The TradeClient is a command line client that sends orders.
(NOT FOR USE WITH COMMERCIAL FIX INTERFACES! It won't work!)
* **SimpleAcceptor:** demonstrates a barebones acceptor application.
* **Executor:** takes orders over a FIX session and "executes" them.
* **TradeClient:** a command-line client that sends orders. _(NOT FOR USE WITH COMMERCIAL FIX INTERFACES! It won't work!)_

TradeClient and Executor can be configured to send and execute
orders with each other.
Expand All @@ -16,39 +17,36 @@ TradeClient can also be configured to connect to SimpleAcceptor,
though TradeClient will not hear any application-level responses from
SimpleAcceptor.

Each app is meant to be run from its target dir, e.g. Examples\Executor\bin\Debug\net461
or Examples\Executor\bin\Debug\netcoreapp2.0. The instructions below assume net461, but
apply equally to netcoreapp2.0.
To run each, go into its directory and use `dotnet run <config>`, e.g.
* `Examples/SimpleAcceptor> dotnet run simpleacc.cfg`
* `Examples/Executor> dotnet run executor.cfg`
* `Examples/TradeClient> dotnet run tradeclient.cfg`


SimpleAcceptor
==============
### SimpleAcceptor

The SimpleAcceptor example shows you how to create a simple acceptor server.
It will let initiators connect to it, and logs all admin and application
It will let initiators connect to it, and logs all admin and application
level messages to the screen. It does not process these messages.

Program.cs demonstrates how to setup and start a new acceptor object
Program.cs demonstrates how to setup and start a new acceptor object
from the Session settings file. SimpleAcceptorApp.cs implements
the Application interface and is where you would handle all your application
level logic.

Configure the SimpleAcceptor by modifying SimpleAcceptor/simpleacc.cfg
This configuration file defines the FIX Sessions the acceptor will
handle. For more information - http://quickfixn.org/tutorial/configuration
handle. For more information:
http://quickfixn.org/tutorial/configuration

Build QuickFIX/n first by running build.bat
Then start the SimpleAcceptor by opening a command prompt at
quickfixn/Examples/SimpleAcceptor/bin/Release/net461 and running:
Examples.SimpleAcceptor.exe simpleacc.cfg

Executor
========
### Executor

The Executor example takes incoming orders and executes them. Executor demonstrates
how to create an acceptor to crack messages and execute orders.
The Executor class inherits MessageCracker and implements Application.
For more information on how message cracking works -
The Executor example takes incoming orders and executes them. Executor demonstrates
how to create an acceptor to crack messages and execute orders.
The Executor class inherits MessageCracker and implements Application.

For more information on how message cracking works:
http://quickfixn.org/tutorial/receiving-messages

The OnMessage callbacks show you how to get field values from the NewOrderSingle
Expand All @@ -59,12 +57,8 @@ the counterparty will reject your message.

The Executor is configured with the executor.cfg file.

Build QuickFIX/n by running build.bat, then start the Executor by opening a command
prompt at quickfixn/Examples/Executor/bin/Release/net461 and running:
Executor.exe executor.cfg

TradeClient
===========
### TradeClient

The TradeClient is a command line example that shows how to create different FIX
message types and versions. You can create new order singles, cancel order requests,
Expand All @@ -76,6 +70,14 @@ demonstration of how to complete certain tasks in your own application.

TradeClient is configured with the tradeclient.cfg file.

Build QuickFIX/n by running build.bat, then start TradeClient by opening a command
prompt at quickfixn/Examples/TradeClient/bin/Release/net461 and running
TradeClient.exe tradeclient.cfg

FIX/Json Examples
-----------------

These demonstrate the FIX-to-Json and Json-to-FIX conversions. They are pretty simple.


Standalone/SerilogLog
---------------------

See the README in that directory.
2 changes: 1 addition & 1 deletion Examples/SimpleAcceptor/Examples.SimpleAcceptor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net6.0</TargetFrameworks>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>SimpleAcceptor</RootNamespace>
<AssemblyName>SimpleAcceptor</AssemblyName>
<Copyright>Copyright © Connamara Systems, LLC 2011</Copyright>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,29 @@ and limited total log size.

The solution contains 2 projects:

1. The SerilogLog is a sample implementation of ILog and ILogFactory.
NOTE: this is a sample, NOT a finished ready-to-use product.
Follow comments in the source code to adjust the example to
your actual requirements.
1. The SerilogLog is a sample implementation of ILog and ILogFactory.
_NOTE: this is a sample, **NOT** a finished ready-to-use product.
Follow comments in the source code to adjust the example to
your actual requirements._

2. The UnitTests are proof that limits for log size are working.

The projects are dependent on QuickFix.dll (ILog and ILogFactory interfaces).
Assuming the standard directory structure, the reference path is:
...\QuickFIXn\bin\Release\netstandard2.0\QuickFix.dll

<project-root>\QuickFIXn\bin\Debug\net6.0\QuickFix.dll

You need to build QuickFIXn release configuration to have the DLL available.
Alternatively, you can change the reference in the both projects.

If you copy/paste the source code in your project, you need to have
references to QuickFix.dll and NuGet Serilog.Sinks.File installed.

Usage example:

ILogFactory logFactory = new SerilogLogFactory(settings);
ThreadedSocketAcceptor _acceptor = new ThreadedSocketAcceptor(executorApp,
storeFactory, settings, logFactory);
- all sessions created by this `_acceptor` will be using SerilogLog

All sessions created by this `_acceptor` will be using SerilogLog
for messages and events logging.
2 changes: 1 addition & 1 deletion Examples/Standalone/SerilogLog/SerilogLog.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

<ItemGroup>
<Reference Include="QuickFix">
<HintPath>..\..\..\QuickFIXn\bin\Release\netstandard2.0\QuickFix.dll</HintPath>
<HintPath>..\..\..\QuickFIXn\bin\Debug\net6.0\QuickFix.dll</HintPath>
</Reference>
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion Examples/Standalone/SerilogLog/UnitTests/UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

<ItemGroup>
<Reference Include="QuickFix">
<HintPath>..\..\..\..\QuickFIXn\bin\Release\netstandard2.0\QuickFix.dll</HintPath>
<HintPath>..\..\..\..\QuickFIXn\bin\Debug\net6.0\QuickFix.dll</HintPath>
</Reference>
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion Examples/TradeClient/Examples.TradeClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net6.0</TargetFrameworks>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>TradeClient</RootNamespace>
<AssemblyName>TradeClient</AssemblyName>
<Copyright>Copyright © Connamara Systems, LLC 2011</Copyright>
Expand Down
3 changes: 2 additions & 1 deletion Examples/TradeClient/tradeclient.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ ResetOnDisconnect=Y
BeginString=FIX.4.4
SenderCompID=CLIENT1
TargetCompID=EXECUTOR
# use this instead to connect to SimpleAcceptor
#TargetCompID=SIMPLE
HeartBtInt=30

1 change: 0 additions & 1 deletion QuickFIXn.sln
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Examples.TradeClient", "Exa
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{FD384F84-3F83-4BF9-9238-82C70B74C2EA}"
ProjectSection(SolutionItems) = preProject
acceptance_test.ps1 = acceptance_test.ps1
appveyor.yml = appveyor.yml
CONTRIBUTING.md = CONTRIBUTING.md
LICENSE = LICENSE
Expand Down
50 changes: 21 additions & 29 deletions QuickFIXn/AbstractInitiator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,41 +7,33 @@ namespace QuickFix
public abstract class AbstractInitiator : IInitiator
{
// from constructor
private IApplication _app = null;
private IMessageStoreFactory _storeFactory = null;
private SessionSettings _settings = null;
private ILogFactory _logFactory = null;
private IMessageFactory _msgFactory = null;

private object sync_ = new object();
private Dictionary<SessionID, Session> sessions_ = new Dictionary<SessionID, Session>();
private HashSet<SessionID> sessionIDs_ = new HashSet<SessionID>();
private HashSet<SessionID> pending_ = new HashSet<SessionID>();
private HashSet<SessionID> connected_ = new HashSet<SessionID>();
private HashSet<SessionID> disconnected_ = new HashSet<SessionID>();
private bool isStopped_ = true;
private readonly IApplication _app;
private readonly IMessageStoreFactory _storeFactory;
private readonly SessionSettings _settings;
private readonly ILogFactory _logFactory;
private readonly IMessageFactory _msgFactory;

private object sync_ = new();
private Dictionary<SessionID, Session> sessions_ = new();
private HashSet<SessionID> sessionIDs_ = new();
private HashSet<SessionID> pending_ = new();
private HashSet<SessionID> connected_ = new();
private HashSet<SessionID> disconnected_ = new();
private Thread thread_;
private SessionFactory sessionFactory_ = null;
private SessionFactory sessionFactory_;

#region Properties

public bool IsStopped
{
get { return isStopped_; }
}
public bool IsStopped { get; private set; } = true;

#endregion

public AbstractInitiator(IApplication app, IMessageStoreFactory storeFactory, SessionSettings settings)
: this(app, storeFactory, settings, null, null)
{ }

public AbstractInitiator(IApplication app, IMessageStoreFactory storeFactory, SessionSettings settings, ILogFactory logFactory)
: this(app, storeFactory, settings, logFactory, null)
{ }

public AbstractInitiator(
IApplication app, IMessageStoreFactory storeFactory, SessionSettings settings, ILogFactory logFactory, IMessageFactory messageFactory)
IApplication app,
IMessageStoreFactory storeFactory,
SessionSettings settings,
ILogFactory? logFactory,

Check warning on line 35 in QuickFIXn/AbstractInitiator.cs

View workflow job for this annotation

GitHub Actions / build

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 35 in QuickFIXn/AbstractInitiator.cs

View workflow job for this annotation

GitHub Actions / build

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
IMessageFactory? messageFactory)

Check warning on line 36 in QuickFIXn/AbstractInitiator.cs

View workflow job for this annotation

GitHub Actions / build

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
{
_app = app;
_storeFactory = storeFactory;
Expand Down Expand Up @@ -71,7 +63,7 @@ public void Start()
throw new ConfigError("No sessions defined for initiator");

// start it up
isStopped_ = false;
IsStopped = false;
OnConfigure(_settings);
thread_ = new Thread(new ThreadStart(OnStart));
thread_.Start();
Expand Down Expand Up @@ -205,7 +197,7 @@ public void Stop(bool force)
SetDisconnected(Session.LookupSession(sessionID).SessionID);
}

isStopped_ = true;
IsStopped = true;
OnStop();

// Give OnStop() time to finish its business
Expand Down
6 changes: 3 additions & 3 deletions QuickFIXn/Fields/Converters/DateTimeConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ private static System.DateTime ConvertFromNanoString(string str, string[] format
{
// GMT offset
int n = dec.Contains('+') ? dec.IndexOf('+') : dec.IndexOf('-');
kind = System.DateTimeKind.Utc;
offset = int.Parse(dec.Substring(n + 1));
kind = System.DateTimeKind.Unspecified;
offset = int.Parse(dec.Substring(n));
dec = dec.Substring(0, n);
}
else
Expand All @@ -87,7 +87,7 @@ private static System.DateTime ConvertFromNanoString(string str, string[] format
// apply GMT offset
if (offset != 0)
{
d = new System.DateTimeOffset(d).ToOffset(System.TimeSpan.FromHours(offset)).DateTime;
d = new System.DateTimeOffset(d, System.TimeSpan.FromHours(offset)).UtcDateTime;
}

long ticks = frac / NanosecondsPerTick;
Expand Down
Loading

0 comments on commit 04bbbc4

Please sign in to comment.