[
  {
    "path": ".github/workflows/python-ci.yml",
    "content": "name: Python CI\n\non:\n  push:\n    branches:\n      - main\n  pull_request:\n    branches:\n      - main\n\njobs:\n  build:\n    runs-on: ubuntu-latest\n    strategy:\n      matrix:\n        python-version: [3.7, 3.8, 3.9]\n\n    steps:\n    - name: Checkout repository\n      uses: actions/checkout@v2\n\n    - name: Set up Python ${{ matrix.python-version }}\n      uses: actions/setup-python@v2\n      with:\n        python-version: ${{ matrix.python-version }}\n\n    - name: Install dependencies\n      run: |\n        python -m pip install --upgrade pip\n        pip install -r requirements.txt\n\n    - name: Run tests\n      run: |\n        python -m unittest discover\n"
  },
  {
    "path": ".github/workflows/python-publish.yml",
    "content": "name: Upload Python Package to PYPI\n\non:\n  pull_request:\n    branches: main\n\npermissions:\n  contents: write\n  pull-requests: write\n\njobs:\n  release-please:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v3\n        with:\n          fetch-depth: 0\n      - uses: actions/setup-python@v4\n        with:\n          python-version: \"3.10\"\n      - name: Install poetry\n        run: python -m pip install poetry\n      - name: Update patch version of package\n        id: versionUpdate\n        run: |\n          poetry version patch\n          echo \"::set-output version=$(poetry version -s)\"\n      - name: Commit and push changes\n        run: |\n          git config --global user.name \"GitHub Actions\"\n          git config --global user.email \"github-actions@users.noreply.github.com\"\n          git checkout -b release-${{ steps.versionUpdate.outputs.version }}\n          git add .\n          git commit -m \"${{ steps.versionUpdate.outputs.version }} release\"\n          git push origin release-${{ steps.versionUpdate.outputs.version }}\n      - name: Create pull request\n        uses: peter-evans/create-pull-request@v3\n        with:\n          title: Release ${{ steps.versionUpdate.outputs.version }}\n          branch: release-${{ steps.versionUpdate.outputs.version }}\n          base: main\n      - name: Build and upload python package\n        env:\n          username: ${{ secrets.PYPI_USERNAME }}\n          password: ${{ secrets.PYPI_PASSWORD }}\n        run: |\n          poetry publish --build -u ${username} -p ${password}}\n"
  },
  {
    "path": ".gitignore",
    "content": "*.py[cod]\n\n# C extensions\n*.so\n\n# pycharm\n.idea/\n.idea\n\n# Packages\n*.egg\n*.egg-info\nbuild\neggs\nparts\nbin\nvar\nsdist\ndevelop-eggs\n.installed.cfg\nlib\nlib64\n\n# Installer logs\npip-log.txt\n\n# Unit test / coverage reports\n.coverage\n.tox\nnosetests.xml\n\n# Complexity\noutput/*.html\noutput/*/index.html\n\n# Sphinx\ndocs/_build\n\n# Cookiecutter\noutput/\n\n# Build\ndist/\nvenv/"
  },
  {
    "path": "LICENSE.md",
    "content": "Copyright (c) 2017, Preetam Sharma\nAll rights reserved.\n\n#TradingPatternScanner\n\nThis work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) license.\n\nYou are free to:\n\n- Share: copy and redistribute the material in any medium or format.\n\nUnder the following terms:\n\n- Attribution: You must give appropriate credit, provide a link to the license, and indicate if changes were made. You must do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use. The credit should be given in the following format: \"Original work by [Preetam Sharma] is licensed under CC BY-NC-SA 4.0 and can be found at (https://github.com/white07S/TradingPatternScanner).\"\n\n- NonCommercial: You may not use the material for commercial purposes. This includes but is not limited to, selling the material, or using it to promote a product or service.\n\n\nFor more information, see the [Creative Commons website](https://creativecommons.org/licenses/by-nc-sa/4.0/) and the [legal code of the license](https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode).\n\n"
  },
  {
    "path": "MANIFEST.in",
    "content": "include README.md\ninclude requirements.txt"
  },
  {
    "path": "README.md",
    "content": "# TradingPatternScanner\n![Python CI](https://github.com/white07S/TradingPatternScanner/actions/workflows/python-ci.yml/badge.svg)\n\n#### Author: Preetam Sharma\n\nOverview\n--------\n\nTrading Pattern Scanner Identifies complex patterns like head and shoulder, wedge and many more.\n\n## New Enhancements\nFour new features for pattern detection have been added:\n\n1. **Basic Head-Shoulder Detection**: The initial unfiltered version of pattern detection. It uses a rolling window to track high and low points, then identifies Head and Shoulder and Inverse Head and Shoulder patterns.\n2. **Head-Shoulder Detection with Savitzky-Golay Filter**: This feature uses the Savitzky-Golay filter to reduce noise and improve pattern detection. It also considers the height of the \"Head\" or \"Inverse Head\" to avoid false pattern recognition.\n3. **Head-Shoulder Detection with Kalman Filter**: This feature utilizes the Kalman Filter, a recursive filter that estimates the state of a system in real time. It's particularly suitable for financial data due to its inherent noise and uncertainties.\n4. **Head-Shoulder Detection with Wavelet Denoising**: This final feature applies wavelet denoising to eliminate noise while preserving key features in the data. It makes pattern detection more robust and reliable, especially in the presence of high-frequency noise.\n\nThese enhancements provide more accurate pattern detection for your financial analysis needs.\n\n## Analysis\nEach method has been rigorously tested and analysed on **synthetic data that closely mirrors real-world financial data**. However, it's important to note that synthetic data is not an exact representation of the real-world, and the performance of each algorithm may vary in a live setting. Therefore, users are encouraged to test each algorithm against their own datasets and pick the one that best suits their needs. \n- Accuracy for head_shoulder_pattern_window: **78.50%**\n- Accuracy for head_shoulder_pattern_filter: **78.50%**\n- Accuracy for head_shoulder_pattern_kf: **73.50%**\n- Accuracy for head_shoulder_pattern_wavelet: **84.50%**\n\n![Analysis](https://github.com/white07S/TradingPatternScanner/blob/main/docs/images/heatmap.png)\n\n## Heatmap Interpretation\n\n* For instance, let's consider a cell in the 2nd row and 2nd column. the score is 10, it means that a significant number of instances were correctly identified as \"Head and Shoulder\" pattern (abbreviated as HS).\n\n* On the contrary, a dark cell outside this diagonal indicates a high number of misclassifications. For example, a dark cell at the intersection of \"HS\" row and \"I-HS\" column would mean that a large number of instances were true \"HS\" but were incorrectly predicted as \"Inverse Head and Shoulder\" (abbreviated as I-HS) by the scanner.\n\n## Abbreviations\nThe abbreviations used in the heatmap and the code are as follows:\n\n* **HS** - Head and Shoulder pattern\n* **I-HS** - Inverse Head and Shoulder pattern\n\n\nInstallation / Usage\n--------------------\n\nInstall using pip:\n\n    $ pip install tradingpattern\n\n    \n# TradingPatternScanner\n\n# Trading patterns:\n* **Head and Shoulder and inverse Head and Shoulder**: These patterns indicate a potential reversal in the market, with the \"head\" being the highest point, and the \"shoulders\" being the points on either side at a slightly lower level.\n* **Multiple top and bottom**: These patterns indicate a range-bound market, with multiple highs and lows forming a horizontal range.\n* **Horizontal support and resistance**: These patterns indicate key levels at which the market has previously struggled to break through.\n* **Ascending and Descending Triangle pattern**: These patterns indicate a potential breakout in the market, with the upper trendline being resistance and the lower trendline being support.\n* **Wedge up and down**: These patterns indicate a potential reversal in the market, with the trendlines converging towards each other.\n* **Channel up and down**: These patterns indicate a strong trend in the market, with price moving within a well-defined upper and lower trendline.\n* **Double top and bottom**: These patterns indicate a potential reversal in the market, with the market hitting a high or low twice and then reversing.\n* **Trend line support and resistance**: These patterns indicate key levels at which the market is likely to experience support or resistance based on historical price action.\n* **Finding Higher-High and Lower-Low**\n\n# Designed for fast performance:\n* **Uses only Pandas as Numpy, no other external libraries**: This approach helps to keep the library lightweight and fast.\n* **Uses the concept of vectorization**: This approach helps to improve performance by processing large amounts of data at once, rather than iterating over each individual data point.\n\n# New and Unique:\n* **No other python** library exists for such task currently: This library is new and unique, as it aims to provide an all-in-one solution for identifying various trading patterns.\n\n\n### Lets check if its works for simplicity I used finviz and checked the pattern with the respective stock.\n\n* Head and Shoulder:\n![Head and Shoulder](https://user-images.githubusercontent.com/58583011/212490681-6dfca525-cd2e-4c87-830a-655ac9294a8a.png)\n\nWe can see that it finds out that we have inverse head and shoulder pattern in the stock on 9th Januray 2023 in 1 day interval. Lets match with Finviz.\n![Finviz](https://user-images.githubusercontent.com/58583011/212490765-220182a5-e637-4f83-9a65-3031b7c99fee.png)\n\n* We can see that Finviz also detects on 9th Januray 2023 in 1 day interval.\n* You can adjust the window size to your liking. A smaller window size will be more sensitive to detecting patterns, but it will also increase the chances of false positives. A larger window size will be less sensitive to detecting patterns, but it will also decrease the chances of false positives.\n\n# Future add-ons:\n* **Request your favourite pattern to get added in the list**: The library is open for suggestions for adding new patterns.\n* **Work on visualization and plotting**: The library can be extended to include visualization and plotting features to help users better understand the patterns identified.\n* **Add unit testing**: The library can be extended to include unit testing to ensure that the code is working as expected and to catch any bugs early on.\n\n"
  },
  {
    "path": "docs/Makefile",
    "content": "# Makefile for Sphinx documentation\n#\n\n# You can set these variables from the command line.\nSPHINXOPTS    =\nSPHINXBUILD   = sphinx-build\nPAPER         =\nBUILDDIR      = build\n\n# User-friendly check for sphinx-build\nifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1)\n\t$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don\\'t have Sphinx installed, grab it from http://sphinx-doc.org/)\nendif\n\n# Internal variables.\nPAPEROPT_a4     = -D latex_paper_size=a4\nPAPEROPT_letter = -D latex_paper_size=letter\nALLSPHINXOPTS   = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source\n# the i18n builder cannot share the environment and doctrees with the others\nI18NSPHINXOPTS  = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source\n\n.PHONY: help\nhelp:\n\t@echo \"Please use \\`make <target>' where <target> is one of\"\n\t@echo \"  html       to make standalone HTML files\"\n\t@echo \"  dirhtml    to make HTML files named index.html in directories\"\n\t@echo \"  singlehtml to make a single large HTML file\"\n\t@echo \"  pickle     to make pickle files\"\n\t@echo \"  json       to make JSON files\"\n\t@echo \"  htmlhelp   to make HTML files and a HTML help project\"\n\t@echo \"  qthelp     to make HTML files and a qthelp project\"\n\t@echo \"  applehelp  to make an Apple Help Book\"\n\t@echo \"  devhelp    to make HTML files and a Devhelp project\"\n\t@echo \"  epub       to make an epub\"\n\t@echo \"  epub3      to make an epub3\"\n\t@echo \"  latex      to make LaTeX files, you can set PAPER=a4 or PAPER=letter\"\n\t@echo \"  latexpdf   to make LaTeX files and run them through pdflatex\"\n\t@echo \"  latexpdfja to make LaTeX files and run them through platex/dvipdfmx\"\n\t@echo \"  text       to make text files\"\n\t@echo \"  man        to make manual pages\"\n\t@echo \"  texinfo    to make Texinfo files\"\n\t@echo \"  info       to make Texinfo files and run them through makeinfo\"\n\t@echo \"  gettext    to make PO message catalogs\"\n\t@echo \"  changes    to make an overview of all changed/added/deprecated items\"\n\t@echo \"  xml        to make Docutils-native XML files\"\n\t@echo \"  pseudoxml  to make pseudoxml-XML files for display purposes\"\n\t@echo \"  linkcheck  to check all external links for integrity\"\n\t@echo \"  doctest    to run all doctests embedded in the documentation (if enabled)\"\n\t@echo \"  coverage   to run coverage check of the documentation (if enabled)\"\n\t@echo \"  dummy      to check syntax errors of document sources\"\n\n.PHONY: clean\nclean:\n\trm -rf $(BUILDDIR)/*\n\n.PHONY: html\nhtml:\n\t$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html\n\t@echo\n\t@echo \"Build finished. The HTML pages are in $(BUILDDIR)/html.\"\n\n.PHONY: dirhtml\ndirhtml:\n\t$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml\n\t@echo\n\t@echo \"Build finished. The HTML pages are in $(BUILDDIR)/dirhtml.\"\n\n.PHONY: singlehtml\nsinglehtml:\n\t$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml\n\t@echo\n\t@echo \"Build finished. The HTML page is in $(BUILDDIR)/singlehtml.\"\n\n.PHONY: pickle\npickle:\n\t$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle\n\t@echo\n\t@echo \"Build finished; now you can process the pickle files.\"\n\n.PHONY: json\njson:\n\t$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json\n\t@echo\n\t@echo \"Build finished; now you can process the JSON files.\"\n\n.PHONY: htmlhelp\nhtmlhelp:\n\t$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp\n\t@echo\n\t@echo \"Build finished; now you can run HTML Help Workshop with the\" \\\n\t      \".hhp project file in $(BUILDDIR)/htmlhelp.\"\n\n.PHONY: qthelp\nqthelp:\n\t$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp\n\t@echo\n\t@echo \"Build finished; now you can run \"qcollectiongenerator\" with the\" \\\n\t      \".qhcp project file in $(BUILDDIR)/qthelp, like this:\"\n\t@echo \"# qcollectiongenerator $(BUILDDIR)/qthelp/twitterpandas.qhcp\"\n\t@echo \"To view the help file:\"\n\t@echo \"# assistant -collectionFile $(BUILDDIR)/qthelp/twitterpandas.qhc\"\n\n.PHONY: applehelp\napplehelp:\n\t$(SPHINXBUILD) -b applehelp $(ALLSPHINXOPTS) $(BUILDDIR)/applehelp\n\t@echo\n\t@echo \"Build finished. The help book is in $(BUILDDIR)/applehelp.\"\n\t@echo \"N.B. You won't be able to view it unless you put it in\" \\\n\t      \"~/Library/Documentation/Help or install it in your application\" \\\n\t      \"bundle.\"\n\n.PHONY: devhelp\ndevhelp:\n\t$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp\n\t@echo\n\t@echo \"Build finished.\"\n\t@echo \"To view the help file:\"\n\t@echo \"# mkdir -p $$HOME/.local/share/devhelp/twitterpandas\"\n\t@echo \"# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/twitterpandas\"\n\t@echo \"# devhelp\"\n\n.PHONY: epub\nepub:\n\t$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub\n\t@echo\n\t@echo \"Build finished. The epub file is in $(BUILDDIR)/epub.\"\n\n.PHONY: epub3\nepub3:\n\t$(SPHINXBUILD) -b epub3 $(ALLSPHINXOPTS) $(BUILDDIR)/epub3\n\t@echo\n\t@echo \"Build finished. The epub3 file is in $(BUILDDIR)/epub3.\"\n\n.PHONY: latex\nlatex:\n\t$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex\n\t@echo\n\t@echo \"Build finished; the LaTeX files are in $(BUILDDIR)/latex.\"\n\t@echo \"Run \\`make' in that directory to run these through (pdf)latex\" \\\n\t      \"(use \\`make latexpdf' here to do that automatically).\"\n\n.PHONY: latexpdf\nlatexpdf:\n\t$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex\n\t@echo \"Running LaTeX files through pdflatex...\"\n\t$(MAKE) -C $(BUILDDIR)/latex all-pdf\n\t@echo \"pdflatex finished; the PDF files are in $(BUILDDIR)/latex.\"\n\n.PHONY: latexpdfja\nlatexpdfja:\n\t$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex\n\t@echo \"Running LaTeX files through platex and dvipdfmx...\"\n\t$(MAKE) -C $(BUILDDIR)/latex all-pdf-ja\n\t@echo \"pdflatex finished; the PDF files are in $(BUILDDIR)/latex.\"\n\n.PHONY: text\ntext:\n\t$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text\n\t@echo\n\t@echo \"Build finished. The text files are in $(BUILDDIR)/text.\"\n\n.PHONY: man\nman:\n\t$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man\n\t@echo\n\t@echo \"Build finished. The manual pages are in $(BUILDDIR)/man.\"\n\n.PHONY: texinfo\ntexinfo:\n\t$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo\n\t@echo\n\t@echo \"Build finished. The Texinfo files are in $(BUILDDIR)/texinfo.\"\n\t@echo \"Run \\`make' in that directory to run these through makeinfo\" \\\n\t      \"(use \\`make info' here to do that automatically).\"\n\n.PHONY: info\ninfo:\n\t$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo\n\t@echo \"Running Texinfo files through makeinfo...\"\n\tmake -C $(BUILDDIR)/texinfo info\n\t@echo \"makeinfo finished; the Info files are in $(BUILDDIR)/texinfo.\"\n\n.PHONY: gettext\ngettext:\n\t$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale\n\t@echo\n\t@echo \"Build finished. The message catalogs are in $(BUILDDIR)/locale.\"\n\n.PHONY: changes\nchanges:\n\t$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes\n\t@echo\n\t@echo \"The overview file is in $(BUILDDIR)/changes.\"\n\n.PHONY: linkcheck\nlinkcheck:\n\t$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck\n\t@echo\n\t@echo \"Link check complete; look for any errors in the above output \" \\\n\t      \"or in $(BUILDDIR)/linkcheck/output.txt.\"\n\n.PHONY: doctest\ndoctest:\n\t$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest\n\t@echo \"Testing of doctests in the sources finished, look at the \" \\\n\t      \"results in $(BUILDDIR)/doctest/output.txt.\"\n\n.PHONY: coverage\ncoverage:\n\t$(SPHINXBUILD) -b coverage $(ALLSPHINXOPTS) $(BUILDDIR)/coverage\n\t@echo \"Testing of coverage in the sources finished, look at the \" \\\n\t      \"results in $(BUILDDIR)/coverage/python.txt.\"\n\n.PHONY: xml\nxml:\n\t$(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml\n\t@echo\n\t@echo \"Build finished. The XML files are in $(BUILDDIR)/xml.\"\n\n.PHONY: pseudoxml\npseudoxml:\n\t$(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml\n\t@echo\n\t@echo \"Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml.\"\n\n.PHONY: dummy\ndummy:\n\t$(SPHINXBUILD) -b dummy $(ALLSPHINXOPTS) $(BUILDDIR)/dummy\n\t@echo\n\t@echo \"Build finished. Dummy builder generates no files.\"\n"
  },
  {
    "path": "docs/make.bat",
    "content": "@ECHO OFF\n\nREM Command file for Sphinx documentation\n\nif \"%SPHINXBUILD%\" == \"\" (\n\tset SPHINXBUILD=sphinx-build\n)\nset BUILDDIR=build\nset ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% source\nset I18NSPHINXOPTS=%SPHINXOPTS% source\nif NOT \"%PAPER%\" == \"\" (\n\tset ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS%\n\tset I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS%\n)\n\nif \"%1\" == \"\" goto help\n\nif \"%1\" == \"help\" (\n\t:help\n\techo.Please use `make ^<target^>` where ^<target^> is one of\n\techo.  html       to make standalone HTML files\n\techo.  dirhtml    to make HTML files named index.html in directories\n\techo.  singlehtml to make a single large HTML file\n\techo.  pickle     to make pickle files\n\techo.  json       to make JSON files\n\techo.  htmlhelp   to make HTML files and a HTML help project\n\techo.  qthelp     to make HTML files and a qthelp project\n\techo.  devhelp    to make HTML files and a Devhelp project\n\techo.  epub       to make an epub\n\techo.  epub3      to make an epub3\n\techo.  latex      to make LaTeX files, you can set PAPER=a4 or PAPER=letter\n\techo.  text       to make text files\n\techo.  man        to make manual pages\n\techo.  texinfo    to make Texinfo files\n\techo.  gettext    to make PO message catalogs\n\techo.  changes    to make an overview over all changed/added/deprecated items\n\techo.  xml        to make Docutils-native XML files\n\techo.  pseudoxml  to make pseudoxml-XML files for display purposes\n\techo.  linkcheck  to check all external links for integrity\n\techo.  doctest    to run all doctests embedded in the documentation if enabled\n\techo.  coverage   to run coverage check of the documentation if enabled\n\techo.  dummy      to check syntax errors of document sources\n\tgoto end\n)\n\nif \"%1\" == \"clean\" (\n\tfor /d %%i in (%BUILDDIR%\\*) do rmdir /q /s %%i\n\tdel /q /s %BUILDDIR%\\*\n\tgoto end\n)\n\n\nREM Check if sphinx-build is available and fallback to Python version if any\n%SPHINXBUILD% 1>NUL 2>NUL\nif errorlevel 9009 goto sphinx_python\ngoto sphinx_ok\n\n:sphinx_python\n\nset SPHINXBUILD=python -m sphinx.__init__\n%SPHINXBUILD% 2> nul\nif errorlevel 9009 (\n\techo.\n\techo.The 'sphinx-build' command was not found. Make sure you have Sphinx\n\techo.installed, then set the SPHINXBUILD environment variable to point\n\techo.to the full path of the 'sphinx-build' executable. Alternatively you\n\techo.may add the Sphinx directory to PATH.\n\techo.\n\techo.If you don't have Sphinx installed, grab it from\n\techo.http://sphinx-doc.org/\n\texit /b 1\n)\n\n:sphinx_ok\n\n\nif \"%1\" == \"html\" (\n\t%SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html\n\tif errorlevel 1 exit /b 1\n\techo.\n\techo.Build finished. The HTML pages are in %BUILDDIR%/html.\n\tgoto end\n)\n\nif \"%1\" == \"dirhtml\" (\n\t%SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml\n\tif errorlevel 1 exit /b 1\n\techo.\n\techo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml.\n\tgoto end\n)\n\nif \"%1\" == \"singlehtml\" (\n\t%SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml\n\tif errorlevel 1 exit /b 1\n\techo.\n\techo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml.\n\tgoto end\n)\n\nif \"%1\" == \"pickle\" (\n\t%SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle\n\tif errorlevel 1 exit /b 1\n\techo.\n\techo.Build finished; now you can process the pickle files.\n\tgoto end\n)\n\nif \"%1\" == \"json\" (\n\t%SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json\n\tif errorlevel 1 exit /b 1\n\techo.\n\techo.Build finished; now you can process the JSON files.\n\tgoto end\n)\n\nif \"%1\" == \"htmlhelp\" (\n\t%SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp\n\tif errorlevel 1 exit /b 1\n\techo.\n\techo.Build finished; now you can run HTML Help Workshop with the ^\n.hhp project file in %BUILDDIR%/htmlhelp.\n\tgoto end\n)\n\nif \"%1\" == \"qthelp\" (\n\t%SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp\n\tif errorlevel 1 exit /b 1\n\techo.\n\techo.Build finished; now you can run \"qcollectiongenerator\" with the ^\n.qhcp project file in %BUILDDIR%/qthelp, like this:\n\techo.^> qcollectiongenerator %BUILDDIR%\\qthelp\\twitterpandas.qhcp\n\techo.To view the help file:\n\techo.^> assistant -collectionFile %BUILDDIR%\\qthelp\\twitterpandas.ghc\n\tgoto end\n)\n\nif \"%1\" == \"devhelp\" (\n\t%SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp\n\tif errorlevel 1 exit /b 1\n\techo.\n\techo.Build finished.\n\tgoto end\n)\n\nif \"%1\" == \"epub\" (\n\t%SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub\n\tif errorlevel 1 exit /b 1\n\techo.\n\techo.Build finished. The epub file is in %BUILDDIR%/epub.\n\tgoto end\n)\n\nif \"%1\" == \"epub3\" (\n\t%SPHINXBUILD% -b epub3 %ALLSPHINXOPTS% %BUILDDIR%/epub3\n\tif errorlevel 1 exit /b 1\n\techo.\n\techo.Build finished. The epub3 file is in %BUILDDIR%/epub3.\n\tgoto end\n)\n\nif \"%1\" == \"latex\" (\n\t%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex\n\tif errorlevel 1 exit /b 1\n\techo.\n\techo.Build finished; the LaTeX files are in %BUILDDIR%/latex.\n\tgoto end\n)\n\nif \"%1\" == \"latexpdf\" (\n\t%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex\n\tcd %BUILDDIR%/latex\n\tmake all-pdf\n\tcd %~dp0\n\techo.\n\techo.Build finished; the PDF files are in %BUILDDIR%/latex.\n\tgoto end\n)\n\nif \"%1\" == \"latexpdfja\" (\n\t%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex\n\tcd %BUILDDIR%/latex\n\tmake all-pdf-ja\n\tcd %~dp0\n\techo.\n\techo.Build finished; the PDF files are in %BUILDDIR%/latex.\n\tgoto end\n)\n\nif \"%1\" == \"text\" (\n\t%SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text\n\tif errorlevel 1 exit /b 1\n\techo.\n\techo.Build finished. The text files are in %BUILDDIR%/text.\n\tgoto end\n)\n\nif \"%1\" == \"man\" (\n\t%SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man\n\tif errorlevel 1 exit /b 1\n\techo.\n\techo.Build finished. The manual pages are in %BUILDDIR%/man.\n\tgoto end\n)\n\nif \"%1\" == \"texinfo\" (\n\t%SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo\n\tif errorlevel 1 exit /b 1\n\techo.\n\techo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo.\n\tgoto end\n)\n\nif \"%1\" == \"gettext\" (\n\t%SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale\n\tif errorlevel 1 exit /b 1\n\techo.\n\techo.Build finished. The message catalogs are in %BUILDDIR%/locale.\n\tgoto end\n)\n\nif \"%1\" == \"changes\" (\n\t%SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes\n\tif errorlevel 1 exit /b 1\n\techo.\n\techo.The overview file is in %BUILDDIR%/changes.\n\tgoto end\n)\n\nif \"%1\" == \"linkcheck\" (\n\t%SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck\n\tif errorlevel 1 exit /b 1\n\techo.\n\techo.Link check complete; look for any errors in the above output ^\nor in %BUILDDIR%/linkcheck/output.txt.\n\tgoto end\n)\n\nif \"%1\" == \"doctest\" (\n\t%SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest\n\tif errorlevel 1 exit /b 1\n\techo.\n\techo.Testing of doctests in the sources finished, look at the ^\nresults in %BUILDDIR%/doctest/output.txt.\n\tgoto end\n)\n\nif \"%1\" == \"coverage\" (\n\t%SPHINXBUILD% -b coverage %ALLSPHINXOPTS% %BUILDDIR%/coverage\n\tif errorlevel 1 exit /b 1\n\techo.\n\techo.Testing of coverage in the sources finished, look at the ^\nresults in %BUILDDIR%/coverage/python.txt.\n\tgoto end\n)\n\nif \"%1\" == \"xml\" (\n\t%SPHINXBUILD% -b xml %ALLSPHINXOPTS% %BUILDDIR%/xml\n\tif errorlevel 1 exit /b 1\n\techo.\n\techo.Build finished. The XML files are in %BUILDDIR%/xml.\n\tgoto end\n)\n\nif \"%1\" == \"pseudoxml\" (\n\t%SPHINXBUILD% -b pseudoxml %ALLSPHINXOPTS% %BUILDDIR%/pseudoxml\n\tif errorlevel 1 exit /b 1\n\techo.\n\techo.Build finished. The pseudo-XML files are in %BUILDDIR%/pseudoxml.\n\tgoto end\n)\n\nif \"%1\" == \"dummy\" (\n\t%SPHINXBUILD% -b dummy %ALLSPHINXOPTS% %BUILDDIR%/dummy\n\tif errorlevel 1 exit /b 1\n\techo.\n\techo.Build finished. Dummy builder generates no files.\n\tgoto end\n)\n\n:end\n"
  },
  {
    "path": "docs/source/conf.py",
    "content": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n#\n# patternscanner documentation build configuration file, created by\n# cookiecutter pipproject\n#\n# This file is execfile()d with the current directory set to its\n# containing dir.\n#\n# Note that not all possible configuration values are present in this\n# autogenerated file.\n#\n# All configuration values have a default; values that are commented out\n# serve to show the default.\n\nimport sys\nimport os\n\n# If extensions (or modules to document with autodoc) are in another directory,\n# add these directories to sys.path here. If the directory is relative to the\n# documentation root, use os.path.abspath to make it absolute, like shown here.\nsys.path.insert(0, os.path.abspath('../..'))\n\n# -- General configuration ------------------------------------------------\n\n# If your documentation needs a minimal Sphinx version, state it here.\n#needs_sphinx = '1.0'\n\n# Add any Sphinx extension module names here, as strings. They can be\n# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom\n# ones.\nextensions = [\n    'sphinx.ext.autodoc',\n]\n\n# Add any paths that contain templates here, relative to this directory.\ntemplates_path = ['_templates']\n\n# The suffix(es) of source filenames.\n# You can specify multiple suffix as a list of string:\n# source_suffix = ['.rst', '.md']\nsource_suffix = '.rst'\n\n# The encoding of source files.\n#source_encoding = 'utf-8-sig'\n\n# The master toctree document.\nmaster_doc = 'index'\n\n# General information about the project.\nproject = 'patternscanner'\ncopyright = '2016, Preetam Sharma'\nauthor = 'Preetam Sharma'\n\n# The version info for the project you're documenting, acts as replacement for\n# |version| and |release|, also used in various other places throughout the\n# built documents.\n#\n# The short X.Y version.\nversion = '0.0.1'\n# The full version, including alpha/beta/rc tags.\nrelease = '0.0.1'\n\n# The language for content autogenerated by Sphinx. Refer to documentation\n# for a list of supported languages.\n#\n# This is also used if you do content translation via gettext catalogs.\n# Usually you set \"language\" from the command line for these cases.\nlanguage = None\n\n# There are two options for replacing |today|: either, you set today to some\n# non-false value, then it is used:\n#today = ''\n# Else, today_fmt is used as the format for a strftime call.\n#today_fmt = '%B %d, %Y'\n\n# List of patterns, relative to source directory, that match files and\n# directories to ignore when looking for source files.\n# This patterns also effect to html_static_path and html_extra_path\nexclude_patterns = []\n\n# The reST default role (used for this markup: `text`) to use for all\n# documents.\n#default_role = None\n\n# If true, '()' will be appended to :func: etc. cross-reference text.\n#add_function_parentheses = True\n\n# If true, the current module name will be prepended to all description\n# unit titles (such as .. function::).\n#add_module_names = True\n\n# If true, sectionauthor and moduleauthor directives will be shown in the\n# output. They are ignored by default.\n#show_authors = False\n\n# The name of the Pygments (syntax highlighting) style to use.\npygments_style = 'sphinx'\n\n# A list of ignored prefixes for module index sorting.\n#modindex_common_prefix = []\n\n# If true, keep warnings as \"system message\" paragraphs in the built documents.\n#keep_warnings = False\n\n# If true, `todo` and `todoList` produce output, else they produce nothing.\ntodo_include_todos = False\n\n\n# -- Options for HTML output ----------------------------------------------\n\n# The theme to use for HTML and HTML Help pages.  See the documentation for\n# a list of builtin themes.\nhtml_theme = 'sphinx_rtd_theme'\n\n# Theme options are theme-specific and customize the look and feel of a theme\n# further.  For a list of options available for each theme, see the\n# documentation.\n#html_theme_options = {}\n\n# Add any paths that contain custom themes here, relative to this directory.\n#html_theme_path = []\n\n# The name for this set of Sphinx documents.\n# \"<project> v<release> documentation\" by default.\n#html_title = 'patternscanner v0.0.1'\n\n# A shorter title for the navigation bar.  Default is the same as html_title.\n#html_short_title = None\n\n# The name of an image file (relative to this directory) to place at the top\n# of the sidebar.\n#html_logo = None\n\n# The name of an image file (relative to this directory) to use as a favicon of\n# the docs.  This file should be a Windows icon file (.ico) being 16x16 or 32x32\n# pixels large.\n#html_favicon = None\n\n# Add any paths that contain custom static files (such as style sheets) here,\n# relative to this directory. They are copied after the builtin static files,\n# so a file named \"default.css\" will overwrite the builtin \"default.css\".\nhtml_static_path = ['_static']\n\n# Add any extra paths that contain custom files (such as robots.txt or\n# .htaccess) here, relative to this directory. These files are copied\n# directly to the root of the documentation.\n#html_extra_path = []\n\n# If not None, a 'Last updated on:' timestamp is inserted at every page\n# bottom, using the given strftime format.\n# The empty string is equivalent to '%b %d, %Y'.\n#html_last_updated_fmt = None\n\n# If true, SmartyPants will be used to convert quotes and dashes to\n# typographically correct entities.\n#html_use_smartypants = True\n\n# Custom sidebar templates, maps document names to template names.\n#html_sidebars = {}\n\n# Additional templates that should be rendered to pages, maps page names to\n# template names.\n#html_additional_pages = {}\n\n# If false, no module index is generated.\n#html_domain_indices = True\n\n# If false, no index is generated.\n#html_use_index = True\n\n# If true, the index is split into individual pages for each letter.\n#html_split_index = False\n\n# If true, links to the reST sources are added to the pages.\n#html_show_sourcelink = True\n\n# If true, \"Created using Sphinx\" is shown in the HTML footer. Default is True.\n#html_show_sphinx = True\n\n# If true, \"(C) Copyright ...\" is shown in the HTML footer. Default is True.\n#html_show_copyright = True\n\n# If true, an OpenSearch description file will be output, and all pages will\n# contain a <link> tag referring to it.  The value of this option must be the\n# base URL from which the finished HTML is served.\n#html_use_opensearch = ''\n\n# This is the file name suffix for HTML files (e.g. \".xhtml\").\n#html_file_suffix = None\n\n# Language to be used for generating the HTML full-text search index.\n# Sphinx supports the following languages:\n#   'da', 'de', 'en', 'es', 'fi', 'fr', 'h', 'it', 'ja'\n#   'nl', 'no', 'pt', 'ro', 'r', 'sv', 'tr', 'zh'\n#html_search_language = 'en'\n\n# A dictionary with options for the search language support, empty by default.\n# 'ja' uses this config value.\n# 'zh' user can custom change `jieba` dictionary path.\n#html_search_options = {'type': 'default'}\n\n# The name of a javascript file (relative to the configuration directory) that\n# implements a search results scorer. If empty, the default will be used.\n#html_search_scorer = 'scorer.js'\n\n# Output file base name for HTML help builder.\nhtmlhelp_basename = 'patternscannerdoc'\n\n# -- Options for LaTeX output ---------------------------------------------\n\nlatex_elements = {\n# The paper size ('letterpaper' or 'a4paper').\n#'papersize': 'letterpaper',\n\n# The font size ('10pt', '11pt' or '12pt').\n#'pointsize': '10pt',\n\n# Additional stuff for the LaTeX preamble.\n#'preamble': '',\n\n# Latex figure (float) alignment\n#'figure_align': 'htbp',\n}\n\n# Grouping the document tree into LaTeX files. List of tuples\n# (source start file, target name, title,\n#  author, documentclass [howto, manual, or own class]).\nlatex_documents = [\n    (master_doc, 'patternscanner.tex', 'patternscanner Documentation',\n     'Preetam Sharma', 'manual'),\n]\n\n# The name of an image file (relative to this directory) to place at the top of\n# the title page.\n#latex_logo = None\n\n# For \"manual\" documents, if this is true, then toplevel headings are parts,\n# not chapters.\n#latex_use_parts = False\n\n# If true, show page references after internal links.\n#latex_show_pagerefs = False\n\n# If true, show URL addresses after external links.\n#latex_show_urls = False\n\n# Documents to append as an appendix to all manuals.\n#latex_appendices = []\n\n# If false, no module index is generated.\n#latex_domain_indices = True\n\n\n# -- Options for manual page output ---------------------------------------\n\n# One entry per manual page. List of tuples\n# (source start file, name, description, authors, manual section).\nman_pages = [\n    (master_doc, 'patternscanner', 'patternscanner Documentation',\n     [author], 1)\n]\n\n# If true, show URL addresses after external links.\n#man_show_urls = False\n\n\n# -- Options for Texinfo output -------------------------------------------\n\n# Grouping the document tree into Texinfo files. List of tuples\n# (source start file, target name, title, author,\n#  dir menu entry, description, category)\ntexinfo_documents = [\n    (master_doc, 'patternscanner', 'patternscanner Documentation',\n     author, 'patternscanner', 'One line description of project.',\n     'Miscellaneous'),\n]\n\n# Documents to append as an appendix to all manuals.\n#texinfo_appendices = []\n\n# If false, no module index is generated.\n#texinfo_domain_indices = True\n\n# How to display URL addresses: 'footnote', 'no', or 'inline'.\n#texinfo_show_urls = 'footnote'\n\n# If true, do not generate a @detailmenu in the \"Top\" node's menu.\n#texinfo_no_detailmenu = False\n"
  },
  {
    "path": "docs/source/index.rst",
    "content": "Welcome to patternscanner's documentation!\n=========================================\n\nContents:\n\n.. toctree::\n   :maxdepth: 2\n\n\n\nIndices and tables\n==================\n\n* :ref:`genindex`\n* :ref:`modindex`\n* :ref:`search`\n\n"
  },
  {
    "path": "pyproject.toml",
    "content": "[tool.poetry]\nname = \"tradingpattern\"\nversion = \"0.0.5\"\nrepository = \"https://github.com/white07S/TradingPatternScanner\"\ndescription = \"Trading Pattern Scanner Identifies complex patterns like head and shoulder, wedge and many more.\"\nauthors = [\"Preetam Sharma\"]\nlicense = \"CC BY-NC-SA 4.0\"\nreadme = \"README.md\"\npackages = [\n    { include = \"tradingpatterns\" }\n]\n\n[tool.poetry.dependencies]\npython = \"^3.10\"\nnumpy = \"^1.24.2\"\npandas = \"^2.0.0\"\n\n[tool.poetry.group.dev.dependencies]\ncoverage = \"^7.2.2\"\nnose = \"^1.3.7\"\nSphinx = \"^6.1.3\"\nsphinx-rtd-theme-citus = \"^0.5.25\"\n\n[build-system]\nrequires = [\"poetry-core\"]\nbuild-backend = \"poetry.core.masonry.api\""
  },
  {
    "path": "requirements.txt",
    "content": "numpy\npandas\n"
  },
  {
    "path": "tests/__init__.py",
    "content": ""
  },
  {
    "path": "tests/test_hs.py",
    "content": "from tradingpatterns.hard_data import generate_sample_df_with_pattern\nfrom tradingpatterns.tradingpatterns import detect_head_shoulder\n\ndef test_detect_head_shoulder():\n    # Generate data with head and shoulder pattern\n    df_head_shoulder = generate_sample_df_with_pattern(\"Head and Shoulder\")\n    df_inv_shoulder = generate_sample_df_with_pattern(\"Inverse Head and Shoulder\")\n    df_with_detection = detect_head_shoulder(df_head_shoulder)\n    df_with_inv_detection = detect_head_shoulder(df_inv_shoulder)\n    assert \"Head and Shoulder\" in df_with_detection['head_shoulder_pattern'].values\n    assert \"Inverse Head and Shoulder\" in df_with_inv_detection['head_shoulder_pattern'].values\n\n\n"
  },
  {
    "path": "tradingpatterns/__init__.py",
    "content": ""
  },
  {
    "path": "tradingpatterns/analysis.py",
    "content": "import matplotlib.pyplot as plt\nimport tradingpatterns_tech\nimport hard_data\nfrom sklearn.metrics import accuracy_score\nimport pandas as pd\nimport seaborn as sns\nfrom collections import Counter\n\ndef main():\n    df = hard_data.generate_data_head_shoulder(10)\n\n    df = detect_and_rename(df, 'window', 3)\n    df = detect_and_rename(df, 'filter', 3, 0.01, 1)\n    df = detect_and_rename(df, 'kf', 3)\n    df = detect_and_rename(df, 'wavelet', 3)\n\n    algorithms = [\n        'head_shoulder_pattern_window', \n        'head_shoulder_pattern_filter', \n        'head_shoulder_pattern_kf', \n        'head_shoulder_pattern_wavelet'\n    ]\n\n    true_labels = ['Head and Shoulder']*10 + ['Inverse Head and Shoulder']*10 + ['No Pattern']*(len(df)-20)\n\n    print_algorithm_accuracies(algorithms, true_labels, df)\n\n    patterns = ['Head and Shoulder', 'Inverse Head and Shoulder']\n    ground_truth_counts = Counter(true_labels)\n    predicted_counts = {alg: Counter(df[alg].fillna('No Pattern')) for alg in algorithms}\n\n    df_counts = pd.DataFrame(index=patterns)\n    df_counts['Ground Truth'] = [ground_truth_counts[pattern] for pattern in patterns]\n\n    for alg in algorithms:\n        df_counts[alg] = [predicted_counts[alg][pattern] for pattern in patterns]\n\n    plot_heatmap(df_counts)\n    plt.savefig('heatmap.png')\n\ndef detect_and_rename(df, method, window, threshold=None, time_delay=None):\n    if method == 'filter':\n        df = tradingpatterns_tech.detect_head_shoulder_filter(df, window, threshold, time_delay)\n    elif method == 'kf':\n        df = tradingpatterns_tech.detect_head_shoulder_kf(df, window)\n    elif method == 'wavelet':\n        df = tradingpatterns_tech.detect_head_shoulder_wavelet(df, window)\n    else:\n        df = tradingpatterns_tech.detect_head_shoulder(df, window)\n\n    try:\n        df.rename(columns={'head_shoulder_pattern': f'head_shoulder_pattern_{method}'}, inplace=True)\n    except KeyError:\n        print(f\"The 'head_shoulder_pattern' column was not found. It seems the function 'detect_head_shoulder_{method}' failed to generate the required column.\")\n        exit(1)\n        \n    return df\n\ndef print_algorithm_accuracies(algorithms, true_labels, df):\n    for alg in algorithms:\n        try:\n            predicted_labels = df[alg].fillna('No Pattern').tolist()\n            accuracy = accuracy_score(true_labels, predicted_labels)\n            print(f'Accuracy for {alg}: {accuracy*100:.2f}%')\n        except KeyError:\n            print(f\"The column {alg} was not found in the dataframe.\")\n            \ndef plot_heatmap(df_counts):\n    sns.heatmap(df_counts, annot=True, fmt=\"d\", cmap=\"YlGnBu\", yticklabels=['HS', 'I-HS'])\n    plt.title(\"Pattern Counts: Ground Truth vs. Predicted\")\n    plt.tight_layout()\n\nif __name__ == \"__main__\":\n    main()\n"
  },
  {
    "path": "tradingpatterns/hard_data.py",
    "content": "import pandas as pd\ndef generate_sample_df_with_pattern(pattern):\n    date_rng = pd.date_range(start='1/1/2020', end='1/10/2020', freq='D')\n    data = {'date': date_rng}\n    if pattern == 'Head and Shoulder':\n        data['Open'] = [90, 85, 80, 90, 85, 80, 75, 80, 85, 90]\n        data['High'] = [95, 90, 85, 95, 90, 85, 80, 85, 90, 95]\n        data['Low'] = [80, 75, 70, 80, 75, 70, 65, 70, 75, 80]\n        data['Close'] = [90, 85, 80, 90, 85, 80, 75, 80, 85, 90]\n        data['Volume'] = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]\n    elif pattern == 'Inverse Head and Shoulder':\n        data['Open'] = [20, 25, 30, 20, 25, 30, 35, 30, 25, 20]\n        data['High'] = [25, 30, 35, 25, 30, 35, 40, 35, 30, 25]\n        data['Low'] = [15, 20, 25, 15, 20, 25, 30, 25, 20, 15]\n        data['Close'] = [20, 25, 30, 20, 25, 30, 35, 30, 25, 20]\n        data['Volume'] = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]\n    elif pattern == \"Double Top\" or \"Double Bottom\" or \"Ascending Triangle\" or \"Descending Triangle\":\n        data['High'] = [95, 90, 85, 95, 90, 85, 80, 85, 90, 95]\n        data['Low'] = [80, 75, 70, 80, 75, 70, 65, 70, 75, 80]\n        df = pd.DataFrame(data)\n        df.iloc[3:5,1] =100\n        df.iloc[6:8,1] =70\n        df.iloc[6:9,2] =70\n    df = pd.DataFrame(data)\n    return df\n\n\nimport pandas as pd\nimport numpy as np\nimport random\nfrom datetime import datetime, timedelta\n\n# Function to generate random OHLCV data\ndef generate_random_data(length):\n    close_values = np.random.randint(100, 200, length).tolist()\n    return {\n        'Open': [value - random.randint(0, 10) for value in close_values],\n        'High': [value + random.randint(0, 10) for value in close_values],\n        'Low': [value - random.randint(0, 10) for value in close_values],\n        'Close': close_values,\n        'Volume': np.random.randint(1000, 2000, length).tolist(),\n    }\n\n# Function to inject head and shoulders and inverse head and shoulders patterns\ndef inject_patterns(data):\n    shoulder_height = random.randint(120, 140)\n    head_height = random.randint(150, 170)\n    inv_shoulder_depth = random.randint(60, 80)\n    inv_head_depth = random.randint(40, 60)\n    \n    # Left Shoulder\n    data['High'][3] = shoulder_height\n    data['Close'][3] = shoulder_height - random.randint(0, 5)\n    \n    # Head\n    data['High'][5] = head_height\n    data['Close'][5] = head_height - random.randint(0, 5)\n    \n    # Right Shoulder\n    data['High'][7] = shoulder_height\n    data['Close'][7] = shoulder_height - random.randint(0, 5)\n    \n    # Left Inverse Shoulder\n    data['Low'][13] = inv_shoulder_depth\n    data['Close'][13] = inv_shoulder_depth + random.randint(0, 5)\n    \n    # Inverse Head\n    data['Low'][15] = inv_head_depth\n    data['Close'][15] = inv_head_depth + random.randint(0, 5)\n    \n    # Right Inverse Shoulder\n    data['Low'][17] = inv_shoulder_depth\n    data['Close'][17] = inv_shoulder_depth + random.randint(0, 5)\n    \n    return data\n\ndef generate_data_head_shoulder(n):\n    # Start date\n    start_date = datetime.now()\n\n    # Dataframe for storing data\n    df = pd.DataFrame()\n\n    # Generate n Head and Shoulders patterns\n    for i in range(n):\n        data = generate_random_data(20)  # 20 data points are needed for one full pattern\n        data = inject_patterns(data)\n        \n        temp_df = pd.DataFrame(data)\n        temp_df['Datetime'] = pd.date_range(start=start_date, periods=20, freq='D')  # Adjust the frequency accordingly\n        start_date += timedelta(days=20)  # Adjust the timedelta accordingly\n        \n        df = df.append(temp_df, ignore_index=True)\n\n    df = df[['Datetime', 'Open', 'High', 'Low', 'Close', 'Volume']]\n\n    return df\n"
  },
  {
    "path": "tradingpatterns/tradingpatterns.py",
    "content": "import pandas as pd\nimport numpy as np\n\n\ndef detect_head_shoulder(df, window=3):\n# Define the rolling window\n    roll_window = window\n    # Create a rolling window for High and Low\n    df['high_roll_max'] = df['High'].rolling(window=roll_window).max()\n    df['low_roll_min'] = df['Low'].rolling(window=roll_window).min()\n    # Create a boolean mask for Head and Shoulder pattern\n    mask_head_shoulder = ((df['high_roll_max'] > df['High'].shift(1)) & (df['high_roll_max'] > df['High'].shift(-1)) & (df['High'] < df['High'].shift(1)) & (df['High'] < df['High'].shift(-1)))\n    # Create a boolean mask for Inverse Head and Shoulder pattern\n    mask_inv_head_shoulder = ((df['low_roll_min'] < df['Low'].shift(1)) & (df['low_roll_min'] < df['Low'].shift(-1)) & (df['Low'] > df['Low'].shift(1)) & (df['Low'] > df['Low'].shift(-1)))\n    # Create a new column for Head and Shoulder and its inverse pattern and populate it using the boolean masks\n    df['head_shoulder_pattern'] = np.nan\n    df.loc[mask_head_shoulder, 'head_shoulder_pattern'] = 'Head and Shoulder'\n    df.loc[mask_inv_head_shoulder, 'head_shoulder_pattern'] = 'Inverse Head and Shoulder'\n    return df \n    # return not df['head_shoulder_pattern'].isna().any().item()\n\ndef detect_multiple_tops_bottoms(df, window=3):\n# Define the rolling window\n    roll_window = window\n    # Create a rolling window for High and Low\n    df['high_roll_max'] = df['High'].rolling(window=roll_window).max()\n    df['low_roll_min'] = df['Low'].rolling(window=roll_window).min()\n    df['close_roll_max'] = df['Close'].rolling(window=roll_window).max()\n    df['close_roll_min'] = df['Close'].rolling(window=roll_window).min()\n    # Create a boolean mask for multiple top pattern\n    mask_top = (df['high_roll_max'] >= df['High'].shift(1)) & (df['close_roll_max'] < df['Close'].shift(1))\n    # Create a boolean mask for multiple bottom pattern\n    mask_bottom = (df['low_roll_min'] <= df['Low'].shift(1)) & (df['close_roll_min'] > df['Close'].shift(1))\n    # Create a new column for multiple top bottom pattern and populate it using the boolean masks\n    df['multiple_top_bottom_pattern'] = np.nan\n    df.loc[mask_top, 'multiple_top_bottom_pattern'] = 'Multiple Top'\n    df.loc[mask_bottom, 'multiple_top_bottom_pattern'] = 'Multiple Bottom'\n    return df\n\ndef calculate_support_resistance(df, window=3):\n# Define the rolling window\n    roll_window = window\n    # Set the number of standard deviation\n    std_dev = 2\n    # Create a rolling window for High and Low\n    df['high_roll_max'] = df['High'].rolling(window=roll_window).max()\n    df['low_roll_min'] = df['Low'].rolling(window=roll_window).min()\n    # Calculate the mean and standard deviation for High and Low\n    mean_high = df['High'].rolling(window=roll_window).mean()\n    std_high = df['High'].rolling(window=roll_window).std()\n    mean_low = df['Low'].rolling(window=roll_window).mean()\n    std_low = df['Low'].rolling(window=roll_window).std()\n    # Create a new column for support and resistance\n    df['support'] = mean_low - std_dev * std_low\n    df['resistance'] = mean_high + std_dev * std_high\n    return df\ndef detect_triangle_pattern(df, window=3):\n    # Define the rolling window\n    roll_window = window\n    # Create a rolling window for High and Low\n    df['high_roll_max'] = df['High'].rolling(window=roll_window).max()\n    df['low_roll_min'] = df['Low'].rolling(window=roll_window).min()\n    # Create a boolean mask for ascending triangle pattern\n    mask_asc = (df['high_roll_max'] >= df['High'].shift(1)) & (df['low_roll_min'] <= df['Low'].shift(1)) & (df['Close'] > df['Close'].shift(1))\n    # Create a boolean mask for descending triangle pattern\n    mask_desc = (df['high_roll_max'] <= df['High'].shift(1)) & (df['low_roll_min'] >= df['Low'].shift(1)) & (df['Close'] < df['Close'].shift(1))\n    # Create a new column for triangle pattern and populate it using the boolean masks\n    df['triangle_pattern'] = np.nan\n    df.loc[mask_asc, 'triangle_pattern'] = 'Ascending Triangle'\n    df.loc[mask_desc, 'triangle_pattern'] = 'Descending Triangle'\n    return df\n\ndef detect_wedge(df, window=3):\n    # Define the rolling window\n    roll_window = window\n    # Create a rolling window for High and Low\n    df['high_roll_max'] = df['High'].rolling(window=roll_window).max()\n    df['low_roll_min'] = df['Low'].rolling(window=roll_window).min()\n    df['trend_high'] = df['High'].rolling(window=roll_window).apply(lambda x: 1 if (x[-1]-x[0])>0 else -1 if (x[-1]-x[0])<0 else 0)\n    df['trend_low'] = df['Low'].rolling(window=roll_window).apply(lambda x: 1 if (x[-1]-x[0])>0 else -1 if (x[-1]-x[0])<0 else 0)\n    # Create a boolean mask for Wedge Up pattern\n    mask_wedge_up = (df['high_roll_max'] >= df['High'].shift(1)) & (df['low_roll_min'] <= df['Low'].shift(1)) & (df['trend_high'] == 1) & (df['trend_low'] == 1)\n    # Create a boolean mask for Wedge Down pattern\n        # Create a boolean mask for Wedge Down pattern\n    mask_wedge_down = (df['high_roll_max'] <= df['High'].shift(1)) & (df['low_roll_min'] >= df['Low'].shift(1)) & (df['trend_high'] == -1) & (df['trend_low'] == -1)\n    # Create a new column for Wedge Up and Wedge Down pattern and populate it using the boolean masks\n    df['wedge_pattern'] = np.nan\n    df.loc[mask_wedge_up, 'wedge_pattern'] = 'Wedge Up'\n    df.loc[mask_wedge_down, 'wedge_pattern'] = 'Wedge Down'\n    return df\ndef detect_channel(df, window=3):\n    # Define the rolling window\n    roll_window = window\n    # Define a factor to check for the range of channel\n    channel_range = 0.1\n    # Create a rolling window for High and Low\n    df['high_roll_max'] = df['High'].rolling(window=roll_window).max()\n    df['low_roll_min'] = df['Low'].rolling(window=roll_window).min()\n    df['trend_high'] = df['High'].rolling(window=roll_window).apply(lambda x: 1 if (x[-1]-x[0])>0 else -1 if (x[-1]-x[0])<0 else 0)\n    df['trend_low'] = df['Low'].rolling(window=roll_window).apply(lambda x: 1 if (x[-1]-x[0])>0 else -1 if (x[-1]-x[0])<0 else 0)\n    # Create a boolean mask for Channel Up pattern\n    mask_channel_up = (df['high_roll_max'] >= df['High'].shift(1)) & (df['low_roll_min'] <= df['Low'].shift(1)) & (df['high_roll_max'] - df['low_roll_min'] <= channel_range * (df['high_roll_max'] + df['low_roll_min'])/2) & (df['trend_high'] == 1) & (df['trend_low'] == 1)\n    # Create a boolean mask for Channel Down pattern\n    mask_channel_down = (df['high_roll_max'] <= df['High'].shift(1)) & (df['low_roll_min'] >= df['Low'].shift(1)) & (df['high_roll_max'] - df['low_roll_min'] <= channel_range * (df['high_roll_max'] + df['low_roll_min'])/2) & (df['trend_high'] == -1) & (df['trend_low'] == -1)\n    # Create a new column for Channel Up and Channel Down pattern and populate it using the boolean masks\n    df['channel_pattern'] = np.nan\n    df.loc[mask_channel_up, 'channel_pattern'] = 'Channel Up'\n    df.loc[mask_channel_down, 'channel_pattern'] = 'Channel Down'\n    return df\n\ndef detect_double_top_bottom(df, window=3, threshold=0.05):\n    # Define the rolling window\n    roll_window = window\n    # Define a threshold to check for the range of pattern\n    range_threshold = threshold\n\n    # Create a rolling window for High and Low\n    df['high_roll_max'] = df['High'].rolling(window=roll_window).max()\n    df['low_roll_min'] = df['Low'].rolling(window=roll_window).min()\n\n    # Create a boolean mask for Double Top pattern\n    mask_double_top = (df['high_roll_max'] >= df['High'].shift(1)) & (df['high_roll_max'] >= df['High'].shift(-1)) & (df['High'] < df['High'].shift(1)) & (df['High'] < df['High'].shift(-1)) & ((df['High'].shift(1) - df['Low'].shift(1)) <= range_threshold * (df['High'].shift(1) + df['Low'].shift(1))/2) & ((df['High'].shift(-1) - df['Low'].shift(-1)) <= range_threshold * (df['High'].shift(-1) + df['Low'].shift(-1))/2)\n    # Create a boolean mask for Double Bottom pattern\n    mask_double_bottom = (df['low_roll_min'] <= df['Low'].shift(1)) & (df['low_roll_min'] <= df['Low'].shift(-1)) & (df['Low'] > df['Low'].shift(1)) & (df['Low'] > df['Low'].shift(-1)) & ((df['High'].shift(1) - df['Low'].shift(1)) <= range_threshold * (df['High'].shift(1) + df['Low'].shift(1))/2) & ((df['High'].shift(-1) - df['Low'].shift(-1)) <= range_threshold * (df['High'].shift(-1) + df['Low'].shift(-1))/2)\n\n    # Create a new column for Double Top and Double Bottom pattern and populate it using the boolean masks\n    df['double_pattern'] = np.nan\n    df.loc[mask_double_top, 'double_pattern'] = 'Double Top'\n    df.loc[mask_double_bottom, 'double_pattern'] = 'Double Bottom'\n\n    return df\n\ndef detect_trendline(df, window=2):\n    # Define the rolling window\n    roll_window = window\n    # Create new columns for the linear regression slope and y-intercept\n    df['slope'] = np.nan\n    df['intercept'] = np.nan\n\n    for i in range(window, len(df)):\n        x = np.array(range(i-window, i))\n        y = df['Close'][i-window:i]\n        A = np.vstack([x, np.ones(len(x))]).T\n        m, c = np.linalg.lstsq(A, y, rcond=None)[0]\n        df.at[df.index[i], 'slope'] = m\n        df.at[df.index[i], 'intercept'] = c\n\n    # Create a boolean mask for trendline support\n    mask_support = df['slope'] > 0\n\n    # Create a boolean mask for trendline resistance\n    mask_resistance = df['slope'] < 0\n\n    # Create new columns for trendline support and resistance\n    df['support'] = np.nan\n    df['resistance'] = np.nan\n\n    # Populate the new columns using the boolean masks\n    df.loc[mask_support, 'support'] = df['Close'] * df['slope'] + df['intercept']\n    df.loc[mask_resistance, 'resistance'] = df['Close'] * df['slope'] + df['intercept']\n\n    return df\n\ndef find_pivots(df):\n    # Calculate differences between consecutive highs and lows\n    high_diffs = df['high'].diff()\n    low_diffs = df['low'].diff()\n\n    # Find higher high\n    higher_high_mask = (high_diffs > 0) & (high_diffs.shift(-1) < 0)\n    \n    # Find lower low\n    lower_low_mask = (low_diffs < 0) & (low_diffs.shift(-1) > 0)\n\n    # Find lower high\n    lower_high_mask = (high_diffs < 0) & (high_diffs.shift(-1) > 0)\n\n    # Find higher low\n    higher_low_mask = (low_diffs > 0) & (low_diffs.shift(-1) < 0)\n\n    # Create signals column\n    df['signal'] = ''\n    df.loc[higher_high_mask, 'signal'] = 'HH'\n    df.loc[lower_low_mask, 'signal'] = 'LL'\n    df.loc[lower_high_mask, 'signal'] = 'LH'\n    df.loc[higher_low_mask, 'signal'] = 'HL'\n\n    return df"
  },
  {
    "path": "tradingpatterns/tradingpatterns_tech.py",
    "content": "from scipy.signal import savgol_filter\nimport numpy as np\nimport pandas as pd\nfrom pykalman import KalmanFilter\nimport pywt\n\n'''\nAlgorithm 1: Basic Head-Shoulder Detection\nThis algorithm implements a basic detection of the \"Head and Shoulder\" and \"Inverse Head and Shoulder\" patterns \nin a data frame. These patterns are significant in financial analysis as they indicate possible market reversals. \nIn the code, the algorithm uses a rolling window to track high and low points in the 'High' and 'Low' columns of \nthe data frame. It then creates boolean masks to identify where these patterns occur. The identified patterns are \nthen added to the data frame in a new 'head_shoulder_pattern' column.\n'''\n\ndef detect_head_shoulder(df, window=3):\n# Define the rolling window\n    roll_window = window\n    # Create a rolling window for High and Low\n    df['high_roll_max'] = df['High'].rolling(window=roll_window).max()\n    df['low_roll_min'] = df['Low'].rolling(window=roll_window).min()\n    # Create a boolean mask for Head and Shoulder pattern\n    mask_head_shoulder = ((df['high_roll_max'] > df['High'].shift(1)) & (df['high_roll_max'] > df['High'].shift(-1)) & (df['High'] < df['High'].shift(1)) & (df['High'] < df['High'].shift(-1)))\n    # Create a boolean mask for Inverse Head and Shoulder pattern\n    mask_inv_head_shoulder = ((df['low_roll_min'] < df['Low'].shift(1)) & (df['low_roll_min'] < df['Low'].shift(-1)) & (df['Low'] > df['Low'].shift(1)) & (df['Low'] > df['Low'].shift(-1)))\n    # Create a new column for Head and Shoulder and its inverse pattern and populate it using the boolean masks\n    df['head_shoulder_pattern'] = np.nan\n    df.loc[mask_head_shoulder, 'head_shoulder_pattern'] = 'Head and Shoulder'\n    df.loc[mask_inv_head_shoulder, 'head_shoulder_pattern'] = 'Inverse Head and Shoulder'\n    return df \n\n'''\nAlgorithm 2: Head-Shoulder Detection with Savitzky-Golay Filter\n\nThis algorithm is an improvement of the first one. It first applies the Savitzky-Golay filter to smooth the 'High' and 'Low' columns. \nThis filter is used to reduce noise and improve the reliability of pattern detection. \nIn addition to the head-shoulder pattern detection of the first algorithm, this algorithm also considers \nthe height of the \"Head\" or \"Inverse Head\" and introduces a threshold to avoid false pattern \nrecognition due to insignificant price changes.\n'''\ndef detect_head_shoulder_filter(df, window=3, threshold=0.01, time_delay=1):\n    roll_window = window\n    df['High_smooth'] = savgol_filter(df['High'], roll_window, 2) # Apply Savitzky-Golay filter\n    df['Low_smooth'] = savgol_filter(df['Low'], roll_window, 2)\n    \n    df['high_roll_max'] = df['High_smooth'].rolling(window=roll_window).max()\n    df['low_roll_min'] = df['Low_smooth'].rolling(window=roll_window).min()\n    \n    # Define the height of the head and inverse head\n    df['head_height'] = df['high_roll_max'] - df['Low'].rolling(window=roll_window).min()\n    df['inv_head_height'] = df['High'].rolling(window=roll_window).max() - df['low_roll_min']\n    \n    # Define the masks for head and shoulder and inverse head and shoulder\n    mask_head_shoulder = ((df['head_height'] > threshold) & (df['high_roll_max'] > df['High_smooth'].shift(time_delay)) & (df['high_roll_max'] > df['High_smooth'].shift(-time_delay)) & (df['High_smooth'] < df['High_smooth'].shift(time_delay)) & (df['High_smooth'] < df['High_smooth'].shift(-time_delay)))\n    mask_inv_head_shoulder = ((df['inv_head_height'] > threshold) & (df['low_roll_min'] < df['Low_smooth'].shift(time_delay)) & (df['low_roll_min'] < df['Low_smooth'].shift(-time_delay)) & (df['Low_smooth'] > df['Low_smooth'].shift(time_delay)) & (df['Low_smooth'] > df['Low_smooth'].shift(-time_delay)))\n    \n    df['head_shoulder_pattern'] = np.nan\n    df.loc[mask_head_shoulder, 'head_shoulder_pattern'] = 'Head and Shoulder'\n    df.loc[mask_inv_head_shoulder, 'head_shoulder_pattern'] = 'Inverse Head and Shoulder'\n    \n    return df\n\n'''\nAlgorithm 3: Head-Shoulder Detection with Kalman Filter\n\nIn this algorithm, the Kalman Filter is used to smooth the 'High' and 'Low' columns. \nThe Kalman Filter is a recursive filter that estimates the state of a system in real time, \nmaking it more suitable for financial data with its inherent noise and uncertainties. \nThis can potentially improve the accuracy of pattern detection. \nThe pattern detection process is similar to Algorithm 1, but it operates on the smoothed data.\n'''\n\n\ndef kalman_smooth(series, n_iter=10):\n    # Initialize Kalman filter\n    kf = KalmanFilter(initial_state_mean=0, n_dim_obs=1)\n\n    # Use the EM algorithm to estimate the best values for the parameters\n    kf = kf.em(series, n_iter=n_iter)\n\n    # Use the observed values of the price to get a rolling mean\n    state_means, _ = kf.filter(series.values)\n\n    return state_means.flatten()\n\n\ndef detect_head_shoulder_kf(df, window=3):\n    roll_window = window\n    df['High_smooth'] = kalman_smooth(df['High'])\n    df['Low_smooth'] = kalman_smooth(df['Low'])\n    \n    df['high_roll_max'] = df['High_smooth'].rolling(window=roll_window).max()\n    df['low_roll_min'] = df['Low_smooth'].rolling(window=roll_window).min()\n    \n    mask_head_shoulder = ((df['high_roll_max'] > df['High_smooth'].shift(1)) & (df['high_roll_max'] > df['High_smooth'].shift(-1)) & (df['High_smooth'] < df['High_smooth'].shift(1)) & (df['High_smooth'] < df['High_smooth'].shift(-1)))\n    mask_inv_head_shoulder = ((df['low_roll_min'] < df['Low_smooth'].shift(1)) & (df['low_roll_min'] < df['Low_smooth'].shift(-1)) & (df['Low_smooth'] > df['Low_smooth'].shift(1)) & (df['Low_smooth'] > df['Low_smooth'].shift(-1)))\n    \n    df['head_shoulder_pattern'] = np.nan\n    df.loc[mask_head_shoulder, 'head_shoulder_pattern'] = 'Head and Shoulder'\n    df.loc[mask_inv_head_shoulder, 'head_shoulder_pattern'] = 'Inverse Head and Shoulder'\n    \n    return df\n\n'''\nAlgorithm 4: Head-Shoulder Detection with Wavelet Denoising\n\nIn this algorithm, wavelet denoising is applied to the 'High' and 'Low' columns before \nthe pattern detection process. Wavelet denoising is an effective technique for eliminating \nnoise while preserving the key features in the data. This can make the pattern detection process \nmore robust and reliable, especially in the presence of high frequency noise in the data. \n'''\n\ndef wavelet_denoise(series, wavelet='db1', level=1):\n    # Perform wavelet decomposition\n    coeff = pywt.wavedec(series, wavelet, mode=\"per\")\n    # Set detail coefficients for levels > level to zero\n    for i in range(1, len(coeff)):\n        coeff[i] = pywt.threshold(coeff[i], value=np.std(coeff[i])/2, mode=\"soft\")\n    # Perform inverse wavelet transform\n    return pywt.waverec(coeff, wavelet, mode=\"per\")\n\n\ndef detect_head_shoulder_wavelet(df, window=3):\n    roll_window = window\n    df['High_smooth'] = wavelet_denoise(df['High'], 'db1', level=1)\n    df['Low_smooth'] = wavelet_denoise(df['Low'], 'db1', level=1)\n    \n    df['high_roll_max'] = df['High_smooth'].rolling(window=roll_window).max()\n    df['low_roll_min'] = df['Low_smooth'].rolling(window=roll_window).min()\n    \n    mask_head_shoulder = ((df['high_roll_max'] > df['High_smooth'].shift(1)) & (df['high_roll_max'] > df['High_smooth'].shift(-1)) & (df['High_smooth'] < df['High_smooth'].shift(1)) & (df['High_smooth'] < df['High_smooth'].shift(-1)))\n    mask_inv_head_shoulder = ((df['low_roll_min'] < df['Low_smooth'].shift(1)) & (df['low_roll_min'] < df['Low_smooth'].shift(-1)) & (df['Low_smooth'] > df['Low_smooth'].shift(1)) & (df['Low_smooth'] > df['Low_smooth'].shift(-1)))\n    \n    df['head_shoulder_pattern'] = np.nan\n    df.loc[mask_head_shoulder, 'head_shoulder_pattern'] = 'Head and Shoulder'\n    df.loc[mask_inv_head_shoulder, 'head_shoulder_pattern'] = 'Inverse Head and Shoulder'\n    \n    return df\n"
  },
  {
    "path": "update_docs.sh",
    "content": "#!/usr/bin/env bash\n\n# build the docs\ncd docs\nmake clean\nmake html\ncd ..\n\n# commit and push\ngit add -A\ngit commit -m \"building and pushing docs\"\ngit push origin master\n\n# switch branches and pull the data we want\ngit checkout gh-pages\nrm -rf .\ntouch .nojekyll\ngit checkout master docs/build/html\nmv ./docs/build/html/* ./\nrm -rf ./docs\ngit add -A\ngit commit -m \"publishing updated docs...\"\ngit push origin gh-pages\n\n# switch back\ngit checkout master"
  }
]