Esempio n. 1
0
def get_history_day(local_symbol, day):
    """Download historical prices for the specified symbol.

    Keyword arguments:
    local_symbol -- ticker symbol
    day          -- day in 'yyyy-mm-dd' form

    """

    start_ms, end_ms = _ms_bounds(local_symbol, day)
    start_time = ds.ms_to_str(start_ms, TIMEZONE, '%Y-%m-%d %H:%M')
    end_time = ds.ms_to_str(end_ms + 1000, TIMEZONE, '%Y-%m-%d %H:%M')
    yield from get_history(local_symbol, start_time, end_time)
Esempio n. 2
0
def create_request(contract, bar_time, bar_count):
    """Return a dictionary containing parameters for a single historical data
    request.

    Keyword arguments:
    contract  -- contract
    bar_time  -- ending time
    bar_count -- number of bars to request

    """
    result = {}
    result['delay'] = config.WAIT_SECONDS
    result['contract'] = contract
    end_date_time = ds.ms_to_str(bar_time, 'UTC', '%Y%m%d %H:%M:%S UTC')
    result['end_date_time'] = end_date_time
    result['duration_str'] = '{0:d} S'.format(int(bar_count *
                                                  config.BAR_SIZE_SECONDS))
    result['bar_size_setting'] = config.BAR_SIZE
    sec_type = contract.sec_type.upper()
    result['what_to_show'] = config.WHAT_TO_SHOW[sec_type]
    result['use_rth'] = config.USE_RTH
    result['format_date'] = config.FORMAT_DATE
    return result