GithubHelp home page GithubHelp logo

arbuzovv / rusquant Goto Github PK

View Code? Open in Web Editor NEW
41.0 2.0 20.0 3.22 MB

Official version of rusquant package for R

Home Page: http://rusquant.ru

License: GNU General Public License v3.0

R 100.00%
r datasource finance trading investing-api finam investing cryptocurrency dividends ipo

rusquant's Introduction

Rusquant

CRAN_Status_Badge CRAN_Downloads CRAN_Ago

Intro

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

Supporting rusquant development

If you are interested in supporting the ongoing development and maintenance of rusquant, please consider becoming a sponsor.

Installation

The current release (1.0.5) is available on CRAN, which you can install via:

install.packages("rusquant")

To install the development version (1.1.0), 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")

Getting Started

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 

Get data from Mfd.ru

getSymbolList('Mfd') # see the availible assets
getSymbols('Сбербанк',src='Mfd')

Get fundamental data from Investing

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

Get microstructure data from AlgoPack

auth(src = "Moex",login = "[email protected]",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')

Live trading using broker account Finam

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)

Author

Vyacheslav Arbuzov

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.