Skip to content

Commit

Permalink
Final retouching and integration of contributed fractal study and tes…
Browse files Browse the repository at this point in the history
…t case
  • Loading branch information
mementum committed May 17, 2017
1 parent 82c1ba7 commit 89488ec
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 2 deletions.
2 changes: 1 addition & 1 deletion backtrader/studies/contrib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@
import backtrader as bt

from .import fractal as fractal
for name in vortex.__all__:
for name in fractal.__all__:
setattr(bt.studies, name, getattr(fractal, name))
5 changes: 4 additions & 1 deletion backtrader/studies/contrib/fractal.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@
import backtrader as bt


class Fractal(bt.PeriodN):
__all__ = ['Fractal']


class Fractal(bt.ind.PeriodN):
'''
References:
[Ref 1] http://www.investopedia.com/articles/trading/06/fractals.asp
Expand Down
51 changes: 51 additions & 0 deletions tests/test_study_fractal.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/usr/bin/env python
# -*- coding: utf-8; py-indent-offset:4 -*-
###############################################################################
#
# Copyright (C) 2015, 2016 Daniel Rodriguez
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
###############################################################################
from __future__ import (absolute_import, division, print_function,
unicode_literals)

import testcommon

import backtrader as bt


chkdatas = 1
chkvals = [
['nan', 'nan', 'nan'],
['nan', 'nan', '3553.692850']
]

chkmin = 5
chkind = bt.studies.Fractal


def test_run(main=False):
datas = [testcommon.getdata(i) for i in range(chkdatas)]
testcommon.runtest(datas,
testcommon.TestStrategy,
main=main,
plot=main,
chkind=chkind,
chkmin=chkmin,
chkvals=chkvals)


if __name__ == '__main__':
test_run(main=True)

0 comments on commit 89488ec

Please sign in to comment.