Skip to content
/ ttrpy Public

Technical analysis and other functions to construct technical trading rules with Python

License

Notifications You must be signed in to change notification settings

joelowj/ttrpy

Repository files navigation

ttrpy

Build Status codecov PRs Welcome

Technical Trading Rule Python is an open source library for popular technical analysis function for financial time series data.

Installation

To install the current release:

$ pip install ttrpy

Usage Overview

Load historical stock data into Pandas from existing csv file or directly from the web.

>>> import pandas as pd
>>> df = pd.read_csv("weekly_MSFT.csv").sort_values(by="timestamp").reset_index(drop=True)
>>> df.tail(3)
      timestamp    open    high     low   close   volume
1098 2019-01-25  106.75   107.88    ...    ...     ...
1099 2019-02-01  106.26   106.48    ...    ...     ...
1100 2019-02-07  102.87   107.27    ...    ...     ...

Let's say we are interested in the overall long-term trend for MSFT, we can use the simple moving average function from the trend package.

>>> from ttrpy.trend.sma import sma
>>> df = sma(df, "close", "sma", 200)
>>> df.tail(3)
      timestamp    open    high     low   close   volume    sma
1098 2019-01-25  106.75   107.88    ...    ...     ...    71.080175
1099 2019-02-01  106.26   106.48    ...    ...     ...    71.392625
1100 2019-02-07  102.87   107.27    ...    ...     ...    71.707025

As easy as that!

Contribution Guidelines

If you want to contribute to ttrpy, be sure to review the contribution guidelines. This project adheres to ttrpy's code of conduct. By participating, you are expected to uphold this code.

To get the local repository set up for development,

$ pip install pipenv
$ pip install --dev

If you find a bug, kindly open an issue here.

If you would like to request a new feature, feel free to do so by opening an issue here.

To fix a bug or enhance an existing module, follow these steps:

  • Fork the repository
  • Create a new branch (git checkout - b branch-name)
  • Make the appropriate changes in the files
  • Add changes to reflect the changes made
  • Commit your changes (git commit -m 'commit message')
  • Push to the branch (git push origin branch-name)
  • Create a Pull Request

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository

License

This project is licensed under Apache License 2.0 - see the LICENSE file for details.