This repository contains the vectorized backtest environment of Minyma Technologies, which can be used to simulate and develop trading algorithms with an all-inclusive visualization environment.
This is our motto. There is no room for errors. Check every single line of code you write to see and be 100% sure that it does what it needs to do. - Tamás
Save coverage report to html file: pytest --cov-report html --cov=minyma_backtest tests. Then open 'htmlcov/index.html'
Copy and paste the following lines in the working directory to build and install the environment. Python 3.9 or 3.10 is required to run this framework.
bash start_dev.sh
pip install -r requirements.txt
sudo bash setup.shpip install -r requirements.txt
setup.batThe whole motivation behind the development of this library is making trading strategy development simple and exciting by ensuring the possibility to freely use any kind of quantitative tool for trading.
First we have to import the necessary packages from our framework.
from minyma_backtest.strategy import Strategy
from minyma_backtest.data import Data
from minyma_backtest.procdata import ProcData
from minyma_backtest.quick_backtest import QuickBacktest
from minyma_backtest.analysis import AnalysisNext we can define a strategy that is inherited from the Strategy class. This class contains a predefined interface, every implemented strategy should follow this. In this example we build a simple moving average crossover-based trading strategy.
class ExampleStrategy(Strategy):
def declare_vals(self):
self.indic_fast = "MA_8" # fast moving average
self.indic_slow = "MA_98" # slow moving average
# prev_fast, prev_slow, act_slow, act_fast variable
# initialization happens automatically and is performed by the
def logic(self, row):
# if the indicator is in the dataset
if self.prev_fast:
# check if the fast moving average crosses from below
if self.prev_fast < self.prev_slow and self.act_fast > self.act_slow:
self.buy(row)
# check if it crosses from above
elif self.prev_fast >= self.prev_slow and self.act_fast <= self.act_slow:
self.sell(row)As a last step we have to read the dataset and add our strategy to the simulation engine.
# this variable will contain a cleaned dataset with no missing dates or values
# parameters: dataset name, path to CSV
processed_data = ProcData("BTCUSDT", "./examples/BTCUSDT_1H.csv")
# define our common dataset variable
# parameters: start date, end date
data = Data("2018-01-01", "2020-12-31")
data.add(processed_data)
# parameters: name, share, trade amount, leverage, stop loss, take profit, commission %
strategy = ExampleStrategy("BTCUSDT_1H_STRAT", 1, 0.9, 1, 0, 0, 0.05)
# define and start the simulation engine
engine = Engine(data, balance=10000)
engine.add_strategy(strategy)
engine.run()
# render a simple analysis dashboard
engine.summary(title="Example Strategy")The project has been made public and open source on 29, September 2025.