コード例 #1
0
        public void UnwrapMessage_AsMsgType_Ok_Sandbox()
        {
            // arrange
            var jsonFixMsg = new JsonFixMessageReceived
            {
                localPseudoHeader = "myPseudoHeader",
                messageTypeCode35 = "D",
                rawFixPayload     = "8=FIX.4.2\u00019=00\u000135=D\u000149=Sender\u000156=Target\u000134=0\u000152=99990909-17:17:17.777\u000154=1\u000155=ABC\u000111=BUY000000001\u000138=1000\u000140=2\u000144=1001.000\u000159=3\u0001117=A001\u000146=A001\u000110=000\u0001"
            };

            // act
            QuickFix.Message fixMsg = _jsonFixWrapper.Unwrap(jsonFixMsg);
            // QuickFix.FIX42.NewOrderSingle newOrderD = new QuickFix.FIX42.NewOrderSingle();

            QuickFix.FIX42.NewOrderSingle newOrderD = _jsonFixWrapper.UnwrapAsType <NewOrderSingle>(jsonFixMsg);


            // issue how to downcast

            // assert
            var expectedTicker = "ABC";
            var expectedTarget = "Target";

            var actualTarget = newOrderD.Header.GetField(new QuickFix.Fields.TargetCompID()).getValue();
            var actualTicker = newOrderD.Header.GetField(new QuickFix.Fields.Symbol()).getValue();

            Assert.Equal(expectedTicker, actualTicker);
            Assert.Equal(expectedTarget, actualTarget);
        }
コード例 #2
0
ファイル: IJsonFixWrapper.cs プロジェクト: marcdata/jsonfix
        public T UnwrapAsType <T>(JsonFixMessageReceived jsonFixMessage) where T : QuickFix.FIX42.Message
        {
            // get tag 35 from header of fix message
            // get messageFactory
            // get typedmessage built from factory


            T typedMessage;

            var beginString    = "FIX.4.2";
            var messageTypeArg = "D";

            var rawFromString = jsonFixMessage.rawFixPayload;

            var messageFactory            = new MessageFactory();
            var pathToFix42DataDictionary = @"C:\Users\marc\Downloads\quickfixn-v1.8.0\spec\fix\FIX42.xml";

            QuickFix.DataDictionary.DataDictionary dd = new QuickFix.DataDictionary.DataDictionary(pathToFix42DataDictionary);

            var x = messageFactory.Create(beginString, messageTypeArg);

            x.FromString(rawFromString, false, dd, dd);

            var er = new ExecutionReport();

            typedMessage = x as T;

            if (typedMessage == null)
            {
                Console.WriteLine("oops");
            }
            return(typedMessage);
        }