예제 #1
0
 def getlasttrade(self,bAllEvenNotInUse=False):
     if not itrade_config.isConnected():
         return
     for eachCurrency in self.m_currencies:
         curTo = eachCurrency[:3]
         curFrom = eachCurrency[3:]
         if bAllEvenNotInUse or self.used(curTo,curFrom):
             self.get(curTo,curFrom)
     self.save()
예제 #2
0
 def getlasttrade(self,bAllEvenNotInUse=False):
     if not itrade_config.isConnected():
         return
     for eachCurrency in self.m_currencies:
         curTo = eachCurrency[:3]
         curFrom = eachCurrency[3:]
         if bAllEvenNotInUse or self.used(curTo,curFrom):
             self.get(curTo,curFrom)
     self.save()
예제 #3
0
    def OnAccess(self,e):
        # get the connector
        m = self.accessmenu.FindItemById(e.GetId())
        m = m.GetText()
        c = getLoginConnector(m)
        if c:
            # with the connector, load user info and open UI
            u,p = c.loadUserInfo()
            u,p = login_UI(self,u,p,c)

            # now, save new user info
            wx.SetCursor(wx.HOURGLASS_CURSOR)
            c.saveUserInfo(u,p)
            if itrade_config.isConnected():
                # and apply these ne login info
                c.login(u,p)
            wx.SetCursor(wx.STANDARD_CURSOR)
예제 #4
0
    def get(self,curTo,curFrom):
        if not itrade_config.isConnected():
            return None

        if curFrom == 'N/A' or curTo == 'N/A':
            return None

        if self.m_connection==None:
            self.m_connection = ITradeConnection(cookies = None,
                               proxy = itrade_config.proxyHostname,
                               proxyAuth = itrade_config.proxyAuthentication,
                               connectionTimeout = itrade_config.connectionTimeout
                               )
            #print "**** Create Currency Connection"

        # pence
        if curFrom in self._s1.keys():
            a = self._s1[curFrom]
        else:
            a = curFrom
        if curTo in self._s1.keys():
            b = self._s1[curTo]
        else:
            b = curTo

        # get data
        url = self.m_url % (a,b)
        try:
            buf = self.m_connection.getDataFromUrl(url)
        except:
            return None

        # extract data
        #print url,buf
        sdata = string.split(buf, ',')
        f = float(sdata[1])

        # pence
        if curFrom in self._s2.keys():
            f = f / self._s2[curFrom]
        if curTo in self._s2.keys():
            f = f * self._s2[curTo]

        #print 'get: %s %s rate = %.4f' %(curTo,curFrom,float(sdata[1]))
        return self.update(curTo,curFrom,f)
예제 #5
0
    def get(self,curTo,curFrom):
        if not itrade_config.isConnected():
            return None

        if curFrom == 'N/A' or curTo == 'N/A':
            return None

        if self.m_connection is None:
            self.m_connection = ITradeConnection(cookies = None,
                               proxy = itrade_config.proxyHostname,
                               proxyAuth = itrade_config.proxyAuthentication,
                               connectionTimeout = itrade_config.connectionTimeout
                               )
            #print "**** Create Currency Connection"

        # pence
        if curFrom in self._s1.keys():
            a = self._s1[curFrom]
        else:
            a = curFrom
        if curTo in self._s1.keys():
            b = self._s1[curTo]
        else:
            b = curTo

        # get data
        url = self.m_url % (a,b)
        try:
            buf = self.m_connection.getDataFromUrl(url)
        except:
            return None

        # extract data
        #print url,buf
        sdata = string.split(buf, ',')
        f = float(sdata[1])

        # pence
        if curFrom in self._s2.keys():
            f = f / self._s2[curFrom]
        if curTo in self._s2.keys():
            f = f * self._s2[curTo]

        #print 'get: %s %s rate = %.4f' %(curTo,curFrom,float(sdata[1]))
        return self.update(curTo,curFrom,f)
예제 #6
0
def import_from_internet(quote, fromdate=None, todate=None):
    bRet = False

    if quote.ticker() == '':
        info("import_from_internet(%s): no ticker" % quote.isin())
        #return bRet

    if not itrade_config.isConnected():
        info("import_from_internet(%s): no connexion" % quote.ticker())
        return bRet

    abc = quote.importconnector()
    if abc and abc.connect():

        state = abc.getstate()
        if state:
            #debug("state=%s" % (state))
            #debug('import historic %s from %s ...' % (quote.ticker(),abc.name()))
            data = abc.getdata(quote, fromdate, todate)
            if data != None:
                if data:
                    #debug('import_from_internet(%s): data:%s'% (quote.ticker(),data))
                    quote.importTrades(data, bLive=False)
                    bRet = True
                else:
                    if itrade_config.verbose:
                        print "import_from_internet(%s): nodata [%s,%s)" % (
                            quote.ticker(), fromdate, todate)
                    bRet = False
            else:
                if itrade_config.verbose:
                    print "import_from_internet(%s): nodata [%s,%s)" % (
                        quote.ticker(), fromdate, todate)
                bRet = False
        else:
            print "import_from_internet(%s): getstate() failure :-(" % quote.ticker(
            )
            bRet = False

        abc.disconnect()
        return bRet
    else:
        print "import_from_internet(%s): connect() failure :-(" % quote.ticker(
        )
        return bRet
예제 #7
0
def import_from_internet(quote,fromdate=None,todate=None):
    bRet = False

    if quote.ticker()=='':
        info("import_from_internet(%s): no ticker" % quote.isin())
        #return bRet

    if not itrade_config.isConnected():
        info("import_from_internet(%s): no connexion" % quote.ticker())
        return bRet

    abc = quote.importconnector()
    if abc and abc.connect():

        state = abc.getstate()
        if state:
            #debug("state=%s" % (state))
            #debug('import historic %s from %s ...' % (quote.ticker(),abc.name()))
            data = abc.getdata(quote,fromdate,todate)
            if data!=None:
                if data:
                    #debug('import_from_internet(%s): data:%s'% (quote.ticker(),data))
                    quote.importTrades(data,bLive=False)
                    bRet = True
                else:
                    if itrade_config.verbose:
                        print "import_from_internet(%s): nodata [%s,%s)" % (quote.ticker(),fromdate,todate)
                    bRet = False
            else:
                if itrade_config.verbose:
                    print "import_from_internet(%s): nodata [%s,%s)" % (quote.ticker(),fromdate,todate)
                bRet = False
        else:
            print "import_from_internet(%s): getstate() failure :-(" % quote.ticker()
            bRet = False

        abc.disconnect()
        return bRet
    else:
        print "import_from_internet(%s): connect() failure :-(" % quote.ticker()
        return bRet
예제 #8
0
 def hasStatus(self):
     return itrade_config.isConnected()
예제 #9
0
 def Run(self):
     time.sleep(3)
     self.Close(True)
     if itrade_config.isConnected():
         itrade_config.checkNewRelease(ping=True)
 def hasStatus(self):
     return itrade_config.isConnected()
예제 #11
0
def liveupdate_from_internet(quote):
    bRet = False

    if not itrade_config.isConnected():
        debug("liveupdate_from_internet(%s): no connexion" % quote.ticker())
        return bRet

    abc = quote.liveconnector()
    abc.acquire()
    if abc.iscacheddataenoughfreshq():
        data = abc.getcacheddata(quote)
        if data:
            #debug(data)
            debug("liveupdate_from_internet(%s): import live from cache" % quote.ticker())
            quote.importTrades(data,bLive=True)
            bRet = True
        else:
            #debug("liveupdate_from_internet(%s): nodata" % quote.ticker())
            bRet = False

        abc.release()
        return bRet

    elif abc.connect():

        state = abc.getstate()
        if state:
            #debug("state=%s" % (state))
            #debug('liveupdate_from_internet(%s): import live from abcbourse ...' % quote.ticker())
            data = abc.getdata(quote)
            if data!=None:
                if data:
                    #debug('liveupdate_from_internet(%s): data:%s'% (quote.ticker(),data))
                    quote.importTrades(data,bLive=True)
                    bRet = True
                else:
                    #debug("liveupdate_from_internet(%s): nodata" % quote.ticker())
                    bRet = False
            else:
                if abc.alive():
                    if itrade_config.verbose:
                        print "liveupdate_from_internet(%s): alive but no trade yet" % quote.ticker()
                else:
                    if itrade_config.verbose:
                        print "liveupdate_from_internet(%s): not alive yet" % quote.ticker()
                bRet = False
        else:
            print "liveupdate_from_internet(%s): getstate() failure :-(" % quote.ticker()
            bRet = False

        abc.disconnect()

        abc.release()
        return bRet

    else:

        print "liveupdate_from_internet(%s): connect() failure :-(" % quote.ticker()

        abc.release()
        return bRet
예제 #12
0
 def Run(self):
     time.sleep(3)
     self.Close(True)
     if itrade_config.isConnected():
         itrade_config.checkNewRelease(ping=True)
예제 #13
0
def liveupdate_from_internet(quote):
    bRet = False

    if not itrade_config.isConnected():
        debug("liveupdate_from_internet(%s): no connexion" % quote.ticker())
        return bRet

    abc = quote.liveconnector()
    abc.acquire()
    if abc.iscacheddataenoughfreshq():
        data = abc.getcacheddata(quote)
        if data:
            #debug(data)
            debug("liveupdate_from_internet(%s): import live from cache" %
                  quote.ticker())
            quote.importTrades(data, bLive=True)
            bRet = True
        else:
            #debug("liveupdate_from_internet(%s): nodata" % quote.ticker())
            bRet = False

        abc.release()
        return bRet

    elif abc.connect():

        state = abc.getstate()
        if state:
            #debug("state=%s" % (state))
            #debug('liveupdate_from_internet(%s): import live from abcbourse ...' % quote.ticker())
            data = abc.getdata(quote)
            if data != None:
                if data:
                    #debug('liveupdate_from_internet(%s): data:%s'% (quote.ticker(),data))
                    quote.importTrades(data, bLive=True)
                    bRet = True
                else:
                    #debug("liveupdate_from_internet(%s): nodata" % quote.ticker())
                    bRet = False
            else:
                if abc.alive():
                    if itrade_config.verbose:
                        print "liveupdate_from_internet(%s): alive but no trade yet" % quote.ticker(
                        )
                else:
                    if itrade_config.verbose:
                        print "liveupdate_from_internet(%s): not alive yet" % quote.ticker(
                        )
                bRet = False
        else:
            print "liveupdate_from_internet(%s): getstate() failure :-(" % quote.ticker(
            )
            bRet = False

        abc.disconnect()

        abc.release()
        return bRet

    else:

        print "liveupdate_from_internet(%s): connect() failure :-(" % quote.ticker(
        )

        abc.release()
        return bRet