Title: | Quantitative Trading Framework |
---|---|
Description: | Collection of functions to retrieve financial data from various sources, including brokerage and exchange platforms, financial websites, and data providers. Includes functions to retrieve account information, portfolio information, and place/cancel orders from different brokers. Additionally, allows users to download historical data such as earnings, dividends, stock splits. |
Authors: | Vyacheslav Arbuzov[cph, cre, aut], Sergey Edunov[aut] |
Maintainer: | Vyacheslav Arbuzov <[email protected]> |
License: | GPL-3 |
Version: | 1.1.1 |
Built: | 2024-11-16 05:51:00 UTC |
Source: | https://github.com/arbuzovv/rusquant |
Sets creds for the Datasource by storing it in an environment variable for the current R session. This token will be used by other functions in the package to authenticate API requests.
auth(src = "Moex", login, password)
auth(src = "Moex", login, password)
src |
datasource name. |
login |
login of datasource |
password |
password of datasource |
Invisible NULL, side-effect function setting an environment variable.
## Not run: auth(login = "[email protected]",password = "mypassword") ## End(Not run)
## Not run: auth(login = "[email protected]",password = "mypassword") ## End(Not run)
This function cancels an existing order on a specified broker or exchange platform
cancelOrder( src = "", api.key = "", orderId = "", clientId = "", board = "", live = TRUE, verbose = TRUE )
cancelOrder( src = "", api.key = "", orderId = "", clientId = "", board = "", live = TRUE, verbose = TRUE )
src |
character string, the name of the broker/exchange platform, e.g. "tinkoff", "finam", "alor" |
api.key |
character string, the API key required for authentication |
orderId |
character string, the ID of the order to be cancelled |
clientId |
character string, the ID of the client account |
board |
character string, the name of the exchange board, required for some platforms |
live |
logical, whether to execute the order in a live environment, default is TRUE |
verbose |
logical, whether to print the HTTP response message, default is TRUE |
character string, the response message from the HTTP request
Not for the faint of heart. All profits and losses related are yours and yours alone. If you don't like it, write it yourself.
cancelOrder(src = 'Finam',api.key = 'finam_token',orderId = 'otderID',clientId = 'your cliend id')
cancelOrder(src = 'Finam',api.key = 'finam_token',orderId = 'otderID',clientId = 'your cliend id')
This function retrieves account information from a brokerage or exchange.
getAccounts(src = "tinkoff", api.key = "", verbose = FALSE)
getAccounts(src = "tinkoff", api.key = "", verbose = FALSE)
src |
a character string specifying the brokerage or exchange. Can be one of "tinkoff" or "alor". Default is "tinkoff". |
api.key |
a character string representing the authorization key for the API. |
verbose |
a logical value indicating whether to print detailed information about the request/response. Default is FALSE. |
A list object with account information, or an error message if the request fails.
Not for the faint of heart. All profits and losses related are yours and yours alone. If you don't like it, write it yourself.
Vyacheslav Arbuzov
# get account information from tinkoff account_info <- getAccounts(src = "Tinkoff", api.key = "your_api_key") # get account information from alor account_info <- getAccounts(src = "Alor", api.key = "your_api_key")
# get account information from tinkoff account_info <- getAccounts(src = "Tinkoff", api.key = "your_api_key") # get account information from alor account_info <- getAccounts(src = "Alor", api.key = "your_api_key")
This function returns dividends data from Investing.com or Tinkoff broker.
getDividends( src = "investing", figi = "", api.key = "", from = Sys.Date() - 10, to = Sys.Date(), country = "" )
getDividends( src = "investing", figi = "", api.key = "", from = Sys.Date() - 10, to = Sys.Date(), country = "" )
src |
source of dividends information. Could be 'investing' or 'tinkoff' |
figi |
FIGI of the instrument to get dividends for (only for Tinkoff broker) |
api.key |
Tinkoff broker API key (only for Tinkoff broker) |
from |
start date of the dividends data. Default is 10 days ago |
to |
end date of the dividends data. Default is today |
country |
a character string with the country name to filter dividends data for (only for Investing.com) |
a list with dividends data
Not for the faint of heart. All profits and losses related are yours and yours alone. If you don't like it, write it yourself.
Vyacheslav Arbuzov
getDividends(from = Sys.Date(),to = Sys.Date()+2,country = "Australia")
getDividends(from = Sys.Date(),to = Sys.Date()+2,country = "Australia")
This function retrieves earnings data from the investing.com website for a specified time period
getEarnings( from = Sys.Date() - 5, to = Sys.Date() + 5, country = "United States" )
getEarnings( from = Sys.Date() - 5, to = Sys.Date() + 5, country = "United States" )
from |
the start date in yyyy-mm-dd format (default is 10 days prior to current date) |
to |
the end date in yyyy-mm-dd format (default is the current date) |
country |
the country from which to get earnings data (default is United States) |
a data frame with earnings data
Not for the faint of heart. All profits and losses related are yours and yours alone. If you don't like it, write it yourself.
Vyacheslav Arbuzov
getEarnings(from = Sys.Date(),to = Sys.Date()+5,country='Belgium')
getEarnings(from = Sys.Date(),to = Sys.Date()+5,country='Belgium')
This function retrieves economic data from the investing.com website for a specified time period
getEconomic(from = Sys.Date() - 10, to = Sys.Date(), country = "United States")
getEconomic(from = Sys.Date() - 10, to = Sys.Date(), country = "United States")
from |
A date in the format of YYYY-MM-DD. Defaults to 10 days ago from the current system date. |
to |
A date in the format of YYYY-MM-DD. Defaults to the current system date. |
country |
a character string with the country name to filter dividends data for (only for Investing.com) |
A data frame containing IPO calendar data for the specified date range.
Not for the faint of heart. All profits and losses related are yours and yours alone. If you don't like it, write it yourself.
Vyacheslav Arbuzov
getEconomic(from = Sys.Date(),to = Sys.Date()+35,country='Belgium')
getEconomic(from = Sys.Date(),to = Sys.Date()+35,country='Belgium')
This function retrieves IPO calendar data from Investing.com for a specified date range
getIPO(from = Sys.Date() - 10, to = Sys.Date())
getIPO(from = Sys.Date() - 10, to = Sys.Date())
from |
The start date of the date range in YYYY-MM-DD format. Default is the current date minus 10 days. |
to |
The end date of the date range in YYYY-MM-DD format. Default is the current date. |
A data frame containing IPO calendar data for the specified date range.
Not for the faint of heart. All profits and losses related are yours and yours alone. If you don't like it, write it yourself.
Vyacheslav Arbuzov
getIPO(from=Sys.Date(),to=Sys.Date()+3)
getIPO(from=Sys.Date(),to=Sys.Date()+3)
This function retrieves order book information
getOrderbook( Symbols, depth = 10, src = "poloniex", adjust = FALSE, verbose = FALSE, auto.assign = TRUE, market = "shares", board = "tqbr", api.key = "", env = globalenv() )
getOrderbook( Symbols, depth = 10, src = "poloniex", adjust = FALSE, verbose = FALSE, auto.assign = TRUE, market = "shares", board = "tqbr", api.key = "", env = globalenv() )
Symbols |
A character vector specifying the symbol to retrieve order book data for. |
depth |
An integer value specifying the number of levels of the order book to retrieve. Defaults to 10. |
src |
A character string specifying the exchange to retrieve data from. Possible values are kraken,poloniex,tinkoff,alor, binance. |
adjust |
A logical value indicating whether to adjust timestamps to match the system timezone. Defaults to FALSE. |
verbose |
A logical value indicating whether to print detailed messages during the function's execution. Defaults to FALSE. |
auto.assign |
A logical value indicating whether to automatically assign the resulting object to the current environment. Defaults to TRUE. |
market |
A character string specifying type of market |
board |
A character string specifying type of board |
api.key |
A character string specifying the API key to use when retrieving data from Alor or Tinkoff. Defaults to "". |
env |
environment where the data will be assigned |
A data.table object containing the order book data for the specified symbol.
Not for the faint of heart. All profits and losses related are yours and yours alone. If you don't like it, write it yourself.
Vyacheslav Arbuzov
getOrderbook('USDTGBP', src = 'kraken') getOrderbook('BTC_USDT', src = 'poloniex')
getOrderbook('USDTGBP', src = 'kraken') getOrderbook('BTC_USDT', src = 'poloniex')
This function retrieves information about orders from different brokers/exchanges
getOrders( src = "", board = "MOEX", api.key = "", orderId = "", clientId = "", stopOrders = FALSE, verbose = TRUE )
getOrders( src = "", board = "MOEX", api.key = "", orderId = "", clientId = "", stopOrders = FALSE, verbose = TRUE )
src |
Character string specifying the source broker/exchange (e.g., "tinkoff", "finam", "alor") |
board |
Character string specifying the trading board (default is "MOEX") |
api.key |
Character string specifying the API key for the broker/exchange |
orderId |
Character string specifying the order ID to retrieve (default is "") |
clientId |
Character string specifying the client ID for the broker/exchange |
stopOrders |
Logical specifying whether to retrieve stop orders (default is FALSE) |
verbose |
Logical specifying whether to display additional information (default is TRUE) |
A list containing order information from the broker/exchange
Not for the faint of heart. All profits and losses related are yours and yours alone. If you don't like it, write it yourself.
Vyacheslav Arbuzov
getTrades
cancelOrder
placeOrder
# Retrieve all orders from Tinkoff getOrders(src = "tinkoff", api.key = "your_api_key", clientId = "your_client_id") # Retrieve all orders from Finam getOrders(src = "finam", api.key = "your_api_key", clientId = "your_client_id") # Retrieve all orders from Alor getOrders(src = "alor", api.key = "your_api_key", clientId = "your_client_id")
# Retrieve all orders from Tinkoff getOrders(src = "tinkoff", api.key = "your_api_key", clientId = "your_client_id") # Retrieve all orders from Finam getOrders(src = "finam", api.key = "your_api_key", clientId = "your_client_id") # Retrieve all orders from Alor getOrders(src = "alor", api.key = "your_api_key", clientId = "your_client_id")
This function retrieves portfolio data from different brokers/exchanges such as Tinkoff, Finam and Alor.
getPortfolio( src = "", board = "MOEX", api.key = "", clientId = "", verbose = TRUE )
getPortfolio( src = "", board = "MOEX", api.key = "", clientId = "", verbose = TRUE )
src |
character indicating the name of the broker/exchange (options are 'tinkoff', 'finam', or 'alor') |
board |
character indicating the name of the board (only required for Alor, default is 'MOEX') |
api.key |
character representing the authorization key required for accessing broker/exchange API |
clientId |
character representing the ID of the client whose portfolio data is being retrieved |
verbose |
logical value indicating whether to print verbose output (default is TRUE) |
A list of portfolio data containing the positions and other relevant information
Not for the faint of heart. All profits and losses related are yours and yours alone. If you don't like it, write it yourself.
Vyacheslav Arbuzov
# Retrieve portfolio data from Tinkoff getPortfolio(src = 'tinkoff', api.key = 'my_api_key', clientId = 'my_client_id') # Retrieve portfolio data from Finam getPortfolio(src = 'finam', api.key = 'my_api_key', clientId = 'my_client_id') # Retrieve portfolio data from Alor getPortfolio(src = 'alor', api.key = 'my_api_key', clientId = 'my_client_id', board = 'MOEX')
# Retrieve portfolio data from Tinkoff getPortfolio(src = 'tinkoff', api.key = 'my_api_key', clientId = 'my_client_id') # Retrieve portfolio data from Finam getPortfolio(src = 'finam', api.key = 'my_api_key', clientId = 'my_client_id') # Retrieve portfolio data from Alor getPortfolio(src = 'alor', api.key = 'my_api_key', clientId = 'my_client_id', board = 'MOEX')
This function retrieves the stock split calendar data from investing.com between two given dates.
getSplits(from = Sys.Date() - 10, to = Sys.Date())
getSplits(from = Sys.Date() - 10, to = Sys.Date())
from |
A date in the format 'YYYY-MM-DD' representing the start of the date range to retrieve data for (default is Sys.Date()-10). |
to |
A date in the format 'YYYY-MM-DD' representing the end of the date range to retrieve data for (default is Sys.Date()). |
A data.table object containing the stock split calendar data from investing.com.
Not for the faint of heart. All profits and losses related are yours and yours alone. If you don't like it, write it yourself.
Vyacheslav Arbuzov
getSplits(from=Sys.Date(),to=Sys.Date()+3)
getSplits(from=Sys.Date(),to=Sys.Date()+3)
This function retrieves a list of symbols for a specified stock exchange from a variety of sources. The available sources are poloniex, rusquant, tinkoff, mfd, finam, alor, and kraken. The function returns a data.table object containing the symbol information for the requested exchange.
getSymbolList( src = "poloniex", verbose = FALSE, auto.assign = FALSE, country = "", api.key = "", type = "Shares", env = globalenv(), user_agent = NULL )
getSymbolList( src = "poloniex", verbose = FALSE, auto.assign = FALSE, country = "", api.key = "", type = "Shares", env = globalenv(), user_agent = NULL )
src |
character indicating the source of the symbol list. Possible values are "poloniex", "rusquant", "tinkoff", "mfd", "finam", "alor", and "kraken". |
verbose |
logical indicating whether or not to print additional information. The default is FALSE. |
auto.assign |
logical indicating whether or not to automatically assign the data.table object to the global environment. The default is FALSE. |
country |
character indicating the country of the exchange. The default is an empty string. |
api.key |
character indicating the API key to be used for accessing the source. The default is an empty string. |
type |
character indicating the type of financial instruments to retrieve. Applicable for the "tinkoff", "gigapack","moex". Possible values are "Bonds", "Currencies", "Etfs", "Futures", "Options", and "Shares". |
env |
The environment where the data should be assigned. Defaults to the global environment. |
user_agent |
The special headers for parsing |
Returns a data.table object containing the symbol information for the specified exchange.
Not for the faint of heart. All profits and losses related are yours and yours alone. If you don't like it, write it yourself.
Vyacheslav Arbuzov
getSymbolList() #getSymbolList(src='moex') #getSymbolList(src='moex',type='Forts')
getSymbolList() #getSymbolList(src='moex') #getSymbolList(src='moex',type='Forts')
Download historical market data from AlgoPack for a given symbol and time range.
getSymbols.Algopack( Symbols = "", env = globalenv(), from = Sys.Date() - 30, to = Sys.Date(), date = Sys.Date(), verbose = FALSE, type = "tradestats", market = "eq", auto.assign = FALSE, ... )
getSymbols.Algopack( Symbols = "", env = globalenv(), from = Sys.Date() - 30, to = Sys.Date(), date = Sys.Date(), verbose = FALSE, type = "tradestats", market = "eq", auto.assign = FALSE, ... )
Symbols |
a character vector of AlgoPack symbols to download data for. |
env |
environment where to create the downloaded data object. |
from |
a character string indicating the start date of the data to download, in YYYY-MM-DD format. |
to |
a character string indicating the end date of the data to download, in YYYY-MM-DD format. |
date |
a character string indicating the date of the data to download, in YYYY-MM-DD format. |
verbose |
a logical indicating whether to print the response details or not. |
type |
a character string indicating the AlgoPack type possible values are c('tradestats','orderstats','obstats','hi2','oi'), default 'tradestats'. |
market |
a character string indicating the market type possible values are c('eq','fo','fx'), default 'eq'. |
auto.assign |
a logical indicating whether to automatically assign the downloaded data to the global environment. |
... |
additional arguments passed to getSymbols.AlgoPack |
returns an data.table object containing financial data
Not for the faint of heart. All profits and losses related are yours and yours alone. If you don't like it, write it yourself.
Vyacheslav Arbuzov
getSymbols.Algopack('SBER',from = '2023-10-24',to='2023-11-04') # open interest for available futures getSymbols.Algopack(date = '2024-05-10',type = 'oi') # open interest for Si futures getSymbols.Algopack(Symbols = 'Si',type = 'oi') # market concentration for available stocks #getSymbols.Algopack(date = '2024-05-10',type = 'hi2') # market concentration for current stock #devgetSymbols.Algopack('SBER',from = '2023-10-24',to='2023-11-04',type = 'hi2') # market concentration for available fx #getSymbols.Algopack(date = '2024-05-10',type = 'hi2',market='fx') # market concentration for available futures #getSymbols.Algopack(date = '2024-05-10',type = 'hi2',market='fo') # market concentration for CNYRUB_TOM #getSymbols.Algopack(Symbols = 'CNYRUB_TOM',type = 'hi2',market='fx')
getSymbols.Algopack('SBER',from = '2023-10-24',to='2023-11-04') # open interest for available futures getSymbols.Algopack(date = '2024-05-10',type = 'oi') # open interest for Si futures getSymbols.Algopack(Symbols = 'Si',type = 'oi') # market concentration for available stocks #getSymbols.Algopack(date = '2024-05-10',type = 'hi2') # market concentration for current stock #devgetSymbols.Algopack('SBER',from = '2023-10-24',to='2023-11-04',type = 'hi2') # market concentration for available fx #getSymbols.Algopack(date = '2024-05-10',type = 'hi2',market='fx') # market concentration for available futures #getSymbols.Algopack(date = '2024-05-10',type = 'hi2',market='fo') # market concentration for CNYRUB_TOM #getSymbols.Algopack(Symbols = 'CNYRUB_TOM',type = 'hi2',market='fx')
Download historical market data from Alor for a given symbol and time range.
getSymbols.Alor( Symbols, env = globalenv(), from = "2007-01-01", to = Sys.Date(), adjust = FALSE, api.key = NULL, period = "day", verbose = TRUE, board = "MOEX", auto.assign = FALSE, ... )
getSymbols.Alor( Symbols, env = globalenv(), from = "2007-01-01", to = Sys.Date(), adjust = FALSE, api.key = NULL, period = "day", verbose = TRUE, board = "MOEX", auto.assign = FALSE, ... )
Symbols |
a character vector of Alor symbols to download data for. |
env |
environment where to create the downloaded data object. |
from |
a character string indicating the start date of the data to download, in YYYY-MM-DD format. |
to |
a character string indicating the end date of the data to download, in YYYY-MM-DD format. |
adjust |
a logical indicating whether to adjust the data for stock splits or not. |
api.key |
an Alor API key. |
period |
a character string indicating the frequency of the data to download. Possible values are '1min', '5min', 'hour', 'day', 'week', and 'month'. |
verbose |
a logical indicating whether to print the response details or not. |
board |
a character string indicating the Alor exchange board to use. Possible values are 'MOEX' and 'SPB'. |
auto.assign |
a logical indicating whether to automatically assign the downloaded data to the global environment. |
... |
additional arguments passed to getSymbols.Alor |
returns an data.table object containing financial data
Not for the faint of heart. All profits and losses related are yours and yours alone. If you don't like it, write it yourself.
Vyacheslav Arbuzov
getSymbols.Alor('SBER',from = '2023-04-01',to='2023-05-04',period = '1min') getSymbols('SBER',src='Alor')
getSymbols.Alor('SBER',from = '2023-04-01',to='2023-05-04',period = '1min') getSymbols('SBER',src='Alor')
Download historical market data from Comon for a given trader id
getSymbols.Comon( Symbols, env = globalenv(), period = "day", verbose = TRUE, auto.assign = FALSE, ... )
getSymbols.Comon( Symbols, env = globalenv(), period = "day", verbose = TRUE, auto.assign = FALSE, ... )
Symbols |
a character id of strategy on Comon |
env |
environment where to create the downloaded data object. |
period |
a character string indicating the frequency of the data to download. Possible values are 'day'. |
verbose |
a logical indicating whether to print the response details or not. |
auto.assign |
a logical indicating whether to automatically assign the downloaded data to the global environment. |
... |
additional arguments passed to getSymbols.Comon |
returns an data.table object containing financial data
Not for the faint of heart. All profits and losses related are yours and yours alone. If you don't like it, write it yourself.
Vyacheslav Arbuzov
getSymbols.Comon('115038') getSymbols('115039',src='Comon')
getSymbols.Comon('115038') getSymbols('115039',src='Comon')
Download historical data from Finam.ru for one or more stock symbols. The data can be returned as an xts object or assigned to a specified environment. This function uses the Finam.ru export service to retrieve data.
getSymbols.Finam( Symbols, env = globalenv(), from = "2007-01-01", to = Sys.Date(), adjust = FALSE, period = "day", market = NULL, verbose = FALSE, auto.assign = FALSE, api.key = "", user_agent = NULL, ... )
getSymbols.Finam( Symbols, env = globalenv(), from = "2007-01-01", to = Sys.Date(), adjust = FALSE, period = "day", market = NULL, verbose = FALSE, auto.assign = FALSE, api.key = "", user_agent = NULL, ... )
Symbols |
A character vector of one or more stock symbols. |
env |
The environment where the data should be assigned. Defaults to the global environment. |
from |
The start date for the data. Defaults to "2007-01-01". |
to |
The end date for the data. Defaults to the current date. |
adjust |
A logical indicating whether to adjust for dividends and splits. Defaults to FALSE. |
period |
The interval to use for the data. Must be one of "tick", "1min", "5min", "10min", "15min", "30min", "hour", "day", "week", or "month". Defaults to "day". |
market |
A character vector indicating the market for each symbol. If NULL, the function will attempt to determine the market automatically. Defaults to NULL. |
verbose |
A logical indicating whether to print progress messages. Defaults to FALSE. |
auto.assign |
A logical indicating whether to assign the data to an object with the same name as the symbol. Defaults to FALSE. |
api.key |
character representing the authorization key required for accessing broker/exchange API |
user_agent |
Header for user agent for Finam |
... |
additional arguments passed to getSymbols.Finam |
returns an data.table object containing the requested data with orders of current account.
Not for the faint of heart. All profits and losses related are yours and yours alone. If you don't like it, write it yourself.
Vyacheslav Arbuzov
api_key = 'set_if_use_API' getSymbols('SBER',src='Finam',api.key = api_key)
api_key = 'set_if_use_API' getSymbols('SBER',src='Finam',api.key = api_key)
Download historical market data from GigaPack for a given symbol and time range.
getSymbols.Gigapack( Symbols, env = globalenv(), from = Sys.Date() - 30, to = Sys.Date(), date = "", verbose = TRUE, field = "", type = "candles", fake = FALSE, reps = 1, trim = 0.1, auto.assign = FALSE, ... )
getSymbols.Gigapack( Symbols, env = globalenv(), from = Sys.Date() - 30, to = Sys.Date(), date = "", verbose = TRUE, field = "", type = "candles", fake = FALSE, reps = 1, trim = 0.1, auto.assign = FALSE, ... )
Symbols |
a character vector of AlgoPack symbols to download data for. |
env |
environment where to create the downloaded data object. |
from |
a character string indicating the start date of the data to download, in YYYY-MM-DD format. |
to |
a character string indicating the end date of the data to download, in YYYY-MM-DD format. |
date |
a character string indicating the specific date of the data to download, in YYYY-MM-DD format. |
verbose |
a logical indicating whether to print the response details or not. |
field |
a character string indicating the GigaPack field |
type |
a character string indicating the GigaPack field candles or tech |
fake |
a bool string indicating the Giga Candles or Alter Giga |
reps |
number of alternative history geneartion |
trim |
number of entropy in data |
auto.assign |
a logical indicating whether to automatically assign the downloaded data to the global environment. |
... |
additional arguments passed to getSymbols.AlgoPack |
returns an data.table object containing financial data
Not for the faint of heart. All profits and losses related are yours and yours alone. If you don't like it, write it yourself.
Vyacheslav Arbuzov
getSymbols.Gigapack('SBER', field = 'disb.q20')
getSymbols.Gigapack('SBER', field = 'disb.q20')
This function retrieves historical financial data for a given symbol from the MarketWatch website and returns it as a data frame or assigns it to an R object.
getSymbols.MarketWatch( Symbols, from = "2007-01-01", to = Sys.Date(), adjust = FALSE, period = "day", market = NULL, countrycode = NULL, verbose = FALSE, auto.assign = FALSE, ... )
getSymbols.MarketWatch( Symbols, from = "2007-01-01", to = Sys.Date(), adjust = FALSE, period = "day", market = NULL, countrycode = NULL, verbose = FALSE, auto.assign = FALSE, ... )
Symbols |
A character vector specifying the name of the financial instrument(s) to retrieve. |
from |
A character string specifying the starting date for the historical data in the format "YYYY-MM-DD". |
to |
A character string specifying the ending date for the historical data in the format "YYYY-MM-DD". |
adjust |
A logical value indicating whether to adjust the prices for splits and dividends. The default value is FALSE. |
period |
A character string specifying the period for which to retrieve the data. The default value is "day". |
market |
A character string specifying the market where the financial instrument is listed. |
countrycode |
A character string specifying the country code of the market where the financial instrument is listed. |
verbose |
A logical value indicating whether to print additional information while running the function. The default value is FALSE. |
auto.assign |
A logical value indicating whether to assign the data to an R object with the same name as the symbol. The default value is FALSE. |
... |
Additional arguments. |
A data frame or an object of class "xts" containing the historical financial data for the given symbol.
Not for the faint of heart. All profits and losses related are yours and yours alone. If you don't like it, write it yourself.
Vyacheslav Arbuzov
getSymbols.MarketWatch(Symbols = 'liborusd3m',market = 'interestrate',countrycode = 'mx') #getSymbols.MarketWatch(Symbols = 'tmubmusd03m',market = 'bond',countrycode = 'bx')
getSymbols.MarketWatch(Symbols = 'liborusd3m',market = 'interestrate',countrycode = 'mx') #getSymbols.MarketWatch(Symbols = 'tmubmusd03m',market = 'bond',countrycode = 'bx')
This function retrieves financial data from Mfd.ru
getSymbols.Mfd( Symbols, env = globalenv(), from = "2007-01-01", to = Sys.Date(), adjust = FALSE, period = "day", verbose = TRUE, auto.assign = FALSE, ... )
getSymbols.Mfd( Symbols, env = globalenv(), from = "2007-01-01", to = Sys.Date(), adjust = FALSE, period = "day", verbose = TRUE, auto.assign = FALSE, ... )
Symbols |
character vector of symbols to retrieve |
env |
environment where the data will be assigned |
from |
a character string representing the starting date in 'YYYY-MM-DD' format. Default is '2007-01-01'. |
to |
a character string representing the ending date in 'YYYY-MM-DD' format. Default is the current system date. |
adjust |
a logical specifying whether to adjust for dividends and stock splits. Default is FALSE. |
period |
a character string specifying the period of the data to retrieve. Must be one of 'tick', '1min', '5min', '10min', '15min', '30min', 'hour', 'day', 'week', or 'month'. Default is 'day'. |
verbose |
a logical specifying whether to print progress messages. Default is TRUE. |
auto.assign |
a logical specifying whether to automatically assign the retrieved data to the symbols specified in the Symbols argument. Default is FALSE. |
... |
additional arguments passed to getSymbols.Mfd |
If auto.assign is TRUE, the function returns the Symbols argument with the retrieved data assigned to each symbol. If auto.assign is FALSE, the function returns an xts object.
Not for the faint of heart. All profits and losses related are yours and yours alone. If you don't like it, write it yourself.
Vyacheslav Arbuzov
Retrieves historical data of a stock from Moscow Exchange (MOEX) using its API.
getSymbols.Moex( Symbols, env = globalenv(), from = "2007-01-01", to = Sys.Date(), adjust = FALSE, period = "day", market = NULL, verbose = FALSE, auto.assign = FALSE, ... )
getSymbols.Moex( Symbols, env = globalenv(), from = "2007-01-01", to = Sys.Date(), adjust = FALSE, period = "day", market = NULL, verbose = FALSE, auto.assign = FALSE, ... )
Symbols |
character vector of ticker symbols to retrieve data for |
env |
environment where data is stored |
from |
character string specifying the start date (default: '2007-01-01') |
to |
character string specifying the end date (default: Sys.Date()) |
adjust |
logical flag indicating whether to adjust prices for dividends and splits (default: FALSE) |
period |
character string specifying the interval of the data ('day', 'hour', '10min', or '1min'; default: 'day') |
market |
character string specifying the market of the data (default: NULL) |
verbose |
logical flag indicating whether to print progress messages (default: FALSE) |
auto.assign |
logical flag indicating whether to automatically assign the resulting data to objects with the same names as Symbols (default: FALSE) |
... |
Additional arguments. |
xts object with historical data
Not for the faint of heart. All profits and losses related are yours and yours alone. If you don't like it, write it yourself.
Vyacheslav Arbuzov
data <- getSymbols.Moex('GAZP', from='2022-01-01', to='2022-01-10', period='day', auto.assign=FALSE)
data <- getSymbols.Moex('GAZP', from='2022-01-01', to='2022-01-10', period='day', auto.assign=FALSE)
This function retrieves financial data from Poloniex.
getSymbols.Poloniex( Symbols, env, return.class = "xts", index.class = "Date", from = "2007-01-01", to = Sys.Date(), adjust = FALSE, period = "day", verbose = TRUE, auto.assign = FALSE, ... )
getSymbols.Poloniex( Symbols, env, return.class = "xts", index.class = "Date", from = "2007-01-01", to = Sys.Date(), adjust = FALSE, period = "day", verbose = TRUE, auto.assign = FALSE, ... )
Symbols |
A character vector with the ticker symbols to retrieve data for. |
env |
The environment where to create the variables. Default is the current environment. |
return.class |
The class to return. Default is xts. |
index.class |
The class for the index column. Default is Date. |
from |
Start date of the data. Default is '2007-01-01'. |
to |
End date of the data. Default is Sys.Date(). |
adjust |
Logical. Adjust the prices. Default is FALSE. |
period |
The period for the candle data. Default is 'day'. |
verbose |
Logical. Print progress messages. Default is TRUE. |
auto.assign |
Logical. Assign data to the environment. Default is FALSE. |
... |
Additional arguments to be passed to functions. |
A list of xts objects if auto.assign
is TRUE, otherwise a single xts object.
Not for the faint of heart. All profits and losses related are yours and yours alone. If you don't like it, write it yourself.
Vyacheslav Arbuzov
getSymbols.Poloniex('BTC_USDT') #getSymbols('BTC_USDT',src='Poloniex')
getSymbols.Poloniex('BTC_USDT') #getSymbols('BTC_USDT',src='Poloniex')
This function retrieves alpha data for the specified alpha,symbols from Rusquant API. The data can be returned in either xts or data.frame format.
getSymbols.Rusquant( Symbols, env = globalenv(), field = NULL, from = "2007-01-01", to = Sys.Date(), period = "day", market = NULL, api.key = NULL, verbose = FALSE, auto.assign = FALSE, ... )
getSymbols.Rusquant( Symbols, env = globalenv(), field = NULL, from = "2007-01-01", to = Sys.Date(), period = "day", market = NULL, api.key = NULL, verbose = FALSE, auto.assign = FALSE, ... )
Symbols |
a character vector of symbols to be downloaded. |
env |
the environment where the data should be stored. Default is the global environment. |
field |
the name(s) of alpha strategy to retrieve from the API. Default is NULL. |
from |
the start date of the data to be retrieved. Default is '2007-01-01'. |
to |
the end date of the data to be retrieved. Default is Sys.Date(). |
period |
a character value indicating the periodicity of the data. Default is 'day'. |
market |
a character value indicating the market where the symbols are traded. Default is NULL. |
api.key |
a character value indicating the API key to be used for the request. Default is NULL. |
verbose |
a logical value indicating whether to print informative messages. Default is FALSE. |
auto.assign |
a logical value indicating whether to automatically assign the downloaded data to an object with the symbol name. Default is FALSE. |
... |
Additional arguments to be passed to functions. |
returns an data.table object containing the requested data with alpha strategy data
Not for the faint of heart. All profits and losses related are yours and yours alone. If you don't like it, write it yourself.
Vyacheslav Arbuzov
rusquant_key = 'get free key from rusquant.ru' getSymbols.Rusquant('SBER',field = 'A1_L_P1',api.key = rusquant_key) getSymbols('SBER',src='Rusquant',field = 'A1_L_P1',api.key = rusquant_key)
rusquant_key = 'get free key from rusquant.ru' getSymbols.Rusquant('SBER',field = 'A1_L_P1',api.key = rusquant_key) getSymbols('SBER',src='Rusquant',field = 'A1_L_P1',api.key = rusquant_key)
Retrieve financial data from Tinkoff API.
getSymbols.Tinkoff( Symbols, from = "2007-01-01", to = Sys.Date(), adjust = FALSE, api.key = NULL, period = "day", market = NULL, verbose = FALSE, auto.assign = FALSE, ... )
getSymbols.Tinkoff( Symbols, from = "2007-01-01", to = Sys.Date(), adjust = FALSE, api.key = NULL, period = "day", market = NULL, verbose = FALSE, auto.assign = FALSE, ... )
Symbols |
A character vector with the names of the symbols to be retrieved. |
from |
A character string representing the start date for the financial data, in the format "YYYY-MM-DD". By default, it is "2007-01-01". |
to |
A character string representing the end date for the financial data, in the format "YYYY-MM-DD". By default, it is the current system date. |
adjust |
A logical value indicating whether to adjust prices for dividends and stock splits. By default, it is FALSE. |
api.key |
A character string containing the API key for accessing Tinkoff API. |
period |
A character string representing the interval of time between two candles. By default it is "day". |
market |
A character string representing the market to which the symbol belongs. By default, it is NULL. |
verbose |
A logical value indicating whether to print verbose output. By default, it is FALSE. |
auto.assign |
A logical value indicating whether to automatically assign the downloaded data to an object with the same name as the symbol. By default, it is FALSE. |
... |
Additional arguments. |
A data table with the financial data for the specified symbol(s).
Not for the faint of heart. All profits and losses related are yours and yours alone. If you don't like it, write it yourself.
Vyacheslav Arbuzov
getSymbols.Tinkoff("BBG004730N88",from=Sys.Date()-5, ap.key = "your_api_key",verbose=TRUE)
getSymbols.Tinkoff("BBG004730N88",from=Sys.Date()-5, ap.key = "your_api_key",verbose=TRUE)
This function retrieves account information from a brokerage or exchange.
getTradelog( Symbols, depth = 500, src = "poloniex", api.key = "", adjust = FALSE, return.class = "data.table", index.class = "Date", market = "shares", board = "tqbr", verbose = FALSE, auto.assign = TRUE, env = globalenv() )
getTradelog( Symbols, depth = 500, src = "poloniex", api.key = "", adjust = FALSE, return.class = "data.table", index.class = "Date", market = "shares", board = "tqbr", verbose = FALSE, auto.assign = TRUE, env = globalenv() )
Symbols |
Character vector specifying the trading pair, e.g. "BTC_ETH". |
depth |
Numeric scalar, specifying the number of trades to retrieve (default = 500). |
src |
Character scalar, specifying the exchange to retrieve trade logs from. The supported exchanges are: "tinkoff", "alor", "poloniex", "kraken", "binance", "bttrex", "cex", "gate", "gatecoin", "gdax", "gemini", "hitbtc", "liqui", and "lykke". |
api.key |
Character scalar, specifying the API key (if required by the exchange). |
adjust |
Logical scalar, specifying whether to adjust timestamps for time zones (default = FALSE). |
return.class |
Character scalar, specifying the class of the returned object. The supported classes are: "data.table", "data.frame", and "xts" (default = "data.table"). |
index.class |
Character scalar, specifying the class of the index column. The supported classes are: "Date" and "POSIXct" (default = "Date"). |
market |
A character string specifying type of market. 'shares' or 'forts' |
board |
A character string specifying type of board |
verbose |
Logical scalar, specifying whether to print verbose output (default = FALSE). |
auto.assign |
Logical scalar, specifying whether to automatically assign the resulting object to the global environment (default = TRUE). |
env |
environment where data is stored |
A data table or data frame with the retrieved trade logs, depending on the value of the return.class
argument.
Not for the faint of heart. All profits and losses related are yours and yours alone. If you don't like it, write it yourself.
Vyacheslav Arbuzov
getTradelog('BTC_USDT', src = 'poloniex') getTradelog('SBER', src = 'moex') getTradelog('SiH5', src = 'moex',market='forts')
getTradelog('BTC_USDT', src = 'poloniex') getTradelog('SBER', src = 'moex') getTradelog('SiH5', src = 'moex',market='forts')
Get trades for a given broker from a specified date to the current date.
getTrades( src = "", api.key = "", clientId = "", figi = "", from = Sys.Date() - 5, to = Sys.Date(), symbol_info = FALSE, time_transform = TRUE, verbose = FALSE )
getTrades( src = "", api.key = "", clientId = "", figi = "", from = Sys.Date() - 5, to = Sys.Date(), symbol_info = FALSE, time_transform = TRUE, verbose = FALSE )
src |
Character string indicating the broker to use. Currently, only "tinkoff" and "alor" are supported. |
api.key |
Character string containing the API key for the broker's API. |
clientId |
Character string containing the client ID for the broker. |
figi |
Character string containing the Financial Instrument Global Identifier for the broker. |
from |
Date specifying the start date for the trade data. Defaults to 5 days ago. |
to |
Date specifying the end date for the trade data. Defaults to the current date. |
symbol_info |
Logical indicating whether to include symbol information in the returned data. Defaults to FALSE. |
time_transform |
Logical indicating whether to transform the timestamps to the local timezone. Defaults to TRUE. |
verbose |
Logical indicating whether to print verbose output. Defaults to FALSE. |
A data frame containing the trade data.
Not for the faint of heart. All profits and losses related are yours and yours alone. If you don't like it, write it yourself.
Vyacheslav Arbuzov
getTrades(src = "tinkoff", api.key = "tks token", clientId = "clientID", figi = "figi",verbose=TRUE)
getTrades(src = "tinkoff", api.key = "tks token", clientId = "clientID", figi = "figi",verbose=TRUE)
This function place an existing order on a specified broker or exchange platform
placeOrder( src = "tinkoff", symbol = "SBER", board = "MOEX", action = "BUY", orderType = "LMT", totalQuantity = "10", lmtPrice = "100", auxPrice = "", api.key = "", live = TRUE, tif = "", orderId = "", clientId = "", verbose = TRUE )
placeOrder( src = "tinkoff", symbol = "SBER", board = "MOEX", action = "BUY", orderType = "LMT", totalQuantity = "10", lmtPrice = "100", auxPrice = "", api.key = "", live = TRUE, tif = "", orderId = "", clientId = "", verbose = TRUE )
src |
A character string indicating the broker/exchange. Currently supported sources are 'tinkoff', 'finam', and 'alor'. |
symbol |
A character string indicating the security symbol. |
board |
A character string indicating the exchange board. |
action |
A character string indicating the action to perform. Possible values are 'BUY' and 'SELL'. |
orderType |
A character string indicating the type of order. Possible values are 'LMT' (limit) and 'MKT' (market). |
totalQuantity |
A character string or numeric value indicating the quantity of securities to order. |
lmtPrice |
A character string or numeric value indicating the limit price for the order. |
auxPrice |
A character string or numeric value indicating the auxiliary price for the order. This parameter is only used when orderType is 'STP' (stop). |
api.key |
A character string indicating the API key to use for authentication with the broker/exchange. |
live |
A logical value indicating whether to place a live (real) order or a test (paper) order. |
tif |
A character string indicating the time-in-force of the order. Possible values are 'DAY', 'GTC' (good till cancel), and 'IOC' (immediate or cancel). |
orderId |
A character string indicating the order ID to use. If empty, a random ID is generated. |
clientId |
A character string indicating the client ID to use. |
verbose |
A logical value indicating whether to print verbose output. |
A list with the result of the order placement.
Not for the faint of heart. All profits and losses related are yours and yours alone. If you don't like it, write it yourself.
myorder = placeOrder(src = 'alor', symbol = 'MTLR-6.23', board = 'MOEX', action = 'BUY', orderType = 'LMT', totalQuantity = 1, lmtPrice = 20000, api.key = '', clientId = 'cliendID')
myorder = placeOrder(src = 'alor', symbol = 'MTLR-6.23', board = 'MOEX', action = 'BUY', orderType = 'LMT', totalQuantity = 1, lmtPrice = 20000, api.key = '', clientId = 'cliendID')