Exemplo n.º 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)
Exemplo n.º 2
0
def print_buckets_(buckets, complete):
    samplesizes = get_sample_sizes(buckets, complete)
    len_buckets = 0
    for key in buckets.keys():
        entry = buckets[key]
        if isinstance(entry, tuple):
            if complete:
                entry, _ = entry
            else:
                _, entry = entry
        elif complete:
            continue

        if not entry:
            continue

        len_buckets += len(entry)
        print("****  fib: {key} ****".format(key=key))
        f.print_complete_summary(entry, [f.Summaries.DAYOFWEEK], samplesizes)
        for item in entry:
            print("---- {}".format(item))
        print()

    return len_buckets
Exemplo n.º 3
0
    lows.append(low_t)
    return highs, lows


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)

    periods = [
        # (f.first_fun_hour, f.Summaries.HOURS, "which hour of day?"),
        (f.first_fun_day, f.Summaries.DAY, "which day of month?"),
        (f.first_fun_weekday, f.Summaries.DAYOFWEEK, "which day of week?"),
        (f.first_fun_month, f.Summaries.MONTHS, "which month of year?")
    ]

    for period in periods:
        f_, p_, t_ = period
        highs_, lows_ = process(data, f_)

        print("HIGHS - {}".format(t_))
        f.print_complete_summary(highs_, [p_])
        # print(highs_)

        print("LOWS - {}".format(t_))
        f.print_complete_summary(lows_, [p_])
        # print(lows_)
Exemplo n.º 4
0
    buckets, closed, total = gap(data_d)

    samples_dow = {}
    samples_mth = {}

    for key in buckets.keys():
        entry = buckets[key]
        for item in entry:
            dayofweek = f.dayofweek(item)
            samples_dow[dayofweek] = samples_dow.get(dayofweek, 0) + 1

            month = calendar.month_name[item.month]
            samples_mth[month] = samples_mth.get(month, 0) + 1

    keys = sorted([int(k) for k in buckets.keys()])
    for key_ in keys:
        key = str(key_)
        entry = buckets[key]
        days_ = int(math.pow(2, float(key) + 1))
        closed_ = len(entry)
        pc_ = closed_ * 100.0 / total

        print("Closed within {days} days: {closed}/{total} {pc:.2f}%".format(closed=closed_, total=total, days=days_, pc=pc_))
        print("-------------------------------------")
        f.print_complete_summary(entry, [f.Summaries.DAYOFWEEK], samples_dow)
        f.print_complete_summary(entry, [f.Summaries.MONTHS], samples_mth)

    pc = closed * 100.0 / total
    print("Gaps closed: {closed}/{total}, {pc:.2f}%".format(
        closed=closed, total=total, pc=pc))