{ "info": { "author": "SJQuant", "author_email": "seonujang92@gmail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "Rofa\n=====\n\nIntroduction\n------------\n\nInterests in **Quant investing** (or trading) are growing fast every day. Many people try to create profitable strategies and test it using past data (It is called 'backetest' by quants). It is good phenomenon in that it can prevent people from wasting their money with unverified strategies, or just news) and enables investing with more statistical approaches. However, some people started to cling to just higher CAGR (compound annual growth rate) and total returns and ignore other statistical performance to ensure robustness of strategy. CAGR is just one factor to evaluate strategy, and if you don't care other evaluations, your investing can be in danger in the future. See below pictures.\n\n.. image:: https://trello-attachments.s3.amazonaws.com/5cff44a05a8aa00f048b6f41/431x282/655dde558a4aa7fbd48f82059130b5fb/image.png\n\n'Strategy B' has underperformed 'Strategy A' before 2014, but it outperformed 'Strategy A' at the end in the perspective of total returns and CAGR. But as you know, we cannot say 'Strategy B' is more robust than 'Strategy A'\n\n**Rofa** is abbreviation for 'Robust Factor'. This module helps you to check factor's robustness. All you do is just prepare data with certain formats, and ask rofa to simulate, and evaluate, and make summarized graph of it. Now you had powerful quant tool **'Rofa'**.\n\nInstallation\n------------\n\n.. code::\n\n pip install rofa\n\n.. note::\n\n You can use any editor to use python, but I recommend using jupyter notebook to start. jupyter notebook allows you to interactively run python code block by block. You can install jupyter notebook as follows.\n\n.. code::\n\n pip install jupyter\n\nTo start it\n\n.. code::\n\n jupyter notebook\n\nGetting started\n---------------\n\n- **Import Rofa**\n\nFirst of all, import ``rofa`` and ``QuantileSimulator`` from rofa\n\n.. code:: python\n\n import rofa\n from rofa import QuantileSimulator\n\n- **Registering daily returns data**\n\nUnfortunately, rofa does not have any data with it. So, in order to run simulation, you need to ****register daily returns data** (pandas DataFrame). If you register returns data once, rofa will find returns data later without re-registering (You can change this option using ``save=False``).\n\n.. code:: python\n\n import pandas as pd\n\n # Read Close Data\n returns= pd.read_pickle('../data/returns.pkl') # Your returns data\n rofa.register_returns(returns)\n\n.. note::\n\n returns dataframe data must have following format, where columns are asset symbols and index is date.\n\n.. image:: https://trello-attachments.s3.amazonaws.com/5cff44a05a8aa00f048b6f41/950x265/e39cca22e2da9014b8bda5cfe78c6f40/image.png\n\n- **Prepare data**\n\nData (pandas Dataframe) must have formats where columns are asset symbols (or code) and index is date such as returns. You can download data used in this example in here_.\n\n.. _here: https://drive.google.com/drive/folders/1HnZYE0smawi_YoxcnTsdESEJuZDme2F5?usp=sharing\n\n.. code:: python\n\n # Read Close Data\n close = pd.read_pickle('../data/close.pkl') # Your data\n\n.. image:: https://trello-attachments.s3.amazonaws.com/5cff44a05a8aa00f048b6f41/947x255/c8dd7064418c602ba01350f25be0a808/image.png\n\n- **QuantileSimulator**\n\n.. code:: python\n\n quan_sim = QuantileSimulator(close, rebalance_freq=10, bins=5)\n\nIn QuantileSimulator, first argument accepts factor data (close here). Additionaly, you can set ``rebalance_freq``, ``bins``, ``tax_rate``, ``weight_model`` and etc.\n\n- **Run simulation**\n\nJust run the simulation. Simulation logics are all done by ``rofa``\n\n.. code:: python\n\n quan_sim.run()\n\n- **Plot portfolio returns**\n\nSimulation classes has plotter plugin inside it, which makes it possible to visuallize the simulation result.\n\n.. code:: python\n\n quan_sim.plotter.plot_portfolio_returns()\n\n.. image:: https://trello-attachments.s3.amazonaws.com/5cff44a05a8aa00f048b6f41/975x588/85eda2c8d19b247c944a86d95c0bc65d/image.png\n\n\nFrom portfolio returns graph, we can compare overall performances and drawdowns of each portfolio.\n\n- **Plot performance metrics (CAGR, MDD, Sharpe, Calmar)**\n\n.. image:: https://trello-attachments.s3.amazonaws.com/5cff44a05a8aa00f048b6f41/1061x655/5ed868976346a3554c2677b6077ab1c5/image.png\n\nFrom this graph, we can check performance metrics and check if there is strong relationship between factor and performance.\n\n- **Plot rolling performance.**\n\n.. image:: https://trello-attachments.s3.amazonaws.com/5cff44a05a8aa00f048b6f41/1076x656/a387b0aa8db6a379c9c578f986b42514/image.png\n\n- **Wait, we can plot all at once**\n\nYou might have though about how come I can memorize all plot methods. Here's a method for you. ``plot_all`` plots all above. Super simple!\n\n.. code:: python\n\n quan_sim.plotter.plot_all()\n\n.. image:: https://trello-attachments.s3.amazonaws.com/5cff44a05a8aa00f048b6f41/476x897/58c2343f257c855bf8d6ec6b1bfd4a7c/image.png\n\n\nTODO\n----\n\n- Add more performance indicators\n- Optimize code for efficiency. There are some points to make code inefficient\n- Create ``LongShortPlotter`` and make all methods used in ``QuantilePlotter``\n- Add statistical analysis plugin such as ``Linear Regression``, ``t-test``, and ``ANOVA``\n- Create ``NakedSimulator`` and add plotter plugins\n- Create ``Evaluator Plugin`` Later\n- Use ``numba`` or ``cython`` to improve performance\n- Better documentation!", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/sjquant/rofa", "keywords": "quant,investment,factor investing,backtest", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "rofa", "package_url": "https://pypi.org/project/rofa/", "platform": "", "project_url": "https://pypi.org/project/rofa/", "project_urls": { "Homepage": "https://github.com/sjquant/rofa" }, "release_url": "https://pypi.org/project/rofa/0.1.2/", "requires_dist": null, "requires_python": "", "summary": "**Rofa ** is abbreviation for Robust Factor", "version": "0.1.2" }, "last_serial": 5385317, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "eac80aa276ee9c5129431f2b2533a1e9", "sha256": "c7a3ef6d2d3f1af828363a3cc85d0dbc26550777e9e49e3259fb7a2a84182f31" }, "downloads": -1, "filename": "rofa-0.1.0-py3.7.egg", "has_sig": false, "md5_digest": "eac80aa276ee9c5129431f2b2533a1e9", "packagetype": "bdist_egg", "python_version": "3.7", "requires_python": null, "size": 21832, "upload_time": "2019-06-11T07:40:06", "url": "https://files.pythonhosted.org/packages/f8/39/387a5d9f22aef91d478ae7c9e2aa9dbcd1213a5bbdb54794f21279f9264a/rofa-0.1.0-py3.7.egg" }, { "comment_text": "", "digests": { "md5": "ee826b9167751b55109c3ca6169e5b3c", "sha256": "6f57f8f7fee8700d0adfac7013b9bd7fd5c13f6314acc1e4c69a0845105d28af" }, "downloads": -1, "filename": "rofa-0.1.0.tar.gz", "has_sig": false, "md5_digest": "ee826b9167751b55109c3ca6169e5b3c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11336, "upload_time": "2019-06-11T07:40:09", "url": "https://files.pythonhosted.org/packages/4b/88/2ee259165cbb794440ba5486367e997e8066b9c6b2f9eae3fe1d97e7f62a/rofa-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "dfefbfcb8ceefc7e82d9a0cee2e536b0", "sha256": "419e2553a97a8173f7f150e081b898d07d12514f14318e641d8692c9218a99b0" }, "downloads": -1, "filename": "rofa-0.1.1.tar.gz", "has_sig": false, "md5_digest": "dfefbfcb8ceefc7e82d9a0cee2e536b0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11291, "upload_time": "2019-06-11T08:14:24", "url": "https://files.pythonhosted.org/packages/52/d9/4a0fc3434db97072e5d144cb0e9ded2da9db7a1bf831848a9e6b79f6f32e/rofa-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "83934e1114652abb3735ce1d15d273fd", "sha256": "2aca49d1fe1a68004325d350c79517ab5b48fb1934874268c659fbf033cae4b5" }, "downloads": -1, "filename": "rofa-0.1.2.tar.gz", "has_sig": false, "md5_digest": "83934e1114652abb3735ce1d15d273fd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11284, "upload_time": "2019-06-11T08:16:42", "url": "https://files.pythonhosted.org/packages/33/31/acc4336ede58f53da8c456039cca2a737e335246e73073427eec8849ec42/rofa-0.1.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "83934e1114652abb3735ce1d15d273fd", "sha256": "2aca49d1fe1a68004325d350c79517ab5b48fb1934874268c659fbf033cae4b5" }, "downloads": -1, "filename": "rofa-0.1.2.tar.gz", "has_sig": false, "md5_digest": "83934e1114652abb3735ce1d15d273fd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11284, "upload_time": "2019-06-11T08:16:42", "url": "https://files.pythonhosted.org/packages/33/31/acc4336ede58f53da8c456039cca2a737e335246e73073427eec8849ec42/rofa-0.1.2.tar.gz" } ] }