def addTransaction(portfolioId): data = request.get_json() ack = portfolioData.addTransaction(client, portfolioId, data[pc.ASSET_CODE], data[pc.ASSET_NAME], data[portfolioData.TXN_CASHFLOW], data[pc.TXN_QUANTITY], dtu.dateParser(data[pc.TXN_DATE]), data.get(pc.TXN_TYPE)) return webio.json(ack)
def portfolioNav(portfolioId): return webio.json(webio.ts2dict(Portfolio(portfolioId, client).nav()))
def portfolioHoldings(portfolioId): return webio.json(webio.df2dict(Portfolio(portfolioId, client).holdings()))
def removeTransaction(portfolioId, transactionId): # todo: add elif for PUT (Modify) if request.method == 'DELETE': ack = portfolioData.removeTransaction(client, portfolioId, int(transactionId)) return webio.json(ack)
def uploadTransactions(portfolioId): file = webio.getUploadedFile() failed = txnUpload.importFundTransactionsFromFile(client, portfolioId, file) return webio.json(failed)
def getFundListOnDate(navDate): return webio.json(fundData.fundList(client, dtu.dateParser(navDate)))
def getPortfolioTransactions(portfolioId): return webio.json(Portfolio(portfolioId, client).transactions())
def getClientPortfolio(clientName): return webio.json(portfolioData.getClientPortfolio(client, clientName))
def getPortfolioData(portfolioId): return webio.json(Portfolio(portfolioId, client).portfolioData())
def getFundNav(Id): return webio.json(webio.ts2dict(Fund(Id, client).nav()))
def getFundReturn(Id, window): return webio.json(webio.ts2dict(Fund(Id, client).rollingReturn(window)))
def updateFundInfo(Id): fundInfo = request.get_json() return webio.json(fundData.updateFundInfo(client, Id, fundInfo))
def enrichedFundInfo(Id): return webio.json(fundData.enrichedFundInfo(client, Id))
def getFundInfo(Id): return webio.json(Fund(Id, client).fundInfo())
def portfolioReturn(portfolioId, window): return webio.json( webio.ts2dict(Portfolio(portfolioId, client).rollingReturn(window)))
def addPortfolio(): clientName = request[pc.CLIENT_NAME].strip() portfolioName = request[pc.PORTFOLIO_NAME].strip() portfolioId = portfolioData.addPortfolio(client, clientName, portfolioName) return webio.json(portfolioId)
def portfolioReturnStats(portfolioId): return webio.json(Portfolio(portfolioId, client).returnStats())
def getFundList(): return webio.json(fundData.fundList(client))