我想对这个关系进行检查,以确保所有票的权重总和为100。
class PortfolioTicker(models.Model):
"""
Helper model for M2M relationship between Tickers and Portfolios
"""
portfolio = models.ForeignKey(Portfolio, models.PROTECT, related_name="tickers")
ticker = models.ForeignKey(Ticker, models.PROTECT)
weight = models.FloatField(null=False)
def __str__(self) -> str:
return f"{self.portfolio} {self.ticker} {self.weight}"
1条答案
按热度按时间k4emjkb11#
如果要为每个滚动条生成报表:
如果要检查给定的股票代码