{"id":27335061,"url":"https://github.com/trentstauff/fxbot","last_synced_at":"2025-04-12T14:46:59.970Z","repository":{"id":40955633,"uuid":"366171822","full_name":"trentstauff/FXBot","owner":"trentstauff","description":"A fully automated Forex trading bot utilizing the OANDA API.","archived":false,"fork":false,"pushed_at":"2022-06-22T04:24:06.000Z","size":98,"stargazers_count":132,"open_issues_count":21,"forks_count":43,"subscribers_count":8,"default_branch":"main","last_synced_at":"2023-11-07T18:22:53.862Z","etag":null,"topics":["algorithmic-trading","bot","finance","forex","machine-learning","oanda-api-v20","python","trading","trading-bot","trading-strategies"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/trentstauff.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-05-10T20:47:59.000Z","updated_at":"2023-10-26T01:33:20.000Z","dependencies_parsed_at":"2022-09-22T14:51:27.627Z","dependency_job_id":null,"html_url":"https://github.com/trentstauff/FXBot","commit_stats":null,"previous_names":[],"tags_count":0,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trentstauff%2FFXBot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trentstauff%2FFXBot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trentstauff%2FFXBot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trentstauff%2FFXBot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/trentstauff","download_url":"https://codeload.github.com/trentstauff/FXBot/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248585248,"owners_count":21128974,"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":["algorithmic-trading","bot","finance","forex","machine-learning","oanda-api-v20","python","trading","trading-bot","trading-strategies"],"created_at":"2025-04-12T14:46:59.295Z","updated_at":"2025-04-12T14:46:59.963Z","avatar_url":"https://github.com/trentstauff.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Codacy Badge](https://app.codacy.com/project/badge/Grade/4d81d46fe74d40ba8d405550e644a812)](https://www.codacy.com/gh/trentstauff/FXBot/dashboard?utm_source=github.com\u0026amp;utm_medium=referral\u0026amp;utm_content=trentstauff/FXBot\u0026amp;utm_campaign=Badge_Grade)\n[![PRs Welcome](https://img.shields.io/badge/PRs%20-welcome-brightgreen.svg)](#contributing)\n\n# Important: \n### This repo relies on submodules. To clone it properly, run:\n\n```\ngit clone --recurse-submodules -j8 https://github.com/trentstauff/FXBot\n```\n# FXBot\n\n![image](https://user-images.githubusercontent.com/53923200/128397947-04711cb7-0b16-4ed6-8c84-3fdacdc2fadc.png)\n\n**FXBot** is just what you guessed- a **Forex trading bot!** It's been developed in Python, enabled by the OANDA V20 API.\n\nThis trading bot allows users to **backtest** and **analyze** their favourite strategies executed on the most popular currency pairs, while also enabling users to dive straight into trading these forex pairs in **real-time, through algorithmic live trading.**\n\nAs we all know, algorithmic trading is the **future of finance**. When looking at the top trading firms in the world, all of them are making a shift towards automated trading, and are investing heavily in the space. The ones who don't automate, are at risk of falling behind their competitors!\n\nThat's what inspired me to make this bot, and to expose to the public how really anyone this day and age can jump headfirst into the algorithmic trading world.\n\n## Disclaimer\n\nBefore downloading and using this bot, please make sure to understand the following:\n\nThrough OANDA, you do NOT need to trade real money, and the same is true with respect to using this bot. OANDA offers practice accounts, which this bot is **highly recommended** to utilize.\n\nIf you do decide to trade real money, this disclaimer is for you.\n\n### Understand the Risk\nTrading Forex involves a risk of loss. Please consider carefully if such trading is appropriate for you. Past performance is not indicative of future results. FXBot has been created solely for educational purposes only and its calculations do not constitute investment recommendations or advice, and it is strongly recommended that you **use this bot as a learning tool.**\n\nIf you are to trade using this bot, understand that algorithmic trading involves a high level of risk and is not appropriate for everyone. No guarantee is being made that by using this bot, the algorithmic trading strategies will result in profitable trading or be free of risk of loss. There is a possibility that you could lose some or all of your investment.\n\n## What FXBot Can Do For You\n\nWhen you first run FXBot, you will be prompted to enter the following:\n\n1) The currency pair you would like to analyze/trade\n2) Whether to conduct backtesting or live trading on said currency pair\n\n![image](https://user-images.githubusercontent.com/53923200/128404575-c66b07cc-fc77-4d28-8d35-58d7ae2d120c.png)\n\n### Backtesting\n\nBacktesting is a method for seeing how well a strategy would have performed on historical data. This powerful technique can gather a lot of important information about the strategy- such as when is the best time for the strategy to operate, which currency pairs it should execute on, and much more. \nIf the strategy performs well during backtesting, then individuals can look into putting the strategy into a production environment and try to beat the market.\n\nFXBot enables users to backtest their strategies, alongside giving flexibility and customization surrounding the parameters passed to the backtester.\n\nWhen running the backtesting section of the bot, users will be prompted to specify the following:\n\n1) The strategy to backtest\n2) The date range the backtest should occur over\n3) Whether the strategy should consider trading costs\n4) The granularity for the backtest session (IE how often should the bot analyze the data and consider positions)?\n5) Values unique to the strategy (if these values are with respect to time, such as moving averages, the time unit is the same as your specified granularity)\n\nNote: **For Backtesting,** here are the accepted granularity values you can choose from. You must enter a choice from this list. **For live trading,** please follow the on screen prompts to enter something along the lines of \"1hr\" or \"30s\".\n![image](https://user-images.githubusercontent.com/53923200/148832211-edd63f5a-8ca5-4d58-8325-661e0e71ebc2.png)\n\n\n![image](https://user-images.githubusercontent.com/53923200/128403680-72bfc834-aa76-4f1f-a1a0-295f24c9ebcf.png)\n\nAfter entering this, the bot will go ahead and conduct the backtesting.\n\nNot only will it test the user's specified parameter choices onto the currency pair, but the bot will also find the most **optimal** parameter values for that time period that allows for the highest ROI. This optimization gives critical information that can be further analyzed by the user to find the best values for their trading situation.\n\nFinally, the bot will plot the results so that the user can tangibly see the performance of the strategy.\n\n### Live Trading\n\nOnce you believe you have found a good strategy and have optimized its unique parameters, you can jump into live trading.\n\nLive trading is exactly how it sounds, it utilizes algorithmic, event-driven trading that allows the user to execute the strategy on data as it happens in real-time. \nThis is where you can realize the full potential of your strategy and see how it performs against the market.\n\nWhen running the live trading section of the bot, users will be prompted to specify the following:\n\n1) The strategy to backtest\n2) The date range the backtest should occur over\n3) The granularity for the trading session (IE how often should the bot analyze the data and consider positions)?\n4) The number of units to trade with (IE the size you want your positions to be)\n5) OPTIONAL: A \"stop profit\" to halt trading if you reach\n6) OPTIONAL: A \"stop-loss\" to halt trading if you go below\n7) Values unique to the strategy (if these values are with respect to time, such as moving averages, the time unit is the same as your specified granularity)\n\n![image](https://user-images.githubusercontent.com/53923200/128405363-900d8ddb-6b43-4dae-bfdf-7fdfbe1b4007.png)\n\nOnce the bot is set up and ready to trade, the trading stream will open. For the duration of the session, the console will continuously output each \"tick\" of data that is being streamed back to the bot, which contains the time of the tick, the bid price, and the ask price.\n\nEvery \"granularity\", the bot will analyze the current market and determine if it should open, close, modify, or hold a position, which is based on the underlying strategy.\n\n![image](https://user-images.githubusercontent.com/53923200/128405765-15760e5f-1807-42a5-997a-06d975a5ea1f.png)\n\nIf any of the stop thresholds have been crossed, or if the user terminates the session, the bot will automatically exit all of its current positions, and the console will default back to the start, where the user can start over.\n\n![image](https://user-images.githubusercontent.com/53923200/128405987-c60bbea3-7c1c-4cae-8b5f-c5e0dab8fea4.png)\n\n\n## Current Strategies\n\n- SMA https://www.google.com/search?q=sma+strategy\u0026oq=SMA+strategy\u0026aqs=chrome.0.0i512j0i67j0i512l2j0i22i30l6.1680j0j7\u0026sourceid=chrome\u0026ie=UTF-8\n- Bollinger Bands https://www.investopedia.com/trading/using-bollinger-bands-to-gauge-trends/\n- Contrarian https://www.investopedia.com/terms/c/contrarian.asp\n- Momentum https://www.investopedia.com/terms/m/momentum_investing.asp\n- Machine Learning Classification Analysis\n- Machine Learning Regression Analysis\n- And much more to come!\n\n## How to Setup FXBot\n\nYou can start off by cloning the repo by running `git clone --recurse-submodules -j8 https://github.com/trentstauff/FXBot`\n\n### Requirements\n\nFirst, you need to have at least a practice account with Oanda (https://oanda.com/). Once logged in, you must create an API token and copy your account number. \n\n#### API Token\n![image](https://user-images.githubusercontent.com/53923200/128407124-08f22bff-a82e-4c47-b150-a3f743e7a38b.png)\n\nThis green button will say \"Generate\". Click it, and copy the API Token.\n![image](https://user-images.githubusercontent.com/53923200/128407767-7e8e738a-2a88-42c1-9744-273b31f63dfc.png)\n\nNavigate back to your account, so you can get your account number.\n![image](https://user-images.githubusercontent.com/53923200/128407881-538e26ac-6e17-46b8-a07b-ce025d4cf527.png)\n\n#### Account Number\n\nClick \"Add Account\".\n![image](https://user-images.githubusercontent.com/53923200/128408490-e0aa2fe3-daac-4f04-8301-0654b9993f37.png)\n\nMake an account.\n**Make sure to select 'v20 fxTrade'**\n![image](https://user-images.githubusercontent.com/53923200/128408746-e17439b8-e97b-4513-9691-c23643040552.png)\n\nOnce you have made an account, grab your account number.\n![image](https://user-images.githubusercontent.com/53923200/128408956-b9bc4f3f-a939-4945-b3a5-2b6736d75548.png)\n\n**Now that you have an OANDA account and these values, you'll need to store them for the bot to use.**\n\nThese values need to be put into a configuration file, with the name `oanda.cfg`, as follows:\n\n(You can make it a .txt file first, type the data, and then rename the file to .cfg)\n\n    [oanda]\n    account_id = XYZ-ABC-...\n    access_token = ZYXCAB...\n    account_type = practice (default) or live\n\n**Place the oanda.cfg file into the same directory as the main.py file in the cloned repository folder.**\n\nAfter cloning the repo, run `pip install -r requirements.txt` to get the required packages.\n\n### Running the application\n\nAfter installing the requirements, open a command prompt and you can start up the program by typing `python main.py` (python3 on Linux, if applicable) while in its directory.\n\n### Thats all! I hope that this bot helps you to see how awesome algorithmic trading can be. \n### If you need any help setting things up, feel free to email me at tstauffe@uwaterloo.ca\n### Have a good one!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrentstauff%2Ffxbot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftrentstauff%2Ffxbot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrentstauff%2Ffxbot/lists"}