예제 #1
0
    def __init__(self, *fundtradeobj, status=None):
        """
        对场内投资组合进行分析的类

        :param fundtradeobj: itrade objects.
        :param status: 场内格式记账单,或 irecord 对象。
        """
        if isinstance(status, irecord):
            status = status.status
        if not fundtradeobj:
            fundtradeobj = []
            for code in status.code.unique():
                fundtradeobj.append(itrade(code, status))
        self.fundtradeobj = tuple(fundtradeobj)
        self.totcftable = self._mergecftb()
예제 #2
0
    def __init__(self, *fundtradeobj, status=None, istatus=None):
        """
        对场内投资组合进行分析的类

        :param fundtradeobj: itrade objects.
        :param status: 场内格式记账单,或 irecord 对象。
        """

        if not fundtradeobj:
            fundtradeobj = []
        if status is None:
            status = istatus
        if isinstance(status, irecord):
            status = status.status
        fundcodelist = [f.code for f in fundtradeobj]
        if status is not None:
            for code in status.code.unique():
                if code not in fundcodelist and not code.startswith("#"):
                    fundtradeobj.append(itrade(code, status))
        self.fundtradeobj = tuple(fundtradeobj)
        self.totcftable = self._mergecftb()
        self.is_in = True
예제 #3
0
 def __init__(self,
              *fundtradeobj,
              status=None,
              istatus=None,
              property=None,
              fetch=False,
              save=False,
              path="",
              form="csv"):
     if isinstance(status, record):
         if not property:
             property = getattr(status, "property", {})
         status = status.status
     elif not property:
         property = {}
     self.is_in = False
     if fundtradeobj:
         for t in fundtradeobj:
             if isinstance(t, itrade):
                 self.is_in = True
             break
     else:
         fundtradeobj = []
         # warning: not a very good way to automatic generate these fund obj
         # because there might be some funds use round_down for share calculation, ie, label=2 must be given
         # unless you are sure corresponding funds are added to the droplist
     fundcodelist = [f.code for f in fundtradeobj]
     if status is not None:
         for code in status.columns:
             if code == "date":
                 continue
             # r1, d2, v4 p = r+d+v
             if code in fundcodelist:
                 continue
             p = property.get(code, 0)
             round_label = p % 2
             dividend_label = ((p - round_label) / 2) % 2
             value_label = ((p - round_label - dividend_label) / 4) % 2
             try:
                 fundtradeobj.append(
                     trade(
                         fundinfo(
                             code,
                             round_label=round_label,
                             dividend_label=dividend_label,
                             fetch=fetch,
                             save=save,
                             path=path,
                             form=form,
                         ),
                         status,
                     ))
             except FundTypeError:
                 fundtradeobj.append(
                     trade(
                         mfundinfo(
                             code,
                             round_label=round_label,
                             value_label=value_label,
                             fetch=fetch,
                             save=save,
                             path=path,
                             form=form,
                         ),
                         status,
                     ))
         if istatus is not None:
             self.is_in = True
             if isinstance(istatus, irecord):
                 istatus = istatus.status
             for code in istatus.code.unique():
                 if code not in fundcodelist and not code.startswith("#"):
                     fundtradeobj.append(itrade(code, istatus))
     self.fundtradeobj = tuple(fundtradeobj)
     self.totcftable = self._mergecftb()