With this package, you will be able to execute API calls to the ‘Matba Rofex’ trading platform.
The main functionalites include:accessing account data and current holdings, retrieving investment quotes, placing and canceling orders, and getting reference data for instruments.
You can find the complete documentation under https://apihub.primary.com.ar/
# To install the package you just need to use the command:
install.packages("rRofex")
# Then load it with
library(rRofex)
You can use the development version to try new features or bug fixes directly from GitHub.
# 1. In R install the package `devtools`.
install.packages("devtools")
# 2. Once `devtools` is installed, install `rRofex`
library(devtools)
devtools::install_github("matbarofex/rRofex")
# 3. Then load it with
library(rRofex)
At the present we provide two libraries for ingesting data from Matba Rofex:
These are the currently available actions within the library:
There are currently three standard protocols that are being used to connecting to the market::
There are different environment on which one can connect to.
For paper trading exists reMarkets. If you go there, you will be able to get free credentials to start trading with a demo account.
If you already have a live trading account with a broker, you should ask them what kind of order management system (OMS) do they use. If they have the suite of Primary, then you will have to ask them for the user, password and base_url.
# Using `trading_login()` you will be able to connect.
# You will need to use this object in each request made. You can have multiple connections simultaneously.
conn <- trading_login(
username = XXX,
password = XXX,
base_url ='https://api.remarkets.primary.com.ar'
)
# The connection is valid only for the day, you can get your log in information with `login_date_time()`
login_date_time(conn)
There are many types of request that you can make in order to get reference data. The basic one is to ask for a detailed list of every listed instrument.
# You can get a complete Reference Data list with details
trading_instruments(
connection = conn,
request = "securities",
sec_detailed = T
)
# If you are interested only in the front month of each contract of features, you can try
trading_instruments_fronts(connection = conn)
# If you only want equities
trading_instruments(
connection = conn,
request = "by_type",
sec_type = "E"
)
You can access real time market data and historical market data. There is a version with Websocket being developed.
# Real Time Prices using the REST protocol
trading_md(
connection = conn,
symbol = "DODic20"
)
# Historical Trades
trading_mdh(
connection = conn,
symbol = "DOJul20",
date_from = "2020-02-06",
date_to = "2020-03-06"
)
With the method trading_new_order()
you will be able to trade on the market. The basic order type is as follows:
trading_new_order(
connection = conn,
account = "XXX",
symbol = "DOEne21",
side = "Buy",
quantity = 10,
price = 92.14
)
If you want to know the status of your arder, you will need ths method:
With trading_account()
and trading_account_report()
you will be able to obtain information about your current position in terms of instruments and in terms of cash and settlement dates.
# With trading account you can get the information about your basket
trading_account(
connection = conn,
account = "XXX"
)
# With trading account report you can have your cash, margins, etc.
trading_account_report(
connection = conn,
account = "XXX"
)
Instead of requesting information using REST protocol, you could get it through Websocket. This means, that you can listen to an object and be notified every time that a change has been made.
The methods available in Websocket protool are:
trading_ws_md()
trading_ws_orders()
trading_ws_close()
Development of this software was driven by Primary as part of an Open Source initiative of Matba Rofex.