How to update the FIX 5.0 tag 528 data dictionary to include values provided by the exchange - fix-protocol

We are currently using Quickfix/J and using FIX 5.0 sp1. Tag 528 replaced tag 47 which has the values we wanted but tag 47 is depracated and the current values we have in FIX 5.0 are the following:
Valid values:
A = Agency
G = Proprietary
I = Individual
P = Principal (Note for CMS purposes, "Principal" includes "Proprietary")
R = Riskless Principal
W = Agent for Other Member
The exchange wants us to add these to the data dictionary.
Ø 528 OrderCapacity N Specifies the capacity of the firm
placing the order.
NASDAQ Defined *
S – Institutional
G – Group
O – Other
M – Market Maker
L – Related Party
E – Error
T – Tax Exempt
D – Special Account Retail
F – Special Account Institutional
Can you please guide on how to do this update?
This is the class for tag 528. Is it possible to create an extension of the tag 528? Can you share how it is done?
public class OrderCapacity extends CharField {
static final long serialVersionUID = 20050617;
public static final int FIELD = 528;
public static final char AGENCY = 'A';
public static final char PROPRIETARY = 'G';
public static final char INDIVIDUAL = 'I';
public static final char PRINCIPAL = 'P';
public static final char RISKLESS_PRINCIPAL = 'R';
public static final char AGENT_FOR_OTHER_MEMBER = 'W';
public OrderCapacity() {
super(528);
}
}

Have a look at the QF/n docs for customizing the data dictionary.
Even though that site is for the C# QF port, the data dictionary files are the same and the instructions should be good for you.
If you need further help, please ask new questions that are more specific.

Related

What is the purpose of the line "public Word(#NonNull String word) {this.mWord = word;}" in this example?

I'm trying to figure out how to use Android's Room library for implementing a prepopulated sqlite database in my app and I came across this Android tutorial. One of the lines (the one in the title) confuses me though, because in another tutorial (also by Android), this line isn't present. Why is this line of code present in the first tutorial but not the second? What is its purpose?
I ask this because my code (which I'm basing off the second tutorial) doesn't include this line and yet this post by a different user attempting to do something similar with a prepopulated database does include it.
Here is some of the code I have (each of the fields has a getter method which just returns this.thatfield'sname):
#Entity (tableName = "words")
public class Words {
#PrimaryKey
#NonNull
#ColumnInfo (name = "word_id")
private int wordId;
#ColumnInfo(name = "a_words")
private String aWords;
#ColumnInfo(name = "b_words")
private String bWords;
#ColumnInfo(name = "c_words")
private String cWords;
This code gives me a "Cannot find setter for field" but just changing the fields from public to private seems to solve that (not sure if this is the best way to solve this error, though).
Why is this line of code present in the first tutorial but not the second?
That line is an additional class constructor that takes 1 non-null String and sets the mWord member/variable to the provided String.
Without then you can only use myWord = new Word(); to instantiate a Word object and the value would be either the default value if provided or null.
With the additional constructor then you could use both
myWord = new Word();
or
myOtherWord = new Word("A Word");
So, in short it's provided an alternative way of constructing/instantiating a new Object of that Class.
Using your code then you could have, for example :-
#Entity(tableName = "words")
class Words {
#ColumnInfo(name = "word_id")
#PrimaryKey
private int wordId;
#ColumnInfo(name = "a_words")
String aWords;
#ColumnInfo(name = "b_words")
String bWords;
#ColumnInfo(name = "c_words")
String cWords;
public void setWordId(int wordId, String aWord, String bWords, String c) {
this.wordId = wordId;
this.aWords = aWord;
this.bWords = bWords;
this.cWords = c;
}
}
Note for demonstration the parameter names use 3 different standards, ideally you would stick to a single standard/convention for naming the parameters.
So now you could use the one constructor that expects 4 parameters e.g.
myWord = new Words(1,"Apple","Banana","Cherry");
which equates to
myWord = new Words();
myWord.wordId = 1;
myWord.aWords = "Apple;
myWord.bWords = "Banana";
myWord.cWords = "Cherry";
As you have specified a constructor, the default constructor is no longer usable.
What is its purpose?
As can be seen, additional constructors, can reduce the amount of coding, there use will also prompt for the values (hence the use of useful parameter names improves i.e. c as above is not very meaningful at all (although in conjunction with the other parameters if would be better than x))

IntelliSense/ReSharper and custom Quickfixn library generation

I am developing a Quickfix/n initiator to be used with several counterparties, in the same instance, all using the same version of FIX (4.2 in this instance) but utilizing a unique messaging specification and I would like to use Intellisense/ReSharper to develop said initiator.
Previously I have used the generate.rb script to create source code from a modified FIX##.xml file but would like to use something like FIX42.DeutcheBank.xml, FIX42.CME.xml, FIX42.Whatever, to generate the source with the generate.rb ruby script or a modified version thereof so they can be parsed by IntelliSense/ReSharper and I am having issues because they all use "FIX.4.2" as begin strings and thus causes a compile error.
I know that I can just refer to a field/group via a key like Tags["BidForwardPointsCME"] or something similar with a DataDictionary but, as stated, I would like to be able to use IntelliSense/ReSharper and reference the message fields/groups with something like Quickfix.CounterParty.WhateverField and using the same dll.
I've banged my head against the internet for answers for 3-4 days with no luck - Is what I would like to do possible? If so, how would one go about it?
Hi in advance to Grant Birchmeier <:-]
For anyone that ever is trying to do this, the answer is pretty simple - probably not the most efficient but it works as far as I know.
the trick is to edit two ruby generation scripts (messages_gen.rb and generate.rb) and place the additional FIX specification XML file(s) in the spec/fix directory.
Assuming that you have a custom FIX xml file for Foo Exchange and that the Foo Exchange uses FIX 4.2, you need to name it FIX.xml (Example: FIXFooExchange.xml)
Next, you will have to override the FIX version in messages_gen.rb like so:
def self.gen_basemsg fixver, destdir
beginstring = fixver
if beginstring.match(/^FIX50/)
beginstring = "FIXT11"
end
if beginstring.match(/^FIXFooExchange/)
beginstring = "FIX42"
end
Next you need to add your custom fix version to 6 method definitions in the generate.rb file.
Those methods are:
initialize
agg_fields
get_field_def
generate_messages
generate_csproj
generate_message_factories
Here are a few examples:
def initialize
#fix40 = FIXDictionary.load spec('FIX40')
#fix41 = FIXDictionary.load spec('FIX41')
#fix42 = FIXDictionary.load spec('FIX42')
#fix43 = FIXDictionary.load spec('FIX43')
#fix44 = FIXDictionary.load spec('FIX44')
#fix50 = FIXDictionary.load spec('FIX50')
#fix50sp1 = FIXDictionary.load spec('FIX50SP1')
#fix50sp2 = FIXDictionary.load spec('FIX50SP2')
#fixFooExchange = FIXDictionary.load spec('FIXFooExchange')
#src_path = File.join File.dirname(__FILE__), '..', 'QuickFIXn'
end
def get_field_def fld_name
# we give priority to latest fix version
fld = merge_field_defs(
#fix50sp2.fields[fld_name],
#fix50sp1.fields[fld_name],
#fix50.fields[fld_name],
#fix44.fields[fld_name],
#fixFooExchange.fields[fld_name],
#fix43.fields[fld_name],
#fix42.fields[fld_name],
#fix41.fields[fld_name],
#fix40.fields[fld_name]
)
End
Basically you just copy one line and replace the fix version with the customized exchange xml data dictionary name.
The class BeginString in FixValues.cs should be modified to look like this:
public class BeginString
{
public const string FIXT11 = "FIXT.1.1";
public const string FIX50 = "FIX.5.0";
public const string FIX44 = "FIX.4.4";
public const string FIX43 = "FIX.4.3";
public const string FIXFooExchange = "FIX.4.2";
public const string FIX42 = "FIX.4.2";
public const string FIX41 = "FIX.4.1";
public const string FIX40 = "FIX.4.0";
}
The Values.cs file contains a single class which should be changed to look like this:
public class Values
{
public const string BeginString_FIXT11 = "FIXT.1.1";
public const string BeginString_FIX50 = "FIX.5.0";
public const string BeginString_FIX44 = "FIX.4.4";
public const string BeginString_FIX43 = "FIX.4.3";
public const string BeginString_FIXFooExchange = "FIX.4.2";
public const string BeginString_FIX42 = "FIX.4.2";
public const string BeginString_FIX41 = "FIX.4.1";
public const string BeginString_FIX40 = "FIX.4.0";
}
Do those things and then run the generate.bat file and you should be able to reference namespaces via '.' rather than using the base FIX version.
Here are some examples:
using QuickFix.FIXFooExchange;
using Message = QuickFix.Message;
QuickFix.FIXFooExchange.MessageFactory mF = new QuickFix.FIXFooExchange.MessageFactory();
and reference message properties like:
string customField = message.yourCustomFieldName.getValue().ToUpper();
instead of by
string customField = message["yourCustomFieldName"].getValue().ToUpper();
Lastly, you need to edit 2 .cs files: FixValues.cs and Values.cs
I've tested this pretty extensively and it seems to work but I would advise that you do testing before you put anything in production.
So the problem is you want 1 QF initiator process to connect to several different counterparties where each session uses a separate data dictionary?
Don't you do this using DataDictionary=somewhere/FIX42.xml in the configuration file?
See also http://quickfixn.org/tutorial/configuration.html AppDataDictionary: This setting supports the possibility of a custom application data dictionary for each session.

INET Nordic FIX protocols extending to nanosecond granularity timestamps

All INET Nordic FIX protocols will be enhanced by extending to nanosecond granularity timestamps on 16.oktober 2015 (see notification and section 3.1.1 in the spec).
The timestamps will look like this: 20150924-10:35:20.840117690
quickfix currently rejects messages that contain fields with this new format with the error: Incorrect data format for value
Are there any plans to support this new format? Or maybe some workaround?
You can first try modifying your data dictionary. For example if you are using fix42.xml that comes with QuickFIX, you can change the affected timestamp fields from type='UTCTIMESTAMP' to type='STRING'.
If that isn't enough, you should instead write a patch against QuickFIX in C++, which should be somewhat straightforward once you know where to patch it, which I think is UtcTimeStampConvertor, around here: https://github.com/quickfix/quickfix/blob/master/src/C%2B%2B/FieldConvertors.h#L564
I think you need to add a case 27: above case 21: near the top, because your format has six extra digits. It looks like the rest of the function doesn't care about the total field length.
Of course if you want to actually inspect the sub-millisecond precision part of these timestamps, you'll need to do more.
No plans in QF/n, but only because this is the first I've heard of this.
I'll need to write some tests to see what the repercussions are. It may be that the time/date parser just truncates the extra nano places when it converts the string to a DateTime.
I've opened an issue: https://github.com/connamara/quickfixn/issues/352
This change is as far as I know kind of breaking the fix protocol definition of timestamps but that's another story.
There is a static class in QuickFixn called DateTimeConverter under QuickFix/Fields/Converters.
To get this to work correctly you would need to add format strings in lines in that class.
Add "yyyyMMdd-HH:mm:ss.fffffff" to DATE_TIME_FORMATS and "HH:mm:ss.fffffff" to TIME_ONLY_FORMATS so that it would look like this.
/// <summary>
/// Convert DateTime to/from String
/// </summary>
public static class DateTimeConverter
{
public const string DATE_TIME_FORMAT_WITH_MILLISECONDS = "{0:yyyyMMdd-HH:mm:ss.fff}";
public const string DATE_TIME_FORMAT_WITHOUT_MILLISECONDS = "{0:yyyyMMdd-HH:mm:ss}";
public const string DATE_ONLY_FORMAT = "{0:yyyyMMdd}";
public const string TIME_ONLY_FORMAT_WITH_MILLISECONDS = "{0:HH:mm:ss.fff}";
public const string TIME_ONLY_FORMAT_WITHOUT_MILLISECONDS = "{0:HH:mm:ss}";
public static string[] DATE_TIME_FORMATS = { "yyyyMMdd-HH:mm:ss.fffffff", "yyyyMMdd-HH:mm:ss.fff", "yyyyMMdd-HH:mm:ss" };
public static string[] DATE_ONLY_FORMATS = { "yyyyMMdd" };
public static string[] TIME_ONLY_FORMATS = { "HH:mm:ss.fffffff", "HH:mm:ss.fff", "HH:mm:ss" };
public static DateTimeStyles DATE_TIME_STYLES = DateTimeStyles.AssumeUniversal | DateTimeStyles.AdjustToUniversal;
public static CultureInfo DATE_TIME_CULTURE_INFO = CultureInfo.InvariantCulture;

Class of a Class

I'm getting just killed trying to make a class of a class. I have shopped around the site and seen several examples but maybe because its 1:43 I am having a hard time understanding them.
I was successfully able to use a class to automate a huge data entry project at work. I created a class called catDist which is the category distribution of types of agricultural products a company could manufacture or sell.
catDist contains six properties:
Private selfWorth As String
Private Q1 As Double
Private Q2 as Double
Private Q3 as Double
Private Q4 As Double
Private activated As Boolean
They all have the standard get and let codes.
There are 48 possible categories. I have a module that creates 48 instances of them with 48 different values for selfWorth (e.g "Cottonseed", or "maize" etc), and sets Q1 through Q4 as 0 . The module originally worked with a Userform that I could type in the values and hit enter. If it saw that I had entered a value inside a particular textbox (yes there were 48X4 textboxes) it would set activated to true and changes the relevant Q's to the values I entered.
WHAT I WANT TO DO NOW.
It was a great success. Now what I want to do is create a class called "Distributor". Each distributor class would have 4 collections have catDist objects. I can create the distributor class. I can create the catDist class. But for the love of God I can not figure out a way to set the corresponding distributor catDist property to the catDist value I used in the Set method.
Sub testRegist()
Dim registrant As testRegistrant
Set registrant = New testRegistrant
registrant.registNum = "Z000123"
'MsgBox (registrant.registNum)
Dim cowMilk As testcatDist
Set cowMilk = New testcatDist
cowMilk.selfWorth = "Cow Milk"
cowMilk.distribution = 4.6
registrant.testCat = cowMilk
Debug.Print registrant.testCat.selfWorth
End Sub
catDist Class
Private pselfWorth As String
Private pdistribution As Double
Public Property Get selfWorth() As String
selfWorth = pselfWorth
End Property
Public Property Let selfWorth(name As String)
pselfWorth = name
End Property
Public Property Get distribution() As Double
distribution = pdistribution
End Property
Public Property Let distribution(dist As Double)
pdistribution = dist
End Property
Registrant a.k.a distributor class
Private pRegistNum As String
Private pCatDist As testcatDist
Public Property Get registNum() As String
registNum = pRegistNum
End Property
Public Property Let registNum(registration As String)
pRegistNum = registration
End Property
Public Property Get testCat() As testcatDist
testCat = pCatDist
End Property
Public Property Let testCat(cat As testcatDist)
Set pCatDist = New testcatDist
pCatDist = cat
End Property
The only problem I see is that you are using Let instead of Set. In VBA you use Set when assigning to objects.
When you write registrant.testCat = cowMilk (in your Sub), testCat = pCatDist (in the getter of testRegistrant.testCat) and pCatDist = cat (in the setter of testRegistrant.testCat) you are implicitly using Let (it's as if you had written Let registrant.testCat = cowMilk) instead of (explicitly) using Set.
So, if you write Set registrant.testCat = cowMilk in your test Sub, Set testCat = pCatDist in the getter and Set pCatDist = cat in the setter you should be good to go.
Also, in the same setter, the initialization of pCatDist isn't needed since you are passing cat to it in the next line.
And, as #GSerg (thank you) says, the signature of your setter should be Public Property Set testCat(cat as testcatDist) instead of Public Property Let.

Is order of dependencies guaranteed when injecting IEnumerable<T>

I register in container services implementing IMyService.
Do I have any guarantees about their order in
container.Resolve<IEnumerable<IMyService>>
?
Just as extra help for people like me landing on this page... Here is an example how one could do it.
public static class AutofacExtensions
{
private const string OrderString = "WithOrderTag";
private static int OrderCounter;
public static IRegistrationBuilder<TLimit, TActivatorData, TRegistrationStyle>
WithOrder<TLimit, TActivatorData, TRegistrationStyle>(
this IRegistrationBuilder<TLimit, TActivatorData, TRegistrationStyle> registrationBuilder)
{
return registrationBuilder.WithMetadata(OrderString, Interlocked.Increment(ref OrderCounter));
}
public static IEnumerable<TComponent> ResolveOrdered<TComponent>(this IComponentContext context)
{
return from m in context.Resolve<IEnumerable<Meta<TComponent>>>()
orderby m.Metadata[OrderString]
select m.Value;
}
}
No, there's no ordering guaranteed here. We've considered extensions to enable it but for now it's something to handle manually.
I don't mean to self-promote, but I have also created a package to solve this problem because I had a similar need: https://github.com/mthamil/Autofac.Extras.Ordering
It uses the IOrderedEnumerable<T> interface to declare the need for ordering.
I know this is an old post but to maintain the order of registration, can't we just use PreserveExistingDefaults() during registration?
builder.RegisterInstance(serviceInstance1).As<IService>().PreserveExistingDefaults();
builder.RegisterInstance(serviceInstance2).As<IService>().PreserveExistingDefaults();
// services should be in the same order of registration
var services = builder.Resolve<IEnumberable<IService>>();
I didn't find any fresh information on topic and wrote a test which is as simple as (you'd better write your own):
var cb = new ContainerBuilder();
cb.RegisterType<MyClass1>().As<IInterface>();
// ...
using (var c = cb.Build())
{
using (var l = c.BeginLifetimeScope())
{
var e = l.Resolve<IEnumerable<IInterface>>().ToArray();
var c = l.Resolve<IReadOnlyCollection<IInterface>>();
var l = l.Resolve<IReadOnlyList<IInterface>>();
// check here, ordering is ok
}
}
Ordering was kept for all cases I've come up with. I know it is not reliable, but I think that in the current version of Autofac (4.6.0) ordering is wisely kept.