Exemplo n.º 1
0
def get_pe_history(index, start, end, proxies = {}):
    if (end - start) > datetime.timedelta(100 + 19*2):
        end_1 = start + datetime.timedelta(100 + 19*2) 
        start_2 = end_1 + datetime.timedelta(1)
        arg1 = {'index':index, 'start': start, 'end': end_1,
                'proxies': proxies}
        arg2 = {'index':index, 'start': start_2, 'end': end,
                'proxies': proxies}
                
        t1 = ThreadReturns(target = get_pe_history, 
                              kwargs = arg1)
        
        t2 = ThreadReturns(target = get_pe_history, 
                              kwargs = arg2)
        t1.start()
        t2.start()
        t1.join()
        t2.join()
        
        return pd.concat([t1.result, t2.result])
        
    else:
        return _get_pe_history_small(index = index, start = start,
                                        end = end, proxies = proxies)
Exemplo n.º 2
0
def get_pe_history(index, start, end, proxies = {}):
    if (end - start) > datetime.timedelta(100 + 19*2):
        end_1 = start + datetime.timedelta(100 + 19*2) 
        start_2 = end_1 + datetime.timedelta(1)
        arg1 = {'index':index, 'start': start, 'end': end_1,
                'proxies': proxies}
        arg2 = {'index':index, 'start': start_2, 'end': end,
                'proxies': proxies}
                
        t1 = ThreadReturns(target = get_pe_history, 
                              kwargs = arg1)
        
        t2 = ThreadReturns(target = get_pe_history, 
                              kwargs = arg2)
        t1.start()
        t2.start()
        t1.join()
        t2.join()
        
        return pd.concat([t1.result, t2.result])
        
    else:
        return _get_pe_history_small(index = index, start = start,
                                        end = end, proxies = proxies)
Exemplo n.º 3
0
    proxies = {'http': 'proxy1.wipro.com:8080'}

    s = time.clock()
    kwarg1 = {
        'index': 'CNX Nifty',
        'start': date(2015, 9, 1),
        'end': date(2015, 9, 24),
        'proxies': proxies
    }
    kwarg2 = {
        'stock': 'WIPRO',
        'start': date(2015, 9, 1),
        'end': date(2015, 9, 24),
        'proxies': proxies
    }
    t1 = ThreadReturns(target=indices.archives.get_price_history,
                       kwargs=kwarg1)
    t2 = ThreadReturns(target=get_price_history, kwargs=kwarg2)
    t3 = ThreadReturns(target=indices.archives.get_pe_history, kwargs=kwarg1)
    t1.start()
    t2.start()
    t3.start()
    t1.join()
    t2.join()
    t3.join()
    e = time.clock()
    print(e - s)
    ind = indices.archives.get_price_history(**kwarg1)
    #lt = get_price_history(**kwarg2)

    ind = t1.result
    lt = t2.result
Exemplo n.º 4
0
import numpy as np
import matplotlib as plt
from bs4 import BeautifulSoup


from matplotlib.pyplot import subplots, draw
from matplotlib.finance import candlestick


if __name__ == "__main__":
    proxies = {"http": "proxy1.wipro.com:8080"}

    s = time.clock()
    kwarg1 = {"index": "CNX Nifty", "start": date(2015, 9, 1), "end": date(2015, 9, 24), "proxies": proxies}
    kwarg2 = {"stock": "WIPRO", "start": date(2015, 9, 1), "end": date(2015, 9, 24), "proxies": proxies}
    t1 = ThreadReturns(target=indices.archives.get_price_history, kwargs=kwarg1)
    t2 = ThreadReturns(target=get_price_history, kwargs=kwarg2)
    t3 = ThreadReturns(target=indices.archives.get_pe_history, kwargs=kwarg1)
    t1.start()
    t2.start()
    t3.start()
    t1.join()
    t2.join()
    t3.join()
    e = time.clock()
    print(e - s)
    # ind = indices.archives.get_price_history(**kwarg1)
    # lt = get_price_history(**kwarg2)

    ind = t1.result
    lt = t2.result