filled_position.py 文件源码

python
阅读 33 收藏 0 点赞 0 评论 0

项目:Odin 作者: JamesBrofos 项目源码 文件源码
def update_market_value(self, price):
        """Compute the current marke value of the position. This is the current
        price multiplied by the direction of the trade (r2epresented by the sign
        of the net number of shares bought and sold). The function also updated
        the unrealized and realized profits and losses.
        """
        # Compute the mean of the bid and ask price to compute the assumed value
        # of the position.
        #
        # N.B. That the market value is akin to the amount of cash that is would
        # be injected into the portfolio if the position were liquidated. This
        # means that if a position is short, then a negative amount will be
        # injected (i.e. paid out). On the other hand, the current value is the
        # profit-and-loss on a position relative to the cost basis.
        self.market_value = self.net * price
        self.unrealized_pnl = self.market_value - self.cost_basis
        self.realized_pnl = self.market_value + self.net_tot_incl_comm
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号