Mariner Backtesting - TA-LIB Two Crows

CDL2CROWS

 

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

Candlestick Plot

Two Crows

Working Example

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

class WE_CDL2CROWS(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.CDL2CROWS(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 = 'CDL2CROWS: ' + self.symbol
        print ktgfunc.talib_table(symbol, 1, dict)

Console

NTES:  2016-07-18 09:30:00.000000
CDL2CROWS: NTES
Input Output
date open high low close integer
2016-02-24 154.40 158.99 150.64 158.47 0.00
2016-02-25 145.57 145.57 130.82 135.01 0.00
2016-02-26 136.51 141.32 134.11 134.17 0.00
2016-02-29 133.94 135.44 132.94 133.40 0.00
2016-03-01 134.87 138.88 133.80 137.53 0.00
2016-03-02 139.42 140.41 131.41 134.70 0.00
2016-03-03 133.71 139.95 133.65 138.80 0.00
2016-03-04 139.98 143.59 139.04 140.46 0.00
2016-03-07 140.37 141.94 138.38 140.35 0.00
2016-03-08 139.42 141.69 136.01 136.44 0.00
2016-03-09 138.75 139.99 135.70 139.86 0.00
2016-03-10 139.52 141.38 136.68 138.79 0.00
2016-03-11 141.38 144.17 140.37 143.49 0.00
2016-03-14 142.57 149.14 142.57 145.94 0.00
2016-03-15 144.26 147.00 143.68 145.64 0.00
2016-03-16 145.28 150.12 143.91 150.09 0.00
2016-03-17 150.34 154.77 150.27 151.25 0.00
2016-03-18 150.62 150.62 144.87 147.20 0.00
2016-03-21 147.04 149.34 146.36 148.04 0.00
2016-03-22 147.82 150.28 147.39 148.83 0.00
2016-03-23 148.00 148.72 143.51 145.12 0.00
2016-03-24 144.37 144.37 141.11 143.85 0.00
2016-03-28 143.75 143.92 139.04 139.39 0.00
2016-03-29 139.27 139.42 135.78 138.25 0.00
2016-03-30 139.25 142.67 138.89 142.01 0.00
2016-03-31 142.47 145.36 142.03 142.95 0.00
2016-04-01 141.70 142.71 139.74 142.40 0.00
2016-04-04 142.34 143.53 139.22 140.69 0.00
2016-04-05 139.65 141.56 138.49 140.68 0.00
2016-04-06 141.08 144.92 140.11 144.07 0.00
2016-04-07 143.61 145.39 141.98 144.23 0.00
2016-04-08 145.03 145.91 141.39 142.63 0.00
2016-04-11 144.13 144.79 138.08 138.30 0.00
2016-04-12 138.73 139.72 135.65 136.59 0.00
2016-04-13 139.39 142.66 138.51 142.12 0.00
2016-04-14 142.86 144.07 139.92 140.82 0.00
2016-04-15 141.14 141.21 137.13 137.68 0.00
2016-04-18 136.27 139.34 136.27 138.41 0.00
2016-04-19 139.48 139.48 134.79 137.18 0.00
2016-04-20 136.41 137.38 135.26 135.35 0.00
2016-04-21 137.03 137.34 132.63 135.55 0.00
2016-04-22 134.42 135.62 131.75 132.49 0.00
2016-04-25 132.42 132.60 130.25 132.50 0.00
2016-04-26 132.50 134.22 131.41 133.02 0.00
2016-04-27 132.33 134.19 131.51 132.56 0.00
2016-04-28 132.93 137.31 132.93 134.29 0.00
2016-04-29 134.08 140.12 134.08 140.09 0.00
2016-05-02 138.78 140.09 137.50 138.77 0.00
2016-05-03 137.41 138.30 135.85 137.10 0.00
2016-05-04 136.25 140.00 136.25 138.88 0.00
2016-05-05 139.43 141.88 138.98 139.87 0.00
2016-05-06 139.35 141.16 136.90 139.70 0.00
2016-05-09 138.89 140.22 137.49 138.35 0.00
2016-05-10 138.39 143.49 137.63 142.77 0.00
2016-05-11 142.93 147.55 141.20 144.54 0.00
2016-05-12 148.51 149.35 138.96 145.16 0.00
2016-05-13 146.09 153.65 145.92 152.73 0.00
2016-05-16 154.84 162.43 154.47 160.92 0.00
2016-05-17 160.76 165.95 159.71 162.78 0.00
2016-05-18 163.06 163.75 159.46 162.85 0.00
2016-05-19 162.10 163.75 158.24 160.53 0.00
2016-05-20 161.78 168.13 161.78 166.08 0.00
2016-05-23 166.01 167.66 163.96 164.20 0.00
2016-05-24 166.07 174.13 165.02 174.00 0.00
2016-05-25 176.06 176.06 171.01 173.00 0.00
2016-05-26 173.01 177.03 172.00 176.83 0.00
2016-05-27 177.49 177.87 173.30 175.79 0.00
2016-05-31 176.93 179.10 175.34 177.84 0.00
2016-06-01 176.01 177.32 172.61 176.16 0.00
2016-06-02 175.73 176.94 172.73 173.60 0.00
2016-06-03 173.91 177.53 173.60 175.56 0.00
2016-06-06 175.80 175.98 173.01 174.52 0.00
2016-06-07 173.77 177.29 172.49 174.81 0.00
2016-06-08 174.68 175.92 173.27 174.82 0.00
2016-06-09 173.51 174.62 169.46 171.48 0.00
2016-06-10 169.06 169.47 161.45 161.98 0.00
2016-06-13 161.00 166.15 161.00 163.21 0.00
2016-06-14 162.76 165.45 162.09 164.46 0.00
2016-06-15 164.78 165.34 162.94 164.30 0.00
2016-06-16 163.50 165.85 162.51 165.28 0.00
2016-06-17 164.21 165.75 161.32 163.11 0.00
2016-06-20 166.34 167.39 163.63 164.94 0.00
2016-06-21 165.41 167.24 164.73 165.77 0.00
2016-06-22 166.61 169.27 165.02 167.53 0.00
2016-06-23 169.60 172.99 167.82 172.91 0.00
2016-06-24 165.44 173.60 165.15 172.09 0.00
2016-06-27 170.49 171.00 165.45 166.66 0.00
2016-06-28 168.72 173.24 168.72 173.00 0.00
2016-06-29 175.00 183.89 172.45 181.48 0.00
2016-06-30 184.82 193.27 184.31 193.22 0.00
2016-07-01 193.25 193.44 183.80 184.57 0.00
2016-07-05 184.00 190.00 183.48 186.84 0.00
2016-07-06 185.78 188.48 185.33 186.12 0.00
2016-07-07 185.00 189.41 185.00 188.44 0.00
2016-07-08 189.16 189.63 182.86 185.13 0.00
2016-07-11 189.16 198.20 188.03 196.62 0.00
2016-07-12 199.62 202.70 195.36 197.33 0.00
2016-07-13 197.66 197.88 193.00 193.63 -100.00
2016-07-14 195.16 197.28 193.51 195.50 0.00
2016-07-15 195.91 199.78 194.25 195.21 0.00