{ "info": { "author": "Maksim Afanasevsky", "author_email": "maxtwen1@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "# AIOPyFIX [![Build Status](https://travis-ci.org/wannabegeek/PyFIX.svg?branch=master)](https://travis-ci.org/wannabegeek/PyFIX)\nOpen Source implementation of a FIX (Financial Information eXchange) Engine implemented in Python asyncio\n\nSee here [http://fixprotocol.org/] for more information on what FIX is.\n\n## Installation\n\nThis package requires Python 3.6 to run.\n\nInstall in the normal python way\n```\npip install aiopyfix\n```\nor from source\n```\npython setup.py install\n``` \nand it should install with no errors\n\n## Usage\nUsing the module should be simple. There is an examples directory, which is the probably best place to start.\n\n### Session Setup\n\nEither you can create a `FIXClient` or a `FIXServer`. The Client initiates the connection and also initaiates the Logon sequence, a Server would sit there waiting for inbound connections, and expect a Logon message to be sent.\n```python\nself.client = FIXClient(\"aiopyfix.FIX44\", \"TARGET\", \"SENDER\")\n\n# tell the client to start the connection sequence\nawait self.client.start('localhost', int(\"9898\"), loop)\n\n\n```\n\nThe argument \"aiopyfix.FIX44\" specified the module which is used as the protocol, this is dynamically loaded, to you can create and specify your own if required.\n\nIf you want to do something useful, other than just watching the session level bits work, you'll probably want to register for connection status changes (you'll need to do this be fore starting the event loop);\n\n```python\nself.client.addConnectionListener(self.onConnect, ConnectionState.CONNECTED)\nself.client.addConnectionListener(self.onDisconnect, ConnectionState.DISCONNECTED)\n```\n\nThe implementatino of thouse methods would be something like this;\n```python\nasync def onConnect(self, session):\n logging.info(\"Established connection to %s\" % (session.address(), ))\n session.addMessageHandler(self.onLogin, MessageDirection.INBOUND, self.client.protocol.msgtype.LOGON)\n\nasync def onDisconnect(self, session):\n logging.info(\"%s has disconnected\" % (session.address(), ))\n session.removeMsgHandler(self.onLogin, MessageDirection.INBOUND, self.client.protocol.msgtype.LOGON)\n```\nin the code above, we are registering to be called back whenever we receive (`MessageDirection.INBOUND`) a logon request `MsgType[35]=A` on that session.\n\nThat is pretty much it for the session setup.\n\n### Message construction and sending\n\nConstructing a message is simple, and is just a matter of adding the fields you require.\nThe session level tags will be added when the message is encoded by the codec. Setting any of the following session tags will result in the tag being duplicated in the message \n- BeginString\n- BodyLength\n- MsgType\n- MsgSeqNo\n- SendingTime\n- SenderCompID\n- TargetCompID\n- CheckSum\n\nExample of building a simple message\n\n```python\nasync def sendOrder(self, connectionHandler):\n self.clOrdID = self.clOrdID + 1\n # get the codec we are currently using for this session\n codec = connectionHandler.codec\n\n # create a new message\n msg = FIXMessage(codec.protocol.msgtype.NEWORDERSINGLE)\n\n # ...and add some data to it\n msg.setField(codec.protocol.fixtags.Price, random.random() * 1000)\n msg.setField(codec.protocol.fixtags.OrderQty, int(random.random() * 10000))\n msg.setField(codec.protocol.fixtags.Symbol, \"VOD.L\")\n msg.setField(codec.protocol.fixtags.SecurityID, \"GB00BH4HKS39\")\n msg.setField(codec.protocol.fixtags.SecurityIDSource, \"4\")\n msg.setField(codec.protocol.fixtags.Symbol, \"VOD.L\")\n msg.setField(codec.protocol.fixtags.Account, \"TEST\")\n msg.setField(codec.protocol.fixtags.HandlInst, \"1\")\n msg.setField(codec.protocol.fixtags.ExDestination, \"XLON\")\n msg.setField(codec.protocol.fixtags.Side, int(random.random() * 2))\n msg.setField(codec.protocol.fixtags.ClOrdID, str(self.clOrdID))\n msg.setField(codec.protocol.fixtags.Currency, \"GBP\")\n\n # send the message on the session\n await connectionHandler.sendMsg(codec.pack(msg, connectionHandler.session))\n```\n\nA message (which is a subclass of `FIXContext`) can also hold instances of `FIXContext`, these will be treated as repeating groups. For example\n\n```\nmsg = FIXMessage(codec.protocol.msgtype.NEWORDERSINGLE)\nmsg.setField(codec.protocol.fixtags.Symbol, \"VOD.L\")\nmsg.setField(codec.protocol.fixtags.SecurityID, \"GB00BH4HKS39\")\nmsg.setField(codec.protocol.fixtags.SecurityIDSource, \"4\")\n\nrptgrp1 = FIXContext()\nrptgrp1.setField(codec.protocol.fixtags.PartyID, \"It's Me\")\nrptgrp1.setField(codec.protocol.fixtags.PartyIDSource, \"1\")\nrptgrp1.setField(codec.protocol.fixtags.PartyRole, \"2\")\n\nmsg.addRepeatingGroup(codec.protocol.fixtags.NoPartyIDs, rptgrp1)\n\nrptgrp2 = FIXContext()\nrptgrp2.setField(codec.protocol.fixtags.PartyID, \"Someone Else\")\nrptgrp2.setField(codec.protocol.fixtags.PartyIDSource, \"2\")\nrptgrp2.setField(codec.protocol.fixtags.PartyRole, \"8\")\nmsg.addRepeatingGroup(codec.protocol.fixtags.NoPartyIDs, rptgrp2)\n\n```\nThis will result in a message like the following\n```\n8=FIX.4.4|9=144|35=D|49=sender|56=target|34=1|52=20150619-11:08:54.000|55=VOD.L|48=GB00BH4HKS39|22=4|453=2|448=It's Me|447=1|452=2|448=Someone Else|447=2|452=8|10=073|\n```\n\nTo send the message you need a handle on the session you want to use, this is provided to you in the callback methods. e.g. in the code above we registered for Logon callbacks using\n```\nsession.addMessageHandler(self.onLogin, MessageDirection.INBOUND, self.client.protocol.msgtype.LOGON)\n```\n\nthe signature for the callback is something like;\n```\nasync def onLogin(self, connectionHandler, msg):\n logging.info(\"Logged in\")\n```\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "https://github.com/maxtwen/AIOPyFix/", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/maxtwen/AIOPyFix/", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "aiopyfix", "package_url": "https://pypi.org/project/aiopyfix/", "platform": "", "project_url": "https://pypi.org/project/aiopyfix/", "project_urls": { "Download": "https://github.com/maxtwen/AIOPyFix/", "Homepage": "https://github.com/maxtwen/AIOPyFix/" }, "release_url": "https://pypi.org/project/aiopyfix/0.4/", "requires_dist": null, "requires_python": "", "summary": "aiopyfix", "version": "0.4" }, "last_serial": 4664863, "releases": { "0.3": [ { "comment_text": "", "digests": { "md5": "c1c482830be683f4fda6c3ed429c49f7", "sha256": "552130c1d243c3a9c6b0c16384374788aff6b660febfcb705ccd4f4d8ab02f92" }, "downloads": -1, "filename": "aiopyfix-0.3-py3-none-any.whl", "has_sig": false, "md5_digest": "c1c482830be683f4fda6c3ed429c49f7", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 28374, "upload_time": "2019-01-06T01:46:47", "url": "https://files.pythonhosted.org/packages/0c/2e/98481edc0eb5ea969fd43081a178da7a0f7c2afa7ff5d595f1bd6f1673ec/aiopyfix-0.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a9807f70b0b20d19740d71185344735c", "sha256": "c383a6f918ff1658b4b40eec2414deafce0b497f02d24a2e016d4be521410db9" }, "downloads": -1, "filename": "aiopyfix-0.3.tar.gz", "has_sig": false, "md5_digest": "a9807f70b0b20d19740d71185344735c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 21439, "upload_time": "2019-01-06T01:46:49", "url": "https://files.pythonhosted.org/packages/d2/73/ac79fffe0d39222fac513b7b144165f5b219a582b9b7f458703a2943d479/aiopyfix-0.3.tar.gz" } ], "0.4": [ { "comment_text": "", "digests": { "md5": "b4afe37fb809bc8ed6fb4e22cfef26b5", "sha256": "87fdab680ad623a48feef40e66f75aa27f3f31c9a658627b7b0feb477d6041a7" }, "downloads": -1, "filename": "aiopyfix-0.4-py3-none-any.whl", "has_sig": false, "md5_digest": "b4afe37fb809bc8ed6fb4e22cfef26b5", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 28388, "upload_time": "2019-01-06T03:23:53", "url": "https://files.pythonhosted.org/packages/d0/c8/b25658100ad203c41729fc9d40ff1bbcb95d23038c1b631c0fc350e74607/aiopyfix-0.4-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "1b82f930616dc18384e2003c02377ab8", "sha256": "0bcfacd4c67cb0ee72b1c10f519f0a6375f54c74a985264e24ab01a7247ddcac" }, "downloads": -1, "filename": "aiopyfix-0.4.tar.gz", "has_sig": false, "md5_digest": "1b82f930616dc18384e2003c02377ab8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 21479, "upload_time": "2019-01-06T03:23:56", "url": "https://files.pythonhosted.org/packages/67/7c/0ff6d0631fdde57ee0aaca5ebc20411aef858d605d5bf26dbfe53c591cba/aiopyfix-0.4.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "b4afe37fb809bc8ed6fb4e22cfef26b5", "sha256": "87fdab680ad623a48feef40e66f75aa27f3f31c9a658627b7b0feb477d6041a7" }, "downloads": -1, "filename": "aiopyfix-0.4-py3-none-any.whl", "has_sig": false, "md5_digest": "b4afe37fb809bc8ed6fb4e22cfef26b5", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 28388, "upload_time": "2019-01-06T03:23:53", "url": "https://files.pythonhosted.org/packages/d0/c8/b25658100ad203c41729fc9d40ff1bbcb95d23038c1b631c0fc350e74607/aiopyfix-0.4-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "1b82f930616dc18384e2003c02377ab8", "sha256": "0bcfacd4c67cb0ee72b1c10f519f0a6375f54c74a985264e24ab01a7247ddcac" }, "downloads": -1, "filename": "aiopyfix-0.4.tar.gz", "has_sig": false, "md5_digest": "1b82f930616dc18384e2003c02377ab8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 21479, "upload_time": "2019-01-06T03:23:56", "url": "https://files.pythonhosted.org/packages/67/7c/0ff6d0631fdde57ee0aaca5ebc20411aef858d605d5bf26dbfe53c591cba/aiopyfix-0.4.tar.gz" } ] }