{"id":22609052,"url":"https://github.com/bitfinexcom/bfxfixgw","last_synced_at":"2025-04-11T06:20:38.443Z","repository":{"id":141634048,"uuid":"78872806","full_name":"bitfinexcom/bfxfixgw","owner":"bitfinexcom","description":"Bitfinex FIX Gateway","archived":false,"fork":false,"pushed_at":"2023-11-23T14:21:35.000Z","size":4579,"stargazers_count":44,"open_issues_count":1,"forks_count":18,"subscribers_count":18,"default_branch":"master","last_synced_at":"2025-03-25T04:17:46.385Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.bitfinex.com","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bitfinexcom.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-01-13T17:57:52.000Z","updated_at":"2025-02-25T22:24:05.000Z","dependencies_parsed_at":"2024-12-08T15:10:50.446Z","dependency_job_id":"c1e11fb8-1b6f-4e03-8258-a0fd422d0285","html_url":"https://github.com/bitfinexcom/bfxfixgw","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitfinexcom%2Fbfxfixgw","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitfinexcom%2Fbfxfixgw/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitfinexcom%2Fbfxfixgw/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitfinexcom%2Fbfxfixgw/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bitfinexcom","download_url":"https://codeload.github.com/bitfinexcom/bfxfixgw/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248352269,"owners_count":21089414,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-08T15:10:45.142Z","updated_at":"2025-04-11T06:20:38.424Z","avatar_url":"https://github.com/bitfinexcom.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"## $\\textcolor{red}{\\textsf{DEPRECATED PROJECT}}$\n### $\\textcolor{red}{\\textsf{This project has been deprecated in favor of a native gateway implementation.}}$\n### $\\textcolor{red}{\\textsf{For more information please contact us via email at}}$ `fix-support@bitfinex.com`\n\n![No Maintenance Intended](https://img.shields.io/badge/No%20Maintenance%20Intended-%E2%9C%95-red.svg)\n\n# Bitfinex GO FIX Gateway\n\nThe Bitfinex FIX gateway uses [QuickFix/go](https://github.com/quickfixgo/quickfix) to implement FIX connectivity. [The Bitfinex Go API](https://github.com/bitfinexcom/bitfinex-api-go) is used to manage the [Bitfinex API websocket](https://bitfinex.readme.io/docs) connection, which ultimately uses [Gorilla](https://github.com/gorilla/websocket).\n\n## Build\n\n### Go Environment\n\nIf one does not already exist, install a Go environment by following [these instructions](https://golang.org/doc/install).  If GOPATH is set to ~/go and the bfxfixgw repository is cloned to ~/go/src/github.com/bitfinexcom/bfxfixgw, then the following simple go command is all that is needed if issued from the ~/go directory.  Both bfxfixgw and fix_client will be installed to ~/go/bin after issuing the command.\n\nObtain all additional sources, build, and install:\n\n```bash\ngo get ./...\n```\n\n### Building Source Changes\n\nLocal bfxfixgw source changes can be built by issuing the following commands from the ~/go/src/github.com/bitfinexcom/bfxfixgw directory.  The install command will copy the latest version of bfxfixgw and fix_client to ~/go/bin.\n\nTest:\n\n```bash\nmake check\n```\n\nLinter:\n\n```bash\nmake lint\n```\n\nBuild:\n\n```bash\nmake build\n```\n\nAnd install binaries:\n\n```bash\nmake install\n```\n\nOr do all above steps:\n\n```bash\nmake all\n```\n\n## Configuration\n\nThe FIX gateway can operate in order routing mode, market data mode, or both.  Order routing \u0026 market data FIX endpoints must be separate with distinct session IDs.\n\n### Environment\n\n- `DEBUG=1` to enable debug logging\n- `FIX_SETTINGS_DIRECTORY=./config` to read the configs from the given directory, `./config`\n  is the default directory.\n\n### Sessions\n\nSessions must be known to the FIX gateway prior to startup.  A FIX gateway can manage any number of sessions.  Each FIX session will create 1 websocket proxy connection.\n\n#### Sequence Numbers\n\nThe market data FIX service does not support resend requests or replaying FIX messages. When connecting to the market data FIX endpoint, a FIX initiator must have the correct sequence number, or a lower than expected sequence number.\n\nThe order routing service strictly tracks sequence numbers and does support message storage. A FIX initiator can send `ResetSeqNumFlag=Y` on Logon to reset session sequence numbers.\n\n### FIX Configuration Examples\n\nExample service FIX session configuration for a market data service:\n\n```\n[DEFAULT]\nSenderCompID=BFXFIX\nResetOnLogon=Y\nReconnectInterval=60\nFileLogPath=tmp/md_service/log\nSocketAcceptPort=5001\nStartTime=00:05:00\nStartDay=Sun\nEndTime=00:00:00\nEndDay=Sun\n\n[SESSION]\nTargetCompID=EXORG_MD\nBeginString=FIX.4.2\nDefaultApplVerID=FIX.4.2\nHeartBtInt=30\n```\n\nExample service FIX session configuration for an order routing service:\n\n```\n[DEFAULT]\nSenderCompID=BFXFIX\nReconnectInterval=60\nFileLogPath=tmp/ord_service/log\nFileStorePath=tmp/ord_service/data\nSocketAcceptPort=5002\nStartTime=00:05:00\nStartDay=Sun\nEndTime=00:00:00\nEndDay=Sun\n\n[SESSION]\nTargetCompID=EXORG_ORD\nBeginString=FIX.4.2\nDefaultApplVerID=FIX.4.2\nHeartBtInt=30\n```\n\n### Gateway Startup\n\nTo startup the gateway in verbose mode (-v) with both order routing and market data endpoints (staging configuration) run the following command:\n\n```bash\nFIX_SETTINGS_DIRECTORY=~/go/src/github.com/bitfinexcom/bfxfixgw/conf/integration_test/service ~/go/bin/bfxfixgw -v -orders -ordcfg \"orders_fix42.cfg\" -md -mdcfg \"marketdata_fix42.cfg\" -rest \"https://api.bitfinex.com/v2/\" -ws \"wss://api.bitfinex.com/ws/2\"\n```\n\n## Authentication\n\nFIX session information must be obtained prior to a FIX client establishing a connection.  The pre-determined TargetCompID, SenderCompID, and FIX version strings should be configured in the FIX client configuration.\n\nOnce sessions are configured, a FIX client can authenticate by adding the Bitfinex User ID, API key, and API secret into the FIX `35=A Logon` message body:\n\n| Field \t\t\t\t| FIX Tag # | Description \t\t|\n|-----------------------|-----------|-------------------|\n| BfxApiKey \t\t\t| 20000\t\t| User's API Key\t|\n| BfxApiSecret \t\t\t| 20001\t\t| User's API Secret\t|\n| BfxUserID \t\t\t| 20002\t\t| User's Bfx ID\t\t|\n\nOptionally, a user can request all session-level orders be canceled when the FIX session is disconnected by setting the following FIX tag `8013=Y`:\n\n| Field \t\t\t\t| FIX Tag # | Description \t\t|\n|-----------------------|-----------|-------------------|\n| CancelOnDisconnect\t| 8013\t\t| Cancel session orders on FIX disconnect |\n\n---\n**Note:**\nFIX clients should use separate API keys for market data and order routing FIX endpoints.\n\n---\n\nThese tags are supported by the gateway's default [data dictionary](spec/Bitfinex_FIX42.xml).  An example staging logon message (`SOH` replaced with `|`):\n\n```\n8=FIX.4.2|9=186|35=A|34=1|49=EXORG_ORD|52=20180416-18:27:47.541|56=BFXFIX|20000=U83q9jkML2GVj1fVxFJOAXQeDGaXIzeZ6PwNPQLEXt4|20001=77SWIRggvw0rCOJUgk9GVcxbldjTxOJP5WLCjWBFIVc|20002=connamara|98=0|108=30|10=117|\n```\n\n## Testing using fix_client\n\nThe project includes a test client utility called fix_client.  fix_client is a simple gateway client that demonstrates a subset of gateway functionality.  The client currently supports sending and canceling orders via the gateway.  Simply run the client, issue a root command (either nos or cxl), and then provide additional request parameters as prompted.\n\n### Configuring fix_client\n\nThe fix_client takes a quickfix configuration file located here ~/go/src/github.com/bitfinexcom/bfxfixgw/conf/integration_test/client/orders_fix42.cfg.  To successfully connect to BFX using the gateway, you must change the following parameters to match the API access of your account.  Please note the security risk of adding credentials to this file in plain text.  You may want to remove these values after you are done with testing using fix_client\n\n```\nApiKey=[User's API Key]  \nApiSecret=[User's API Secret]  \nBfxUserID=[User's Bfx ID]  \n```\n\n### Running fix_client Example\n\nHere is an example of using fix_client to place a market order.  All outgoing and incoming FIX traffic is logged.  You can decode the FIX manually or using your favorite FIX parser.  Please be careful to avoid sending FIX logs that contain private keys to online parsers.  Some logging has been stripped out for clarity and user input is **bold**.  \n\n\u003e**./fix_client -cfg ../src/github.com/bitfinexcom/bfxfixgw/conf/integration_test/client/orders_fix42.cfg**  \nEnter command:  \n**nos**  \n-\u003e New Order Single  \nEnter ClOrdID (integer):  \n**1**  \nEnter symbol:  \n**tBTCUSD**  \nEnter order type:  \n**market**  \nEnter qty:  \n**0.05**  \nEnter side:  \n**buy**  \nOptions? (hidden, postonly, fok): [FIX Client] MockFix.ToApp (outgoing): 8=FIX.4.2|9=126|35=D|34=547|49=EXORG_ORD|52=20180504-16:45:04.697|56=BFXFIX|11=1|21=3|38=0.0500|40=1|54=1|55=tBTCUSD|60=20180504-16:45:03.518|10=249|  \n[FIX Client] MockFix.FromApp (incoming): 8=FIX.4.2|9=221|35=8|34=550|49=BFXFIX|52=20180504-16:45:04.804|56=EXORG_ORD|1=connamara|6=0.00|11=1|14=0.0000|17=43a98b1d-0312-41cf-9678-33e268e9bff9|20=3|32=0.0000|37=1149703695|38=0.0500|39=0|40=1|54=1|55=tBTCUSD|59=1|150=0|151=0.0500|10=007|  \n\u003c2018-05-04 16:45:05.823298994 +0000 UTC, FIX.4.2:EXORG_ORD-\u003eBFXFIX, incoming\u003e  \n[FIX Client] MockFix.FromApp (incoming): 8=FIX.4.2|9=250|35=8|34=551|49=BFXFIX|52=20180504-16:45:05.818|56=EXORG_ORD|1=connamara|6=850.00|11=1|12=0.0001|13=3|14=0.0500|17=1cfb00fc-9ea6-4dca-8d9f-a5cce1cc0959|20=3|31=850.0000|32=0.0500|37=1149703695|38=0.0500|39=2|40=1|54=1|55=tBTCUSD|59=1|150=2|151=0.0000|10=182  \n\n## Market Data Distribution\n\nThe FIX gateway service may be configured to distribute market data. Starting the process with `-md` will enable market data distribution, configured by the `-mdcfg` flag.\n\n### Examples\n\nSubscribe to `tBTCUSD` top-of-book Precision0 updates:\n\n```\n8=FIX.4.2|9=111|35=V|34=2|49=EXORG_MD|52=20180417-19:40:17.467|56=BFXFIX|146=1|55=tBTCUSD|262=req-tBTCUSD|263=1|264=1|20003=P0|10=167|\n```\n\nSubscribe to `tETHUSD` full raw book updates at 25 price levels:\n\n```\n8=FIX.4.2|9=112|35=V|34=3|49=EXORG_MD|52=20180417-19:46:44.594|56=BFXFIX|146=1|55=tETHUSD|262=req-tETHUSD|263=1|264=25|20003=R0|10=248|\n```\n\nReceive FIX `35=W` book snapshot (for the first tBTCUSD request):\n\n```\n8=FIX.4.2|9=168|35=W|34=3|49=BFXFIX|52=20180417-19:40:21.294|56=EXORG_MD|22=8|48=tBTCUSD|55=tBTCUSD|262=req-tBTCUSD|268=2|269=0|270=1663.9000|271=0.0400|269=1|270=1670.8000|271=0.1000|10=242|\n```\n\nReceive FIX `35=X` market data incremental update (for the first tBTCUSD request):\n\n```\n8=FIX.4.2|9=140|35=X|34=5|49=BFXFIX|52=20180417-19:41:48.474|56=EXORG_MD|262=req-tBTCUSD|268=1|279=2|269=1|55=tBTCUSD|48=tBTCUSD|22=8|270=0.0000|271=1.0000|10=185|\n```\n\nReceive FIX `35=X` trade incremental update (for the first tBTCUSD request):\n\n```\n8=FIX.4.2|9=143|35=X|34=5|49=BFXFIX|52=20180417-21:25:27.455|56=EXORG_MD|262=req-tBTCUSD|268=1|279=0|269=2|55=tBTCUSD|48=tBTCUSD|22=8|270=1671.0000|271=0.1000|10=081|\n```\n\nReceive FIX `35=AP` wallet snapshot and/or update\n\n```\n8=FIX.4.2|9=190|35=AP|34=2|49=BFXFIX|52=20190801-19:29:05.679|56=EXORG_ORD|1=user123|15=fUSD|581=exchange|715=20190801|721=fd96bcd8-0133-4740-a1e1-044feddd1be7|730=1123.4500|731=1|734=1234.5600|746=10.0000|10=099|\n```\n\nReceive FIX `35=AP` balance update\n\n```\n8=FIX.4.2|9=184|35=AP|34=2|49=BFXFIX|52=20190801-19:31:26.318|56=EXORG_ORD|1=user123|15=all|581=balance|715=20190801|721=fcefabf1-13b2-4f06-8015-521109c640de|730=12.3400|731=1|734=123.4500|746=0.0000|10=139|\n```\n\n## Order Routing\n\nOrder routing can be enabled with the `-ord` and `-ordcfg` flags on startup.\n\nThe following table lists Bitfinex order type support in the FIX gateway:\n\n| Order Type\t| FIX 4.2\t| FIX 4.4\t| FIX 5.0\t|\n|---------------|:---------:|:---------:|:---------:|\n| Market\t\t| ✔\t\t\t| ✔\t\t\t| ✔\t\t\t|\n| Limit\t\t\t| ✔\t\t\t| ✔\t\t\t| ✔\t\t\t|\n| Stop\t\t\t| ✔\t\t\t| ✔\t\t\t| ✔\t\t\t|\n| Stop Limit\t| ✔\t\t\t| ✔\t\t\t| ✔\t\t\t|\n| Trailing Stop | ✔\t\t\t| ✔\t\t\t| ✔\t\t\t|\n\nBelow is a table of various Bitfinex order features and their FIX `35=D NewOrderSingle` tags:\n\n| Bitfinex Order Feature \t| FIX Tag\t\t\t\t| FIX Tag Value\t\t\t\t\t|\n|---------------------------|-----------------------|-------------------------------|\n| Hidden\t\t\t\t\t| DisplayMethod (1084)\t| Undisclosed (4)\t\t\t\t|\n| Post-Only\u003csup\u003e*\u003c/sup\u003e\t\t| ExecInst (18)\t\t\t| Participate don't initiate (6)|\n| One Cancels Other (OCO)   | ContingencyType (1385)| One Cancels the Other (1)     |\n| Fill or Kill\t\t\t\t| TimeInForce (59)\t\t| Fill or Kill (4)\t\t\t\t|\n| Good till Date\t\t\t| TimeInForce (59)\t\t| Good till Date (6)\t\t\t|\n| Good till Date\t\t\t| ExpireTime (126)\t\t| Example: 2006-01-02 15:04:05\t|\n| Margin\u003csup\u003e*\u003c/sup\u003e        | CashMargin (544)\t\t| Margin Open (2)\t\t\t\t|\n| Leverage          \t\t| Leverage (20005)\t\t| Example: 10 (INTEGER)     \t|\n\n\u003csup\u003e*\u003c/sup\u003e Post-Only orders are considered to have a Good-till-Cancel time in force.  \n\n\u003csup\u003e*\u003c/sup\u003e Margin order execution reports respond with CashMargin (544) = Margin Close (3)\n\nFor a trailing stop order:\n\n| Trailing Stop Feature\t\t| FIX Tag\t\t\t\t| FIX Tag Value\t\t\t\t\t\t|\n|---------------------------|-----------------------|-----------------------------------|\n| Order Type\t\t\t\t| OrdType (40)\t\t\t| Stop (3) or Stop Limit (4)\t|\n| Execute as Trailing Peg\t| ExecInst (18)\t\t\t| Primary Peg (R)\t\t\t\t|\n| Trailing Peg Value\t\t| PegOffsetValue (211)\t| Price\u003csup\u003e*\u003c/sup\u003e\t\t\t\t|\n\n\u003csup\u003e*\u003c/sup\u003e The trailing stop price should be in the same units as a Price (44) or StopPx (99).\n\ne.g. For a trailing stop order where the stop should trail the market by $5.25, the following FIX tags should be set:\n\n| Field\t\t\t\t| Tag\t| Value\t\t|\n|-------------------|-------|-----------|\n| OrdType\t\t\t| 40\t| 4\t\t\t|\n| ExecInst\t\t\t| 18\t| R\t\t\t|\n| PegOffsetValue\t| 211\t| 5.25\t\t|\n\n### Examples\n\nSend limit new order single:\n\n```\n8=FIX.4.2|9=142|35=D|34=34|49=EXORG_ORD|52=20180417-22:28:26.326|56=BFXFIX|11=2000|21=3|38=0.1000|40=2|44=20000.0000|54=2|55=tBTCUSD|60=20180417-22:28:26.326|10=208|\n```\n\nReceive FIX `35=8` execution report for working order:\n\n```\n8=FIX.4.2|9=232|35=8|34=38|49=BFXFIX|52=20180417-22:28:26.555|56=EXORG_ORD|1=connamara|6=0.00|11=2000|14=0.0000|17=935a0300-2f34-4908-9e03-6b899f9718c6|20=3|32=0.0000|37=1149698709|38=0.1000|39=0|40=2|44=20000.0000|54=2|55=tBTCUSD|150=0|151=0.1000|10=097|\n```\n\nSend market new order single:\n\n```\n8=FIX.4.2|9=128|35=D|34=39|49=EXORG_ORD|52=20180417-22:30:34.310|56=BFXFIX|11=2002|21=3|38=1.5000|40=1|54=2|55=tBTCUSD|60=20180417-22:30:34.310|10=059|\n```\n\nReceive FIX `35=8` execution report for a partial fill:\n\n```\n8=FIX.4.2|9=249|35=8|34=45|49=BFXFIX|52=20180417-22:30:35.100|56=EXORG_ORD|1=connamara|6=1663.90|11=2002|12=0.1331|13=3|14=0.0400|17=f4d8af6e-04ce-447b-80ed-3e82d1476274|20=3|31=1663.9000|32=0.0400|37=1149698710|38=1.5000|39=1|40=1|54=2|55=tBTCUSD|150=1|151=1.4600|10=163|\n```\n\nReceive the alst FIX `35=8` execution report for a full fill:\n\n```\n8=FIX.4.2|9=249|35=8|34=48|49=BFXFIX|52=20180417-22:30:35.135|56=EXORG_ORD|1=connamara|6=1662.70|11=2002|12=0.3327|13=3|14=1.5000|17=6ee60005-4e99-4e6d-aa51-3aa617489dc7|20=3|31=1663.5000|32=0.1000|37=1149698710|38=1.5000|39=2|40=1|54=2|55=tBTCUSD|150=2|151=0.0000|10=112|\n```\n\nCancel working limit order:\n\n```\n8=FIX.4.2|9=116|35=F|34=36|49=EXORG_ORD|52=20180417-22:29:11.115|56=BFXFIX|11=2001|41=2000|54=2|55=tBTCUSD|60=20180417-22:29:11.115|10=051|\n```\n\nReceive FIX `35=8` pending cancel acknowledgement:\n```\n8=FIX.4.2|9=296|35=8|34=40|49=BFXFIX|52=20180417-22:29:11.290|56=EXORG_ORD|1=connamara|6=0.00|11=2000|14=0.0000|17=d067ff27-4182-454f-8c51-bd08c09b5730|20=3|37=1149698709|38=0.1000|39=6|40=2|44=20000.0000|54=2|55=tBTCUSD|58=Submitted for cancellation; waiting for confirmation (ID: 1149698709).|150=6|151=0.1000|10=112|\n```\n\nReceive FIX `35=8` cancel acknowledgement:\n\n```\n8=FIX.4.2|9=244|35=8|34=41|49=BFXFIX|52=20180417-22:29:11.305|56=EXORG_ORD|1=connamara|6=0.00|11=2000|14=0.0000|17=a674d1b4-214e-408a-8cc1-fa364ecd8d97|20=3|32=0.0000|37=1149698709|38=0.1000|39=4|40=2|44=20000.0000|54=2|55=tBTCUSD|58=CANCELED|150=4|151=0.0000|10=112|\n```\n\n## Order State Details\n\nWhen receiving a Bitfinex Order update object (on, ou, oc), the following tables demonstrate rules for mapping FIX tag `39 OrdStatus`:\n\n### Order Update Status Mappings\n\n| BFX Order State \t| FIX OrdStatus Code \t| Order Status \t\t|\n|-------------------|-----------------------|-------------------|\n| ACTIVE\t\t\t| 0\t\t\t\t\t\t| NEW\t\t\t\t|\n| EXECUTED\t\t\t| 2\t\t\t\t\t\t| FILLED\t\t\t|\n| PARTIALLY FILLED\t| 1\t\t\t\t\t\t| PARTIALLY FILLED\t|\n| CANCELED\t\t\t| 4\t\t\t\t\t\t| CANCELED\t\t\t|\n\nExecutions are received as `te` TradeExecution messages and `tu` TradeUpdate messages.  TradeExecution messages come first, but generally omit the order type, original price, fee, and some other fields.  The gateway processes `tu` TradeUpdate messages as executions.  When receiving a TradeUpdate, MsgType `8` ExecutionReports are generated following these rules:\n\n- 1 TradeUpdate message will create 1 ExecutionReport\n- Tag 37 OrderID is derived from the `tu` server-assigned ID\n- An order's CID is mapped to a tag 11 ClOrdID\n- The gateway maintains an in-memory cache of ClOrdID -\u003e order information, including:\n\t- Original order details (symbol, account, price, quantity, type, side)\n\t- Calculated state details (average fill price, total open quantity, total filled quantity)\n\t- Executions related to the original order\n\t- Cancel details related to a ClOrdID (original order ID, symbol, account, ClOrdID, and side)\n- When receiving order state updates (rejection, fill, cancel acknowledgement), the cache must be referenced to provide FIX-required details\n- When receiving a TradeUpdate, if cached details indicate the incoming TradeUpdate would fully fill the order, the gateway will publish an ExecutionReport with an OrdStatus of FILLED.\n\n### Synthetic Order State Message Mappings\n\n`on-req` generally maps to PENDING NEW, with an exception for market orders, which do not receive subsequent `on` ack working messages.\n\n| BFX Order Type\t| Incoming BFX Message\t| FIX OrdStatus Code\t| Order Status\t\t| Notes\t|\n|-------------------|-----------------------|-----------------------|-------------------|-------|\n| EXCHANGE MARKET\t| n (on-req)\t\t\t| 0\t\t\t\t\t| NEW\t| Market orders do not receive `on` messages. |\n| EXCHANGE LIMIT\t| n (on-req)\t\t\t| 0\t\t\t\t\t\t| PENDING NEW\t\t| |\n| EXCHANGE LIMIT\t| oc\t\t\t\t\t| 4\t\t\t\t\t\t| CANCELED\t\t\t| `oc` objects are also received for terminal order states, such as fills, in which case an `oc` will generate no FIX message |\n| EXCHANGE LIMIT\t| ou\t\t\t\t\t| Depends on status\t\t| Depends on status\t| |\n\n## Troubleshooting\n\nBelow are a few common issues with simple procedures to resolve runtime problems:\n\n#### FIX client won't log on\n\nIf the session has been rolled over or restarted, a FIX initiator may have a higher sequence number than its acceptor, which is an error condition.  Simply reset the FIX initiator's sequence number (deleting the sequence store file in QuickFIX works) and the initiator should no longer disconnect on logon.\n\n#### FIX logs on but does not process requests\n\nEnsure the correct endpoint is configured for use. (i.e. MarketDataRequests should be sent to the FIX Market Data endpoint, and NewOrderSingle messages should be sent to the order routing endpoint).\n\n# Issues\n\n## Average prices \u0026 working quantities for out-of-session working orders\n\nOrders placed outside of the FIX trading session may sometimes have incorrect filled quantities (FIX tag 14 `CumQty`), remaining quantities (FIX tag 151 `LeavesQty`), and/or average prices (FIX tag 6 `AvgPx`). The gateway uses an order's individual executions to calculate average prices, filled quantities, and remaining quantities on demand. The gateway does not receive working order execution details in order snapshots on client logon.  Therefore, the gateway will attempt to go out-of-band, using the authenticated REST API, to fetch execution details for working orders.  Out of band requests use the same API key as the orders websocket connection, and may suffer from internet routing race conditions.  Occasionally the order trades endpoint will unexpectedly return an empty set, therefore execution details may not always be available to the gateway.\n\nInternet routing race conditions could be solved with a future enhancement to the gateway to use yet another (third) API key for authenticated out-of-band REST requests.\n\n## Execution reports out of order\n\nTo preserve fee information, `tu` API messages are used to populate execution reports.  However, the API publishes `tu` messages out of order, so corresponding ERs may also be out of order.\n\n## Immediate or Cancel collapses into Fill or Kill time in force\n\nIf an order is sent with an Immediate or Cancel time in force, the order will be mapped as a Bitfinex fill or kill limit order. Corresponding execution reports will indicate the order was placed as a fill or kill limit and not an IOC limit order.\n\n## Unsolicited trailing stop Execution Report missing trailing peg\n\nIf a trailing stop order was placed outside of the FIX session, a `39=0 NEW` Execution Report will be missing the trailing stop peg price.  The Bitfinex API currently does not return trailing stop peg prices on order new notification acknowledgements, but instead lists the calculated stop price, which is included in tag `99 StopPx` on the `39=0 NEW` ExecutionReport.  Subsequent ExecutionReports related to the unsolicited trailing stop may also be missing the peg price until the gateway's cache is updated from the Bitfinex API.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitfinexcom%2Fbfxfixgw","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbitfinexcom%2Fbfxfixgw","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitfinexcom%2Fbfxfixgw/lists"}