コード例 #1
0
def get_unit_test_delete():
    '''
    Deletes all portfolios and respective holdings that are of type 'unit test'
    '''
    portfolios = investmentportfolio.Get_Portfolios_by_Selector('type','unit test portfolio')['portfolios']
    print(portfolios)
    for p in portfolios:
        holdings = investmentportfolio.Get_Portfolio_Holdings(p['name'],False)
        # delete all holdings
        for h in holdings['holdings']:
            timestamp = h['timestamp']
            rev = h['_rev']
            investmentportfolio.Delete_Portfolio_Holdings(p['name'],timestamp,rev)
        investmentportfolio.Delete_Portfolio(p['name'],p['timestamp'],p['_rev'])
    return "Portfolios deleted successfully."
コード例 #2
0
def reset_app():
    '''
    Deletes all portfolios and respective holdings that are of type 'user_portfolio', 'benchmark', and 'root' (instrument universe)
    '''
    portfolios = investmentportfolio.Get_Portfolios_by_Selector('type','user_portfolio')['portfolios']
    portfolios += investmentportfolio.Get_Portfolios_by_Selector('type','benchmark')['portfolios']
    portfolios += investmentportfolio.Get_Portfolios_by_Selector('type','root')['portfolios']
    for p in portfolios:
        holdings = investmentportfolio.Get_Portfolio_Holdings(p['name'],False)
        # delete all holdings
        for h in holdings['holdings']:
            timestamp = h['timestamp']
            rev = h['_rev']
            investmentportfolio.Delete_Portfolio_Holdings(p['name'],timestamp,rev)
        investmentportfolio.Delete_Portfolio(p['name'],p['timestamp'],p['_rev'])
    return "Portfolios deleted successfully."