Ejemplo n.º 1
0
    """
    
    if market == 'stockOption':
        m = 'DTOP_O_'
    elif market == 'indexFuture':
        m = 'DTOP_F_'
    
    dateList = []
    # get file list from directory
    for f in os.listdir(folder):
        if m in f:
            # crop the date from filename
            row = f.replace(m,'').replace('.zip','')
            dateList.append(date(int(row[:4]), int(row[4:6]), int(row[6:])))

            
    latest = dateList[0]
    for x in range(1,len(dateList)):
        if dateList[x] > latest:
            latest = dateList[x]
    
    return latest

folder = './storage'
today = date.today()

downloader = Hkex()
downloader.fetchDtop('stockOption', getLatestDate('stockOption',folder), today)
downloader.fetchDtop('indexFuture', getLatestDate('indexFuture',folder), today)

Ejemplo n.º 2
0
#!/usr/bin/python
"""cli.py: command line version to test the script"""

from hkex import Hkex

sector = raw_input('Dwnload index(index) or stock option(stock) or "all"?')
start = raw_input('Start date (dd-mm-yyyy):')
end = raw_input('End date (dd-mm-yyyy):')

downloader = Hkex()

if sector == 'index':
    data = downloader.fetchDtop('indexFuture', start, end)
elif sector == 'stock':
    data = downloader.fetchDtop('stockOption', start, end)
elif sector == 'all':
    data = downloader.fetchDtop('all', start, end)