Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from JonathonMurphy/master
Updating/fixing documentation
- Loading branch information
Showing
3 changed files
with
33 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |