Mariner Backtesting - TA-LIB Vector Trigonometric ATan

ATAN

 

 real = ATAN(close)

Plot

Vector Trigonometric ATan

Working Example

 from cloudquant.interfaces import Strategy
from collections import OrderedDict
import ktgfunc
import talib

class WE_ATAN(Strategy):

    def on_start(self, md, order, service, account):
        # symbol and timestamp
        print(self.symbol + ":  " + service.time_to_string(service.system_time))
        daily_bars = md.bar.daily(start=-100)
        # normalize close prices for use with arctan
        close = daily_bars.close  / max(daily_bars.close) * 3
        real = talib.ATAN(close)

        # get the date values
        dates = service._context.market._storage.market_hours.keys()
        dateList = []
        for date in dates:
           dateList.append(str(date.strftime('%Y-%m-%d')))
        dates = sorted(dateList, reverse=True)[1:101]
        dates.sort()

        dict = OrderedDict()
        dict['date'] = dates
        dict['close'] = close
        dict['real'] = real
        symbol = 'ATAN: ' + self.symbol
        print ktgfunc.talib_table(symbol, 1, dict)

Console

MSFT:  2017-02-09 09:30:00.000000
ATAN: MSFT
Input Output
date close real
2016-09-16 2.59 1.20
2016-09-19 2.58 1.20
2016-09-20 2.57 1.20
2016-09-21 2.62 1.21
2016-09-22 2.62 1.21
2016-09-23 2.60 1.20
2016-09-26 2.58 1.20
2016-09-27 2.63 1.21
2016-09-28 2.63 1.21
2016-09-29 2.60 1.20
2016-09-30 2.61 1.20
2016-10-03 2.60 1.20
2016-10-04 2.59 1.20
2016-10-05 2.61 1.21
2016-10-06 2.62 1.21
2016-10-07 2.62 1.21
2016-10-10 2.63 1.21
2016-10-11 2.59 1.20
2016-10-12 2.59 1.20
2016-10-13 2.58 1.20
2016-10-14 2.60 1.20
2016-10-17 2.59 1.20
2016-10-18 2.61 1.21
2016-10-19 2.61 1.20
2016-10-20 2.59 1.20
2016-10-21 2.70 1.22
2016-10-24 2.76 1.22
2016-10-25 2.76 1.22
2016-10-26 2.75 1.22
2016-10-27 2.72 1.22
2016-10-28 2.71 1.22
2016-10-31 2.71 1.22
2016-11-01 2.71 1.22
2016-11-02 2.69 1.22
2016-11-03 2.68 1.21
2016-11-04 2.66 1.21
2016-11-07 2.74 1.22
2016-11-08 2.74 1.22
2016-11-09 2.73 1.22
2016-11-10 2.66 1.21
2016-11-11 2.67 1.21
2016-11-14 2.63 1.21
2016-11-15 2.68 1.21
2016-11-16 2.72 1.22
2016-11-17 2.77 1.22
2016-11-18 2.75 1.22
2016-11-21 2.78 1.22
2016-11-22 2.79 1.23
2016-11-23 2.75 1.22
2016-11-25 2.76 1.22
2016-11-28 2.76 1.22
2016-11-29 2.79 1.23
2016-11-30 2.75 1.22
2016-12-01 2.70 1.22
2016-12-02 2.70 1.22
2016-12-05 2.75 1.22
2016-12-06 2.73 1.22
2016-12-07 2.80 1.23
2016-12-08 2.78 1.23
2016-12-09 2.83 1.23
2016-12-12 2.84 1.23
2016-12-13 2.87 1.24
2016-12-14 2.86 1.23
2016-12-15 2.85 1.23
2016-12-16 2.84 1.23
2016-12-19 2.90 1.24
2016-12-20 2.90 1.24
2016-12-21 2.90 1.24
2016-12-22 2.90 1.24
2016-12-23 2.88 1.24
2016-12-27 2.89 1.24
2016-12-28 2.87 1.24
2016-12-29 2.87 1.24
2016-12-30 2.83 1.23
2017-01-03 2.85 1.23
2017-01-04 2.84 1.23
2017-01-05 2.84 1.23
2017-01-06 2.87 1.24
2017-01-09 2.86 1.23
2017-01-10 2.86 1.23
2017-01-11 2.88 1.24
2017-01-12 2.86 1.23
2017-01-13 2.86 1.23
2017-01-17 2.85 1.23
2017-01-18 2.85 1.23
2017-01-19 2.84 1.23
2017-01-20 2.86 1.23
2017-01-23 2.87 1.24
2017-01-24 2.90 1.24
2017-01-25 2.90 1.24
2017-01-26 2.93 1.24
2017-01-27 3.00 1.25
2017-01-30 2.97 1.25
2017-01-31 2.95 1.24
2017-02-01 2.90 1.24
2017-02-02 2.88 1.24
2017-02-03 2.90 1.24
2017-02-06 2.90 1.24
2017-02-07 2.89 1.24
2017-02-08 2.89 1.24