This is a README
Have you read it? If not, please do so.
If you have read this line but not the ones below, please read the lines below. If you have read all the lines, thank you!
The intent of this project is to explore the potential of algorithmic trading. Written in python, Gappy takes advantage of TD Ameritrade's API in order to make trades on the behalf of the account holder. The current in-progress algorithm identifies a selection of stock tickers which have gapped-up in the pre-market hours (hence Gappy!). Then, those tickers are monitored and a buy-order will be sent if the following criteria are fulfilled. NOTE: this strategy has been inspired by a range of YouTube videos I watched a long time ago. If I ever re-find the videos, I'll link them.
- The first correction has taken place. (a stock may gap-up, but at some point there has to be some consolidation where the first-movers dump their early morning quick profits. After this point, the stock is less volatile; and, if the following conditions are met, it has a higher chance of maintaining an upward trend on which we can capitalize)
- This first correction (represented by a red candle) is referred to as the trigger candle
- Correction must not be confused with shorting! If the volume of the current red candle is less than the volume of the prior green candle (or less than half than the prior candle in general), it's semi-safe to assume the volume is due to profit-taking (correction) and not shorting (excessive selling of the stock).
- Until a buy-order is placed AND while we have a red candle, then the trigger price associated with the trigger candle is the highest value of a red candle
- We find our first green candle. (indicates beginning of potential up-turn)
- The stock breaks the resistance identified by the trigger price by at least $0.01. (This can be modified by the user, but $0.01 over the resistance on a "well-behaved" stock is a decent indicator that a future up-turn is possible/within a respectable realm of probability)
The sell-order criteria are still in the works, but might follow some combination of the below listed Methods:
STOP-LOSS METHOD
- if the ticker drops below a certain price, then sell. This is defined during the buy-order by some percentage of risk. (i.e. if stock A is bought at $10 and you'd like to risk at most 20%, then the stop loss would be placed at $8).
- The STOP-LOSS price can be increased as the stock price increases. (i.e. if stock A is bought at $10 and it increases to $12, the STOP-LOSS can be increased to, say, $9 or $10 or $11. Whatever the user decides. Maybe the STOP-LOSS increases by $0.50 for every $1.00 increase over the purchase price. Or, maybe there is some sort of percentage rule: for every 10% increase in price, the STOP-LOSS increases by 10%)
REALIZE PROFITS METHOD
- Incorporate the STOP-LOSS from above.
- In addition, once the stock crosses a certain profit percentage threshold (defined by the user), sell! This guarantees that once you've hit your desired percentage gain, you're out! The intent is to limit "greediness." However, with proper utilization of the STOP-LOSS method, you could probably guarantee close to the same, and occasionally better, results.
There are a few libraries which need to be imported:
- splinter - creates instance of your desired browser in order to perform authorization
- chromedriver - This should all ready download with the repository, but here it is if you lose it. If you're using Google Chrome, you'll need this in addition to splinter. If you're using some other (inferior) browser, check the splinter documentation. Also, don't forget to keep track of where you keep the driver file, you'll need to store the path in a
config.py
file described below. I keep the driver file inresources
. - beautifulsoup4 - XML and HTML parser
You will also have to setup a config.py
file within a folder named private
(i.e. private/config.py
within the root directory). See the private-example
folder.
1. This code is currently incomplete and does not function as it should. I've take a bit of a hiatus from this project for the time-being. I'd say it's about 97.3% complete in regards to infrastructure, but the core trading-logic is at about 67.2% (buying procedure is pretty much done, but selling needs to be handled).
2. The results of this program are not indicative of any financial prowess and should not be used as professional advice
I, Quinton Wiebe, the creator of this program absolve myself of all responsibility in the case of lost funds.
In the case of increased funds, I take full responsibility