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/

Installation

# To install the package you just need to use the command:
install.packages("rRofex")

# Then load it with
library(rRofex)

Development version

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)

References

At the present we provide two libraries for ingesting data from Matba Rofex:

  • rRofex: methods for trading.
  • acyRsa: methods for accessing Back Office data from ACyRSA

Summary of actions for trading

These are the currently available actions within the library:

  • Authentication
  • Reference data request
  • Real-time and historical market data request
  • Orders placement
  • Orders management
  • Account information request

Environments:

  • Demo Environment: go to reMarkets to get free credentials.
  • Production: for credentials please contact: for more information.
  • Production - xOMS: please contact your broker for credentials.

Connection Protocols

There are currently three standard protocols that are being used to connecting to the market::

  1. REST. Inside this library most methods use this protocol internaly.
  2. Websocket. It is under development on branch ‘websocket’ on GitHub. The methods have the suffix ‘ws’ inside it’s name.
  3. FIX. We don’t have any short term plans to develop this wrapper.

Examples

1. Log in

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)

2. Reference Data

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")

3. Market Data

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")

4. Order Placement

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)

5. Order Management

If you want to know the status of your arder, you will need ths method:

trading_orders(connection = conn,
               account = "XXX")

6. Account Information

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 = "REM731")

# With trading account report you can have your cash, margins, etc.
trading_account_report(connection = conn,
                       account = "REM731")

Acknowledgments

Development of this software was driven by Primary as part of an Open Source initiative of Matba Rofex.

Author/Maintainer

Internal Contributors