예제 #1
0
    def test_fix_namespace(self, env, result):
        # `result.fix` namespace can be used for applying advanced
        # assertion rules to fix messages, which can
        # be nested (e.g. repeating groups)
        # For more info about FIX protocol, please see:
        # https://en.wikipedia.org/wiki/Financial_Information_eXchange

        # `fix.match` can compare two fix messages, and
        # supports custom comparators (like `dict.match`)

        fix_msg_1 = {
            36:
            6,
            22:
            5,
            55:
            2,
            38:
            5,
            555: [
                {
                    600: "A",
                    601: "A",
                    683: [{
                        688: "a",
                        689: "a"
                    }, {
                        688: "b",
                        689: "b"
                    }],
                },
                {
                    600: "B",
                    601: "B",
                    683: [{
                        688: "c",
                        689: "c"
                    }, {
                        688: "d",
                        689: "d"
                    }],
                },
            ],
        }

        fix_msg_2 = {
            36:
            6,
            22:
            5,
            55:
            2,
            38:
            comparison.GreaterEqual(4),
            555: [
                {
                    600:
                    "A",
                    601:
                    "B",
                    683: [
                        {
                            688: "a",
                            689: re.compile(r"[a-z]")
                        },
                        {
                            688: "b",
                            689: "b"
                        },
                    ],
                },
                {
                    600:
                    "C",
                    601:
                    "B",
                    683: [
                        {
                            688: "c",
                            689: comparison.In(("c", "d"))
                        },
                        {
                            688: "d",
                            689: "d"
                        },
                    ],
                },
            ],
        }
        result.fix.match(fix_msg_1, fix_msg_2)

        # `fix.check` can be used for checking existence / absence
        # of certain tags in a fix message

        result.fix.check(msg=fix_msg_1,
                         has_tags=[26, 22, 11],
                         absent_tags=[444, 555])

        # `fix.log` can be used to log a fix message in human readable format.

        result.fix.log(
            msg={
                36: 6,
                22: 5,
                55: 2,
                38: 5,
                555: [{
                    556: "USD",
                    624: 1
                }, {
                    556: "EUR",
                    624: 2
                }],
            })
예제 #2
0
    def test_fix_namespace(self, env, result):

        # `fix.match` can compare two fix messages, and
        # supports custom comparators (like `dict.match`)

        fix_msg_1 = {
            36: 6,
            22: 5,
            55: 2,
            38: 5,
            555: [
                {
                    600: "A",
                    601: "A",
                    683: [{688: "a", 689: None}, {688: "b", 689: "b"}],
                },
                {
                    600: "B",
                    601: "B",
                    683: [{688: "c", 689: "c"}, {688: "d", 689: "d"}],
                },
            ],
        }

        fix_msg_2 = {
            36: 6,
            22: 5,
            55: 2,
            38: comparison.GreaterEqual(4),
            555: [
                {
                    600: "A",
                    601: "B",
                    683: [
                        {688: "a", 689: re.compile(r"[a-z]")},
                        {688: "b", 689: "b"},
                    ],
                },
                {
                    600: "C",
                    601: "B",
                    683: [
                        {688: "c", 689: comparison.In(("c", "d"))},
                        {688: "d", 689: "d"},
                    ],
                },
            ],
        }
        result.fix.match(fix_msg_1, fix_msg_2)

        # `fix.check` can be used for checking existence / absence
        # of certain tags in a fix message

        result.fix.check(
            msg=fix_msg_1, has_tags=[26, 22, 11], absent_tags=[444, 555]
        )

        # `fix.log` can be used to log a fix message in human readable format.

        result.fix.log(
            msg={
                36: 6,
                22: 5,
                55: 2,
                38: 5,
                555: [{556: "USD", 624: 1}, {556: "EUR", 624: 2}],
            }
        )
예제 #3
0
    def test_fix_namespace(self, env, result):
        # `result.fix` namespace can be used for applying advanced
        # assertion rules to fix messages, which can
        # be nested (e.g. repeating groups)
        # For more info about FIX protocol, please see:
        # https://en.wikipedia.org/wiki/Financial_Information_eXchange

        # `fix.match` can compare two fix messages, and
        # supports custom comparators (like `dict.match`)

        fix_msg_1 = {
            36: 6,
            22: 5,
            55: 2,
            38: 5,
            555: [
                {
                    600: 'A',
                    601: 'A',
                    683: [
                        {
                            688: 'a',
                            689: 'a'
                        },
                        {
                            688: 'b',
                            689: 'b'
                        }
                    ]
                },
                {
                    600: 'B',
                    601: 'B',
                    683: [
                        {
                            688: 'c',
                            689: 'c'
                        },
                        {
                            688: 'd',
                            689: 'd'
                        }
                    ]
                }
            ]
        }

        fix_msg_2 = {
            36: 6,
            22: 5,
            55: 2,
            38: comparison.GreaterEqual(4),
            555: [
                {
                    600: 'A',
                    601: 'B',
                    683: [
                        {
                            688: 'a',
                            689: re.compile(r'[a-z]')
                        },
                        {
                            688: 'b',
                            689: 'b'
                        }
                    ]
                },
                {
                    600: 'C',
                    601: 'B',
                    683: [
                        {
                            688: 'c',
                            689: comparison.In(('c', 'd'))
                        },
                        {
                            688: 'd',
                            689: 'd'
                        }
                    ]
                }
            ]
        }
        result.fix.match(fix_msg_1, fix_msg_2)

        # `fix.check` can be used for checking existence / absence
        # of certain tags in a fix message

        result.fix.check(
            msg=fix_msg_1,
            has_tags=[26, 22, 11],
            absent_tags=[444, 555],
        )