<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def __get_model_for_portfolio_value(input_model: PortfolioValueInputModel ) -> PortfolioValueViewModel: """ loads the data for portfolio value """

    result = PortfolioValueViewModel()
    result.filter = input_model

    ref_datum = Datum()
    ref_datum.from_datetime(input_model.as_of_date)
    ref_date = ref_datum.end_of_day()

    result.stock_rows = []
    with BookAggregate() as svc:
        book = svc.book
        stocks_svc = svc.securities

        if input_model.stock:
            symbols = input_model.stock.split(",")
            stocks = stocks_svc.get_stocks(symbols)
        else:
            stocks = stocks_svc.get_all()

        for stock in stocks:
            row: StockViewModel = portfoliovalue.get_stock_model_from(
                book, stock, as_of_date=ref_date)
            if row and row.balance > 0:
                result.stock_rows.append(row)

    return result