Stock market prediction is considered as an important yet challenging aspect of financial analysis. The difficulty of forecasting arises from volatile and non-linear nature of stock market, which is affected by varied uncertain factors, ranging from financial ratios to macroeconomic indicators. Recent advances in machine learning, particularly ensembles, have made it possible for academic researchers and financial practitioners to forecast the stock market more efficiently. The novelty of this work is to evaluate how stock return in an oil-dependent country (i.e., Iran), which has been facing stagflation for a long time due to economic and political issues, is affected by fundamental and macroeconomic indicators. Our main objectives are to (1) find the most important fundamental and macroeconomic indicators that control the stock returns of companies listed on the Tehran Stock Exchange (TSE); (2) compare the performance of newly developed bagging- and boosting-based ensembles in predicting annual real stock returns of the TSE; and (3) develop multiclass classification models to forecast stock returns. Prior studies mainly focused on developing binary classification models, which simply predict whether stock returns will be positive or negative in the future. We, however, design multiclass classification models to provide more information for the investors and reduce the uncertainties associated with the prediction. To this end, we first provide a comprehensive list of 57 potential features affecting the stock returns. Next, the data are carefully preprocessed and fed to 14 different bagging- and boosting-based ensembles (e.g., Random Forest, LightGBM, XGBoost, Extra-Trees, AdaBoost, CatBoost) to predict the stock returns. The performance of ensembles is evaluated through different measures (e.g., accuracy, F-score, G-mean). We then propose a novel feature selection method to identify the most contributing features to the stock returns. Our proposed model identifies nearly 65% of 57 original features as redundancy, resulting in 20 most significant features. The selected features are fed to the mentioned ensembles to re-predict the stock returns. Finally, the performance of stock returns forecasts with and without selected features is compared. To design the ensembles, we employ the data from listed companies on the TSE for a 15-year period, spanning between 2005 to 2020. Results suggest that boosting ensembles, in general, outperform bagging-based methods. Among the boosting ensembles, XGBoost and AdaBoost provide the best and worst predictive performance, respectively. Among the bagging-like ensembles, Rotation Forest is the most accurate one, whereas Random Patches performs the worst. Further, our proposed feature selection approach effectively identifies the most representative features for stock returns prediction and can be used as a reliable framework for future investment decisions.