Closed MislavSag closed 2 years ago
Yes, check out the fork over on github.com/yogat3ch/AlpacaforR where it is implemented.
There is no vignette("AlpacaforR", "Websockets") in you fork?
Oops, forgot to finish that! I'll get one up by the end of the weekend. I think the helpfiles give a pretty good understanding of how to use it in lieu of the vignette.
Is it possible to use websocket with paper trading? I am from EU, so, for now I am planning to just use alpaca for backtesting and paper trading. I wold be great if there would be few samples of trading strategies, like this one: https://github.com/alpacahq/alpaca-trade-api-python/tree/master/examples
Websockets streaming of price data comes through Polygon and thus only users with cash accounts are able to use the feature. You will have access to just trade and account updates as solely a paper user.
As for trading strategies - that's where your creativity comes in :D
Without price data, I think it is nor usefull. In the end I think you have to use web socket with price data, to test your strategies. I already have some srategies, but in python. But I have analysis in R, so I hope I will set it up with AlpacaforR. The thing is that there are great packages like backtrader and quantconnect for backtesting/trading and there is nothing even close in R.
You can access historical price data from the Alpaca v1 API through the market_data
function.
Websockets are for streaming realtime price data - only necessary if you are live-testing your algorithm. You can backtest to your heart's desire with the historical data.
I personally built my own backtesting engine but you can check out quantstrat
(an older package) and flyingfox for existing backtesting functionality in R.
It seems quantstrat is not maintained anymore. Do you take into account slippage, market impact, possibility that order want be fulfilled ant other important factors in backtesing?
Account slippage - no, it's random. Market impact - no, I'm not trading with enough money to where that matters. Possibility that order won't be fulfilled - the strategy is made such that unfilled orders don't matter.
I think these are questions or Alpaca itself, I'm closing this issue unless there's a reason to re-open it. Thanks!
First, thanks for the great package. I think this is the first package of this kind in R. The main reason I moved to python, from R, are great backtest / trading tools.
I saw on Alpaca site some examples with streaming: https://github.com/alpacahq/alpaca-trade-api-python/tree/master/examples
Is it even possible to set up the stream with this package, even theoretically?