Order_target_percent() using portfolio_value


I think order_target_percent() should not be using portfolio_value for the calculations, here is an example:

  1. initialize - portfolio_value 100 BTC.
  2. handle - Time is 01:00. Run order_target_value(symbol('ltc_btc'), 1.0).
  3. handle - Time is 02:00, Litecoin price went up by 10%. Run order_target_value(symbol('ltc_btc'), 1.0).

Because portfolio_value is now 110 BTC, it will try buying more LTC.
However, there is no actual BTC to buy this extra LTC because the position is still open.

Instead of using portfolio_value, it should use something that indicates how many BTC (or quote_currency) you currently have left.

What are your thoughts?