Skip to content

cp5_basic_mean_reversion.py #10

@liqinglin54951

Description

@liqinglin54951

mark the remaining position to market i.e. pnl would be what it would be if we closed at current price

author line 106 : open_pnl += abs(sell_sum_qty - position) * (close_price - buy_sum_price_qty / buy_sum_qty)

should be corrected since:

position -= NUM_SHARES_PER_TRADE # reduce position by the size of this trade
sell_sum_qty += NUM_SHARES_PER_TRADE
so the remaining position : abs(position)
Line 106 : open_pnl += abs(position) * (close_price - buy_sum_price_qty / buy_sum_qty)
and the author line 111 : open_pnl += abs(buy_sum_qty - position) * (sell_sum_price_qty/sell_sum_qty - close_price)
also need to be corrected:
Line 111 : open_pnl += abs(buy_sum_qty - position) * (sell_sum_price_qty/sell_sum_qty - close_price)

Note: abs(position) = abs(buy_sum_qty-sell_sum_qty)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions