asset.py 文件源码

python
阅读 34 收藏 0 点赞 0 评论 0

项目:py-investment 作者: kprestel 项目源码 文件源码
def get_price_quote(self, d=None, column='adj_close'):
        """
        Get the price of an Asset.

        :param date or datetime d: The datetime of when to retrieve the price quote from.
            (default: ``date.today()``)
        :param str column: The header of the column to use to get the price quote from.
            (default: ``adj_close``
        :return: namedtuple with price and the the datetime
        :rtype: namedtuple
        """
        quote = namedtuple('Quote', 'price time')
        if d is None:
            df = web.get_quote_yahoo(self.ticker)
            d = date.today()
            time = dt_utils.parse_date(df['time'][0]).time()
            dt = datetime.combine(d, time=time)
            return quote(price=df['last'], time=dt)
        else:
            price = self.ohlcv.ix[d][column][0]
            return quote(price=price, time=d)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号