diff --git a/simplefix/__init__.py b/simplefix/__init__.py index 556aef5..096aebf 100644 --- a/simplefix/__init__.py +++ b/simplefix/__init__.py @@ -27,6 +27,7 @@ from .message import FixMessage, SOH from .parser import FixParser +from .constants import * def pretty_print(s): diff --git a/simplefix/constants.py b/simplefix/constants.py new file mode 100644 index 0000000..c42c778 --- /dev/null +++ b/simplefix/constants.py @@ -0,0 +1,123 @@ +#! /usr/bin/env python +######################################################################## +# SimpleFIX +# Copyright (C) 2017, David Arnold. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# +######################################################################## + +"""FIX protocol constants.""" + +SOH_BYTE = b'\x01' +EQUALS_BYTE = b'=' + +MSGTYPE_HEARTBEAT = b'0' +MSGTYPE_TEST_REQUEST = b'1' +MSGTYPE_RESEND_REQUEST = b'2' +MSGTYPE_REJECT = b'3' +MSGTYPE_SEQUENCE_RESET = b'4' +MSGTYPE_LOGOUT = b'5' +MSGTYPE_INDICATION_OF_INTEREST = b'6' +MSGTYPE_ADVERTISEMENT = b'7' +MSGTYPE_EXECUTION_REPORT = b'8' +MSGTYPE_ORDER_CANCEL_REJECT = b'9' +MSGTYPE_LOGON = b'A' +MSGTYPE_NEWS = b'B' +MSGTYPE_EMAIL = b'C' +MSGTYPE_NEW_ORDER_SINGLE = b'D' +MSGTYPE_NEW_ORDER_LIST = b'E' +MSGTYPE_ORDER_CANCEL_REQUEST = b'F' +MSGTYPE_ORDER_STATUS_REQUEST = b'G' +MSGTYPE_ALLOCATION = b'J' +MSGTYPE_LIST_CANCEL_REQUEST = b'K' +MSGTYPE_LIST_EXECUTE = b'L' +MSGTYPE_LIST_STATUS_REQUEST = b'M' +MSGTYPE_LIST_STATUS = b'N' +MSGTYPE_ALLOCATION_ACK = b'P' +MSGTYPE_DONT_KNOW_TRADE = b'Q' +MSGTYPE_QUOTE_REQUEST = b'R' +MSGTYPE_QUOTE = b'S' +MSGTYPE_SETTLEMENT_INSTRUCTIONS = b'T' +MSGTYPE_MARKET_DATA_REQUEST = b'V' +MSGTYPE_MARKET_DATA_SNAPSHOT_FULL_REFRESH = b'W' +MSGTYPE_MARKET_DATA_INCREMENTAL_REFRESH = b'X' +MSGTYPE_MARKET_DATA_REQUEST_REJECT = b'Y' +MSGTYPE_QUOTE_CANCEL = b'Z' +MSGTYPE_QUOTE_STATUS_REQUEST = b'a' +MSGTYPE_QUOTE_ACKNOWLEDGEMENT = b'b' +MSGYYPE_SECURITY_DEFINITION_REQUEST = b'c' +MSGTYPE_SECURITY_DEFINITION = b'd' +MSGTYPE_SECURITY_STATUS_REQUEST = b'e' +MSGTYPE_SECURITY_STATUS = b'f' +MSGTYPE_TRADING_SESSION_STATUS_REQUEST = b'g' +MSGTYPE_TRADING_SESSION_STATUS = b'h' +MSGTYPE_MASS_QUOTE = b'i' +MSGTYPE_BUSINESS_MESSAGE_REJECT = b'j' +MSGTYPE_BID_REQUEST = b'k' +MSGTYPE_BID_RESPONSE = b'l' +MSGTYPE_LIST_STRIKE_PRICE = b'm' +MSGTYPE_XML_MESSAGE = b'n' +MSGTYPE_REGISTRATION_INSTRUCTIONS = b'o' +MSGTYPE_REGISTRATION_INSTRUCTIONS_RESPONSE = b'p' +MSGTYPE_ORDER_MASS_CANCEL_REQUEST = b'q' +MSGTYPE_ORDER_MASS_CANCEL_REPORT = b'r' +MSGTYPE_NEW_ORDER_CROSS = b's' +MSGTYPE_CROSS_ORDER_CANCEL_REPLACE_REQUEST = b't' +MSGTYPE_CROSS_ORDER_CANCEL_REQUEST = b'u' +MSGTYPE_SECURITY_TYPE_REQUEST = b'v' +MSGTYPE_SECURITY_TYPES = b'w' +MSGTYPE_SECURITY_LIST_REQUEST = b'x' +MSGTYPE_SECURITY_LIST = b'y' +MSGTYPE_DERIVATIVE_SECURITY_LIST_REQUEST = b'z' +MSGTYPE_DERIVATIVE_SECURITY_LIST = b'AA' +MSGTYPE_NEW_ORDER_MULTILEG = b'AB' +MSGTYPE_MULTILEG_ORDER_CANCEL_REPLACE_REQUEST = b'AC' +MSGTYPE_TRADE_CAPTURE_REPORT_REQUEST = b'AD' +MSGTYPE_TRADE_CAPTURE_REPORT = b'AE' +MSGTYPE_ORDER_MASS_STATUS_REQUEST = b'AF' +MSGTYPE_QUOTE_REQUEST_REJECT = b'AG' +MSGTYPE_RFQ_REQUEST = b'AH' +MSGTYPE_QUOTE_STATUS_REPORT = b'AI' +MSGTYPE_QUOTE_RESPONSE = b'AJ' +MSGTYPE_CONFIRMATION = b'AK' +MSGTYPE_POSITION_MAINTENANCE_REQUEST = b'AL' +MSGTYPE_POSITION_MAINTENANCE_REPORT = b'AM' +MSGTYPE_REQUEST_FOR_POSITIONS = b'AN' +MSGTYPE_REQUEST_FOR_POSITIONS_ACK = b'AO' +MSGTYPE_POSITION_REPORT = b'AP' +MSGTYPE_TRADE_CAPTURE_REPORT_REQUEST_ACK = b'AQ' +MSGTYPE_TRADE_CAPTURE_REPORT_ACK = b'AR' +MSGTYPE_ALLOCATION_REPORT = b'AS' +MSGTYPE_ALLOCATION_REPORT_ACK = b'AT' +MSGTYPE_CONFIRMATION_ACK = b'AU' +MSGTYPE_SETTLEMENT_INSTRUCTION_REQUEST = b'AV' +MSGTYPE_ASSIGNMENT_REPORT = b'AW' +MSGTYPE_COLLATERAL_REQUEST = b'AX' +MSGTYPE_COLLATERAL_ASSIGNMENT = b'AY' +MSGTYPE_COLLATERAL_RESPONSE = b'AZ' +MSGTYPE_COLLATERAL_REPORT = b'BA' +MSGTYPE_COLLATERAL_INQUIRY = b'BB' +MSGTYPE_NETWORK_STATUS_REQUEST = b'BC' +MSGTYPE_NETWORK_STATUS_RESPONSE = b'BD' +MSGTYPE_USER_REQUEST = b'BE' +MSGTYPE_USER_RESPONSE = b'BF' +MSGTYPE_COLLATERAL_INQUIRY_ACK = b'BG' +MSGTYPE_CONFIRMATION_REQUEST = 'BH' + diff --git a/test/all.py b/test/all.py index e444d83..e7cb91e 100644 --- a/test/all.py +++ b/test/all.py @@ -25,9 +25,11 @@ import unittest +from test_constants import ConstantsTests from test_init import InitTests from test_message import MessageTests from test_parser import ParserTests + if __name__ == "__main__": unittest.main() diff --git a/test/test_constants.py b/test/test_constants.py new file mode 100644 index 0000000..07269b9 --- /dev/null +++ b/test/test_constants.py @@ -0,0 +1,44 @@ +#! /usr/bin/env python +######################################################################## +# SimpleFIX +# Copyright (C) 2017, David Arnold. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# +######################################################################## + +import unittest +import simplefix + + +class ConstantsTests(unittest.TestCase): + + def setUp(self): + pass + + def tearDown(self): + pass + + def test_35(self): + self.assertEqual(b'0', simplefix.MSGTYPE_HEARTBEAT) + return + + +if __name__ == "__main__": + unittest.main()