当前位置: 首页>>代码示例>>Python>>正文


Python History.notePrices方法代码示例

本文整理汇总了Python中history.History.notePrices方法的典型用法代码示例。如果您正苦于以下问题:Python History.notePrices方法的具体用法?Python History.notePrices怎么用?Python History.notePrices使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在history.History的用法示例。


在下文中一共展示了History.notePrices方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: createHistory

# 需要导入模块: from history import History [as 别名]
# 或者: from history.History import notePrices [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)
开发者ID:danieltebbutt,项目名称:Portfolio,代码行数:60,代码来源:new.py


注:本文中的history.History.notePrices方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。