def __init__(self, *fundtradeobj, status=None, fetch=False, save=False, path="", form="csv", totmoney=100000, cashobj=None): super().__init__(*fundtradeobj, status=status, fetch=fetch, save=save, path=path, form=form) if cashobj is None: cashobj = cashinfo() self.totmoney = totmoney nst = mulfix._vcash(totmoney, self.totcftable, cashobj) cashtrade = trade(cashobj, nst) # super().__init__(*self.fundtradeobj, cashtrade) self.fundtradeobj = list(self.fundtradeobj) self.fundtradeobj.append(cashtrade) self.fundtradeobj = tuple(self.fundtradeobj) btnk = bottleneck(self.totcftable) if btnk > totmoney: raise TradeBehaviorError("the initial total cash is too low") self.totcftable = pd.DataFrame(data={ "date": [nst.iloc[0].date], "cash": [-totmoney] })
def get_current_mulfix(self, totmoney=None): """ get ``xa.mulfix`` of the whole setup :return: """ if self.trades: if totmoney is None: totmoney = self.totmoney return mulfix(*[v for _, v in self.trades.items()], totmoney=totmoney, cashobj=cashinfo(start=self.start)) else: return
def __init__(self, *fundtradeobj, status=None, fetch=False, save=False, path='', form='csv', totmoney=100000, cashobj=None): super().__init__(*fundtradeobj, status=status, fetch=fetch, save=save, path=path, form=form) if cashobj is None: cashobj = cashinfo() self.totmoney = totmoney nst = mulfix._vcash(totmoney, self.totcftable, cashobj) cashtrade = trade(cashobj, nst) # super().__init__(*self.fundtradeobj, cashtrade) self.fundtradeobj = list(self.fundtradeobj) self.fundtradeobj.append(cashtrade) self.fundtradeobj = tuple(self.fundtradeobj) btnk = bottleneck(self.totcftable) if btnk > totmoney: raise Exception('the initial total cash is too low') self.totcftable = pd.DataFrame(data={'date': [nst.iloc[0].date], 'cash': [-totmoney]})