It is a critical challenge in financial time series analysis to reduce noise and forecast future stock prices. In this paper, we propose Opemod, an optimal performing selection model to predict and adaptively select prediction modes based on performance. Opemod is designed with three parts: two-ends extension mode decomposition (TEEMD) algorithm, attention based encoder and decoder (AED) model, and optimal performing selection (OPS) algorithm. Firstly, we propose TEEMD algorithm to restrain the end effect of sequence decomposition by differently extending and truncating both two ends of the sequence, and the original financial time series are decomposed into intrinsic mode functions (IMFs) more accuracy by TEEMD. Secondly, we design a novel encoding and decoding model based on both LSTM and multi-head attention mechanism (AED) to capture both long-term and short-term dependence information. Thus the trends of IMFs can be predicted separately. Finally, after the processes of decomposition and prediction, OPS is used to select modes with the best performance. Extensive experiments have been carried out on CSI 300 index and Dow Jones index (DJI) datasets, and the results show that Opemod can get better investment return than other state-of-the-art methods.