@check_is_trading
@export_as_api
@ExecutionContext.enforce_phase(EXECUTION_PHASE.HANDLE_BAR, EXECUTION_PHASE.SCHEDULED)
def order_value(id_or_ins, cash_amount, style=None):
 order_book_id = assure_order_book_id(id_or_ins)
 bar_dict = ExecutionContext.get_current_bar_dict()
 price = bar_dict[order_book_id].close
 round_lot = int(get_data_proxy().instrument(order_book_id).round_lot)
 amount = (((cash_amount // price) // round_lot) * round_lot)
 position = get_simu_exchange().account.portfolio.positions[order_book_id]
 if (amount < 0):
  if (abs(amount) > position.sellable):
   amount = (- position.sellable)
 return order_shares(order_book_id, amount, style)

@ check_is_trading @ export_as_api @ ExecutionContext . enforce_phase ( EXECUTION_PHASE . HANDLE_BAR , EXECUTION_PHASE . SCHEDULED ) def order_value ( id_or_ins , cash_amount , style = None ) : order_book_id = assure_order_book_id ( id_or_ins ) bar_dict = ExecutionContext . get_current_bar_dict ( ) price = bar_dict [ order_book_id ] . close round_lot = int ( get_data_proxy ( ) . instrument ( order_book_id ) . round_lot ) amount = ( ( ( cash_amount // price ) // round_lot ) * round_lot ) position = get_simu_exchange ( ) . account . portfolio . positions [ order_book_id ] if ( amount < 0 ) : if ( abs ( amount ) > position . sellable ) : amount = ( - position . sellable ) return order_shares ( order_book_id , amount , style )
place an order by specified value amount rather than specific number of shares/lots .