简体   繁体   English

IntelliSense / ReSharper和自定义Quickfixn库生成

[英]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. 我正在开发一个Quickfix / n启动器,以便在同一实例中与多个交易对手一起使用,它们都使用相同版本的FIX(在此实例中为4.2),但是利用了唯一的消息传递规范,并且我想使用Intellisense / ReSharper进行开发说发起人。

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. 以前我曾使用generate.rb脚本从修改后的FIX ##。xml文件创建源代码,但想使用FIX42.DeutcheBank.xml,FIX42.CME.xml,FIX42之类的东西来生成源代码, generate.rb ruby​​脚本或其修改版本,因此它们可以被IntelliSense / ReSharper解析,并且我遇到了问题,因为它们都使用“ FIX.4.2”作为开始字符串,从而导致编译错误。

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. 我知道我可以通过诸如Tag [“ BidForwardPointsCME”]之类的键或与DataDictionary类似的键来引用字段/组,但是如上所述,我希望能够使用IntelliSense / ReSharper并引用消息字段/与类似Quickfix.CounterParty.WhateverField的组并使用相同的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? 我在互联网上摔倒了3-4天,没有运气-我想做些什么吗? If so, how would one go about it? 如果是这样,将如何处理?

Hi in advance to Grant Birchmeier <:-] 预先向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. 技巧是编辑两个ruby生成脚本(messages_gen.rb和generate.rb),并将其他FIX规范XML文件放置在spec / fix目录中。

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) 假定您具有针对Foo Exchange的自定义FIX xml文件,并且Foo Exchange使用FIX 4.2,则需要将其命名为FIX.xml(示例:FIXFooExchange.xml)

Next, you will have to override the FIX version in messages_gen.rb like so: 接下来,您将必须像这样在messages_gen.rb中覆盖FIX版本:

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. 接下来,您需要将您的自定义修订版本添加到generate.rb文件中的6个方法定义中。

Those methods are: 这些方法是:

initialize 初始化

agg_fields agg_fields

get_field_def get_field_def

generate_messages generate_messages

generate_csproj generate_csproj

generate_message_factories 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. 基本上,您只需复制一行,然后用自定义的Exchange XML数据字典名称替换修订版本。

The class BeginString in FixValues.cs should be modified to look like this: FixValues.cs中的BeginString类应修改为如下形式:

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: Values.cs文件包含一个类,应该将其更改为以下形式:

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 '.' 做这些事情,然后运行generate.bat文件,您应该能够通过“。”引用名称空间。 rather than using the base FIX version. 而不是使用基本的FIX版本。 Here are some examples: using QuickFix.FIXFooExchange; 这里是一些示例:使用QuickFix.FIXFooExchange; using Message = QuickFix.Message; 使用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 最后,您需要编辑2个.cs文件:FixValues.cs和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? 因此,问题是您希望1个QF启动器进程连接到几个不同的交易对手,其中每个会话使用单独的数据字典?

Don't you do this using DataDictionary=somewhere/FIX42.xml in the configuration file? 您不使用配置文件中的DataDictionary=somewhere/FIX42.xml来执行此操作吗?

See also http://quickfixn.org/tutorial/configuration.html AppDataDictionary: This setting supports the possibility of a custom application data dictionary for each session. 另请参见http://quickfixn.org/tutorial/configuration.html AppDataDictionary: This setting supports the possibility of a custom application data dictionary for each session.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM