flooidio / tradebot

Trading Bot
BSD 2-Clause "Simplified" License
2 stars 0 forks source link

Options Trading Strategy Brainstorm #6

Open joe-wojniak opened 3 years ago

joe-wojniak commented 3 years ago

Which options trading strategies might be best for a trading bot?

fredyvilla commented 3 years ago

I would start with spreads on SPX for 2DTE, 1DTE or 0 DTE.

fredyvilla commented 3 years ago

Bullish put credit spreads provide better P/L statistically than Bearish call credit spreads or condors.

joe-wojniak commented 3 years ago

Some short term strategies use the short term momentum of the underlying and then sell a CALL or PUT spread depending upon the direction. For example, SPX is trending down COB Friday: 2021-05-21 SPX CHART 2021-05-21 SPX RISK 2021-05-21 SPX RISK PUT

jwwjcw commented 3 years ago

I've never been a fan of covered calls. I'm thinking that married puts risk would be hard to scale. I use married puts in my IRA sometimes but there always seems to be a mismatch in the put versus the number of shares.

jwwjcw commented 3 years ago

Here’s an approach that I dabbled with the you may or may not find useful for shorter term trading. The SPY chart shows an indicator that I developed for TradeStation that does a prediction “x” bars in advance using a Kalman filter of ATR. I haven’t tested this on short timeframes but the indicator is normally 70%+ accurate. The chart is a 5 minute chart and is saying that after 30 minutes of trading the next day, SPY should be trading between 414.03 & 415.87. I would expect that a lot of the missed predictions would be due to gaps at the open (you can see this on the chart). I haven’t really evaluated this for shorter timeframes. Might be a fun group project… I’ve used this as a check in my longer term options positions (versus relying solely on delta as an estimation of POP). I’ve occasionally looked at ways to improve the prediction but without much luck. I have used this in longer term Iron Condors as the algorithm appears to predict on a weekly & monthly basis with the same accuracy. One pit fall is that the predictions are often (not always) far OTM. I haven’t found a good, automated, way to monitor delta versus the prediction without getting blurry eyed from looking up quotes so I’ve put this on the shelf.
I didn’t develop the python code for this. My development process to date has been brute force on my desktop without using Git. I’ve basically done my own development environment. I have indicators in TradeStation that I’ve developed over the years and export the data as .txt file from my platform. I then have a folder that contains the data and use pandas or brute force parsing to get into the data.
I don’t think that I mentioned on our zoom that I do have a computer science degree and have been thinking about taking a Masters in Data Sciences at UBC next year. So, I guess it’s about time that I dive into Git/GitHub. I was think that I would develop a repo for my Kalman work (I’ve dubbed it KATR) and some of my work on trading channels. In the meantime please let me know if you would like to look at the KATR indicator code. The code is in TradeStation EasyLanguage but I’m sure you could decode it.

SPY 5 Min

joe-wojniak commented 3 years ago

Kalman filters are interesting, I haven't looked into them in detail yet. Feel free to post into a new folder at the root level of the project directory. I'd love to read through your code. FYI- Python has become the language most data scientists use, although many academics continue to use R.

-Joe W.

On Sun, May 23, 2021 at 1:50 PM jwwjcw @.***> wrote:

Here’s an approach that I dabbled with the you may or may not find useful for shorter term trading. The SPY chart shows an indicator that I developed for TradeStation that does a prediction “x” bars in advance using a Kalman filter of ATR. I haven’t tested this on short timeframes but the indicator is normally 70%+ accurate. The chart is a 5 minute chart and is saying that after 30 minutes of trading the next day, SPY should be trading between 414.03 & 415.87. I would expect that a lot of the missed predictions would be due to gaps at the open (you can see this on the chart). I haven’t really evaluated this for shorter timeframes. Might be a fun group project… I’ve used this as a check in my longer term options positions (versus relying solely on delta as an estimation of POP). I’ve occasionally looked at ways to improve the prediction but without much luck. I have used this in longer term Iron Condors as the algorithm appears to predict on a weekly & monthly basis with the same accuracy. One pit fall is that the predictions are often (not always) far OTM. I haven’t found a good, automated, way to monitor delta versus the prediction without getting blurry eyed from looking up quotes so I’ve put this on the shelf. I didn’t develop the python code for this. My development process to date has been brute force on my desktop without using Git. I’ve basically done my own development environment. I have indicators in TradeStation that I’ve developed over the years and export the data as .txt file from my platform. I then have a folder that contains the data and use pandas or brute force parsing to get into the data. I don’t think that I mentioned on our zoom that I do have a computer science degree and have been thinking about taking a Masters in Data Sciences at UBC next year. So, I guess it’s about time that I dive into Git/GitHub. I was think that I would develop a repo for my Kalman work (I’ve dubbed it KATR) and some of my work on trading channels. In the meantime please let me know if you would like to look at the KATR indicator code. The code is in TradeStation EasyLanguage but I’m sure you could decode it.

[image: SPY 5 Min] https://user-images.githubusercontent.com/58279021/119274554-7c735880-bbde-11eb-954e-0fe6d6d641c2.jpg

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/flooidio/tradebot/issues/6#issuecomment-846615174, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEAV4CAO7O3GZG4Z5XLV4W3TPFL6PANCNFSM45HLZBMQ .

-- -Joe Wojniak

CONFIDENTIALITY NOTICE: The contents of this email message and any attachments are intended solely for the addressee(s) and may contain confidential and/or privileged information and may be legally protected from disclosure.

fredyvilla commented 3 years ago

I write indicators in TradingView and TOS but would be definitely interested in learning EasyScript. We should be able to port the code over to python. I don't know much about Kalman filter. Sounds very interesting. The red and blue lines seem to mirror the underlying price movement. Is this a leading or lagging indicator?

jwwjcw commented 3 years ago

KATR.txt

jwwjcw commented 3 years ago

KATR is lagging in the sense that it is based on ATR; however, it is more predictive versus leading. When I first developed this I was looking for a way to combine weekly (or monthly) bars to sell 120 day+ spreads hoping to find an edge. The reason I scrapped it is that the predictions range from 0 to about 20 delta options. So if I sell a put based on this the best I can do is normally a 20 delta. So, without connecting the delta with the prediction in some meaningful way it becomes tedious to look for trades. However, my (very recent) thought was that if there is a focus on one symbol at a lower timeframe there may be some edge in these predictions. This may or may not help with short 0/1 DTE trades.

jwwjcw commented 3 years ago

With respect to back testing an options strategy there are several entry "triggers" that could be considered.

  1. Find the delta then the strike price and monitor the option. I would guess this is the most common.
  2. Use an indicator such as ATR, KATR, STD, etc. This would start with a price target then a strike price could be found.
  3. Machine Learning projections. These signals would be based upon any number of statistics from the underlying or from the options chain.
  4. There are other indicators that may be appropriate but they would all be signal based. For example, (I'm not endorsing the idea) a moving average crossover or key reversal. Signals would not always be present. If any of these type signals were found to be productive they would be included in a machine learning algo.

Once in a trade there may be some benefit to monitoring the Greeks...

It's not clear to me which approach would have the best results and it may be appropriate to sample each? For the really short term trades I would expect machine learning would be superior but that is just a gut feeling (and I'm biased).

If we are looking at specific entries in a very short term expiration and focused on a signal symbol (SPY) then it looks like the data from https://datashop.cboe.com/options-intervals is not too expensive. I've included a sample download (attached) that we could possibly play with as input data. From there a bot could be generated and/or manual trading could be used.

I would think that starting with 1 or 2 DTE would be a good way to go. Then use pandas to filter the input. Thoughts? J Sample 30 min option quotes.xlsx

J

jwwjcw commented 3 years ago

If we use this type of historic data for testing we would need to match quote dates with expiration dates and select only the expiration dates that are 1 or 2 days away from the quote dates. These files will be huge so we could cut the dataset down to only the selected days to expiration as a first step. Next step could be to specify puts or calls and further reduce the data. We can always come back to this step and do the other.

The assumption is that we are selling premium. At this point we could then find the desired opening time (10:30 or 11:30 in the sample data) to make the sale. We could then locate the desired option to sell based upon whatever algorithm we select. In the case of delta multiple items could be found so we would need to select a specific item based on some criteria (lowest delta?). Once the option is selected we would have the bid price and all the other stats to play with.

At this point we could manage the trade and/or just pick out at time to close the trade (15:30 or 16:00). This should yield some basic stats to work with. I think all the above is very do-able with pandas.

Provided all the above tests well we could turn to the development of a bot.

Thoughts? J

joe-wojniak commented 3 years ago

I think we can structure it as a machine learning problem, which then finds the optimum result. This simply requires features (KATR, delta, price, a technical indicator of the underlying, etc.) and the outcome- for example, closing the trade when X% profit is achieved. We have a data collector running, storing the options chain data from TDAmeritrade. Historical data could help us start exploring data relationships and early model development while live data is being stored. I'm not sure what critical mass is for machine learning-- in most cases thousands of records is a good place to start. In the case of options, I think we'd want thousands of expired contracts. I'll check ^SPX to see how many weekly contracts there are. Continuing the discussion on Discord