0

私はプロトコルを修正し、プログラミングをすばやく修正する初心者です。ICE から Trade Capture レポートを取得するための支援を求めています。sample/tutorial をググって、quick fix/n を使用して取引レポートを取得しましたが、十分な出力を得ることができません。私の問題は、Trade Capture レポートまたは取引情報を取得することです。TradeCaptureReportRequest、TradeCaptureReportRequestAck、TradeCaptureReport クラスを使用してみましたが、何とか機能しています。情報を抽出する簡単な方法は大きな助けになります。事前にすべての人に感謝します。

4

1 に答える 1

2

コメントするには長すぎるので、回答として投稿します。カスタム定数、メッセージ タイプなどを作成したことを覚えておいてください (アクセプター サーバーも作成したので、ICE 定数/列挙型に制限されません)。ICE に必要なフィールドを決定し、変更を加える必要があります。これをコピーして貼り付けるのは簡単ではありません...

まず、必要なファイルがすべて含まれており、参照されていることを確認する必要があります。プロジェクトに「fix」というフォルダーを作成し、すべての修正ファイルをそこにコピーします。これらは (少なくとも 1 つの) FixXXX.xml ファイルである必要があります。FIX50SP1 または 2 を使用している場合は、FIXT11.xml も必要です。.xml ファイルに加えて、initiator.cfg ファイルが必要です (サーバーではなくイニシエーターを作成していると仮定します。 ICE に接続するには、イニシエーターが正しい使用法です. 最後に、QuickFix.dll が必要です. 私のツリーは以下のようになります: ここに画像の説明を入力

XML ファイルについては詳しく説明しません。それを理解する必要があります。非常に紛らわしく、時間がかかります。特に SP1 または 2 と共に FIXT11.XML を使用する場合はなおさらです。

あなたのinitiator.cfgは以下のようになっているはずです:

# default settings for sessions
[DEFAULT]
FileStorePath=store
FileLogPath=log
ConnectionType=initiator
ReconnectInterval=60
SenderCompID=[Enter yours]

ResetOnLogon=Y 
ResetOnLogout=Y 
ResetOnDisconnect=Y 


[SESSION]
BeginString=FIXT.1.1
TargetCompID=[Enter ICE Acceptor]
DefaultApplVerID=FIX.5.0
StartTime=12:30:00
EndTime=21:30:00
# overide default setting for RecconnectInterval
ReconnectInterval=30
HeartBtInt=30
SocketConnectPort=[From ICE]
# (optional) only listen for incoming connections on a specific host
#SocketConnectHost=127.0.0.1
SocketConnectHost=[ICE Ip Address- from your documentation/registration]
DataDictionary=..\..\fix\FIX50.xml
TransportDataDictionary=..\..\fix\FIXT11.xml

OK、QuickFix.dll をインポートして参照し、initiator.cfg が適切に接続されていると仮定すると、実際にはかなり単純です。

すべてを処理するクラスを作成します。テスト関数である AddToLB を無視します。

public class TCT_Fix : Control, IApplication
{
    private readonly string username = [removed]
    private readonly string password = [removed]
    public string InitiatorID;                           
    SessionID sessionID;                                 
    public bool running;                                 
    SessionSettings settings;
    IMessageStoreFactory storeFactory;
    ILogFactory logFactory;
    SocketInitiator initiator;
    public event EventHandler AddToLB;
    public event EventHandler AddToAdmin;
    public void StopIt()
    {
        if (sessionID == null) return;
        try
        {
            Session.LookupSession(sessionID).Disconnect("Stopping");
            settings.Remove(sessionID);
            settings = null;
            initiator.Dispose();
            settings = new SessionSettings(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "fix", "initiator.cfg"));
            storeFactory = new FileStoreFactory(settings);
            logFactory = new FileLogFactory(settings);
            initiator = new SocketInitiator(
                this,
                storeFactory,
                settings,
                logFactory);
        }
        catch { }   
    }
    public void FromApp(QuickFix.Message msg, SessionID sessionID)
    {
        var sMsg = "FROM APP: " + msg.ToString();
        AddToLB(sMsg, null);
        if (msg.Header.GetField(35) == "TC") //Cash
        {
            DateTime dtTdate;
            float fPrice;
            int Qty;
            int OrdType;
            bool BPisBuyer;

            DateTime.TryParse(msg.GetField(CustomConstants.TDATE),out dtTdate);
            string BPSide = msg.GetField(CustomConstants.BP_SIDE);                
            float.TryParse(msg.GetField(CustomConstants.F_PRICE), out fPrice);
            int.TryParse(msg.GetField(CustomConstants.QTY), out Qty);
            string TCTReference = msg.GetField(CustomConstants.TCT_REF);
            string BPAcct = msg.GetField(CustomConstants.BP_COMPANY);
            int.TryParse(msg.GetField(CustomConstants.ORDER_TYPE), out OrdType);
            string ExecBkr = msg.GetField(CustomConstants.EXEC_BKR);
            string CounterParty = msg.GetField(CustomConstants.COUNTER_PARTY);
            BPisBuyer = msg.GetField(CustomConstants.IS_BUYER) == "Y";
            string BPTrader = msg.GetField(CustomConstants.BP_TRADER);
            string CounterTrader = msg.GetField(CustomConstants.COUNTER_TRADER);
            string Grade = msg.GetField(CustomConstants.GRADE);
            string Location = msg.GetField(CustomConstants.LOCATION);
            string CycDt = msg.GetField(CustomConstants.CYCLE_DATE);
            string DelMo = msg.GetField(CustomConstants.DELIVER_MONTH);
            string Terms = msg.GetField(CustomConstants.TERMS);
            string Payment = msg.GetField(CustomConstants.PAYMENT);
            string Origin = msg.GetField(CustomConstants.ORIGIN);
            string NumOfCyc = msg.GetField(CustomConstants.NUM_OF_CYCLES);
            string Via = msg.GetField(CustomConstants.VIA);
            string MoveMo = msg.GetField(CustomConstants.MOVE_MONTH);
            string Comment = msg.GetField(CustomConstants.COMMENT);
        }
        else if (msg.Header.GetField(35) == "TE") //EFP
        {
            DateTime dtTdate;
            float fPrice;
            int Qty;
            int OrdType;
            bool BPisBuyer;
            bool IsWater;

            DateTime.TryParse(msg.GetField(CustomConstants.TDATE), out dtTdate);
            string BPSide = msg.GetField(CustomConstants.BP_SIDE);
            float.TryParse(msg.GetField(CustomConstants.F_PRICE), out fPrice);
            int.TryParse(msg.GetField(CustomConstants.QTY), out Qty);
            string TCTReference = msg.GetField(CustomConstants.TCT_REF);
            string BPAcct = msg.GetField(CustomConstants.BP_COMPANY);
            int.TryParse(msg.GetField(CustomConstants.ORDER_TYPE), out OrdType);
            string ExecBkr = msg.GetField(CustomConstants.EXEC_BKR);
            string CounterParty = msg.GetField(CustomConstants.COUNTER_PARTY);
            BPisBuyer = msg.GetField(CustomConstants.IS_BUYER) == "Y";
            string BPTrader = msg.GetField(CustomConstants.BP_TRADER);
            string CounterTrader = msg.GetField(CustomConstants.COUNTER_TRADER);
            string Grade = msg.GetField(CustomConstants.GRADE);
            string Location = msg.GetField(CustomConstants.LOCATION);
            string CycDt = msg.GetField(CustomConstants.CYCLE_DATE);
            string DelMo = msg.GetField(CustomConstants.DELIVER_MONTH);
            string Terms = msg.GetField(CustomConstants.TERMS);
            string Payment = msg.GetField(CustomConstants.PAYMENT);
            string Origin = msg.GetField(CustomConstants.ORIGIN);
            string NumOfCyc = msg.GetField(CustomConstants.NUM_OF_CYCLES);
            string Via = msg.GetField(CustomConstants.VIA);
            string MoveMo = msg.GetField(CustomConstants.MOVE_MONTH);
            string Comment = msg.GetField(CustomConstants.COMMENT);
            IsWater = msg.GetField(CustomConstants.ISWATER) == "Y";
            string BPFloorBkr = msg.GetField(CustomConstants.BP_FLOOR_BKR);
            string CounterFloorBkr = msg.GetField(CustomConstants.COUNTER_FLOOR_BKR);
            string Diff = msg.GetField(CustomConstants.DIFFERENCE);
            string MercMo = msg.GetField(CustomConstants.MERC_MO);
            string MercPr = msg.GetField(CustomConstants.MERC_PRICE);
        }
        else if (msg.Header.GetField(35) == "TI") //Index
        {
            DateTime dtTdate;
            float fPrice;
            int Qty;
            int OrdType;
            bool BPisBuyer;
            bool IsWater;

            DateTime.TryParse(msg.GetField(CustomConstants.TDATE), out dtTdate);
            string BPSide = msg.GetField(CustomConstants.BP_SIDE);
            float.TryParse(msg.GetField(CustomConstants.F_PRICE), out fPrice);
            int.TryParse(msg.GetField(CustomConstants.QTY), out Qty);
            string TCTReference = msg.GetField(CustomConstants.TCT_REF);
            string BPAcct = msg.GetField(CustomConstants.BP_COMPANY);
            int.TryParse(msg.GetField(CustomConstants.ORDER_TYPE), out OrdType);
            string ExecBkr = msg.GetField(CustomConstants.EXEC_BKR);
            string CounterParty = msg.GetField(CustomConstants.COUNTER_PARTY);
            BPisBuyer = msg.GetField(CustomConstants.IS_BUYER) == "Y";
            string BPTrader = msg.GetField(CustomConstants.BP_TRADER);
            string CounterTrader = msg.GetField(CustomConstants.COUNTER_TRADER);
            string Grade = msg.GetField(CustomConstants.GRADE);
            string Location = msg.GetField(CustomConstants.LOCATION);
            string CycDt = msg.GetField(CustomConstants.CYCLE_DATE);
            string DelMo = msg.GetField(CustomConstants.DELIVER_MONTH);
            string Terms = msg.GetField(CustomConstants.TERMS);
            string Payment = msg.GetField(CustomConstants.PAYMENT);
            string Origin = msg.GetField(CustomConstants.ORIGIN);
            string NumOfCyc = msg.GetField(CustomConstants.NUM_OF_CYCLES);
            string Via = msg.GetField(CustomConstants.VIA);
            string MoveMo = msg.GetField(CustomConstants.MOVE_MONTH);
            string Comment = msg.GetField(CustomConstants.COMMENT);
            IsWater = msg.GetField(CustomConstants.ISWATER) == "Y";
            string BPFloorBkr = msg.GetField(CustomConstants.BP_FLOOR_BKR);
            string CounterFloorBkr = msg.GetField(CustomConstants.COUNTER_FLOOR_BKR);
            string Diff = msg.GetField(CustomConstants.DIFFERENCE);
            string MercMo = msg.GetField(CustomConstants.MERC_MO);
            string MercPr = msg.GetField(CustomConstants.MERC_PRICE);


        }
    }
    public void OnCreate(SessionID sessionID)
    {
        AddToAdmin("SESSION CREATED: " + sessionID.ToString(), null);
    }
    public void OnLogout(SessionID sessionID)
    {
        AddToAdmin("LOGOUT: " + this.sessionID.ToString(), null);       
    }
    public void OnLogon(SessionID sessionID)
    {
        this.sessionID = sessionID;
        AddToAdmin("LOG ON: " + this.sessionID.ToString(),null);
    }
    public void FromAdmin(QuickFix.Message msg, SessionID sessionID)
    {
        AddToAdmin("FROM ADMIN: " + msg.ToString(), null);
    }
    public void ToAdmin(QuickFix.Message msg, SessionID sessionID)
    {
        if (msg.Header.GetField(35).ToString() == "A")
        {
            msg.SetField(new QuickFix.Fields.Username(username));
            msg.SetField(new QuickFix.Fields.Password(password));
        }

        AddToAdmin("TO ADMIN: " + msg.ToString(), null);
    }
    public void ToApp(QuickFix.Message msg, SessionID sessionID)
    {
        AddToLB("TO APP: " + msg.ToString(), null);       
    }        
    public void GetTestMessage(string msgType)
    {
        if (sessionID == null) return;
        QuickFix.FIX50.TestMessage msg = new QuickFix.FIX50.TestMessage();
        msg.TestType = msgType;
        msg.Header.SetField(new QuickFix.Fields.MsgType("TEST"));
        msg.SetField(new QuickFix.Fields.StringField(CustomConstants.TEST_TYPE, msgType));
        Session.SendToTarget(msg, sessionID);
    }
    public TCT_Fix()
    {
        settings = new SessionSettings(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "fix", "initiator.cfg"));
        storeFactory = new FileStoreFactory(settings);
        logFactory = new FileLogFactory(settings);
        initiator = new SocketInitiator(
            this,
            storeFactory,
            settings,
            logFactory);
    }
    public TCT_Fix(ref string initID)
    {
        InitiatorID = initID;
        settings = new SessionSettings(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "fix", "initiator.cfg"));
        storeFactory = new FileStoreFactory(settings);
        logFactory = new FileLogFactory(settings);
        initiator = new SocketInitiator(
            this,
            storeFactory,
            settings,
            logFactory);
    }
    public void RunIt()
    {
        if (running) return;
        if(initiator.IsStopped)
        {
            try
            {   
                initiator.Start(); //This can throw an error due to current set up.  I would recommend making the connection,
                                   //pulling data, and then closing the connection (polling) to ensure the initiator clears the
                                   //log files
                                   //reference http://lists.quickfixn.com/pipermail/quickfixn-quickfixn.com/2013q1/000747.html
                                   //2013 issue, still unresolved...  Restart app
            }
            catch(Exception ex)
            {
                if (MessageBox.Show("Error restarting initiator.  Program will close due to file access.  This is a Quickfix bug, not an issue with this program.  Please restart." + Environment.NewLine + Environment.NewLine +
                    "Reference: http://lists.quickfixn.com/pipermail/quickfixn-quickfixn.com/2013q1/000747.html for more information.  Click ok to copy link to clipboard.  Click \"X\" to ignore.") == DialogResult.OK)
                {
                    Clipboard.SetText("http://lists.quickfixn.com/pipermail/quickfixn-quickfixn.com/2013q1/000747.html");
                }
                throw new Exception(ex.ToString());
            }
        }          
        running = true;           
    }
}

最後に、目立たせるために (これは実際には上記のブロックにもあります)、以下のようなメッセージを作成します。ICE メッセージには、私の「TestMessage」にはない特定の必須フィールドがあることに注意してください。ただし、プロダクションからコードを提供することはできません-申し訳ありません。

public void GetTestMessage(string msgType)
    {
        if (sessionID == null) return;
        QuickFix.FIX50.TestMessage msg = new QuickFix.FIX50.TestMessage();
        msg.TestType = msgType;
        msg.Header.SetField(new QuickFix.Fields.MsgType("TEST"));
        msg.SetField(new QuickFix.Fields.StringField(CustomConstants.TEST_TYPE, msgType));
        Session.SendToTarget(msg, sessionID);
    }

学習曲線はかなりのものです。手に入れるまでは、遊び続ける必要があります。しかし、一度それを理解すると、それは理にかなっています。それにこだわります。他に何か必要な場合はお知らせください。

于 2016-11-14T20:41:09.013 に答える