This thread is about implementing the strategy In & Out for paper/live trading. Ideally we will work together on this and will end up with a mix between a tutorial and a discussion where the In & Out algo is an example for any algo one wants to trade live. My plan is to share what I've learned about porting a strategy from Quantopian to live paper trading.
And of course you are welcome to share your experience with this as well!
A while ago I met someone with whom I considered founding something like a small hedge fund. Part of this was to look for the best way to run algorithms that execute actual trades. As it is best practice, the first stage was to paper trade the algorithm for a while before we start investing in it. Long story short, our algorithm dind't make it beyond the paper stage and we abandoned the project, no one lost money but we gained valuable experience which I'm willing to share.
In order to automatially trade a strategy you generally need
- a computer where the algorithm can run and
- a broker where the algo can send the orders to.
I've tried some different roads which would probably lead to the same goal but naturally chose the one that was easiest for me.
Among the roads I started but didn't follow are:
- implementing the algo on QuantConnect to trade it from there --> would have cost money just to try it
- using IBridgePy --> wasn't possible on Linux
- using Zipline-live --> was a bit of a hassle to set up with data
- using Alpaca with Blueshift integration --> Blushift didn't have the symbols I needed
- and probably some I don't remember...
I ended up using Alpaca as a broker. They have no costs for orders and a very nice python library. I also belive it was the only no (or 'low') cost broker I could find that has an API and a paper account where you can use the API without having to put in funds first.
For instance, allthough Thinkorswimm has a paper account, you couldn't use the TD-Ameritrade API with it. Perhaps this has changed by now, but back then you only could use the API for live trading with real money.
There may be brokers better suited for your needs, so feel free to use them instead!
For the computer there are many choices, from your own computer over cloud servers, to a dedicated VPS. I even could have used the host of my website - if they had python 3 instead of 2 (and no, they still haven't upgraded).
In the end I decided to use PythonAnywhere. Like the name hints it has already python on it with the most common libraries. With their free plan you get everything you need to run a trading script once a day (or continuously, but I wouldn't do that).
So, what I can show here is to use Alpaca + PA in order to run a live paper test. It's probably just one or two steps from there to trading with real money, but I haven't done that yet and also have no plans to do so just to show how it works ;)
Setting everything up will take some work/time and I can't post everything at once, so I will post it bit by bit. Also, I'll start with a simpler algo first, from there we can expand it further until we have the In & Out strategy 'up and running'.
If you have some experience with this, feel free to join!
It would probably be beneficial to see how different people tackle this task.
In the meantime I'll prepare a notebook with some simple code using the alpaca library.