!!! warning!!! in version 1.1.1 new method of auth to algopack, see ?auth method
Rusquant is a package for interaction with alternative data, trading API of different exchanges and brokers. Package provides access to market data for storage, analysis, algorithmic trading, strategy backtesting. Also this is data downloader from different data sources starting from close price to order book and tradelog.
Current available brokers - tinkoff.ru, finam.ru, alorbroker.ru. Current available datasources - previous brokers + MOEX, MFD.RU, Poloniex, MarketWatch, Investing, AlgoPack
If you are interested in supporting the ongoing development and maintenance of rusquant, please consider becoming a sponsor.
The current release (1.1.1) is available on CRAN, which you can install via:
install.packages("rusquant")
To install the development version (1.1.1), you need to clone the repository and build from source, or run one of:
# lightweight
remotes::install_github("arbuzovv/rusquant")
# or
devtools::install_github("arbuzovv/rusquant")
It is possible to import data from a variety of sources with one rusquant
function: getSymbols()
. For example:
library(rusquant)
getSymbolList('Finam') # download all available symbols in finam.ru
getSymbols('LKOH',src='Finam') # default = main market
getSymbols('LKOH',src = 'Finam') # main market
getSymbols.Moex('SBER')
# type period
getSymbols('LKOH',src='Finam',period='day') # day bars - default parameter
getSymbols('LKOH',src='Finam',period='5min') # 5 min bar
getSymbols('LKOH',src='Finam',period='15min') # 15 min bar
getSymbols.Moex('SBER',period = '1min',from=Sys.Date()-20) # 1 min bar
getSymbolList('Mfd') # see the availible assets
getSymbols('Сбербанк',src='Mfd')
getEarnings(from = Sys.Date(),to = Sys.Date()+3,country='Belgium')
getEconomic(from = Sys.Date() - 10, to = Sys.Date(), country = "United States")
getIPO(from='2023-01-23',to='2023-01-25')
getDividends(from = Sys.Date(),to = Sys.Date()+2,country = "Australia")
getDividends(from = '2023-08-01',to = '2023-08-05',country = 'United States')
auth(src = "Moex",login = "arbuzov@yandex.ru",password = "mypass")
getSymbols.Algopack('SBER',from = '2023-10-24',to='2023-11-04')
getSymbols.Algopack('ROSN',from = '2023-10-24',to='2023-11-04',type = 'obstats')
# 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 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')
# orderbook data
getOrderbook('SBER', src = 'moex')
getOrderbook('SiH5', src = 'moex',market='forts')
# orderbook data
getOrderbook('SBER', src = 'moex')
getOrderbook('SiH5', src = 'moex',market='forts')
# tradelog data
getTradelog('SBER', src = 'moex')
getTradelog('SiH5', src = 'moex',market='forts')
finam_token = 'mytoken'
finam_account = 'accountid'
#get portfolio info
finam_portfolio = getPortfolio(src = 'Finam',api.key = finam_token,clientId = finam_account)
current_balance = finam_portfolio$equity
finam_universe = data.table(getSymbolList(src = 'Finam',api.key = finam_token))
#change positions
trade_symbol = 'SBER'
last_price = try(tail((getSymbols.Finam(trade_symbol,period = '1min',from=Sys.Date()-2))[,4],1),silent = T)
size_order = 1
trade_side = ifelse(size_order>0,'Buy','Sell')
board = 'TQBR'
myorder = placeOrder(src = 'finam',
symbol = trade_symbol,
board = board,
action = trade_side,
totalQuantity = size_order,
lmtPrice = as.numeric(last_price),
api.key = finam_token,
clientId = finam_account)
print(myorder)
my_orders_status = getOrders(src = 'finam',api.key = finam_token,clientId = finam_account)$orders
print(my_orders_status)