Sometime ago, I wrote an article on how to download stocks market data for free using Alpaca, a trading broker and API. I published this article because I had worked on projects that needed stocks market data before and I realized that finding these data for free is very hard. However, having these data is not enough to test trading algorithms, whether traditional or AI/ML-based. To do this, you still need to implement a testing or simulation environment that integrates these data.

In this post, I introduce the Trading Market Simulator (TMS): a simple simulator I have developed to get data from Alpaca and simulate a stream of live market data, so you can test your trading strategies on data from any day of your choice in no time.

Trading Market Simulator (TMS)

TMS is a Python module that not only simulates the market but also a broker, so you can manage multiple accounts, opening and closing positions to test your trading strategies and algorithms. With TMS you can simulate long and short positions, customizing the spreads so they match with the ones used by your preferred broker. TMS uses data from Alpaca Broker, so you can simulate trades on U.S. stocks as long as they are included in Alpaca.

With TMS you can:

  • Automatically download market data for any U.S. stock of your choice (as long as it is included in Alpaca)
  • Simulate a stream of live market data for any day with a 1 minute granularity
  • Test your trading algorithms and strategies in a simple environment, but as close as possible to the real environment on Alpaca so you can simply copy-paste your code between TMS and Alpaca
  • Customize spreads for broker: you can simulate different spreads depending on the broker you want to use (more customizations such as commissions will come soon)

TMS is open-source software (MIT License) and its published on Github, so you can utilize it in any project you like and modify it for your needs. Note that TMS is not associated to Alpaca in any way.

#data-science #investing #trading #programming #finance

Introducing TMS: a Trading Market Simulator
2.10 GEEK