Пример #1
0
def print_yr_summary(datafile):
    data = f.filter_thisyr(
        f.load_candles(datafile))

    samplesizes = f.get_sample_sizes(
        f.get_interday_summary(data, f.classify_month))

    bearbull = f.get_bearbull_summary(data)

    for bb in f.BEARBULL_KEYS:
        print("**** {key} ****".format(key=bb))
        f.print_complete_summary(bearbull.get(bb, []), [f.Summaries.MONTHS], samplesizes)
Пример #2
0

if __name__ == '__main__':
    logging.basicConfig(filename="/tmp/retracement.log",
                        filemode='w',
                        format='%(asctime)s,%(msecs)d %(name)s %(levelname)s' +
                        '%(message)s line:%(lineno)d',
                        datefmt='%H:%M:%S',
                        level=logging.DEBUG)

    # years = [2016, 2017, 2018]
    years = [2018]

    # ltf data
    datafile_ltf = sys.argv[1]
    data_ltf = f.filter(f.load_candles(datafile_ltf), f.filter_year, years)

    # day data
    datafile_d = sys.argv[2]
    data_d = weekday(f.filter(f.load_candles(datafile_d), f.filter_year,
                              years))

    # profile bearish days
    beardates = dates(f.filter(data_d, f.filter_bearish, True))  # , False)
    bearbuckets = retracement(f.BearBull.BEARISH, data_ltf, beardates)
    print_buckets(bearbuckets)

    # profile bullish days
    bulldates = dates(f.filter(data_d, f.filter_bullish, True))  # , False)
    bullbuckets = retracement(f.BearBull.BULLISH, data_ltf, bulldates)
    print_buckets(bullbuckets)
Пример #3
0
            item1 = item
            continue

        delta = abs(item1.close - item.close)
        day = item.time.weekday()

        print(item.high, item.low)

        price, cnt = buckets.get(day, (0., 0))
        price += delta
        cnt += 1
        buckets[day] = (price, cnt)

    for day in buckets:
        price, cnt = buckets[day]
        ave = price / cnt
        buckets[day] = (price, cnt, ave)

    return buckets


if __name__ == '__main__':
    # years = [2013, 2014, 2015, 2016, 2017, 2018]
    years = [2018]

    # data
    datafile = sys.argv[1]
    data = f.filter(f.load_candles(datafile), f.filter_year, years)

    print(process(data))
Пример #4
0
                self.wick_item = item
            elif self.wick_high and high < self.wick_high - DELTA or self.wick_low and low + DELTA:
                self.store_result(success)
                wick_success += 1

        return (wick_success, success), (wick_fails, fails)


if __name__ == '__main__':
    logging.basicConfig(
        filename="/tmp/rangebreaks.log",
        filemode='w',
        format='%(asctime)s,%(msecs)d %(name)s %(levelname)s' +
               '%(message)s line:%(lineno)d',
        datefmt='%H:%M:%S',
        level=logging.DEBUG)

    # years = [2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018]
    years = [2018]

    # day data
    datafile = sys.argv[1]
    data = f.filter(
        f.load_candles(datafile),
        f.filter_year,
        years)

    (wick_success, success), (wick_fails, fails) = Wicks().process(data)
    print(wick_success)
    print(wick_fails)
Пример #5
0
            low_ = None
        data_idx += 1

    return within, total


if __name__ == '__main__':
    logging.basicConfig(
        filename="/tmp/rangebreaks.log",
        filemode='w',
        format='%(asctime)s,%(msecs)d %(name)s %(levelname)s' +
               '%(message)s line:%(lineno)d',
        datefmt='%H:%M:%S',
        level=logging.DEBUG)

    years = [2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018]
    # years = [2018]

    # day data
    datafile_d = sys.argv[1]
    data_d = f.filter(
        f.load_candles(datafile_d),
        f.filter_year,
        years)

    within, total = rangebreaks(data_d)

    pc = within * 100.0 / total
    print("Ranges maintained: {within}/{total}, {pc:.2f}%".format(
        within=within, total=total, pc=pc))
Пример #6
0
            elif trend_m == f.BearBull.BULLISH and item.low < bull_low:
                low = bull_low = item.low

        elif trend_m == f.BearBull.BEARISH and item.high > high:
            high = item.high
        elif trend_m == f.BearBull.BULLISH and item.low < low:
            low = item.low

        if dayofweek == 'Friday':
            close = item.close

    bear_pc = (bear_high_cnt * 100.) / bear_cnt if bear_cnt else 100
    bear_result = "BEARISH WEEKS: M-T/ HIGH: {num}/{tot} {pc:.2f}%".format(
        num=bear_high_cnt, tot=bear_cnt, pc=bear_pc)
    print(bear_result)

    bull_pc = (bull_low_cnt * 100.) / bull_cnt if bull_cnt else 100
    bull_result = "BULLISH WEEKS: M-T/ LOW: {num}/{tot} {pc:.2f}%".format(
        num=bull_low_cnt, tot=bull_cnt, pc=bull_pc)
    print(bull_result)


if __name__ == '__main__':
    data = f.filter(
        f.load_candles(sys.argv[1]),
        f.filter_year,
        #[2013, 2014, 2015, 2016, 2017, 2018])
        [2018])
    week_highlow(data, False)
Пример #7
0
                    period=period, pair=pair),
                filemode='w',
                format='%(asctime)s,%(msecs)d %(name)s %(levelname)s' +
                       '%(message)s line:%(lineno)d',
                datefmt='%H:%M:%S',
                level=logging.DEBUG)

            # years = [2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018]
            #
            # years = [2018]

            years = [2013, 2014, 2015, 2016, 2017, 2018]

            # data
            data = f.filter(
                f.load_candles(datafile_p),
                f.filter_year,
                years)

            # # day data
            # if period == '1_D':
            #     data_d = data
            # else:
            #     data_d = f.filter(
            #         f.load_candles(datafile_d),
            #         f.filter_year,
            #         years)
            #     emas, emal = Touches.ema(data_d)
            emas = emal = None

            winners_max = 0