{"id":13449693,"url":"https://github.com/chrism2671/PyTrendFollow","last_synced_at":"2025-03-22T22:33:38.770Z","repository":{"id":63979751,"uuid":"122750976","full_name":"chrism2671/PyTrendFollow","owner":"chrism2671","description":"PyTrendFollow - systematic futures trading using trend following","archived":false,"fork":false,"pushed_at":"2018-04-25T09:12:02.000Z","size":3653,"stargazers_count":393,"open_issues_count":14,"forks_count":77,"subscribers_count":25,"default_branch":"master","last_synced_at":"2025-03-18T09:45:24.180Z","etag":null,"topics":["algorithmic-trading","python","systematic-trading-strategies","trading","trading-bot"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chrism2671.png","metadata":{"files":{"readme":"README.md","changelog":null,"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-02-24T15:10:27.000Z","updated_at":"2025-03-15T17:41:11.000Z","dependencies_parsed_at":"2022-11-30T13:35:44.145Z","dependency_job_id":null,"html_url":"https://github.com/chrism2671/PyTrendFollow","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/chrism2671%2FPyTrendFollow","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrism2671%2FPyTrendFollow/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrism2671%2FPyTrendFollow/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrism2671%2FPyTrendFollow/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chrism2671","download_url":"https://codeload.github.com/chrism2671/PyTrendFollow/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245029280,"owners_count":20549681,"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":["algorithmic-trading","python","systematic-trading-strategies","trading","trading-bot"],"created_at":"2024-07-31T06:00:51.558Z","updated_at":"2025-03-22T22:33:37.388Z","avatar_url":"https://github.com/chrism2671.png","language":"Python","funding_links":[],"categories":["Trading bots","Alpha Collections"],"sub_categories":["Cryptocurrencies","General Alpha"],"readme":"# PyTrendFollow - Systematic Futures Trading using Trend Following\n\n## Introduction\n\nThis program trades futures using a systematic trend following strategy, similar to most managed\n futures hedge funds. It produces returns of around ~20% per year, based on a volatility of 25%.\n  You can read more about trend following in the /docs folder. Start with [introduction to trend following](https://github.com/chrism2671/PyTrendFollow/blob/master/docs/Introduction%20to%20Trend%20Following.ipynb). If you just want to play with futures data, see [working with prices](https://github.com/chrism2671/PyTrendFollow/blob/master/docs/Working%20with%20Prices.ipynb).\n\n## Features\n* Integration with Interactive Brokers for fully automated trading.\n* Automatic downloading of contract data from Quandl \u0026 Interactive Brokers.\n* Automatic rolling of futures contracts.\n* Trading strategies backtesting on historical data\n* Designed to use Jupyter notebook as an R\u0026D environment.\n\n## Installation\n\n### Data sources\n\nThe system supports downloading of price data from\n 1. [Quandl](https://www.quandl.com/)\n 1. [Interactive Brokers](https://www.interactivebrokers.com) (IB)\n\nIt is recommended (though not required) to have data subscriptions for both Quandl and IB.\n Quandl has more historical contracts and works well for backtesting,\n while IB data is usually updated more frequently and is better for live trading.\n\nTo use MySQL as the data storage backend (optional, default is HDF5), you'll need a configured\n server with privileges to create databases and tables.\n\n### Trading\n\nFor automated trading with Interactive Brokers, install the latest\n [TWS terminal](https://www.interactivebrokers.com/en/index.php?f=16040)\n   or [Gateway](https://www.interactivebrokers.com/en/index.php?f=16457). You'll need to enable the API and set it to port 4001.\n\n### Code\n\n1. Python version 3.* is required\n1. Get the code:\n\n    `git clone https://github.com/chrism2671/PyTrendFollow.git`\n\n    `cd PyTrendFollow`\n1. Install requirements:\n    * install python tkinter (for Linux it's usually present in a distribution repository, e.g.\n      for Ubuntu: `apt-get install python3-tk`) if necessary.\n    * To compile the binary version of [arch](https://pypi.org/project/arch/4.0/), you will need the\n      development lirbary for your version of Python. e.g., for Python 3.5 on Ubuntu, use \n      `apt-get install libpython3.5-dev`.\n    * install Python requirements: `pip3 install -r requirements.txt`\n1. `cp config/settings.py.template config/settings.py`, update the settings file with your API keys,\n data path, etc. If you don't use one of the data sources (IB or Quandl), comment the corresponding\n line in `data_sources`.\n1. `cp config/strategy.py.template config/strategy.py`, review and update the strategy parameters if\n necessary\n\n## Usage\n\nBefore you start, run the IB TWS terminal or Gateway, go to `Edit -\u003e Global configuration -\u003e API -\u003e\nSettings` and make sure that `Socket port` matches the value of `ib_port` in your local\n `config/settings.py` file (default value is 4001).\n\n* To download contracts data from IB and Quandl:\n\n    `python download.py quandl --concurrent`\n\n    `python download.py ib`\n\n    Use the `--concurrent` flag only if you have the concurrent downloads feature enabled on Quandl,\n otherwise you'll hit API requests limit.\n\n* After the download has completed, make sure the data is valid:\n\n    `python validate.py`\n\n    The output of this script should be a table showing if the data for each instrument in the\n    portfolio is not corrupted, is up to date and some other useful information.\n\n* To place your market orders now, update positions and quit:\n\n    `python scheduler.py --now --quit`\n\n* To schedule portfolio update for a specific time every day:\n\n    `python scheduler.py`\n\nFor more details on how the system works and how to experiment with it, check out the `docs/`\n directory.\n\n## Status, Disclaimers etc\n\nThis project is dev status. Use at your own risk. We are looking for contributors and bug fixes.\n\nOnly tested on Linux for now, but should work on Windows / MacOS.\n\n## Acknowledgements\n\nThis project is based heavily on the work of Rob Carver \u0026 the\n [PySystemTrade](https://github.com/robcarver17/pysystemtrade) project.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchrism2671%2FPyTrendFollow","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchrism2671%2FPyTrendFollow","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchrism2671%2FPyTrendFollow/lists"}