inplus_data_source.py 文件源码

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

项目:InplusTrader_Linux 作者: zhengwsh 项目源码 文件源码
def get_risk_free_rate(self, start_date, end_date):
        mongo_dates = self._yield_curve['dates'].find({}, {"_id":0}).sort('date', pymongo.ASCENDING)
        _dates = np.array([np.uint32(d['date']) for d in mongo_dates])

        tenor = risk_free_helper.get_tenor_for(start_date, end_date)
        tenor = tenor[-1] + tenor[:-1]
        mongo_data = self._yield_curve[tenor].find({}, {"_id":0})
        _table = np.array([d['data'] for d in mongo_data])

        d = start_date.year * 10000 + start_date.month * 100 + start_date.day
        pos = _dates.searchsorted(d)
        if pos > 0 and (pos == len(_dates) or _dates[pos] != d):
            pos -= 1
        while pos >= 0 and np.isnan(_table[pos]):
            # data is missing ...
            pos -= 1

        return _table[pos]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号