StratLab


NameStratLab JSON
Version 1.0.20 PyPI version JSON
download
home_pagehttps://github.com/rstickles16/StratLab
SummaryStratLab is a Python library designed to backtest stock market strategies.
upload_time2024-10-26 17:31:58
maintainerNone
docs_urlNone
authorRobert Stickles
requires_python>=3.6
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # What is StratLab?
StratLab is a Python library designed to backtest stock market strategies. The library currently uses the yfinance (Yahoo Finance) API as a means for extracting financial data, which is then manipulated utilizing Pandas dataframes and Numpy functions. There are also options to extract the backtested results directly into excel files.
# How do you install it?
Run the following command in your terminal
```bash
pip install StratLab
```
# How do you use it?
Step 1: Initialize backtest
```python
# This imports the StratLab library and intializes the Backtest.
# The to_excel argument writes an excel file to your desktop with an analysis of the backtest.
import StratLib as sl

bt = sl.Backtest(to_excel=True)
```
Step 2: Add condition for trade
```python
# This example creates a condition in the backtest for when
# ^NDX (Nasdaq 100 Index) price is above its 200D moving average...
bt.add_condition(
  name='200 SMA Bullish',
  ticker_1='^NDX',
  study_1='price',
  operator='>',
  ticker_2='^NDX',
  study_2='sma',
  study_2_period=200
)
```

Step 3: Add holding for the condition(s)
```python
# This example tells the backtest to hold ^NDX (Nasdaq 100 Index)
# when the "200 SMA Bullish" condition is True...
bt.add_holding(
  conditions=['200 SMA Bullish'],
  flags=['True'],
  holdings_list=['^NDX']
)
```

Step 4: Run the backtest
```python
bt.run()


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/rstickles16/StratLab",
    "name": "StratLab",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": null,
    "author": "Robert Stickles",
    "author_email": "rstickles16@outlook.com",
    "download_url": "https://files.pythonhosted.org/packages/7c/53/9f8e64b533c3e4966ffa03f5f06cc16ed4b97ccda84df5983b54f3b6dcbe/StratLab-1.0.20.tar.gz",
    "platform": null,
    "description": "# What is StratLab?\nStratLab is a Python library designed to backtest stock market strategies. The library currently uses the yfinance (Yahoo Finance) API as a means for extracting financial data, which is then manipulated utilizing Pandas dataframes and Numpy functions. There are also options to extract the backtested results directly into excel files.\n# How do you install it?\nRun the following command in your terminal\n```bash\npip install StratLab\n```\n# How do you use it?\nStep 1: Initialize backtest\n```python\n# This imports the StratLab library and intializes the Backtest.\n# The to_excel argument writes an excel file to your desktop with an analysis of the backtest.\nimport StratLib as sl\n\nbt = sl.Backtest(to_excel=True)\n```\nStep 2: Add condition for trade\n```python\n# This example creates a condition in the backtest for when\n# ^NDX (Nasdaq 100 Index) price is above its 200D moving average...\nbt.add_condition(\n  name='200 SMA Bullish',\n  ticker_1='^NDX',\n  study_1='price',\n  operator='>',\n  ticker_2='^NDX',\n  study_2='sma',\n  study_2_period=200\n)\n```\n\nStep 3: Add holding for the condition(s)\n```python\n# This example tells the backtest to hold ^NDX (Nasdaq 100 Index)\n# when the \"200 SMA Bullish\" condition is True...\nbt.add_holding(\n  conditions=['200 SMA Bullish'],\n  flags=['True'],\n  holdings_list=['^NDX']\n)\n```\n\nStep 4: Run the backtest\n```python\nbt.run()\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "StratLab is a Python library designed to backtest stock market strategies.",
    "version": "1.0.20",
    "project_urls": {
        "Homepage": "https://github.com/rstickles16/StratLab"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "883f1193f86f01c1d0afaca430788ec651bb5470f38c85a0d471aeb6ce12adfe",
                "md5": "997a476a664349e6c330a6992e46be5f",
                "sha256": "a207cd403de1f84e2c8ffc0916ec14095c52de30503afd354c51666a93510334"
            },
            "downloads": -1,
            "filename": "StratLab-1.0.20-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "997a476a664349e6c330a6992e46be5f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 15713,
            "upload_time": "2024-10-26T17:31:56",
            "upload_time_iso_8601": "2024-10-26T17:31:56.515375Z",
            "url": "https://files.pythonhosted.org/packages/88/3f/1193f86f01c1d0afaca430788ec651bb5470f38c85a0d471aeb6ce12adfe/StratLab-1.0.20-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7c539f8e64b533c3e4966ffa03f5f06cc16ed4b97ccda84df5983b54f3b6dcbe",
                "md5": "1b4f07040cc7fc87d6e62f00bcb1e8e4",
                "sha256": "d6f28ed5842aaf72b2ad1737a4aa000b80424e01667387923b502a90286e2ec3"
            },
            "downloads": -1,
            "filename": "StratLab-1.0.20.tar.gz",
            "has_sig": false,
            "md5_digest": "1b4f07040cc7fc87d6e62f00bcb1e8e4",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 12502,
            "upload_time": "2024-10-26T17:31:58",
            "upload_time_iso_8601": "2024-10-26T17:31:58.995049Z",
            "url": "https://files.pythonhosted.org/packages/7c/53/9f8e64b533c3e4966ffa03f5f06cc16ed4b97ccda84df5983b54f3b6dcbe/StratLab-1.0.20.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-26 17:31:58",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "rstickles16",
    "github_project": "StratLab",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "stratlab"
}
        
Elapsed time: 0.49754s