Code Monkey home page Code Monkey logo

medium's Introduction

Medium articles code repository

This GitHub repository contains the code of all my Medium articles related to the stock market, crypto market, reinforcement learning, machine learning, and some other additional interesting topics. The articles cover a range of topics such as financial time series analysis, stock price prediction, portfolio optimization, and trading strategies, among others. The code is organized by article and includes Jupyter notebooks, Python scripts, and other relevant files.

The repository is intended for researchers, practitioners, and enthusiasts who want to learn more about the intersection of finance and machine learning. By providing access to the code of the articles, the repository enables users to reproduce the results and experiment with their own variations.

The repository is updated regularly with new articles and code. Contributions from the community are welcome and encouraged.

Please note that the information and code provided in this repository is for educational and informational purposes only and should not be construed as financial advice. Trading stocks and other financial instruments involves risk, and you should always do your own research and seek the advice of a licensed financial advisor before making any investment decisions. The author and publisher of this repository make no representation or warranties with respect to the accuracy or completeness of the contents of this repository and specifically disclaim any implied warranties of merchantability or fitness for any particular purpose. The author and publisher of this repository shall in no event be liable for any loss of profit or any other commercial damages, including but not limited to special, incidental, consequential, or other damages.

Articles

01.Preparation: https://medium.com/@diegodegese/ea191a15970c

02.Environment: https://medium.com/@diegodegese/b9b1b7a8a8fa

03.RLNextClose: https://medium.com/@diegodegese/c56677a9943

04.RLSellHoldBuy: https://medium.com/@diegodegese/2ab5f542a41d

05.RLStopLossTarget: https://medium.com/@diegodegese/cc03c3bcc9cb

06.GASellHoldBuy: https://medium.com/@diegodegese/541b04be685b

07.StrategyTests:

08.GABBStrategy:

09.CryptoDataDownload:

10.GARangePrices: https://medium.com/@diegodegese/fe9ed1081f8a

11.OptionsBacktest:

12.RLNextTrendNysi: https://medium.com/@diegodegese/4d4466433dda

13.TrendIntraday:

14.OptionsNakedPuts:

15.OptionsNysiTrend:

16.OptionsGATrend:

17.TrendFollowing:

18.BestPossibleStrategy:

19.MarketSentiment:

20.GAMACDStrategy:

21.ControlChartStrategy:

22.MarketDataDownload:

23.OptionsStrategy:

24.TradingAlert:

25.BBGASeries

medium's People

Contributors

crapher avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

medium's Issues

OpenAI Gymnasium instead of gym ?

@crapher

Hello Diego,

First of all thank you for creating a very nice learning environment ! I've started going through your Medium posts from the beginning, but I'm running into some problems with OpenAI's gym in sections 3, 4, and 5. When I run the code (using python3.11) I get :

./medium/venv/lib/python3.11/site-packages/stable_baselines3/common/vec_env/patch_gym.py:49: UserWarning: You provided an OpenAI Gym environment. We strongly recommend transitioning to Gymnasium environments. Stable-Baselines3 is automatically wrapping your environments in a compatibility layer, which could potentially cause issues.

And in fact it fails to run. I tried simply replacing "gym" with "gymnasium" in your code, but maybe that was a little too optimistic (it doesn't work either without further modifications). I suspect that this is all because I'm using different versions of the various packages than you used when you wrote the code. As such it could be helpful if you can include information somewhere about what python and package versions this has been tested with.

Rasmus

Some questions and remarks about your option backtesting work

@crapher

Hello Diego,

First of all thanks for the work you have done regarding the options backtesting (11.OptionsBacktest) as explained earlier on the Medium Platform in your article called "SPY Options Trading with a Profitable 1-Minute Strategy to Multiply Returns and Limit Risk". Later on I saw you extended your work to QQQ and AAPL as well. Super cool !

I'm a data enthusiast and stock market watcher as well, and I replayed and reviewed your code, trying to understand the rules you applied to trigger a new trade or close one. The code you have written is somewhat hard to interpret as it has not been fully commented out. One example would be this line: df.loc[:,'open_point'] = np.where((df['open_point'] - df['close_point']) == (df['open_point'].shift(-1) - df['close_point'].shift(-1)), 0, df['open_point'])

It looks like the code is comparing rows in order to flag them as a possible trade (or not). But the 'why' is not clear to me.
So a short explanation of the steps would be helpful.

One other thing that I could not figure out was the meaning of 'POO' (percentage over price). What is that all about?

Last remark I would make is that I am also intrigued by the posts of Michael Petryni. To me it looks like he is trading in the following manner:

  • Record the opening price of the first 1 minute bar of a relevant option at 09:30 (you have done this too)
  • Recheck the option price again at 09:44 and see if it has a positive or negative trend (you have done this too)
  • Take a trade a 09:45 of the closest ITM option. If the trend is positive take a call, otherwise a put
  • Let the trade run with a build-in stop loss level of 70% (not sure if Michael uses a SL, but I would)
  • Check at the end of the day if you have been profitable

If you have no problem with it I would like to use one of your option data files to code his scenario and see what it brings. Would you be oke with me using your options data file ?

Regards, Nick

Question about qqq_options_1m_dte_0_credit_spread.py

In your code for "How I Achieved Almost 85% Win Rate Using 0DTE Options and the Credit Spread Strategy on QQQ", I see you're using data which having some columns such as expire_date, kind, strike, open_underlying,close_underlying. Could you please give me how to have these columns?

Question on the spy alert credit spread

Hi Diego,

Thank you for sharing.
I'm a little stuck and would really appreciate your advice.

The code runs at 10.30 and I get the following message:
INFO:root:Sleeping for 23:53:18 (Checking @ 2024-01-03 10:30:00-05:00)

Q1. Any time I run the code it goes to sleep again after a couple of minutes until the next day.
My understanding is the code is designed to run at 10.30 to examine the first hour of trading but I thought it would continue to run until the end of the trading day. Please advise.

Q2. Why 10.30?

Q3. Finally, have you tested this strategy on other stocks or ETFs?

Thank you,

Kieran

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.