本文整理汇总了Python中pandas.io.data.DataReader.code方法的典型用法代码示例。如果您正苦于以下问题:Python DataReader.code方法的具体用法?Python DataReader.code怎么用?Python DataReader.code使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pandas.io.data.DataReader
的用法示例。
在下文中一共展示了DataReader.code方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from pandas.io.data import DataReader [as 别名]
# 或者: from pandas.io.data.DataReader import code [as 别名]
def main():
# db = psql.get_db()
# product_codes = db.prepare('''SELECT p.code AS code, p.id as id
# FROM products p LEFT JOIN companies c ON p.company_id = c.id
# WHERE c.sector IS NOT NULL
# and p.id < 9354
# ORDER BY p.id''')()
product_codes = get_components_yahoo('^DJI').index
total = len(product_codes)
cur = 0
products=[]
logger.info('Start downloading of %d products.', len(product_codes))
for code in product_codes:
cur += 1
try:
product = DataReader(code, 'yahoo', start=date_from, end=date_to)
except:
logger.warn('(%d/%d) Fail downloading %s.', cur, total, code)
continue
product.code = code
products.append(product)
logger.info('(%d/%d) Downloaded %s.', cur, total, code)
logger.info('Download complete.')
return opt(products)
示例2: apply
# 需要导入模块: from pandas.io.data import DataReader [as 别名]
# 或者: from pandas.io.data.DataReader import code [as 别名]
def apply(self):
self.analyze()
self.summary()
# self.plot()
def __call__(self, *args, **kwargs):
self.__dict__.update(kwargs)
self.analyze()
return self.revenue
if __name__ == '__main__':
import util.log
from pandas.io.data import DataReader
date_from = '2003-01-01'
date_to = '2013-01-01'
model = MACD(12, 26, 9, verbose=True)
code = 'GOOG'
product = DataReader(code, 'yahoo', start=date_from, end=date_to)
product.code = code
model.product = product
model.analyze()
model.summary()
# From 2003-01-01 to 2013-01-01, MACD(12, 26, 9)
# Trade stat: 154 trades, total revenue 6904.1657838
示例3: demo
# 需要导入模块: from pandas.io.data import DataReader [as 别名]
# 或者: from pandas.io.data.DataReader import code [as 别名]
def demo():
product = DataReader(code, 'yahoo', start=date_from, end=date_to)
product.code = code
opt([product])