{"id":22647756,"url":"https://github.com/davidhintelmann/oanda-rest-v20","last_synced_at":"2025-03-29T06:48:14.919Z","repository":{"id":156030361,"uuid":"120154878","full_name":"davidhintelmann/Oanda-REST-V20","owner":"davidhintelmann","description":"Oanda's V20 REST API example usage","archived":false,"fork":false,"pushed_at":"2020-09-29T21:24:24.000Z","size":35,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-02-03T20:03:19.766Z","etag":null,"topics":["forex","indices","metals","oanda","oanda-api-v20","python","rest-api","restful"],"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/davidhintelmann.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-02-04T04:34:04.000Z","updated_at":"2024-09-10T05:39:33.000Z","dependencies_parsed_at":null,"dependency_job_id":"283faa47-54fd-4815-a906-ac5977acd1cf","html_url":"https://github.com/davidhintelmann/Oanda-REST-V20","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/davidhintelmann%2FOanda-REST-V20","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidhintelmann%2FOanda-REST-V20/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidhintelmann%2FOanda-REST-V20/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidhintelmann%2FOanda-REST-V20/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/davidhintelmann","download_url":"https://codeload.github.com/davidhintelmann/Oanda-REST-V20/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246150409,"owners_count":20731419,"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":["forex","indices","metals","oanda","oanda-api-v20","python","rest-api","restful"],"created_at":"2024-12-09T07:34:30.848Z","updated_at":"2025-03-29T06:48:14.900Z","avatar_url":"https://github.com/davidhintelmann.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Oanda REST API example\nThis folder has two small apps developed for interfacing with [Oandas](http://developer.oanda.com) REST API.\n Specifically using Oandas V-20 REST API.  \n \nOanda-first only has downloading historical data prices for 'EUR_USD' FOREX prices, and scaling two different currencies.  \nWhile Oanda-Event is an intro to an event driven software for streaming live prices from Oanda\nas well building on what was learned from Oanda-first to begin data collection for backtesting.\nInspiration for the event driven software written in python comes from [Quant Start](https://www.quantstart.com/articles/Forex-Trading-Diary-1-Automated-Forex-Trading-with-the-OANDA-API).  \n**Warning, this is for educational purposes only.**\n\nDependencies       \t| Version          |\n--------------------|------------------|\nPython \t\t\t\t| 3.6.4   \t\t  \t|\nglob2\t\t\t       | 0.5     \t      |\nmatplotlib \t\t\t| 2.1.0\t\t\t  \t|\nnumpy \t\t\t\t\t| 1.13.3 \t\t\t\t|\npandas \t\t\t\t| 0.22.0   \t\t\t| \n\n## Oanda-first\u003cbr\u003e\nThis folder contains a means to look at past FOREX prices, and compare them.  \n\n### Functions in OHLC.py \nGrabToken() will grab users API token from res folder.  \nReturns token as string.  \n\n```\nGrabToken(path=token_path)\n```\nGrabCandles() requires 6 parameters and returns 12 values.  \nParameter gran is granularity or frequency of tick data (OHLC data).   \nReturns instru, time, volume, bid OHLCs, ask OHLCs, ticks as numpy arrays. \n\n```\nGrabCandles(token, instru, start, gran, based, count=1000)\n```\n### Function in GrabAll.py  \nGrabAllCandles() grabs different prices at a time from 'EUR' currency  \nReturns only instru and ask close as numpy arrays.\n\n```\nGrabAll()\n```  \n\n### Function in NormCur.py  \nNormCur() requires Bid close (s for scale and n for normalize).  \nThis is an ad hoc way to scale Currencies with vastly different prices to be \"on top\" on one another.  \nReturns normalized or scaled prices as numpy array.\n\n\n```\nNormCur(BCn, BCs)\n```\nNow use matplotlib.pyplot to plot simple line graphs to see if you plot the same data as Oanda shows in their downloadable app.  \nThis will show you are connecting with their API correctly.  \n\n## Oanda-Event\u003cbr\u003e  \nThis folder contains event driven software to stream live tick feed data.  \nThere has been plenty learned from (Oanda-first) which is to be implemented in the Backtest folder. \n\n### enivro.py\nThe python file one would edit when switching from demo mode (monopoly money) to a live brokerage account, see more at Oandas API website. There are two functions to either GrabToken() or GrabID() which will grab the users info from the res folder (needs to be edited with ones own API key from [Oanda](https://developer.oanda.com/rest-live-v20/introduction/)\n\n### events.py\nA simple python script only has two classes since this is a very simple event driven progrom with only two events. The first event is TickEvent class and the other is OrderEvent class. When ever new OHLC data is downloaded, from steam.py, this new data will be queued as a new event for the program. The other type of event is OrderEvent which happens when ever strategy.py script conditions are met.\n\n### strategytest.py\nThis is the brains of the program and unfortuntely only has a very simple script as this event driven python program will not produce a profit, this is for educational purposes only!\n\n### steam.py\nThis file is used to request an http session with [Oanda](https://developer.oanda.com/rest-live-v20/account-ep/) endpoints.\n\n### trading.py\nThe heart of the program will be executed with this script. All events processed with this file and functions are imported, from files above, to download and execute trades on a live demo account (can be upgraded to a live brokerage account but this is outside the scope of this repo). \n \n### Backtest folder \n#### Functions in downloadOHLC.py  \nGrabHistoryPrice() is a class that requires 4 parameters to initialize and one optional parameter.  \nReturns one HTTP response.  \n\n```\nGrabHistoryPrice(domain, token, instru, gran, count=500)\n```\n\n##### Methods for this class\nrequestHistStream() is a method that begins an http connection to the endpoint /v3/instruments/ from Oanda's API. This method is never called directly. All other methods in this class build of this one.\n\n```\nrequestHistStream()\n```\n\ndownloadSingle() is a method that downloads the single FOREX instrument data in JSON format.\n\n```\ndownloadSingle()\n```\n\ndownloadAll() is a method that downloads the all FOREX instruments data in JSON format. The FOREX instruments included are in list found in this method. One can find more about these endpoints [here](https://developer.oanda.com/rest-live-v20/instrument-ep/).\n\n```\ndownloadAll()\n```\n#### enviroB.py  \nThis is the python file one would edit when switching from demo mode (monopoly money) to a live brokerage account, see more at Oandas API website. There are two functions to either GrabToken() or GrabID() which will grab the users info from the res folder (needs to be edited with ones own API key from [Oanda](https://developer.oanda.com/rest-live-v20/introduction/)\n\n#### plotOHLC.py \nThis file has one class to plot OHLC data to visually inspect the data.\nplotOHLC() has two arugments, the first one is the primary currency and the second is the granularity of the data (ie 5 second candles, 10 minute, 1 days, etc).\n\n```\nplotOHLC(primarycur, gran=None)\n```\n\n## \u003cbr\u003e\n**Please note**\nA live tick stream has been developed based on [Quant Start](https://www.quantstart.com/articles/Forex-Trading-Diary-1-Automated-Forex-Trading-with-the-OANDA-API) tutorial on an event driven software to control an automatted trading platform. **WARNING** FOR EDUCATIONAL PURPOSES ONLY.\n\nThis code will require folder called res in parent directory (this folder). The res folder will need to have a ids.json file for ID and an oanda_api_key.json file for API token issued by Oanda (example json files in res folder). Token and ID Key can be obtained for free from Oanda.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidhintelmann%2Foanda-rest-v20","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdavidhintelmann%2Foanda-rest-v20","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidhintelmann%2Foanda-rest-v20/lists"}