Skip to content

Commit

Permalink
First public commit 0.9.1
Browse files Browse the repository at this point in the history
  • Loading branch information
mementum committed Feb 1, 2020
0 parents commit 07a9e84
Show file tree
Hide file tree
Showing 51 changed files with 3,555 additions and 0 deletions.
65 changes: 65 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.cache
nosetests.xml
coverage.xml

# Translations
*.mo
*.pot

# Django stuff:
*.log

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Backups
*.bak
*~
.#*
*#
*.swp
*.swo

.ipynb*
samples2/
1 change: 1 addition & 0 deletions AUTHOR
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Project Founder and Lead Developer: Daniel Rodriguez (https://github.com/mementum)
2 changes: 2 additions & 0 deletions COPYRIGHT
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Copyright (C) 2020 Daniel Rodriguez
This projct is governed by the MIT License
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 Daniel Rodriguez

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
32 changes: 32 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
``bta-lib`` - A ``pandas`` based *Technical Analysis Library*
=============================================================

.. image:: https://img.shields.io/pypi/v/bta-lib.svg
:alt: PyPi Version
:scale: 100%
:target: https://pypi.python.org/pypi/bta-lib/

.. image:: https://img.shields.io/github/release/mementum/bta-lib.svg
:alt: Release
:scale: 100%
:target: https://github.com/mementum/bta-lib/releases/

``bta-lib`` is ``pandas`` based technical analysis library and part of the
``backtrader`` family.

Links
-----

- Main Page: https://btalib.backtrader.com/
- Documentation: https://btalib.backtrader.com/introduction/
- Community: https://community.backtrader.com/category/10/bta-lib
- GitHub Repo: https://github.com/mementum/bta-lib

Installation
------------

Via ``pip``::

pip install bta-lib

**Remember**: ``pandas`` is a requirement. Read the docs!!!
15 changes: 15 additions & 0 deletions btalib/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env python
# -*- coding: utf-8; py-indent-offset:4 -*-
###############################################################################
# Copyright (C) 2020 Daniel Rodriguez
# Use of this source code is governed by the MIT License
###############################################################################
from .version import * # noqa: F401 F403

from .meta import * # noqa: F401 F403
from .utils import * # noqa: F401 F403

from .indicator import * # noqa: F401 F403

from .indicators import * # noqa: F401 F403
from . import indicators as ind # noqa: F401
67 changes: 67 additions & 0 deletions btalib/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/usr/bin/env python
# -*- coding: utf-8; py-indent-offset:4 -*-
###############################################################################
# Copyright (C) 2020 Daniel Rodriguez
# Use of this source code is governed by the MIT License
###############################################################################

__all__ = []


# Standard ordering of OHLCV_OI fields
OHLC_INDICES = {
'open': 0,
'high': 1,
'low': 2,
'close': 3,
'volume': 4,
'openinterest': 5,
}

OHLC_FIRST = False


def set_use_ohlc_indices_first(onoff=True):
global OHLC_FIRST
OHLC_FIRST = onoff


def set_input_indices(**kwargs):
OHLC_INDICES.update(kwargs)


def get_input_indices():
return OHLC_INDICES.copy()


RETVAL = '' # can be 'dataframe', 'df'


def set_return(val):
global RETVAL
RETVAL = val


def set_return_dataframe():
global RETVAL
RETVAL = 'df'


def get_return():
return RETVAL


def get_return_dataframe():
return RETVAL in ['df', 'dataframe']


TALIB_COMPAT = False # global flag for ta-lib compatibility


def set_talib_compat(onoff=True):
global TALIB_COMPAT
TALIB_COMPAT = onoff


def get_talib_compat():
return TALIB_COMPAT
50 changes: 50 additions & 0 deletions btalib/errors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/env python
# -*- coding: utf-8; py-indent-offset:4 -*-
###############################################################################
# Copyright (C) 2020 Daniel Rodriguez
# Use of this source code is governed by the MIT License
###############################################################################
__all__ = ['TaPyError', 'InputsError', ]


class TaPyError(Exception):
pass


class InputsError(TaPyError):
pass


def OneInputNeededZeroProvided():
errmsg = 'One (1) input is at least needed and 0 were provided'
raise InputsError(errmsg)


def MultiDimSmall():
errmsg = (
'The multidimensional input size is smaller than the number of needed '
'inputs'
)
raise InputsError(errmsg)


def MultiDimType():
errmsg = (
'Only DataFrames or library/user indicators are accepted as '
'multi-dimensional inputs'
)
raise InputsError(errmsg)


def PandasNotTopStack():
errmsg = (
'Pandas DataFrames only valid as input from outside of the library'
)
raise InputsError(errmsg)


def ColdIndexStrNotFound(name, rename):
errmsg = (
'OHLC Column Name "{}" remapped to "{}", but this cannot be found'
)
raise InputsError(errmsg.format(name, rename))
Loading

0 comments on commit 07a9e84

Please sign in to comment.