Exemplo n.º 1
0
        list2 = scrapeKlseRelated('scrapers/investingcom/klse.idmap')
        if len(list2):
            pypath = os.environ['PYTHONPATH'].split(os.pathsep)
            if any("klsemvp" in s for s in pypath):
                from analytics.mvp import mpvUpdateKlseRelated
                mpvUpdateKlseRelated()

        if S.USEMONGO:
            # do not perform upsert ops due to speed
            eodlist = list2 + list1
            dbUpdateLatest(eodlist)


if __name__ == '__main__':
    args = docopt(__doc__)
    cfg = loadCfg(S.DATA_DIR)
    '''
    preUpdateProcessing()
    print scrapeKlseRelated('scrapers/investingcom/klse.idmap', False)
    dbUpdateLatest()

    stocks = 'AASIA,ADVPKG,AEM,AIM,AMTEK,ASIABRN,ATLAN,ATURMJU,AVI,AYER,BCB,BHIC,BIG,BIPORT,BJFOOD,BJMEDIA,BLDPLNT,BOXPAK,BREM,BRIGHT,BTM,CAMRES,CEPCO,CFM,CHUAN,CICB,CNASIA,CYMAO,DEGEM,DIGISTA,DKLS,DOLMITE,EIG,EKSONS,EPMB,EUROSP,FACBIND,FCW,FSBM,GCE,GETS,GOCEAN,GOPENG,GPA,HCK,HHHCORP,HLT,ICAP,INNITY,IPMUDA,ITRONIC,JASKITA,JETSON,JIANKUN,KAMDAR,KANGER,KIALIM,KLCC,KLUANG,KOMARK,KOTRA,KPSCB,KYM,LBICAP,LEBTECH,LIONDIV,LIONFIB,LNGRES,MALPAC,MBG,MELATI,MENTIGA,MERGE,METROD,MGRC,MHCARE,MILUX,MISC,MSNIAGA,NICE,NPC,NSOP,OCB,OFI,OIB,OVERSEA,PENSONI,PESONA,PGLOBE,PJBUMI,PLB,PLS,PTGTIN,RAPID,REX,RSAWIT,SANBUMI,SAPIND,SBAGAN,SCIB,SEALINK,SEB,SERSOL,SHCHAN,SINOTOP,SJC,SMISCOR,SNC,SNTORIA,SRIDGE,STERPRO,STONE,SUNSURIA,SUNZEN,SYCAL,TAFI,TFP,TGL,THRIVEN,TSRCAP,UMS,UMSNGB,WEIDA,WOODLAN,XIANLNG,YFG,ZECON,ZELAN'
    stocks = 'D&O,E&O,F&N,L&G,M&G,P&O,Y&G'
    postUpdateProcessing()
    stocks = getCounters(args['COUNTER'], args['--klse'],
                         args['--portfolio'], args['--watchlist'], False)
    '''
    global klse, mt4date
    klse = "scrapers/i3investor/klse.txt"
    mt4date = args['--mt4']
    if args['--klse']:
Exemplo n.º 2
0
                ID_MAPPING[name.strip()] = int(var)
            if dbg:
                print dict(ID_MAPPING.items()[0:10])
        '''
    except EnvironmentError:
        print "Missing idmap.ini file"
        sys.exit(1)
    except KeyError:
        print "loadIdMap KeyError:", name
        sys.exit(2)
    return ID_MAPPING


if __name__ == '__main__':
    args = docopt(__doc__)
    cfg = loadCfg("../../data/")
    global DBG_ALL
    DBG_ALL = True if args['--debug'] else False
    # OUTPUT_FILE = sys.argv[1]
    idmap = loadIdMap(dbg=DBG_ALL)

    WRITE_CSV = True
    S.RESUME_FILE = True if args['--resume'] else False

    # scrapeKlseRelated('klse.idmap', False)
    '''
    stocks = 'ALAQAR,AMFIRST,ARREIT,ATRIUM,AXREIT,CAP,CLIQ,CLOUD,CSL,FOCUSP,GDB,GFM,GNB,HLCAP,ICAP,JMEDU,KINSTEL,MSPORTS,NPS,PARLO,PERDANA,PETONE,PINEAPP,QES,RALCO,SONA,TIMWELL,TWRREIT,WEGMANS,WINTONI,XINQUAN'
    '''
    stocks = ''
    klse = "../i3investor/klse.txt"
Exemplo n.º 3
0
    sbchartlinks = []
    SB_URL = 'https://my.stockbit.com/#/symbol/KLSE-'
    stocklist = formStocklist(counters, getI3Dir() + 'klse.txt')
    for key in stocklist.iterkeys():
        if i3:
            i3chartlinks.append(S.I3_KLSE_URL + '/servlets/stk/chart/' +
                                stocklist[key] + '.jsp')
        if sb:
            sbchartlinks.append(SB_URL + key + '/chartbit')

    return i3chartlinks, sbchartlinks


if __name__ == '__main__':
    args = docopt(__doc__)
    loadCfg(getDataDir(S.DATA_DIR))
    counters = getCounters(args['COUNTER'], args['--portfolio'],
                           args['--watchlist'])
    if args['--debug']:
        S.DBG_ALL = True
    if S.DBG_ALL:
        print getTime(), counters

    if len(counters) > 0:
        i3chartlinks, sbchartlinks = compileLinks(args['--i3'], args['--sb'],
                                                  counters)
        if S.DBG_ALL:
            print getTime(), i3chartlinks
            print getTime(), sbchartlinks
    else:
        LOGIN_URL = S.I3_KLSE_URL + LOGIN_URL
Exemplo n.º 4
0
        with cd(S.DATA_DIR):
            mongod = subprocess.Popen(
                ['mongod', '--dbpath',
                 os.path.expanduser(S.DATA_DIR)])


def initKlseDB():
    startMongoD()
    global mongo_client
    mongo_client = MongoClient()
    db = mongo_client.klsedb
    return db


def closeKlseDB():
    if mongo_client is not None:
        print 'Terminating Mongo Client ...'
        mongo_client.close()
    if mongod is not None:
        print 'Terminating MongoDB daemon ...'
        mongod.terminate()


if __name__ == '__main__':
    loadCfg(S.DATA_DIR)
    with cd(getDataDir(S.DATA_DIR)):
        exportCounters()
        exportQuotes()
    closeKlseDB()
    pass