Exemplo n.º 1
0
def get_new_symbol_from_error_response(symbol):
    url = STOCK_SYMBOL_CODE_URL.format(symbol)
    response = requests.get(url)
    regex = re.compile('live_market\/dynaContent\/live_watch\/option_chain\/optionKeys.jsp\?symbolCode=[0-9]*&symbol=([a-zA-Z0-9]*)')
    match = regex.search(response._content)
    new_symbol =  match.groups()[0]
    return new_symbol
Exemplo n.º 2
0
def get_code_for_symbol(symbol):
    url = STOCK_SYMBOL_CODE_URL.format(symbol)
    response = requests.get(url)
    parse_result = urlparse.urlparse(response.url)
    query_dict = urlparse.parse_qs(parse_result.query)

    if 'symbolCode' in query_dict.keys():
        symbol = query_dict['symbol'][0]
        symbol_code = query_dict['symbolCode'][0]
        return symbol_code

    return None