Exemple #1
0
    def load(self, fn=None):
        # open and read the file to load these closure information
        infile = itrade_csv.read(
            fn, os.path.join(itrade_config.dirSysData, 'closed.txt'))
        if infile:
            # scan each line to read each quote
            for eachLine in infile:
                item = itrade_csv.parse(eachLine, 3)
                if item:
                    if len(item) > 2:
                        self.addClosed(item[0], item[1], item[2])
                    else:
                        info("can't import item=%s" % item)

        # open and read the file to load these SRD information
        infile = itrade_csv.read(
            fn, os.path.join(itrade_config.dirSysData, 'srd.txt'))
        if infile:
            # scan each line to read each quote
            for eachLine in infile:
                item = itrade_csv.parse(eachLine, 3)
                if item:
                    if len(item) > 2:
                        self.addSRD(item[0], item[1], item[2])
                    else:
                        info("can't import item=%s" % item)
Exemple #2
0
    def load(self, fn=None):
        if self.m_llang.has_key(self.m_lang):
            warning('lang %s already loaded !' % self.m_lang)
            return

        infile = itrade_csv.read(
            fn,
            os.path.join(itrade_config.dirSysData,
                         '%s.messages.txt' % self.m_lang))
        if infile:
            # store filename used for messaging
            if fn:
                self.m_llang[self.m_lang] = fn
            else:
                self.m_llang[self.m_lang] = os.path.join(
                    itrade_config.dirSysData, '%s.messages.txt' % self.m_lang)

            # scan each line to read each trade
            for eachLine in infile:
                item = itrade_csv.parse(eachLine, 2)
                if item:
                    self.addMsg(item)

            # info
            print 'Language Pack %s : %s' % (self.m_lang,
                                             self.m_llang[self.m_lang])
        else:
            print 'No Language Pack for %s !' % self.m_lang
    def load(self,fn):
        infile = itrade_csv.read(None,os.path.join(itrade_config.dirUserData,'%s.matrix.txt' % fn))
        if infile:
            # scan each line to read each quote
            for eachLine in infile:
                item = itrade_csv.parse(eachLine,1)
                if item:
                    if len(item)>4:
                        #print 'addKey:new fmt: %s : %s : %s : %s '% (item[0],item[2],item[3],item[5])
                        ref = None

                        # be sure the market is loaded
                        quotes.loadMarket(item[3])

                        if item[0]=='':
                            quote = quotes.lookupTicker(ticker=item[2],market=item[3],place=item[5])
                            if quote:
                                ref = quote.key()

                        if not ref:
                            ref = quote_reference(isin=item[0],ticker=item[2],market=item[3],place=item[5])

                        if not self.addKey(ref):
                            print 'load (new format): %s/%s : quote not found in quotes list ! (ref=%s)' % (item[0],item[2],ref)

                    elif len(item)<=4:
                        print 'old matrix format : not supported anymore'
    def load(self, fn):
        infile = itrade_csv.read(
            None, os.path.join(itrade_config.dirUserData,
                               '%s.matrix.txt' % fn))
        if infile:
            # scan each line to read each quote
            for eachLine in infile:
                item = itrade_csv.parse(eachLine, 1)
                if item:
                    if len(item) > 4:
                        #print 'addKey:new fmt: %s : %s : %s : %s '% (item[0],item[2],item[3],item[5])
                        ref = None

                        # be sure the market is loaded
                        quotes.loadMarket(item[3])

                        if item[0] == '':
                            quote = quotes.lookupTicker(ticker=item[2],
                                                        market=item[3],
                                                        place=item[5])
                            if quote:
                                ref = quote.key()

                        if not ref:
                            ref = quote_reference(isin=item[0],
                                                  ticker=item[2],
                                                  market=item[3],
                                                  place=item[5])

                        if not self.addKey(ref):
                            print 'load (new format): %s/%s : quote not found in quotes list ! (ref=%s)' % (
                                item[0], item[2], ref)

                    elif len(item) <= 4:
                        print 'old matrix format : not supported anymore'
Exemple #5
0
 def load(self,fn=None):
     # open and read the file to load these alerts information
     infile = itrade_csv.read(fn,os.path.join(itrade_config.dirUserData,'alerts.txt'))
     if infile:
         # scan each line to read each alert
         for eachLine in infile:
             item = itrade_csv.parse(eachLine,2)
             if item:
                 self.addAlert(item[1],int(item[0]))
 def load(self,fn=None):
     # open and read the file to load these alerts information
     infile = itrade_csv.read(fn, itrade_config.default_alerts_file())
     if infile:
         # scan each line to read each alert
         for eachLine in infile:
             item = itrade_csv.parse(eachLine,2)
             if item:
                 self.addAlert(item[1],int(item[0]))
Exemple #7
0
 def load(self, fn=None):
     # open and read the file to load these alerts information
     infile = itrade_csv.read(fn, itrade_config.default_alerts_file())
     if infile:
         # scan each line to read each alert
         for eachLine in infile:
             item = itrade_csv.parse(eachLine, 2)
             if item:
                 self.addAlert(item[1], int(item[0]))
Exemple #8
0
 def load(self,fn=None):
     # open and read the file to load these alerts information
     infile = itrade_csv.read(fn,os.path.join(itrade_config.dirUserData,'alerts.txt'))
     if infile:
         # scan each line to read each alert
         for eachLine in infile:
             item = itrade_csv.parse(eachLine,2)
             if item:
                 self.addAlert(item[1],int(item[0]))
 def load(self,fn=None):
     # open and read the file to load these currencies information
     infile = itrade_csv.read(fn,os.path.join(itrade_config.dirCacheData,'currencies.txt'))
     if infile:
         # scan each line to read each rate
         for eachLine in infile:
             item = itrade_csv.parse(eachLine,3)
             if item:
                 # logging.debug('%s ::: %s' % (eachLine,item))
                 self.update(item[0],item[1],float(item[2]))
Exemple #10
0
 def load(self,fn=None):
     # open and read the file to load these currencies information
     infile = itrade_csv.read(fn,os.path.join(itrade_config.dirCacheData,'currencies.txt'))
     if infile:
         # scan each line to read each rate
         for eachLine in infile:
             item = itrade_csv.parse(eachLine,3)
             if item:
                 # debug('%s ::: %s' % (eachLine,item))
                 self.update(item[0],item[1],float(item[2]))
 def load(self,infile=None):
     infile = itrade_csv.read(infile,os.path.join(itrade_config.dirCacheData,'%s.txt' % self.m_quote.key()))
     #print 'Trades:load::',infile
     if infile:
         # scan each line to read each trade
         #debug('Trades::load %s %s' % (self.m_quote.ticker(),self.m_quote.key()))
         for eachLine in infile:
             item = itrade_csv.parse(eachLine,7)
             if item:
                 if (item[0]==self.m_quote.key()) or (item[0]==self.m_quote.isin() and item[0]!=''):
                     #print item
                     self.add(item,bImporting=True);
Exemple #12
0
 def load(self,infile=None):
     infile = itrade_csv.read(infile,os.path.join(itrade_config.dirCacheData,'%s.txt' % self.m_quote.key()))
     #print 'Trades:load::',infile
     if infile:
         # scan each line to read each trade
         debug('Trades::load %s %s' % (self.m_quote.ticker(),self.m_quote.key()))
         for eachLine in infile:
             item = itrade_csv.parse(eachLine,7)
             if item:
                 if (item[0]==self.m_quote.key()) or (item[0]==self.m_quote.isin() and item[0]!=''):
                     #print item
                     debug('Trades::load %s on %s' % (item[5],item[1]))
                     self.add(item,bImporting=True)
Exemple #13
0
    def load(self,fn=None):
        # open and read the file to load these closure information
        infile = itrade_csv.read(fn,os.path.join(itrade_config.dirSysData,'closed.txt'))
        if infile:
            # scan each line to read each quote
            for eachLine in infile:
                item = itrade_csv.parse(eachLine,3)
                if item:
                    if len(item)>2:
                        self.addClosed(item[0],item[1],item[2])
                    else:
                        info("can't import item=%s" % item)

        # open and read the file to load these SRD information
        infile = itrade_csv.read(fn,os.path.join(itrade_config.dirSysData,'srd.txt'))
        if infile:
            # scan each line to read each quote
            for eachLine in infile:
                item = itrade_csv.parse(eachLine,3)
                if item:
                    if len(item)>2:
                        self.addSRD(item[0],item[1],item[2])
                    else:
                        info("can't import item=%s" % item)
    def load(self, fn=None):
        if self.m_lang in self.m_llang:
            logging.warning('lang %s already loaded !' % self.m_lang)
            return

        if fn is None:
            fn = os.path.join(itrade_config.dir_sys_data(), '%s.messages.txt'%self.m_lang)
        infile = itrade_csv.read(fn)
        if infile:
            # store filename used for messaging
            self.m_llang[self.m_lang] = fn

            # scan each line to read each trade
            for eachLine in infile:
                item = itrade_csv.parse(eachLine.decode("utf-8"),2)
                if item:
                    self.addMsg(item)

            # info
            print 'Language Pack %s : %s' % (self.m_lang,self.m_llang[self.m_lang])
        else:
            print 'No Language Pack for %s !' % self.m_lang
Exemple #15
0
    def load(self, fn=None):
        if self.m_lang in self.m_llang:
            logging.warning('lang %s already loaded !' % self.m_lang)
            return

        if fn is None:
            fn = os.path.join(itrade_config.dir_sys_data(),
                              '%s.messages.txt' % self.m_lang)
        infile = itrade_csv.read(fn)
        if infile:
            # store filename used for messaging
            self.m_llang[self.m_lang] = fn

            # scan each line to read each trade
            for eachLine in infile:
                item = itrade_csv.parse(eachLine.decode("utf-8"), 2)
                if item:
                    self.addMsg(item)

            # info
            print 'Language Pack %s : %s' % (self.m_lang,
                                             self.m_llang[self.m_lang])
        else:
            print 'No Language Pack for %s !' % self.m_lang
    # build the ticker using the suffix
    key = market + "." + place
    if yahoo_suffix.has_key(key):
        sticker = ticker + yahoo_suffix[key]
    else:
        sticker = ticker

    # check if we need to translate to something different !
    if yahoo_map_tickers.has_key(sticker):
        return yahoo_map_tickers[sticker]

    return sticker


infile = itrade_csv.read(None, os.path.join(itrade_config.dirSysData, "yahoo_tickers.txt"))
if infile:
    # scan each line to read each quote
    for eachLine in infile:
        item = itrade_csv.parse(eachLine, 2)
        if item:
            yahoo_map_tickers[item[0]] = item[1].strip().upper()


# ============================================================================
# euronext_place2mep
# ============================================================================

euronext_place = {"PAR": 1, "AMS": 2, "BRU": 3, "LIS": 5}

    # build the ticker using the suffix
    key = market + '.' + place
    if yahoo_suffix.has_key(key):
        sticker = ticker + yahoo_suffix[key]
    else:
        sticker = ticker

    # check if we need to translate to something different !
    if yahoo_map_tickers.has_key(sticker):
        return yahoo_map_tickers[sticker]

    return sticker


infile = itrade_csv.read(
    None, os.path.join(itrade_config.dirSysData, 'yahoo_tickers.txt'))
if infile:
    # scan each line to read each quote
    for eachLine in infile:
        item = itrade_csv.parse(eachLine, 2)
        if item:
            yahoo_map_tickers[item[0]] = item[1].strip().upper()

# ============================================================================
# yahooUrl
#
# some marketplaces seems to use various URL from Yahoo website :-(
# ============================================================================


def yahooUrl(market, live):