本文整理汇总了Python中itrade_connection.ITradeConnection类的典型用法代码示例。如果您正苦于以下问题:Python ITradeConnection类的具体用法?Python ITradeConnection怎么用?Python ITradeConnection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ITradeConnection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Import_ListOfQuotes_NZE
def Import_ListOfQuotes_NZE(quotes,market='NEW ZEALAND EXCHANGE',dlg=None,x=0):
if itrade_config.verbose:
print 'Update %s list of symbols' % market
connection=ITradeConnection(cookies=None,
proxy=itrade_config.proxyHostname,
proxyAuth=itrade_config.proxyAuthentication)
if market=='NEW ZEALAND EXCHANGE':
url = 'http://www.findata.co.nz/Markets/NZX/%s.htm'
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
select_alpha = map(chr,range(65,91)) # A to Z
count = 0
isin = ''
for letter in select_alpha:
if dlg:
dlg.Update(x," NZX : %s to Z"%letter)
try:
data=connection.getDataFromUrl(url%letter)
except:
debug('Import_ListOfQuotes_NZE unable to connect :-(')
return False
# returns the data
lines = splitLines(data)
for line in lines:
if '"hideInfo();">' in line:
tickername = line[line.find('"hideInfo();">')+14:line.find('</td><td align=right>')]
if not 'Index' in tickername:
ticker = tickername[:tickername.index('<')]
if not '0' in ticker[-1:]:
name = tickername[tickername.index('<td>')+4:]
count = count + 1
# ok to proceed
quotes.addQuote(isin=isin,name=name,
ticker=ticker,market='NEW ZEALAND EXCHANGE',currency='NZD',place='NZE',country='NZ')
if itrade_config.verbose:
print 'Imported %d lines from NEW ZEALAND EXCHANGE' % (count)
return True
示例2: Import_ListOfQuotes_SWX
def Import_ListOfQuotes_SWX(quotes,market='SWISS EXCHANGE',dlg=None,x=0):
if itrade_config.verbose:
print 'Update %s list of symbols' % market
connection = ITradeConnection(cookies = None,
proxy = itrade_config.proxyHostname,
proxyAuth = itrade_config.proxyAuthentication,
connectionTimeout = itrade_config.connectionTimeout
)
if market=='SWISS EXCHANGE':
url = 'http://www.six-swiss-exchange.com/shares/companies/download/issuers_all_fr.csv'
try:
data = connection.getDataFromUrl(url)
except:
info('Import_ListOfQuotes_SWX_%s:unable to get file name :-(' % market)
return False
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
# returns the data
lines = splitLines(data)
n = 0
isin = ''
for line in lines[1:]:
line = line.replace('!',' ')
line = line.replace(',',' ')
line = line.replace('à','a')
line = line.replace('ä','a')
line = line.replace('â','a')
line = line.replace('ö','o')
line = line.replace('ü','u')
line = line.replace('é','e')
line = line.replace('è','e')
line = line.replace('+',' ')
data = string.split(line,';') # csv line
name = data[0].strip()
ticker = data[1].strip()
country = data[3].strip()
currency = data[4].strip()
exchange = data[5].strip()
quotes.addQuote(isin=isin,name=name, ticker=ticker,market='SWISS EXCHANGE',
currency=currency,place=exchange,country=country)
n = n + 1
if itrade_config.verbose:
print 'Imported %d lines from %s' % (n,market)
return True
示例3: Import_ListOfQuotes_ASX
def Import_ListOfQuotes_ASX(quotes,market='ASX',dlg=None,x=0):
print 'Update %s list of symbols' % market
connection = ITradeConnection(cookies = None,
proxy = itrade_config.proxyHostname,
proxyAuth = itrade_config.proxyAuthentication,
connectionTimeout = itrade_config.connectionTimeout
)
if market=='ASX':
url = "http://www.asx.com.au/asx/research/ASXListedCompanies.csv"
n = 0
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_ASX:unable to connect :-(')
return False
# returns the data
lines = splitLines(data)
isin = ''
for line in lines[3:]:
line = line.replace('"','')
data = string.split (line, ',')
name=data[0]
ticker=data[1]
quotes.addQuote(isin = isin,name = name, \
ticker = ticker,market='ASX',currency='AUD',place='SYD',country='AU')
n = n + 1
if itrade_config.verbose:
print 'Imported %d lines from %s data.' % (n,market)
return True
示例4: Import_ListOfQuotes_OTCBB
def Import_ListOfQuotes_OTCBB(quotes,market='OTCBB',dlg=None,x=0):
if itrade_config.verbose:
print 'Update %s list of symbols' % market
connection = ITradeConnection(cookies = None,
proxy = itrade_config.proxyHostname,
proxyAuth = itrade_config.proxyAuthentication,
connectionTimeout = itrade_config.connectionTimeout
)
if market=='OTCBB':
url = 'http://www.otcbb.com/dynamic/tradingdata/download/allotcbb.txt'
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_OTCBB:unable to connect :-(')
return False
# returns the data
lines = splitLines(data)
count = 0
isin = ''
for line in lines[1:]:
if '|' in line:
data = string.split (line, '|')
if data[3]== 'ACTIVE':
count = count + 1
name = data[2]
name = name.strip()
name =name.replace(',','')
ticker = data[0]
quotes.addQuote(isin=isin,name=name,ticker=ticker,market='OTCBB',currency='USD',place='NYC',country='US')
if itrade_config.verbose:
print 'Imported %d lines from OTCBB data.' % count
return True
示例5: Import_ListOfQuotes_Xetra
def Import_ListOfQuotes_Xetra(quotes,market='FRANKFURT EXCHANGE',dlg=None,x=0):
if itrade_config.verbose:
print 'Update %s list of symbols' % market
connection = ITradeConnection(cookies = None,
proxy = itrade_config.proxyHostname,
proxyAuth = itrade_config.proxyAuthentication,
connectionTimeout = itrade_config.connectionTimeout
)
if market=='FRANKFURT EXCHANGE':
url = 'http://deutsche-boerse.com/dbag/dispatch/en/xetraCSV/gdb_navigation/trading/20_tradable_instruments/900_tradable_instruments/100_xetra'
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_Deutsche Borse AG :unable to connect :-(')
return False
# returns the data
lines = splitLines(data)
n = 0
for line in lines[6:]:
data = string.split (line, ';') # ; delimited
if len(data) >5:
if data[8] == 'EQUITIES FFM2':
if data[2][:2] == 'DE':
name = data[1].replace(',','').replace(' ','').replace (' -','-').replace ('. ','.').replace(' + ','&').replace('+','&')
quotes.addQuote(isin=data[2],name=name,ticker=data[5],market='FRANKFURT EXCHANGE',currency=data[73],place='FRA',country='DE')
n = n + 1
if itrade_config.verbose:
print 'Imported %d/%d lines from %s' % (n,len(lines),market)
return True
示例6: checkNewRelease
def checkNewRelease(ping=False):
# just to test : remove '#' from the line just below
#__svnversion__ = 'r565'
# development release : do not test
if not ping and __svnversion__[0] == 'x':
if verbose:
print 'checkNewRelease(): development release'
return 'dev'
from itrade_connection import ITradeConnection
connection = ITradeConnection(cookies = None,
proxy = proxyHostname,
proxyAuth = proxyAuthentication,
connectionTimeout = 3
)
# get OFFICIAL file from svn
try:
latest=connection.getDataFromUrl(softwareLatest)
except IOError:
print 'checkNewRelease(): exeption getting OFFICIAL file'
return 'err'
if latest[0]!='r':
if verbose:
print 'checkNewRelease(): OFFICIAL file malformed'
return 'err'
# development release : do not test
if __svnversion__[0] == 'x':
if verbose:
print 'checkNewRelease(): development release (ping)'
return 'dev'
current = int(__svnversion__[1:])
latest = int(latest[1:])
#print current,latest
if current<latest:
print 'checkNewRelease(): please update (%d vs %d) : %s' % (current,latest,downloadURL)
return downloadURL
else:
print 'checkNewRelease(): up to date'
return 'ok'
示例7: __init__
def __init__(self):
debug('Import_yahoojp:__init__')
self.m_connection = ITradeConnection(cookies = None,
proxy = itrade_config.proxyHostname,
proxyAuth = itrade_config.proxyAuthentication,
connectionTimeout = itrade_config.connectionTimeout
)
示例8: Import_ListOfQuotes_NYSE
def Import_ListOfQuotes_NYSE(quotes,market='NYSE',dlg=None,x=0):
print 'Update %s list of symbols' % market
connection = ITradeConnection(cookies = None,
proxy = itrade_config.proxyHostname,
proxyAuth = itrade_config.proxyAuthentication,
connectionTimeout = itrade_config.connectionTimeout
)
if market=='NYSE':
url = "http://www.nysedata.com/nysedata/asp/download.asp?s=txt&prod=symbols"
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_NYSE:unable to connect :-(')
return False
# returns the data
lines = splitLines(data)
for line in lines:
data = string.split (line, '|')
if len(data)==5:
country,issuer,issue = extractCUSIP(data[1])
if issue=='10':
#print data[1],country,issuer,issue,data[2]
if country=='US':
isin = buildISIN(country,data[1])
name = filterName(data[2])
quotes.addQuote(isin=isin,name=name,ticker=data[0],market='NYSE',currency='USD',place='NYC',country='US')
print 'Imported %d lines from NYSE data.' % len(lines)
return True
示例9: __init__
def __init__(self):
debug('Import_euronext:__init__')
self.m_url = 'http://www.euronext.com/tools/datacentre/dataCentreDownloadExcell.jcsv'
self.m_connection = ITradeConnection(cookies = None,
proxy = itrade_config.proxyHostname,
proxyAuth = itrade_config.proxyAuthentication,
connectionTimeout = itrade_config.connectionTimeout
)
示例10: Import_ListOfQuotes_ASX
def Import_ListOfQuotes_ASX(quotes,market='ASX',dlg=None,x=0):
print 'Update %s list of symbols' % market
connection = ITradeConnection(cookies = None,
proxy = itrade_config.proxyHostname,
proxyAuth = itrade_config.proxyAuthentication,
connectionTimeout = itrade_config.connectionTimeout
)
if market=='ASX':
url = "http://www.asx.com.au/programs/ISIN.xls" # is actually tab delimited
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_ASX:unable to connect :-(')
return False
# returns the data
lines = splitLines(data)
n = 0
for line in lines[5:]: # skip header lines (PeterMills> 2007-06-22)
data = string.split (line, '\t') # tab delimited
if data[2]=='ORDINARY FULLY PAID': # only want ordinary shares
quotes.addQuote(isin=data[3],name=data[1].replace(',',' '), \
ticker=data[0],market='ASX',currency='AUD',place='SYD',country='AU')
n = n + 1
print 'Imported %d/%d lines from ASX data.' % (n,len(lines))
return True
示例11: __init__
def __init__(self):
debug('News_Balo:__init__')
self.m_feed = None
self.m_url = None
self.m_quote = None
self.m_baseurl = "balo.journal-officiel.gouv.fr"
self.m_connection = ITradeConnection(cookies = None,
proxy = itrade_config.proxyHostname,
proxyAuth = itrade_config.proxyAuthentication,
connectionTimeout = itrade_config.connectionTimeout
)
示例12: __init__
def __init__(self):
debug("LiveUpdate_boursorama:__init__")
self.m_default_host = "www.boursorama.fr"
self.m_login_url = "https://www.boursorama.fr/logunique.phtml"
self.m_logged = False
self.m_cookies = ITradeCookies()
# Manualy set the cookie that tell boursorama we are a cookie aware browser
self.m_cookies.set("SUP_COOKIE=OUI")
self.m_connection = ITradeConnection(
cookies=None,
proxy=itrade_config.proxyHostname,
proxyAuth=itrade_config.proxyAuthentication,
connectionTimeout=itrade_config.connectionTimeout,
)
debug("Boursorama login (%s) - ready to run" % self.m_default_host)
示例13: __init__
def __init__(self,market='TOKYO EXCHANGE'):
debug('LiveUpdate_yahoojp:__init__')
self.m_connected = False
self.m_livelock = thread.allocate_lock()
self.m_dateindice = {}
self.m_clock = {}
self.m_dcmpd = {}
self.m_lastclock = 0
self.m_lastdate = "20070101"
self.m_connection = ITradeConnection(cookies = None,
proxy = itrade_config.proxyHostname,
proxyAuth = itrade_config.proxyAuthentication,
connectionTimeout = itrade_config.connectionTimeout
)
示例14: get
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)
示例15: __init__
def __init__(self):
debug('News_Boursorama:__init__')
self.m_feed = None
self.m_url = None
self.m_quote = None
self.m_baseurl = {}
self.m_host = "www.boursorama.com"
self.m_conn = None
self.m_baseurl[0] = "http://www.boursorama.com/infos/actualites/actu_societes_code.phtml?symbole=1rP%s"
self.m_baseurl[1] = "http://www.boursorama.com/communique/communique_code.phtml?symbole=1rP%s"
self.m_baseurl[2] = "http://www.boursorama.com/infos/calendrier_code.phtml?symbole=1rP%s"
self.m_baseurl[3] = "http://www.boursorama.com/conseils/conseils_index_code.phtml?symbole=1rP%s"
self.m_baselink = "http://www.boursorama.com/infos/imprimer_news.phtml?news=%s"
self.m_connection = ITradeConnection(cookies = None,
proxy = itrade_config.proxyHostname,
proxyAuth = itrade_config.proxyAuthentication,
connectionTimeout = itrade_config.connectionTimeout
)