{"id":24496845,"url":"https://github.com/10mohi6/oanda-backtest-python","last_synced_at":"2025-10-19T08:26:09.473Z","repository":{"id":35163651,"uuid":"214610230","full_name":"10mohi6/oanda-backtest-python","owner":"10mohi6","description":"oanda-backtest is a python library for backtest with oanda fx trade rest api on Python 3.6 and above.","archived":false,"fork":false,"pushed_at":"2022-12-08T07:43:36.000Z","size":391,"stargazers_count":14,"open_issues_count":5,"forks_count":8,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-18T16:51:52.593Z","etag":null,"topics":["api","backtest","fx","oanda","python","trade"],"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":"2019-10-12T08:34:34.000Z","updated_at":"2025-02-18T23:08:56.000Z","dependencies_parsed_at":"2023-01-15T15:05:59.119Z","dependency_job_id":null,"html_url":"https://github.com/10mohi6/oanda-backtest-python","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/10mohi6/oanda-backtest-python","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/10mohi6%2Foanda-backtest-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/10mohi6%2Foanda-backtest-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/10mohi6%2Foanda-backtest-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/10mohi6%2Foanda-backtest-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/10mohi6","download_url":"https://codeload.github.com/10mohi6/oanda-backtest-python/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/10mohi6%2Foanda-backtest-python/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260876222,"owners_count":23075923,"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":["api","backtest","fx","oanda","python","trade"],"created_at":"2025-01-21T21:19:05.558Z","updated_at":"2025-10-19T08:26:04.429Z","avatar_url":"https://github.com/10mohi6.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# oanda-backtest\n\n[![PyPI](https://img.shields.io/pypi/v/oanda-backtest)](https://pypi.org/project/oanda-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/oanda-backtest-python/branch/master/graph/badge.svg)](https://codecov.io/gh/10mohi6/oanda-backtest-python)\n[![Build Status](https://travis-ci.com/10mohi6/oanda-backtest-python.svg?branch=master)](https://travis-ci.com/10mohi6/oanda-backtest-python)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/oanda-backtest)](https://pypi.org/project/oanda-backtest/)\n[![Downloads](https://pepy.tech/badge/oanda-backtest)](https://pepy.tech/project/oanda-backtest)\n\noanda-backtest is a python library for backtest with oanda fx trade rest api on Python 3.6 and above.\n\n\n## Installation\n\n    $ pip install oanda-backtest\n\n## Usage\n\n### basic\n```python\nfrom oanda_backtest import Backtest\n\nbt = Backtest(access_token='\u003cyour access token\u003e', environment='practice')\nbt.candles(\"EUR_USD\")\nfast_ma = bt.sma(period=5)\nslow_ma = bt.sma(period=25)\nbt.sell_exit = bt.buy_entry = (fast_ma \u003e slow_ma) \u0026 (fast_ma.shift() \u003c= slow_ma.shift())\nbt.buy_exit = bt.sell_entry = (fast_ma \u003c slow_ma) \u0026 (fast_ma.shift() \u003e= slow_ma.shift())\nbt.run()\nbt.plot()\n```\n\n### advanced\n```python\nfrom oanda_backtest import Backtest\n\nbt = Backtest(access_token='\u003cyour access token\u003e', environment='practice')\nfilepath='usd-jpy-h1.csv'\nif bt.exists(filepath):\n    bt.read_csv(filepath)\nelse:\n    params = {\n        \"granularity\": \"H1\",  # 1 hour candlesticks (default=S5)\n        \"count\": 5000 # 5000 candlesticks (default=500, maximum=5000)\n    }\n    bt.candles(\"USD_JPY\", params)\n    bt.to_csv(filepath)\n\nfast_ma = bt.sma(period=10)\nslow_ma = bt.sma(period=30)\nexit_ma = bt.sma(period=5)\nbt.buy_entry = (fast_ma \u003e slow_ma) \u0026 (fast_ma.shift() \u003c= slow_ma.shift())\nbt.sell_entry = (fast_ma \u003c slow_ma) \u0026 (fast_ma.shift() \u003e= slow_ma.shift())\nbt.buy_exit = (bt.C \u003c exit_ma) \u0026 (bt.C.shift() \u003e= exit_ma.shift())\nbt.sell_exit = (bt.C \u003e exit_ma) \u0026 (bt.C.shift() \u003c= exit_ma.shift())\n\nbt.initial_deposit = 100000 # default=0\nbt.units = 1000 # currency unit (default=10000)\nbt.stop_loss = 50 # stop loss pips (default=0)\nbt.take_profit = 100 # take profit pips (default=0)\n\nprint(bt.run())\nbt.plot(\"backtest.png\")\n\n```\n\n```python\ntotal profit        1989.000\ntotal trades         171.000\nwin rate              35.088\nprofit factor          1.198\nmaximum drawdown    2745.000\nrecovery factor        0.725\nriskreward ratio       2.236\nsharpe ratio           0.050\naverage return        10.666\nstop loss              5.000\ntake profit            5.000\n```\n![advanced.png](https://raw.githubusercontent.com/10mohi6/oanda-backtest-python/master/tests/advanced.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 'bband'\n- Stochastic Oscillator 'stoch'\n- Market Momentum 'mom'\n\n\n## Getting started\n\nFor help getting started with OANDA REST API, view our online [documentation](https://developer.oanda.com/rest-live-v20/introduction/).\n\n\n## Contributing\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F10mohi6%2Foanda-backtest-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F10mohi6%2Foanda-backtest-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F10mohi6%2Foanda-backtest-python/lists"}