Skip to content

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

@geekgu

Description

@geekgu
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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions