code: def allocate(self, amount, child=None, update=True):
          
          # allocate to child
          if child is not None:
              if child not in self.children:
                  c = SecurityBase(child)
                  c.setup(self._universe)
                  # update to bring up to speed
                  c.update(self.now)
                  # add child to tree
                  self._add_child(c)
  
              # allocate to child
              self.children[child].allocate(amount)
          # allocate to self
          else:
              # adjust parent's capital
              # no need to update now - avoids repetition
              if self.parent == self:
                  self.parent.adjust(-amount, update=False, flow=True)
              else:
                  # do NOT set as flow - parent will be another strategy
                  # and therefore should not incur flow
                  self.parent.adjust(-amount, update=False, flow=False)
  
              # adjust self's capital
              self.adjust(amount, update=False, flow=True)
  
              # push allocation down to children if any
              # use _weight to avoid triggering an update
              if self.children is not None:
                  [c.allocate(amount * c._weight, update=False)
                   for c in self._childrenv]
  
              # mark as stale if update requested
              if update:
                  self.root.stale = True
docs: Allocate capital to Strategy. By default, capital is allocated
          recursively down the children, proportionally to the children's
          weights.  If a child is specified, capital will be allocated
          to that specific child.
  
          Allocation also have a side-effect. They will deduct the same amount
          from the parent's "account" to offset the allocation. If there is
          remaining capital after allocation, it will remain in Strategy.
  
          Args:
              * amount (float): Amount to allocate.
              * child (str): If specified, allocation will be directed to child
                  only. Specified by name.
              * update (bool): Force update.