{"id":24496842,"url":"https://github.com/10mohi6/bybit-backtest-python","last_synced_at":"2025-07-21T12:36:26.774Z","repository":{"id":57416728,"uuid":"306942832","full_name":"10mohi6/bybit-backtest-python","owner":"10mohi6","description":"bybit-backtest is a python library for backtest with bybit fx trade on Python 3.7 and above.","archived":false,"fork":false,"pushed_at":"2021-04-01T06:49:17.000Z","size":50,"stargazers_count":10,"open_issues_count":1,"forks_count":4,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-14T04:14:16.656Z","etag":null,"topics":["backtest","btc","bybit","fx","python","trade","usd","usdt"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/10mohi6.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-10-24T18:06:56.000Z","updated_at":"2025-01-10T14:46:53.000Z","dependencies_parsed_at":"2022-09-26T17:11:28.568Z","dependency_job_id":null,"html_url":"https://github.com/10mohi6/bybit-backtest-python","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/10mohi6%2Fbybit-backtest-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/10mohi6%2Fbybit-backtest-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/10mohi6%2Fbybit-backtest-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/10mohi6%2Fbybit-backtest-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/10mohi6","download_url":"https://codeload.github.com/10mohi6/bybit-backtest-python/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248819408,"owners_count":21166477,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["backtest","btc","bybit","fx","python","trade","usd","usdt"],"created_at":"2025-01-21T21:19:04.967Z","updated_at":"2025-04-14T04:14:21.233Z","avatar_url":"https://github.com/10mohi6.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# bybit-backtest\n\n[![PyPI](https://img.shields.io/pypi/v/bybit-backtest)](https://pypi.org/project/bybit-backtest/)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![codecov](https://codecov.io/gh/10mohi6/bybit-backtest-python/branch/main/graph/badge.svg?token=ZFgiyy2cc2)](undefined)\n[![Build Status](https://travis-ci.com/10mohi6/bybit-backtest-python.svg?branch=main)](https://travis-ci.com/10mohi6/bybit-backtest-python)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/bybit-backtest)](https://pypi.org/project/bybit-backtest/)\n[![Downloads](https://pepy.tech/badge/bybit-backtest)](https://pepy.tech/project/bybit-backtest)\n\nbybit-backtest is a python library for backtest with bybit fx trade on Python 3.7 and above.\n\nbacktest data from [here](https://public.bybit.com/trading/)\n\n## Installation\n\n    $ pip install bybit-backtest\n\n## Usage\n\n### basic run\n```python\nfrom bybit_backtest import Backtest\n\nclass MyBacktest(Backtest):\n    def strategy(self):\n        fast_ma = self.sma(period=5)\n        slow_ma = self.sma(period=25)\n        # golden cross\n        self.sell_exit = self.buy_entry = (fast_ma \u003e slow_ma) \u0026 (\n            fast_ma.shift() \u003c= slow_ma.shift()\n        )\n        # dead cross\n        self.buy_exit = self.sell_entry = (fast_ma \u003c slow_ma) \u0026 (\n            fast_ma.shift() \u003e= slow_ma.shift()\n        )\n\nMyBacktest().run()\n```\n\n### advanced run\n```python\nfrom bybit_backtest import Backtest\n\nclass MyBacktest(Backtest):\n    def strategy(self):\n        rsi = self.rsi(period=10)\n        ema = self.ema(period=20)\n        lower = ema - (ema * 0.001)\n        upper = ema + (ema * 0.001)\n        self.buy_entry = (rsi \u003c 30) \u0026 (self.df.C \u003c lower)\n        self.sell_entry = (rsi \u003e 70) \u0026 (self.df.C \u003e upper)\n        self.sell_exit = ema \u003e self.df.C\n        self.buy_exit = ema \u003c self.df.C\n        self.qty = 0.1 # order quantity (default=0.001)\n        self.stop_loss = 50 # stop loss (default=0 stop loss none)\n        self.take_profit = 100 # take profit (default=0 take profit none)\n\nMyBacktest(\n    symbol=\"BTCUSD\", # default=BTCUSD\n    sqlite_file_name=\"backtest.sqlite3\", # (default=backtest.sqlite3)\n    from_date=\"2020-04-01\", # (default=\"\")\n    to_date=\"2020-10-25\", # (default=\"\")\n    interval=\"1T\", # 5-60S(second), 1-60T(minute), 1-24H(hour) (default=1T)\n    download_data_dir=\"data\", # download data directory (default=data)\n).run(\"backtest.png\")\n```\n```python\ntotal profit          491.800\ntotal trades        10309.000\nwin rate               65.700\nprofit factor           1.047\nmaximum drawdown      135.500\nrecovery factor         3.630\nriskreward ratio        0.551\nsharpe ratio            0.020\naverage return          0.001\nstop loss            1779.000\ntake profit            93.000\n```\n![backtest.png](https://raw.githubusercontent.com/10mohi6/bybit-backtest-python/main/tests/backtest.png)\n\n\n## Supported indicators\n- Simple Moving Average 'sma'\n- Exponential Moving Average 'ema'\n- Moving Average Convergence Divergence 'macd'\n- Relative Strenght Index 'rsi'\n- Bollinger Bands 'bbands'\n- Stochastic Oscillator 'stoch'\n\n\n## Getting started\nFor help getting started with Bybit APIs and Websocket, view our online [documentation](https://bybit-exchange.github.io/docs/inverse/#t-introduction).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F10mohi6%2Fbybit-backtest-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F10mohi6%2Fbybit-backtest-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F10mohi6%2Fbybit-backtest-python/lists"}