I cannot speak to the contemporary situation concerning the Catholic Church’s teaching on speculation, but the history of it has been chronicled by the economist, Murray Rothbard, in his book “Economic Thought Before Adam Smith.”
https://www.mises.org/library/austrian-perspective-history-economic-thought
Rothbard shows how the scholars of the Catholic Church moderated and eventually overcame the restrictions placed on speculative gain initiated under Charlemagne. He cites Rufinus in his Summa (1157-59) of Gratian’s Decretum as the first scholar to justify arbitrage gain or profit from speculation coupled with the labor and expense of the lay merchant (p. 38). He did so on the same grounds as he justified profit to artisans as a result of their labor and expenses.
As Rothbard points out, Thomas Aquinas explicitly justified uncertainty of the future as a source of gain for a merchant (pp. 53-54).
The Late Scholastics tended to be even more favorable toward merchant activity. For example, Rothbard cites Thomas Cajetan in his treatise on foreign exchange, De Cambiis (1499), as the founder of expectations theory in economics (pp. 100-101).