public Order operate ( int index , Decimal price , Decimal amount ) { Order order = null ; if ( isNew ( ) ) { order = new Order ( index , startingType , price , amount ) ; entry = order ; } else if ( isOpened ( ) ) { if ( index < entry . getIndex ( ) ) { throw new IllegalStateException ( "The index i is less than the entryOrder index" ) ; } order = new Order ( index , startingType . complementType ( ) , price , amount ) ; exit = order ; } return order ; }
Operates the trade at the index - th position