All Projects → IFFranciscoME → ROandaAPI

IFFranciscoME / ROandaAPI

Licence: other
R Code API for Forex Trading with OANDA Broker

Programming Languages

r
7636 projects

Projects that are alternatives of or similar to ROandaAPI

oanda api
A ruby client for the Oanda REST API.
Stars: ✭ 35 (+59.09%)
Mutual labels:  oanda, forex, forex-trading
Heptet
Pair Trading - Reinforcement Learning - with Oanda Trading API
Stars: ✭ 51 (+131.82%)
Mutual labels:  oanda, forex
AutoTrader
A Python-based development platform for automated trading systems - from backtesting to optimisation to livetrading.
Stars: ✭ 227 (+931.82%)
Mutual labels:  oanda, forex
binaryapi
Binary.com & Deriv.com API for Python
Stars: ✭ 32 (+45.45%)
Mutual labels:  forex, forex-trading
fhub
Python client for Finnhub API
Stars: ✭ 31 (+40.91%)
Mutual labels:  forex, forex-trading
Metatrader
Expert advisors, scripts, indicators and code libraries for Metatrader.
Stars: ✭ 99 (+350%)
Mutual labels:  forex, forex-trading
xapi-node
xStation5 Trading API for NodeJS/JS
Stars: ✭ 36 (+63.64%)
Mutual labels:  forex, forex-trading
Median-and-Turbo-Renko-indicator-bundle
MQL5 header file for 'Median and Turbo renko indicator bundle' available for MT5 via MQL5 Market. The file lets you easily create a Renko EA in MT5 using the Median Renko indicator.
Stars: ✭ 68 (+209.09%)
Mutual labels:  forex, forex-trading
MT5-TradingToolCrypto
All the tradingtools: crypto integration to metatrader including cryptobridgepro, crypto charts, paymentbot, indicators, robots are located here. Just download the zip folder, drag and drop into Metatrader 5 directory
Stars: ✭ 70 (+218.18%)
Mutual labels:  forex, forex-trading
Sequence-to-Sequence-Learning-of-Financial-Time-Series-in-Algorithmic-Trading
My bachelor's thesis—analyzing the application of LSTM-based RNNs on financial markets. 🤓
Stars: ✭ 64 (+190.91%)
Mutual labels:  forex, forex-trading
robinhood.tools
📈🤑💰 Advanced trading tools and resources for Robinhood Web.
Stars: ✭ 27 (+22.73%)
Mutual labels:  forex, forex-trading
Gym Fx
Forex trading simulator environment for OpenAI Gym, observations contain the order status, performance and timeseries loaded from a CSV file containing rates and indicators. Work In Progress
Stars: ✭ 151 (+586.36%)
Mutual labels:  forex
Ratesapi
Forex conversion exchange rates api for free
Stars: ✭ 144 (+554.55%)
Mutual labels:  forex
intrinio-realtime-java-sdk
Intrinio Java SDK for Real-Time Stock Prices
Stars: ✭ 22 (+0%)
Mutual labels:  forex
Iextrading4j
IEX Cloud open source API wrapper
Stars: ✭ 112 (+409.09%)
Mutual labels:  forex
Oandapyv20 Examples
Examples demonstrating the use of oandapyV20 (oanda-api-v20)
Stars: ✭ 102 (+363.64%)
Mutual labels:  forex
Pytrader Python Mt4 Mt5 Trading Api Connector Drag N Drop
End-to-End solution connecting Metatrader4 & Metatrader5 💹 with Python with a simple drag and drop EA. Fully tested bug free & efficient solution for live & paper trading⭐ Full Documentation ready.
Stars: ✭ 93 (+322.73%)
Mutual labels:  forex
Oxr
💱 Node.js wrapper for the Open Exchange Rates API
Stars: ✭ 72 (+227.27%)
Mutual labels:  forex
forx
💰a command line tool for checking exchange rates between currencies, both crypto and fiat.
Stars: ✭ 52 (+136.36%)
Mutual labels:  forex
Jiji2
Forex algorithmic trading framework using OANDA REST API.
Stars: ✭ 211 (+859.09%)
Mutual labels:  forex

ROandaAPI

R Code API for Forex Trading with OANDA Broker (CFTC and SEC regulated retail broker). This code is a series of functions for using the Oanda REST API, more about Oanda can be read at their HomePage

  • Initial Developer: IF.FranciscoME
  • License: GNU General Public License
  • Location: Guadalajara, Mexico

Last Update 16-08-2016

It was added the Count option to the HisPrices function, that is for retrieving a fixed amount of candles instead of retrieving whatever number of candles is present in a date range from Start to End. It is still available the option of getting the historic prices from a date range though. The Count option is to use the smaller granularity values since from 1 day to another there are more than 5000 candles and that is the limit from OANDA for the amount of history available per request. So now every request of Historic prices must include the Count parameter, if the request is for a date range the value of Count must be NULL, if the request is for a fixed amount of candles, the the values of Start and End, both, must be NULL.

Previous Reading

At Oanda one can trade more than just FOREX market, but mainly it is that, so in order to have a better comprehension about what FOREX trading actually is:

And about What and API, REST API are ?

Getting Started

  1. Have an account: You must actually get an account with OANDA, either Live or Practice is ok and exactly the same, if you do not have one you can create it from here Open Account

  2. Get REST API Access: Log in -> Search for Manage API Access link -> Generate Personal Access Token

  3. Save Info Safely: Having that Token is like having your password, so keep it safe. If you ever lost it or need to change it, its ok and the previous one goes deprecated as soon as you generate another one, so you can Revoke it whenever you want.

More Official Resources

OANDA has a dedicated page to provide all sort of help and examples for developers, in many languages, you can always go there and consider have a resource full place for you Algorithmic Trading.

R Requirements

  • Any version its ok.
  • Does not have to be used RStudio or any other GUI for R.
  • Specific packages will be needed, i just added a code in order to autodetect them and install them if you havent yet

The previous packages are actually necessary not for running the functions, those are regular expressions of R, but when you call and execute them in your code. Thats because some functions i used inside the API. in case you prefer have access to this API with one line of code, you can use the following and the functions will available locally (Note: You must run this code every time you begin R Session).

Step by Step for Minimal Example

1. Install Required Libraries

Install required libraries if not already installed, if they are installed just load them.

Pkg <- c("base","downloader","forecast","httr","jsonlite","lubridate","moments",
"PerformanceAnalytics","quantmod","reshape2","RCurl","stats","scales","tseries",
"TTR","TSA","xts","zoo")

inst <- Pkg %in% installed.packages()
if(length(Pkg[!inst]) > 0) install.packages(Pkg[!inst])
instpackages <- lapply(Pkg, library, character.only=TRUE)

2. Load in local environment the ROandaAPI Code

Uses the function source_url from the package downloader to source a R script located in a GitHub repository.

downloader::source_url("http://bit.ly/GitHubROandaAPI",prompt=FALSE,quiet=TRUE)

3. Data Inputs

AccountID is a 7 digit number, the input must be numeric, Token is where yours go, and the Start and End are dates in format *"YYYY-MM-DD".

AccountType <- "practice"
AccountID   <- 1234567
Token       <- "ba207fab3522f33fda6a91dbfee0522f6-cdbba372874e6e69e4694f050f890277"
TimeAlign   <- "America%2FMexico_City"
Granularity <- "H6"
Start <- "2015-01-01"
End   <- "2015-10-01"

4. Two Functions as an example

InstList in order to get the available instruments in Oanda , and HisPrices* to get the historical prices of the selected instrument, in this case the 117th so is the XAU_USD, that is Gold Vs Usd.

InstList     <- data.frame(InstrumentsList(AccountType,Token,AccountID))[,c(1,3)]
Instrument   <- InstList[117,1]
PastPriceAPI <- HisPrices(AccountType,Granularity,DayAlign,TimeAlign,Token,Instrument,Start,End)

5. Minimal Functional Example

# -------------------------------------------------------------- Basic Trade Example -- #
# -- Step 0 .- Get System Time -------------------------------------------------------- #
# -- Step 1 .- Get Instrument Lists --------------------------------------------------- #
# -- Step 2 .- Get current price of a chosen instrument ------------------------------- #
# -- Step 3 .- Open a "buy" MARKET ORDER of previously chosen instrument -------------- #
# -- Step 4 .- Get TradeID of previously Opened trade --------------------------------- #
# -- Step 5 .- Modify TP and SL ------------------------------------------------------- #
# -- Step 6 .- Close TradeID ---------------------------------------------------------- #
# ------------------------------------------------------------------------------------- #

# -- 0.- Get System Time
Step0 <- Sys.time()

# -- 1.- Get Instrument Lists
Step1 <- InstrumentsList(OA_At,OA_Ak,OA_Ai)

# -- 2 .- Get current price of a chosen instrument
OA_In <- Step1[1,] # AU200_AUD
Step2 <- ActualPrice(OA_At,OA_Ak,OA_In$Instrument)

# -- 3 .- Open a "buy" market order of previously chosen instrument
Step3 <- NewOrder(AccountType = OA_At,
         AccountID  = OA_Ai,
         Token = OA_Ak,
         OrderType  = OA_Ot,
         Instrument = OA_In$Instrument,
         Count  = OA_Ls,
         Side   = OA_Sd,
         SL = trunc(Step2$Ask*0.95), # 5  % loss
         TP = trunc(Step2$Ask*1.10), # 10 % Profit
         TS = 100)                   # 10 Pips for Trailing Stop

Step4 <- OpenTrades(AccountType = OA_At,
                    AccountID = OA_Ai,
                    Token = OA_Ak,
                    Instrument = OA_In$Instrument)

Step5 <- ModifyTrade(AccountType = OA_At,
                     AccountID = OA_Ai,
                     Token = OA_Ak,
                     TradeID = 10406993698, 
                     StopLoss = 0, 
                     TakeProfit = 0,
                     TrailingStop = 150)

Step6 <- CloseTrade(AccountType = OA_At,
                    AccountID = OA_Ai,
                    Token = OA_Ak,
                    TradeID = Step4$trades$id[1])
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].