Mariner Backtesting - TA-LIB Unique 3 River

CDLUNIQUE3RIVER(open, high, low, close)

CDLUNIQUE3RIVER

 integer = CDLUNIQUE3RIVER(open, high, low, close)
  • 0 = No Signal
  • -100 = Bearish Signal
  • 100 = Bullish Signal

Candlestick Plot

Unique 3 River

 

Working Example

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

class WE_CDLUNIQUE3RIVER(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)
        close = daily_bars.close
        high = daily_bars.high
        low = daily_bars.low
        open = daily_bars.open
        integer = talib.CDLUNIQUE3RIVER(open, high, low, 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['open'] = open
        dict['high'] = high
        dict['low'] = low
        dict['close'] = close
        dict['integer'] = integer
        symbol = 'CDLUNIQUE3RIVER: ' + self.symbol
        print ktgfunc.talib_table(symbol, 1, dict)

Console

GOOG:  2015-05-07 09:30:00.000000
CDLUNIQUE3RIVER: GOOG
Input Output
date open high low close integer
2014-12-11 527.80 533.92 527.10 528.34 0.00
2014-12-12 523.51 528.50 518.66 518.66 0.00
2014-12-15 522.74 523.10 513.27 513.80 0.00
2014-12-16 511.56 513.05 489.00 495.39 0.00
2014-12-17 497.00 507.00 496.81 504.89 0.00
2014-12-18 512.95 513.87 504.70 511.10 0.00
2014-12-19 511.51 517.72 506.91 516.35 0.00
2014-12-22 516.08 526.46 516.08 524.87 0.00
2014-12-23 527.00 534.56 526.29 530.59 0.00
2014-12-24 530.51 531.76 527.02 528.77 0.00
2014-12-26 528.77 534.25 527.31 534.03 0.00
2014-12-29 532.19 535.48 530.01 530.33 0.00
2014-12-30 528.09 531.15 527.13 530.42 0.00
2014-12-31 531.25 532.60 525.80 526.40 0.00
2015-01-02 529.01 531.27 524.10 524.81 0.00
2015-01-05 523.26 524.33 513.06 513.87 0.00
2015-01-06 515.00 516.17 501.05 501.96 0.00
2015-01-07 507.00 507.24 499.65 501.10 0.00
2015-01-08 497.99 503.48 491.00 502.68 0.00
2015-01-09 506.00 506.00 494.79 496.17 0.00
2015-01-12 494.94 495.98 487.56 492.55 0.00
2015-01-13 498.84 502.98 492.39 496.18 0.00
2015-01-14 494.65 503.23 493.00 500.87 0.00
2015-01-15 505.57 505.68 497.76 501.79 0.00
2015-01-16 500.01 508.19 500.00 508.08 0.00
2015-01-20 511.00 512.50 506.02 506.90 0.00
2015-01-21 507.25 519.28 506.20 518.04 0.00
2015-01-22 518.04 536.33 518.04 534.39 0.00
2015-01-23 535.59 542.17 533.00 539.95 0.00
2015-01-26 538.53 539.00 529.66 535.21 0.00
2015-01-27 529.25 530.71 518.19 518.63 0.00
2015-01-28 522.78 523.00 509.86 510.00 0.00
2015-01-29 511.00 511.09 501.20 510.66 0.00
2015-01-30 515.86 539.87 515.52 534.52 0.00
2015-02-02 531.73 533.00 518.55 528.48 0.00
2015-02-03 528.00 533.40 523.25 529.24 0.00
2015-02-04 529.24 532.67 521.23 522.76 0.00
2015-02-05 523.79 528.50 522.07 527.58 0.00
2015-02-06 528.30 537.21 526.41 531.00 0.00
2015-02-09 528.00 532.00 526.01 527.83 0.00
2015-02-10 529.30 537.70 526.92 536.94 0.00
2015-02-11 535.30 538.45 533.34 535.97 0.00
2015-02-12 537.10 544.84 534.67 542.93 0.00
2015-02-13 543.88 549.91 543.13 549.01 0.00
2015-02-17 546.83 550.00 541.09 542.84 0.00
2015-02-18 542.10 545.50 537.50 539.70 0.00
2015-02-19 538.04 543.11 538.01 542.87 0.00
2015-02-20 543.13 544.00 535.80 538.95 0.00
2015-02-23 536.05 536.44 529.41 531.91 0.00
2015-02-24 530.00 536.79 528.25 536.09 0.00
2015-02-25 535.90 546.22 535.45 543.87 0.00
2015-02-26 543.21 556.14 541.50 555.48 0.00
2015-02-27 554.24 564.71 552.90 558.40 0.00
2015-03-02 558.50 572.15 558.50 571.34 0.00
2015-03-03 570.45 575.39 566.52 573.64 0.00
2015-03-04 571.87 577.11 568.01 573.37 0.00
2015-03-05 575.02 577.91 573.41 575.33 0.00
2015-03-06 574.88 576.68 566.76 567.68 0.00
2015-03-09 566.86 570.27 563.53 568.85 0.00
2015-03-10 564.25 564.85 554.73 555.01 0.00
2015-03-11 555.14 558.14 550.68 551.18 0.00
2015-03-12 553.51 556.37 550.46 555.51 0.00
2015-03-13 553.50 558.40 544.22 547.32 0.00
2015-03-16 550.95 556.85 546.00 554.51 0.00
2015-03-17 551.71 553.80 548.00 550.84 0.00
2015-03-18 552.50 559.78 547.00 559.50 0.00
2015-03-19 559.39 560.80 556.15 557.99 0.00
2015-03-20 561.65 561.72 559.05 560.36 0.00
2015-03-23 560.43 562.36 555.83 558.81 0.00
2015-03-24 555.00 574.59 555.00 570.19 0.00
2015-03-25 570.50 572.26 558.74 558.78 0.00
2015-03-26 557.59 558.90 550.65 555.17 0.00
2015-03-27 553.00 555.28 548.13 548.34 0.00
2015-03-30 551.62 553.47 548.17 552.03 0.00
2015-03-31 550.00 554.71 546.72 548.00 0.00
2015-04-01 548.60 551.14 539.50 542.56 0.00
2015-04-02 540.85 540.85 533.85 535.53 0.00
2015-04-06 532.22 538.41 529.57 536.77 0.00
2015-04-07 538.08 542.69 536.00 537.02 0.00
2015-04-08 538.38 543.85 538.38 541.61 0.00
2015-04-09 541.03 541.95 535.49 540.78 0.00
2015-04-10 542.29 542.29 537.31 540.01 0.00
2015-04-13 538.41 544.06 537.31 539.17 0.00
2015-04-14 536.25 537.57 528.09 530.39 0.00
2015-04-15 528.70 534.73 523.22 532.53 0.00
2015-04-16 529.90 535.59 529.61 533.80 0.00
2015-04-17 528.66 529.84 521.01 524.05 0.00
2015-04-20 525.60 536.09 524.50 535.38 0.00
2015-04-21 535.00 539.39 533.67 533.97 0.00
2015-04-22 534.40 541.08 531.75 539.36 0.00
2015-04-23 541.00 550.96 540.23 547.00 0.00
2015-04-24 566.10 571.14 557.25 565.06 0.00
2015-04-27 563.39 565.95 553.20 555.37 0.00
2015-04-28 554.64 556.02 550.37 553.68 0.00
2015-04-29 550.47 553.68 546.91 549.08 0.00
2015-04-30 547.87 548.59 535.05 537.34 0.00
2015-05-01 538.43 539.54 532.10 537.90 0.00
2015-05-04 538.53 544.07 535.06 540.78 100.00
2015-05-05 538.21 539.74 530.39 530.80 0.00
2015-05-06 531.24 532.38 521.09 524.22 0.00