def requires(self):
        # Dec 1 EST
        d = (496967, 497148)
        # Dec 1, 12 am - 1 am EST
        d_hr = (496967, 496972)
        yield MakeNetwork(start_height=d_hr[0], end_height=d_hr[1])

        block, start, stop = get_blocks()
        start_time = get_next_time(get_tx_time(start), 18, 0, after=True)
        stop_time = get_next_time(get_tx_time(stop), 18, 0, after=False)
        # start_time, stop_time = 1505175181, 1510009531
        for ml, p in itertools.product(
            [
                'lasso',
                'elasticnet',
                # 'svr-linear',
                # 'svr-rbf',
                'ridge'
            ],
            ['future', 'current', 'volume']):
            yield LearnPredictPrice(start_time=start_time,
                                    end_time=stop_time,
                                    interval_size=HOURS_24,
                                    ml_technique=ml,
                                    problem=p)
Beispiel #2
0
def _decypher(cyphertext, key):
    letters = string.ascii_uppercase
    shifts = [letters.index(letter) for letter in key]
    blocks = processing.get_blocks(text=cyphertext,size=len(key))
    cols = processing.get_columns(blocks)
    decyphered_blocks = processing.to_blocks([fa.shift(col, shift) for col, shift in zip(cols, shifts)])
    decyphered = ''.join(decyphered_blocks)
    return decyphered
Beispiel #3
0
def restore_key(cyphertext, key_len):
    key = ''
    blocks = processing.get_blocks(text=cyphertext, size=key_len)
    columns = processing.get_columns(blocks)
    frequencies = _get_letter_frequencies(text=cyphertext)
    for column in columns:
        key += _find_key_letter(text=column, lf=frequencies)
    return key
Beispiel #4
0
def find_key_length(cyphertext, max_key_len):
    min_diff = maxsize
    key_len = 0
    for candidate_length in range(1, max_key_len + 1):
        groups = processing.get_blocks(text=cyphertext, size=candidate_length)
        columns = processing.get_columns(groups)
        ics = [_ic(letter_counts=fa.get_letter_counts(text=column)) for column in columns]
        delta_bar_ic = sum(ics) / len(ics)
        if EN_IC-delta_bar_ic < min_diff:
            min_diff = EN_IC-delta_bar_ic
            key_len = candidate_length
        print('KEY_LENGTH: ' + str(candidate_length) + '\n')
        print('IC by column: '+str(ics))
        print('delta bar IC: '+str(delta_bar_ic)+'\n')
    return key_len