本文整理汇总了Python中history.History.currentTickers方法的典型用法代码示例。如果您正苦于以下问题:Python History.currentTickers方法的具体用法?Python History.currentTickers怎么用?Python History.currentTickers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类history.History
的用法示例。
在下文中一共展示了History.currentTickers方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: createHistory
# 需要导入模块: from history import History [as 别名]
# 或者: from history.History import currentTickers [as 别名]
def createHistory(portfolioFile = None, forceReload = False):
# Read all transactions from disk
transactions = transaction.readTransactions(portfolioFile)
startDate = transactions[0].date
# And all investments
investments = investment.learn_investments(transactions)
# Build a list of all mentioned tickers
tickerList = []
for trans in transactions:
if trans.ticker not in tickerList:
tickerList.append(trans.ticker)
# Hard code currency list. !! Should pick these out of investments really.
currencyList = ["USD", "Euro", "NOK"]
# Build a history of our transactions
history = History(transactions)
# Load what we've got from disk
prices = {}
Price.loadHistoricalPricesFromDisk(prices)
# Start reading all the HTML we're going to need now.
urlCache, currencyInfo, tickerInfo = cacheUrls(tickerList, currencyList, investments, history, startDate, prices, forceReload)
# Load currency histories
for currency in currencyInfo:
Price.getCurrencyHistory(currency[0],
currency[1],
date.today(),
prices,
urlCache)
# Load current prices from the Web
Price.loadCurrentPricesFromWeb(history.currentTickers(), prices, urlCache)
# Now load historical prices from the Web
for ticker in tickerInfo:
Price.loadHistoricalPricesFromWeb(ticker[0], ticker[1], ticker[2], prices, urlCache)
# Fill in any gaps
Price.fixPriceGaps(prices)
# Now save any new data to disk
Price.savePricesToDisk(prices)
# And fill in any gaps between the last noted price and today
Price.fixLastPrices(prices, history.currentTickers())
# Give the prices to our history
history.notePrices(prices)
# Done with all the HTML that we read
#urlCache.clean_urls()
return (history, investments)