Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

示例代码中应该要过滤一下univ中不在quantos中分配策略标的范围中的标的 #2

Open
geekgu opened this issue Mar 6, 2018 · 0 comments

Comments

@geekgu
Copy link

geekgu commented Mar 6, 2018

def _to_valide_goals(self, goals_raw):
    #goals_raw =基于投资范围以及策略选出来的标的
    #univ =quantos分配的策略标的
    univ, msg = self.ctx.trade_api.query_universe()
    univ.loc[:, 'size'] = 0.0
    univ.loc[:, 'ref_price'] = 0.0
    univ = univ.set_index('security').sort_index(axis=0)
    univ = univ[['size', 'ref_price']]
    for d in goals_raw:
        symbol = d['symbol']
        size = d['size']
        # TODO: better method needed
        if symbol in univ.index and symbol in self.univ_price_dic:
            univ.loc[symbol, 'ref_price'] = self.univ_price_dic[symbol]['last']
            if size > 0:
                univ.loc[symbol, 'size'] = size
    univ = univ[univ['size']>0]  #add by geekgu
    goals_valid = list(univ.reset_index().to_dict(orient='index').values())
    return goals_valid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant