[R-SIG-Finance] RobinHood R API

Daniel Cegiełka d@n|e|@ceg|e|k@ @end|ng |rom gm@||@com
Mon Apr 8 10:33:03 CEST 2019

Hi Steve,

I have never worked with RobinHood, but I have analyzed the code of
this package. Maybe my insights will be useful for you.

RobinHood, as well as Alpaca Markets, operate in the PFOF model
(payment for order flow). Your order does not go public, but is sold
to market makers. Is it good or bad? Currently, the PFOF model is
regulated by Regulation NMS[1] - your order must be filled at a price
equal to or better than the NBBO (National Best Bid and Offer) or best
price rule in short. In fact, most brokers work in the PFOF model too
- you pay a commission, but they sell your orders anyway. So RH and
Alpaca are fair here - if we make money from selling your order, you
do not pay commissions anymore. I explain this because I have noticed
that many people don't understand the RH and Alpaca's business model.

[1] https://www.investopedia.com/terms/r/regulation-nms.asp

As for this R package, it works in the request-response model. It's
not the best pattern for algo trading. Your application will have to
work in the so-called batch model:

repeat {

This is inefficient, so this solution is only suitable for very slow
models. It's difficult to manage the execution, so you should place
orders type of market.

The best pattern for algo trading is event-driven. Here you subscribe
to data stream (events) and your application responds to every new
message. IBrokers is written in this model:


Your minimal strategy should look like this:

subscribe(c('AAPL', 'MSFT', 'GS'))

on_tick <- function()

on_order <- function()
    # accepted, rejected etc.

on_exec <- function()

on_system_event <- function()

# main event loop
run_strategy(host = 'api_server', port = 123, daemon = TRUE)

place_order() means submit  and subscribe orders events.

>From what I see, RobinHood R package wasn't designed to work in such
an event-driven model.

I hope that will be helpful for you.

Best regards,

czw., 4 kwi 2019 o 19:28 Steve Hun via R-SIG-Finance
<r-sig-finance using r-project.org> napisał(a):

> hi,
> Has anyone used the RobinHood package for order management? For example, dynamic stop level setting (in other words, not use standard trailing stop) and filled order tracking?
> Thanks
>         [[alternative HTML version deleted]]
> _______________________________________________
> R-SIG-Finance using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions should go.

More information about the R-SIG-Finance mailing list