{"id":22608970,"url":"https://github.com/bitfinexcom/bfx-hf-algo-server","last_synced_at":"2025-04-11T06:14:52.668Z","repository":{"id":33155980,"uuid":"143998079","full_name":"bitfinexcom/bfx-hf-algo-server","owner":"bitfinexcom","description":null,"archived":false,"fork":false,"pushed_at":"2022-07-07T20:00:29.000Z","size":406,"stargazers_count":44,"open_issues_count":6,"forks_count":18,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-04-11T06:14:47.887Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bitfinexcom.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-08-08T10:28:23.000Z","updated_at":"2023-11-04T10:09:40.000Z","dependencies_parsed_at":"2022-06-28T12:02:01.385Z","dependency_job_id":null,"html_url":"https://github.com/bitfinexcom/bfx-hf-algo-server","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitfinexcom%2Fbfx-hf-algo-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitfinexcom%2Fbfx-hf-algo-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitfinexcom%2Fbfx-hf-algo-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitfinexcom%2Fbfx-hf-algo-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bitfinexcom","download_url":"https://codeload.github.com/bitfinexcom/bfx-hf-algo-server/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248351393,"owners_count":21089272,"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:24.202Z","updated_at":"2025-04-11T06:14:52.645Z","avatar_url":"https://github.com/bitfinexcom.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Bitfinex Honey Framework Algorithmic Order Server for Node.JS\n\n[![Build Status](https://travis-ci.org/bitfinexcom/bfx-hf-algo-server.svg?branch=master)](https://travis-ci.org/bitfinexcom/bfx-hf-algo-server)\n\nThis is a thin wrapper around the [`bfx-hf-algo`](https://github.com/bitfinexcom/bfx-hf-algo) `AOHost` class, which connects it to the Bitfinex notification system in order to start algo orders from the order form in the bfx UI. The AOHost automatically uploads all relevant order form layouts on startup.\n\nThe algo orders themselves are implemented in [`bfx-hf-algo`](https://github.com/bitfinexcom/bfx-hf-algo).\n\nAlgo orders are automatically persisted via a DB backend provided by the user, and are resumed when the algo server starts up.\n\n### Features\n\n* Enables the execution of algorithmic orders via the official Bitfinex UI\n* Exposes a WebSocket API for executing \u0026 managing the operation of algo orders\n* Allows for the usage of custom DB backends via the `bfx-hf-models` system\n\n### Installation\n\nFor standalone usage:\n```bash\ngit clone https://github.com/bitfinexcom/bfx-hf-algo-server\ncd bfx-hf-algo-server\nnpm i\n\ntouch .env\n\necho 'DB_FILENAME=db/algo-server-db.json' \u003e\u003e .env\necho 'API_KEY=...' \u003e\u003e .env\necho 'API_SECRET=...' \u003e\u003e .env\n\nnpm start\n```\n\nFor usage/extension within an existing project:\n```bash\nnpm i --save bfx-hf-algo-server\n```\n\n### Quickstart\n\nBy default, the `lowdb` DB backend is used. To run the standard server, populate `.env` with your API credentials and DB path:\n```\nAPI_KEY=...\nAPI_SECRET=...\nDB_FILENAME=...\n```\n\nThen run `npm start`\n\nRefresh your Bitfinex UI after all order form layouts have been uploaded. Once the server is listening, select an algorithmic order from the order form dropdown and fill in your desired arguments.\n\nTo start an algo order click the 'Submit' button in the Bitfinex UI to generate a broadcast notification which will be picked up by your running algo server instance, starting the desired order.\n\nThe server can be stopped/started at will, with running algo orders automatically resuming if the contents of `db/*` have not been cleared.\n\n### Docs\n\n[Refer to `docs/server.md`](/docs/server.md) for JSDoc-generated API documentation. For documentation on the available WebSocket API commands, [see `docs/ws_api.md`](/docs/ws_api.md).\n\n[See the `examples/`](/examples) folder for executable examples.\n\n### Example\n\n```js\nconst {\n  IcebergOrder, TWAPOrder, AccumulateDistribute, MACrossover\n} = require('bfx-hf-algo')\n\nconst WebSocket = require('ws')\nconst AOServer = require('bfx-hf-algo-server')\nconst HFDB = require('bfx-hf-models')\nconst HFDBLowDBAdapter = require('bfx-hf-models-adapter-lowdb')\nconst {\n  AOAdapter: BFXAOAdapter, schema: HFDBBitfinexSchema\n} = require('bfx-hf-ext-plugin-bitfinex')\n\nconst DB_PATH = './some_path/db.json'\n\n// create database instance for persisting algo orders\nconst db = new HFDB({\n  schema: HFDBBitfinexSchema,\n  adapter: HFDBLowDBAdapter({\n    dbPath: DB_PATH,\n    schema: HFDBBitfinexSchema\n  })\n})\n\n// create exchange adapter for order execution\nconst adapter = new BFXAOAdapter({\n  apiKey: '...',\n  apiSecret: '...'\n})\n\n// spawn algo server instance\nconst server = new AOServer({\n  db,\n  adapter,\n  port: 8877,\n  aos: [\n    PingPong,\n    Iceberg,\n    TWAP,\n    AccumulateDistribute,\n    MACrossover\n  ]\n})\n\nserver.on('auth:success', () =\u003e { /* ... */ })\nserver.on('auth:error', (error) =\u003e { /* ... */ })\n\n// ao server now ready to accept orders on port 8877\n// example order submit\n\nconst ws = new WebSocket('ws://localhost:8877')\n\nws.on('open', () =\u003e {\n  ws.send(JSON.stringify(['submit.ao', 'bfx-accumulate_distribute', {\n    symbol: 'tEOSUSD',\n    amount: 10,\n    sliceAmount: 1,\n    sliceInterval: 5 * 1000,\n    intervalDistortion: 0.20,\n    amountDistortion: 0.20,\n    orderType: 'MARKET',\n    submitDelay: 150,\n    cancelDelay: 150,\n    catchUp: true,\n    awaitFill: true,\n    _margin: true\n  }]))\n})\n```\n\n### Contributing\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitfinexcom%2Fbfx-hf-algo-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbitfinexcom%2Fbfx-hf-algo-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitfinexcom%2Fbfx-hf-algo-server/lists"}