class_docstr: Create a new portfolio with a unique name. All portfolios
  are stored in ``Portfolio.portfolios``.
  
  Parameters
  ----------
  group_name : str
      The group represented in the portfolio.
  tag : str
      A unique identifier.
  space : alphapy.Space, optional
      Namespace for the portfolio.
  maxpos : int, optional
      The maximum number of positions.
  posby : str, optional
      The denominator for position sizing.
  kopos : int, optional
      The number of positions to kick out from the portfolio.
  koby : str, optional
      The "kick out" criteria. For example, a ``koby`` value
      of '-profit' means the three least profitable positions
      will be closed.
  restricted : bool, optional
      If ``True``, then the portfolio is limited to a maximum
      number of positions ``maxpos``.
  weightby : str, optional
      The weighting variable to balance the portfolio, e.g.,
      by closing price, by volatility, or by any column.
  startcap : float, optional
      The amount of starting capital.
  margin : float, optional
      The amount of margin required, expressed as a fraction.
  mincash : float, optional
      Minimum amount of cash on hand, expressed as a fraction
      of the total portfolio value.
  fixedfrac : float, optional
      The fixed fraction for any given position.
  maxloss : float, optional
      Stop loss for any given position.
  
  Attributes
  ----------
  portfolios : dict
      Class variable for storing all known portfolios
  value : float
      Class variable for storing all known portfolios
  netprofit : float
      Net profit ($) since previous valuation.
  netreturn : float
      Net return (%) since previous valuation
  totalprofit : float
      Total profit ($) since inception.
  totalreturn : float
      Total return (%) since inception.
class_docstr_tok: ["Create","a","new","portfolio","with","a","unique","name",".","All","portfolios","are","stored","in","``","Portfolio.portfolios","``",".","Parameters","--","--","--","--","--","group_name",":","str","The","group","represented","in","the","portfolio",".","tag",":","str","A","unique","identifier",".","space",":","alphapy.Space",",","optional","Namespace","for","the","portfolio",".","maxpos",":","int",",","optional","The","maximum","number","of","positions",".","posby",":","str",",","optional","The","denominator","for","position","sizing",".","kopos",":","int",",","optional","The","number","of","positions","to","kick","out","from","the","portfolio",".","koby",":","str",",","optional","The","``","kick","out","''","criteria",".","For","example",",","a","``","koby","``","value","of","'-profit","'","means","the","three","least","profitable","positions","will","be","closed",".","restricted",":","bool",",","optional","If","``","True","``",",","then","the","portfolio","is","limited","to","a","maximum","number","of","positions","``","maxpos","``",".","weightby",":","str",",","optional","The","weighting","variable","to","balance","the","portfolio",",","e.g.",",","by","closing","price",",","by","volatility",",","or","by","any","column",".","startcap",":","float",",","optional","The","amount","of","starting","capital",".","margin",":","float",",","optional","The","amount","of","margin","required",",","expressed","as","a","fraction",".","mincash",":","float",",","optional","Minimum","amount","of","cash","on","hand",",","expressed","as","a","fraction","of","the","total","portfolio","value",".","fixedfrac",":","float",",","optional","The","fixed","fraction","for","any","given","position",".","maxloss",":","float",",","optional","Stop","loss","for","any","given","position",".","Attributes","--","--","--","--","--","portfolios",":","dict","Class","variable","for","storing","all","known","portfolios","value",":","float","Class","variable","for","storing","all","known","portfolios","netprofit",":","float","Net","profit","(","$",")","since","previous","valuation",".","netreturn",":","float","Net","return","(","%",")","since","previous","valuation","totalprofit",":","float","Total","profit","(","$",")","since","inception",".","totalreturn",":","float","Total","return","(","%",")","since","inception","."]
code: def __init__(
      self,
      group_name,
      tag,
      space=Space(),
      maxpos=10,
      posby="close",
      kopos=0,
      koby="-profit",
      restricted=False,
      weightby="quantity",
      startcap=100000,
      margin=0.5,
      mincash=0.2,
      fixedfrac=0.1,
      maxloss=0.1,
  ):
      # initialization
      self.group_name = group_name
      self.tag = tag
      self.space = space
      self.positions = {}
      self.startdate = None
      self.enddate = None
      self.npos = 0
      self.maxpos = maxpos
      self.posby = posby
      self.kopos = kopos
      self.koby = koby
      self.restricted = restricted
      self.weightby = weightby
      self.weights = []
      self.startcap = startcap
      self.cash = startcap
      self.margin = margin
      self.mincash = mincash
      self.fixedfrac = fixedfrac
      self.maxloss = maxloss
      self.value = startcap
      self.netprofit = 0.0
      self.netreturn = 0.0
      self.totalprofit = 0.0
      self.totalreturn = 0.0
      # add portfolio to portfolios list
      pn = portfolio_name(group_name, tag)
      Portfolio.portfolios[pn] = self
  
imports: from alphapy.frame import Frame
  from alphapy.frame import frame_name
  from alphapy.frame import read_frame
  from alphapy.frame import write_frame
  from alphapy.globals import MULTIPLIERS, SSEP
  from alphapy.globals import Orders
  from alphapy.space import Space
  import logging
  import math
  import numpy
  from pandas import DataFrame
  from pandas import date_range
  from pandas import Series
label_desc: Use image node_id 2 to create a new Portfolio object  with example: obj = Portfolio(group_name, tag, space, maxpos, posby, kopos, koby, restricted, weightby, startcap, margin, mincash, fixedfrac, maxloss)