简体   繁体   English

如何在QuickFix中获取SessionID

[英]How to get SessionID in QuickFix

I am using QuickFix with Python. 我正在使用QuickFix和Python。 On the back of this question, I've explored the SessionID class a bit, but I am mystified by the behavior. 这个问题的背面,我已经探讨了一下SessionID类,但我对这种行为感到困惑。

The SessionID class is described here . 这里描述 SessionID类。 It is formed of a BeginString, SenderCompID and TargetCompID. 它由BeginString,SenderCompID和TargetCompID组成。

Say my SessionID in string form looks like this: FIX.4.2:LMXTS->TS68. 以字符串形式说我的SessionID如下所示:FIX.4.2:LMXTS-> TS68。

fix.SessionID().fromString() returns :-> fix.SessionID().fromString()返回:->

Which if you look, are the three filler characters separating the BeginString, SenderCompID and TargetCompID. 如果你看,它是分隔BeginString,SenderCompID和TargetCompID的三个填充字符。

fix.SessionID().getBeginString returns 8=☺ (ie the BeginString is nowhere). fix.SessionID().getBeginString返回8=☺ (即BeginString无处)。 And the same thing applies to getSenderCompID and getTargetCompID , they return 49=☺ and 56=☺ respectively. 同样的事情适用于getSenderCompIDgetTargetCompID ,它们分别返回49=☺56=☺

fix.SessionID().getTargetCompID().getValue() returns the empty string '' . fix.SessionID().getTargetCompID().getValue()返回空字符串''

Trying another way, fix.SessionID().fromString('FIX.4.2:LMXTS->TS68') returns None . 另一种方法是, fix.SessionID().fromString('FIX.4.2:LMXTS->TS68')返回None

I am trying to get these values after the session is created (which I can explicitly see happening when I pass fix.ScreenLogFactory(settings) to the initiator. So I am confused. 我试图创建会话获取这些值(当我将fix.ScreenLogFactory(settings)传递给启动器时,我可以明确地看到这些值。所以我很困惑。

The method void onLogon( const SessionID& ) {} in Application.h is fired when the session is logged on, and gives you a reference to a SessionID . 该方法void onLogon( const SessionID& ) {}Application.h当会话登录被触发,并给您一个参考SessionID You could inspect the SessionID object inside onLogon to see how it behaves. 您可以检查onLogonSessionID对象以查看其行为方式。

It sounds like you're looking at the session directly after creating it, before logging on etc. So that means you're not using a breakpoint in, say, FromApp or ToApp to look at the session properties there. 听起来你在创建之后直接查看会话,然后登录等等。这意味着你没有在FromApp或ToApp中使用断点来查看那里的会话属性。 If you do, you get the properties directly ie SenderCompID, or TargetCompID. 如果这样做,您可以直接获得属性,即SenderCompID或TargetCompID。

I cannot find the method SessionID in the objects I use. 我在我使用的对象中找不到方法SessionID。 How do you define your 'fix' object? 你如何定义你的'修复'对象?

you can do it any of the quickfix methods after your session is created as the sesionId is one of the parameters. 您可以在创建会话后执行任何quickfix方法,因为sesionId是其中一个参数。

The first method fired is onCreate so you can potentially store the sesionId in your class var and then reuse if if and when required to retrieve your settings. 第一个触发的方法是onCreate,因此您可以将sesionId存储在类var中,然后在需要时以及何时检索您的设置时重复使用。 You can also use the onLogon method as suggested in one of the other answers. 您还可以使用其他答案中建议的onLogon方法。

Example below 以下示例

def onCreate(self, sessionID):
    self.session_id = sessionID
    target = sessionID.getTargetCompID().getString()
    sender = sessionID.getSenderCompID().getString()

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

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