コード例 #1
0
    def OnValid(self,event):
        if self.Validate() and self.TransferDataFromWindow():
            # get fields
            self.m_isin = self.editISIN.GetValue()
            self.m_name = self.editName.GetValue()
            self.m_ticker = self.editTicker.GetValue()
            self.m_market = self.editMarket.GetValue()
            self.m_country = self.dispCountry.GetValue()
            self.m_currency = self.editCurrency.GetValue()
            self.m_place = self.editPlace.GetValue()

            # check isin ?
            if self.qmode == QLIST_ADD:
                # check validity
                if self.m_isin!='':
                    if not checkISIN(self.m_isin):
                        #__xdlg = wx.MessageDialog(self, message('invalid_isin') % self.m_isin, self.tt, wx.OK | wx.ICON_ERROR)
                        #__xidRet = dlg.ShowModal()
                        #__xdlg.Destroy()
                        iTradeError(self, message('invalid_isin') % self.m_isin, self.tt)
                        self.editISIN.SetFocus()
                        return

                # check uniqueness
                ref = quote_reference(self.m_isin,self.m_ticker,self.m_market,self.m_place)
                if quotes.lookupKey(ref):
                    #__xdlg = wx.MessageDialog(self, message('listquote_duplicate_ref') % ref, self.tt, wx.OK | wx.ICON_ERROR)
                    #__xidRet = dlg.ShowModal()
                    #__xdlg.Destroy()
                    iTradeError(self, message('listquote_duplicate_ref') % ref, self.tt)
                    return

            # isin,name,ticker,market,currency,place,country
            self.aRet = (self.m_isin,self.m_name,self.m_ticker,self.m_market,self.m_currency,self.m_place,self.m_country)
            self.EndModal(wx.ID_OK)
コード例 #2
0
    def OnValid(self, event):
        if self.Validate() and self.TransferDataFromWindow():
            # get fields
            self.m_isin = self.editISIN.GetLabel()
            self.m_name = self.editName.GetLabel()
            self.m_ticker = self.editTicker.GetLabel()
            self.m_market = self.editMarket.GetLabel()
            self.m_country = self.dispCountry.GetLabel()
            self.m_currency = self.editCurrency.GetLabel()
            self.m_place = self.editPlace.GetLabel()

            # check isin ?
            if self.qmode == QLIST_ADD:
                # check validity
                if self.m_isin != '':
                    if not checkISIN(self.m_isin):
                        #__xdlg = wx.MessageDialog(self, message('invalid_isin') % self.m_isin, self.tt, wx.OK | wx.ICON_ERROR)
                        #__xidRet = dlg.ShowModal()
                        #__xdlg.Destroy()
                        iTradeError(self,
                                    message('invalid_isin') % self.m_isin,
                                    self.tt)
                        self.editISIN.SetFocus()
                        return

                # check uniqueness
                ref = quote_reference(self.m_isin, self.m_ticker,
                                      self.m_market, self.m_place)
                if quotes.lookupKey(ref):
                    #__xdlg = wx.MessageDialog(self, message('listquote_duplicate_ref') % ref, self.tt, wx.OK | wx.ICON_ERROR)
                    #__xidRet = dlg.ShowModal()
                    #__xdlg.Destroy()
                    iTradeError(self,
                                message('listquote_duplicate_ref') % ref,
                                self.tt)
                    return

            # isin,name,ticker,market,currency,place,country
            self.aRet = (self.m_isin, self.m_name, self.m_ticker,
                         self.m_market, self.m_currency, self.m_place,
                         self.m_country)
            self.EndModal(wx.ID_OK)
コード例 #3
0
def Import_ListOfQuotes_Euronext(quotes,market='EURONEXT',dlg=None,x=0):
    print 'Update %s list of symbols' % market
    connection = ITradeConnection(cookies = None,
                               proxy = itrade_config.proxyHostname,
                               proxyAuth = itrade_config.proxyAuthentication,
                               connectionTimeout = max(45,itrade_config.connectionTimeout)
                               )

    cha = "7213"

    if market=='EURONEXT':
        url = "http://www.euronext.com/search/download/trapridownloadpopup.jcsv?pricesearchresults=actif&filter=1&lan=EN&belongsToList=market_EURLS&cha=%s&format=txt&formatDecimal=.&formatDate=dd/MM/yy" % cha
    elif market=='ALTERNEXT':
        url = "http://www.euronext.com/search/download/trapridownloadpopup.jcsv?pricesearchresults=actif&filter=1&lan=EN&belongsToList=market_ALTX&cha=%s&format=txt&formatDecimal=.&formatDate=dd/MM/yy" % cha
    elif market=='PARIS MARCHE LIBRE':
        url = "http://www.euronext.com/search/download/trapridownloadpopup.jcsv?pricesearchresults=actif&filter=1&lan=EN&belongsToList=market_MC&cha=%s&format=txt&formatDecimal=.&formatDate=dd/MM/yy" % cha
    elif market=='BRUXELLES MARCHE LIBRE':
        url = "http://www.euronext.com/search/download/trapridownloadpopup.jcsv?pricesearchresults=actif&filter=1&lan=EN&belongsToList=market_BRUMC&cha=%s&format=txt&formatDecimal=.&formatDate=dd/MM/yy" % cha
    else:
        return False

    def splitLines(buf):
        lines = string.split(buf, '\n')
        lines = filter(lambda x:x, lines)
        def removeCarriage(s):
            if s[-1]=='\r':
                return s[:-1]
            else:
                return s
        lines = [removeCarriage(l) for l in lines]
        return lines

    try:
        data=connection.getDataFromUrl(url)
    except:
        debug('Import_ListOfQuotes_Euronext:unable to connect :-(')
        return False

    indice = {}
    """
    "Instrument's name";
    "ISIN";
    "Euronext code";
    "MEP";
    "Symbol";
    "ICB Sector (Level 4)";
    "Trading currency";
    "Last";
    "Volume";
    "D/D-1 (%)";
    "Date - time (CET)";
    "Turnover";
    "Total number of shares";
    "Capitalisation";
    "Trading mode";
    "Day First";
    "Day High";
    "Day High / Date - time (CET)";
    "Day Low";
    "Day Low / Date - time (CET)";
    "31-12/Change (%)";
    "31-12/High";
    "31-12/High/Date";
    "31-12/Low";
    "31-12/Low/Date";
    "52 weeks/Change (%)";
    "52 weeks/High";
    "52 weeks/High/Date";
    "52 weeks/Low";
    "52 weeks/Low/Date";
    "Suspended";
    "Suspended / Date - time (CET)";
    "Reserved";
    "Reserved / Date - time (CET)"
    """

    # returns the data
    lines = splitLines(data)
    count = 0

    for line in lines:
        data = string.split (line, ';')

        if len(data)>2:
            if not indice.has_key("ISIN"):
                i = 0
                for ind in data:
                    indice[ind] = i
                    i = i + 1

                iName = indice["Instrument's name"]
                iISIN = indice["ISIN"]
                iMEP = indice["MEP"]
                iTicker = indice["Symbol"]
                iCurr = indice["Trading currency"]

            else:
                if data[iISIN]!="ISIN":
                    if checkISIN(data[iISIN]):
                        if data[iMEP]=='PAR' or data[iMEP]=='BRU' or data[iMEP]=='AMS' or data[iMEP]=='LIS':
                            name = filterName(data[iName])
                            quotes.addQuote(isin=data[iISIN],name=name,ticker=data[iTicker],market=market,currency=data[iCurr],place=data[iMEP],country=None)
                            count = count + 1
                        else:
                            if itrade_config.verbose:
                                print 'unknown place :',data[iMEP],'>>>',data
                    else:
                        if itrade_config.verbose:
                            print 'invalid ISIN :',data[iISIN],'>>>',data

        else:
            print len(data),'>>>',data

    print 'Imported %d/%d lines from %s data.' % (count,len(lines),market)

    return True
コード例 #4
0
def Import_ListOfQuotes_Euronext(quotes, market='EURONEXT', dlg=None, x=0):
    print 'Update %s list of symbols' % market
    connection = ITradeConnection(cookies=None,
                                  proxy=itrade_config.proxyHostname,
                                  proxyAuth=itrade_config.proxyAuthentication,
                                  connectionTimeout=max(
                                      45, itrade_config.connectionTimeout))

    cha = "7213"

    if market == 'EURONEXT':
        url = "http://www.euronext.com/search/download/trapridownloadpopup.jcsv?pricesearchresults=actif&filter=1&lan=EN&belongsToList=market_EURLS&cha=%s&format=txt&formatDecimal=.&formatDate=dd/MM/yy" % cha
    elif market == 'ALTERNEXT':
        url = "http://www.euronext.com/search/download/trapridownloadpopup.jcsv?pricesearchresults=actif&filter=1&lan=EN&belongsToList=market_ALTX&cha=%s&format=txt&formatDecimal=.&formatDate=dd/MM/yy" % cha
    elif market == 'PARIS MARCHE LIBRE':
        url = "http://www.euronext.com/search/download/trapridownloadpopup.jcsv?pricesearchresults=actif&filter=1&lan=EN&belongsToList=market_MC&cha=%s&format=txt&formatDecimal=.&formatDate=dd/MM/yy" % cha
    elif market == 'BRUXELLES MARCHE LIBRE':
        url = "http://www.euronext.com/search/download/trapridownloadpopup.jcsv?pricesearchresults=actif&filter=1&lan=EN&belongsToList=market_BRUMC&cha=%s&format=txt&formatDecimal=.&formatDate=dd/MM/yy" % cha
    else:
        return False

    def splitLines(buf):
        lines = string.split(buf, '\n')
        lines = filter(lambda x: x, lines)

        def removeCarriage(s):
            if s[-1] == '\r':
                return s[:-1]
            else:
                return s

        lines = [removeCarriage(l) for l in lines]
        return lines

    try:
        data = connection.getDataFromUrl(url)
    except:
        debug('Import_ListOfQuotes_Euronext:unable to connect :-(')
        return False

    indice = {}
    """
    "Instrument's name";
    "ISIN";
    "Euronext code";
    "MEP";
    "Symbol";
    "ICB Sector (Level 4)";
    "Trading currency";
    "Last";
    "Volume";
    "D/D-1 (%)";
    "Date - time (CET)";
    "Turnover";
    "Total number of shares";
    "Capitalisation";
    "Trading mode";
    "Day First";
    "Day High";
    "Day High / Date - time (CET)";
    "Day Low";
    "Day Low / Date - time (CET)";
    "31-12/Change (%)";
    "31-12/High";
    "31-12/High/Date";
    "31-12/Low";
    "31-12/Low/Date";
    "52 weeks/Change (%)";
    "52 weeks/High";
    "52 weeks/High/Date";
    "52 weeks/Low";
    "52 weeks/Low/Date";
    "Suspended";
    "Suspended / Date - time (CET)";
    "Reserved";
    "Reserved / Date - time (CET)"
    """

    # returns the data
    lines = splitLines(data)
    count = 0

    for line in lines:
        data = string.split(line, ';')

        if len(data) > 2:
            if not indice.has_key("ISIN"):
                i = 0
                for ind in data:
                    indice[ind] = i
                    i = i + 1

                iName = indice["Instrument's name"]
                iISIN = indice["ISIN"]
                iMEP = indice["MEP"]
                iTicker = indice["Symbol"]
                iCurr = indice["Trading currency"]

            else:
                if data[iISIN] != "ISIN":
                    if checkISIN(data[iISIN]):
                        if data[iMEP] == 'PAR' or data[iMEP] == 'BRU' or data[
                                iMEP] == 'AMS' or data[iMEP] == 'LIS':
                            name = filterName(data[iName])
                            quotes.addQuote(isin=data[iISIN],
                                            name=name,
                                            ticker=data[iTicker],
                                            market=market,
                                            currency=data[iCurr],
                                            place=data[iMEP],
                                            country=None)
                            count = count + 1
                        else:
                            if itrade_config.verbose:
                                print 'unknown place :', data[
                                    iMEP], '>>>', data
                    else:
                        if itrade_config.verbose:
                            print 'invalid ISIN :', data[iISIN], '>>>', data

        else:
            print len(data), '>>>', data

    print 'Imported %d/%d lines from %s data.' % (count, len(lines), market)

    return True