{"id":37085604,"url":"https://github.com/sjquant/rofa","last_synced_at":"2026-01-14T10:31:51.843Z","repository":{"id":57462546,"uuid":"191320033","full_name":"sjquant/rofa","owner":"sjquant","description":"Rofa is abbreviation for 'Robust Factor'","archived":false,"fork":false,"pushed_at":"2019-12-31T11:23:03.000Z","size":792,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-11-27T19:55:15.196Z","etag":null,"topics":["backtest","factor","finance","investment","portfolio","python","stock"],"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/sjquant.png","metadata":{"files":{"readme":"README.rst","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":"2019-06-11T07:43:17.000Z","updated_at":"2022-06-15T08:48:55.000Z","dependencies_parsed_at":"2022-09-12T14:22:15.438Z","dependency_job_id":null,"html_url":"https://github.com/sjquant/rofa","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sjquant/rofa","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sjquant%2Frofa","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sjquant%2Frofa/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sjquant%2Frofa/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sjquant%2Frofa/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sjquant","download_url":"https://codeload.github.com/sjquant/rofa/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sjquant%2Frofa/sbom","scorecard":{"id":828836,"data":{"date":"2025-08-11","repo":{"name":"github.com/sjquant/rofa","commit":"27f15e483be1c15da53b0cfee1bfa6e318374f5c"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.7,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":0,"reason":"Found 0/6 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":7,"reason":"3 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: PYSEC-2024-48 / GHSA-fj7x-q9j7-g6q6","Warn: Project is vulnerable to: PYSEC-2018-100 / GHSA-r38r-qp28-2m63","Warn: Project is vulnerable to: PYSEC-2020-73"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-23T17:10:52.172Z","repository_id":57462546,"created_at":"2025-08-23T17:10:52.172Z","updated_at":"2025-08-23T17:10:52.172Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28417441,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T10:25:19.714Z","status":"ssl_error","status_checked_at":"2026-01-14T10:22:49.371Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["backtest","factor","finance","investment","portfolio","python","stock"],"created_at":"2026-01-14T10:31:51.194Z","updated_at":"2026-01-14T10:31:51.837Z","avatar_url":"https://github.com/sjquant.png","language":"Python","readme":"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!","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsjquant%2Frofa","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsjquant%2Frofa","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsjquant%2Frofa/lists"}