SmartBots: Backtesting is only the tip of the iceberg.

SmartLever
4 min readJan 24, 2023

--

There are numerous libraries that test a trading strategy or system. None of them are able to complete the circle and move from testing to real-time implementation. They don’t do it because it’s not their job. A testing library is only one of the components required to create a working portfolio of strategies; additional components from various technologies must be brought together. This is not a problem for hedge funds and other quantitative funds, which can easily hire talent, but for a single person, the range of knowledge and technologies required expands significantly. SmartBots fills this void with a platform that connects the dots of various technologies and orchestrates them in a synchronized way so that we can go from idea to real-time implementation in a tenth of the time it would normally take.

You will be able to complete a backtesting strategy like this at the end of this article.

An end-to-end Platform.

  • Data Feed: Services that connect to real-time data and feed the strategy portfolio.
  • Historical Data: Download historical data for research and testing purposes.
  • DataBase: Database to store everything and access it at any time.
  • Broker: Trading connections to any broker.
  • Portfolio: Strategies that we combine with one another and between assets to control the profit-risk binomial.
  • ETLs: Processes for downloading daily data and training models.
  • Dashboards: Monitors that provide us with information about our models’ behavior.
  • Backtesting: Library to simulate the portfolio with historical data.
  • Alert-system: Real-time alert system. Do we want to know when an operation is completed or if a service is unavailable due to an unforeseen event?
  • Event-driven: Event-driven architecture, it is similar to a video game in which the character moves and triggers events that cause reactions from other characters or the appearance of new scenarios; in this case, we model and generate buy and sell signals based on the events that come to us from various data sources. To make them a reality, we must orchestrate a number of necessary components.
  • Statistical-edge: Most importantly, there is little we can do without a mathematical edge of the model we want to implement.

Any type of asset.

Because of the event-driven architecture, we can create bots that can operate in any financial market, cryptocurrency, or sports betting. Any asset type is welcome. In other words, we have a vehicle that can handle any terrain.

A backtesting from 0.

Even if you have no idea what Docker or Git are, I encourage you to install them and try to get to the end of the process. They are must-have programs, and we can learn what they are for later.

  1. At least 8 GB of RAM and 100 GB of storage are required. Some possibilities:
  • Cloud server: If we want to leave the model running in real time, this is the best option.

Paid option: https://www.digitalocean.com/ , https://aws.amazon.com/

Always a free option, at first I thought it was a waxed cat, but I’ve been using it for more than three months and it’s still working and free, here’s the manual I used: https://levelup.gitconnected.com/a-powerful-server-from-oracle-cloud-always-free-cbc73d9fbfee

  • Local computer: If we want to use our own idle, such as Pycharm or Visual Studio, this is the best option.

2. Install Git, if we don’t already have it.

3. Install Docker-Compose, If we don’t already have it

4. Clone the project.

5. Navigate to the project folder:

cd SmartBots/

6. Navigate to the docker folder

cd docker/
docker compose -f docker-compose_basic.yml --env-file ./compose.env up -d

Allow a few minutes for everything to download and run.

7. Welcome to SmartBots! The basic services will be available to you:

  • portainer (Need to log in): Service to manage the containers. Enter your server ip:9000 into your browser (localhost:9000). You will enter Docker Portainer, create a password, and be inside.
  • mongodb (No action required): Mongo database.
  • rabbitmq (No action required): Messaging service.
  • event_keeper (No action required): Event keeper service.
  • jupyterlab (Necessary to enter after Portainer): Service to manage the code. To obtain the token in the container docker, locate the jupyterlab container, navigate to logs, and copy the token that appears in the console.

Go to your server ip:4444 and copy the token there.

8. Example of Backtesting a Strategy: In Jupyter Lab, navigate to src/application/bots/backtesting.ipynb and run the code and enjoy¡.

Subscribe to all our news here.

The train is in the station and you can’t miss it, so join us on this journey. We are an open community and if you want to collaborate with us, please send us an email: andres@smartlever.tech

--

--