ta4j/src/main/java/eu/verdelhan/ta4j/Trade.java
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;
    }
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;
    }
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
@param index the tick index
@param price the price
@param amount the amount
@return the order
Operates the trade at the index - th position