Skip to content

Commit

Permalink
Merge pull request #27 from JonathonMurphy/master
Browse files Browse the repository at this point in the history
Updating/fixing documentation
  • Loading branch information
da4089 committed May 27, 2020
2 parents aaa1263 + 8753f39 commit f5318c3
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 10 deletions.
3 changes: 1 addition & 2 deletions doc/creating.rst
Expand Up @@ -7,7 +7,7 @@ To create a FIX message, first create an instance of the FixMessage class.

.. code-block:: python
msg = simplefix.FixMessage()
messsage = simplefix.FixMessage()
You can then add fields to the message as required. You should add the
Expand Down Expand Up @@ -163,4 +163,3 @@ which will result in the FIX message content (where | represents the SOH):
.. epigraph::

95=17|96=RAW DATA \\x00\\x01 VALUE|

7 changes: 2 additions & 5 deletions doc/import.rst
Expand Up @@ -9,7 +9,7 @@ or you can import some or all bindings directly.
import simplefix
fix_msg = simplefix.Message()
message = simplefix.FixMessage()
Or
Expand All @@ -19,7 +19,7 @@ Or
from simplefix import *
fix_msg = Message()
message = FixMessage()
Note that the "import *" form is explicitly supported, with the exposed
Expand All @@ -28,6 +28,3 @@ package.
All the example code in this document will use the first form, which is
recommended.



33 changes: 30 additions & 3 deletions doc/parsing.rst
@@ -1,18 +1,45 @@
Parsing Messages
----------------

To parse a FIX message, first create an instance of the FixParser class.

.. code-block:: python
parser = simplefix.FixParser()
To extract FIX messages from a byte buffer, such as that received from a
socket, you should first create an instance of the ``FixParser`` class. For
each byte string received, append it to the internal reassembly buffer using
socket, you should append it to the internal reassembly buffer using
``append_buffer()`` . At any time, you can call ``get_message()`` : if there's
no complete message in the parser's internal buffer, it'll return None,
otherwise, it'll return a ``FixMessage`` instance.

.. code-block:: python
parser.append_buffer(response_from_socket)
message = parser.get_message()
Once you've received a ``FixMessage`` from ``get_message()`` , you can: check
the number of fields with ``count()`` , retrieve the value of a field using
``get()`` or the built-in "[ ]" syntax, or iterate over all the fields using
"for ... in ...".

.. code-block:: python
message.count(49)
>>> 1
message.get(35)
>>> 'A'
message["35"]
>>> 'A'
Members of repeating groups can be accessed using ``get(tag, nth)``, where the
"nth" value is an integer indicating the number of the group to use (note
that the first group is number one, not zero).
that the first group is number one, not zero).

.. code-block:: python
messsage = get(9061, 2)
>>> 22

0 comments on commit f5318c3

Please sign in to comment.