Exemplo n.º 1
0
    def __init__(self, tree, obj, parent=None):
        cache = tree.cache
        self.isposition = False
        if isinstance(obj, jsonFund):
            obj = obj.dbobj

        if isinstance(obj, jsonPosition):
            self.isposition = obj
            obj = obj.dbobj
            self.folder = False
            self.movable = True
            self.__mkt_risk = MarketRiskPosition(cache, self)
            self.fund = parent.fund
        elif isinstance(obj, Fund):
            self.isfund = True
            self.__mkt_risk = MarketRiskPortfolio(cache, self)
            self.fund = obj
        else:
            self.canaddto = True
            self.editable = True
            self.movable = True
            self.__mkt_risk = MarketRiskPortfolio(cache, self)
            self.fund = parent.fund

        self.tree = tree
        self.parent = parent
        self.children = []
        positionBase.__init__(self, cache, obj, tree.dte)
Exemplo n.º 2
0
    def _build(self):
        self.__mkt_risk = MarketRiskPortfolio(self.cache, self)
        dt = self.dte.dateonly
        funds = self.dbobj.fund_set.all()

        self.funds = []

        # debugging
        #funds = funds[:1]

        # Create the funds
        for f in funds:
            self.funds.append(self.cache.portfolio(f, dt))

        # Add the callbacks
        funds = self.funds[:]
        for f in funds:
            f.addcallback(self.addfund)