nl_tokens: Runs the provided strategy over the managed series ( from startIndex to finishIndex ) . <p >
pl_tokens: public TradingRecord run ( Strategy strategy , OrderType orderType , Decimal amount , int startIndex , int finishIndex ) { int runBeginIndex = Math . <mask> ( startIndex , timeSeries . getBeginIndex ( ) ) ; int runEndIndex = Math . min ( finishIndex , timeSeries . getEndIndex ( ) ) ; log . trace ( "Running strategy (indexes: {} -> {}): {} (starting with {})" , runBeginIndex , runEndIndex , strategy , orderType ) ; TradingRecord tradingRecord = new BaseTradingRecord ( orderType ) ; for ( int i = runBeginIndex ; i <= runEndIndex ; i ++ ) { // For each tick between both indexes...        if ( strategy . shouldOperate ( i , tradingRecord ) ) { tradingRecord . operate ( i , timeSeries . getTick ( i ) . getClosePrice ( ) , amount ) ; } } if ( ! tradingRecord . isClosed ( ) ) { // If the last trade is still opened, we search out of the run end index. // May works if the end index for this run was inferior to the actual number of ticks int seriesMaxSize = Math . max ( timeSeries . getEndIndex ( ) + 1 , timeSeries . getTickData ( ) . size ( ) ) ; for ( int i = runEndIndex + 1 ; i < seriesMaxSize ; i ++ ) { // For each tick after the end index of this run... // --> Trying to close the last trade if ( strategy . shouldOperate ( i , tradingRecord ) ) { tradingRecord . operate ( i , timeSeries . getTick ( i ) . getClosePrice ( ) , amount ) ; break ; } } } return tradingRecord ; }