regholl2023 / Advanced-Stock-Market-Trading-Robot-for-Alpaca

Advanced buying and selling robot to monitor stock market symbols from text files.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool


    Welcome to the Future of Trading with the Bull Market Advanced Stock Market Trading Robot! 

                Why Trade Manually When You Can Automate It? 

    Introducing the 2023 Edition of the Bull Market Advanced Stock Market Trading Robot, Version 3   

I recommend running this robot on the strongest trading days like Wednesday, Thursday, and Friday.

On the slower trading days: Monday and Tuesday, or days when prices do not move much, the low price buying, Billionaire Stock Market Robot will usually perform really well.

***** Upgrade to the newest version of this Python Robot today because some Python code updates were finished and some errors were recently fixed on 1-26-2024. *****

This python 3 code was tested with python 3.10 in Ubuntu 22.04 LTS Linux.

The wisest stock market investors resist the human impulse to buy stocks from human emotion related thought processes. Stocks should never be purchased based upon human emotions and should always be purchased with carefully planned out rules of logic. I am confident to announce that the newest version of this Advanced Stock Market Trading Robot is capable of resisting the human impulse to buy stocks at the wrong times because it will carefully weigh the price decreases against the price increases to prevent costly mistakes from buying stocks at the wrong times in excessive stock share numbers. For this reason, stock purchases are limited to some extent per sock purchase and this can be modified in the python code function named "def allocate_cash_equally" and with the variable named "max_allocation_per_symbol." This is a great achievement for myself as a computer programmer because it means that this is finally becoming a really effective and successful stock trading robot. I was using the new-performance-stock-list-writer.py python code with exchange traded funds or ETF funds when achieving success with this Advanced Stock Market Robot. I like the ETF funds QQQ and VTI. Results may vary, although seem very successful in general.

This new version of the robot is extra careful to help your stock market investments be successful by watching stock prices after the time of 9:30am Eastern time to buy stocks after the stock market has began trading for the current trading day for a wise buying decision to be made ( 9:30am Eastern Time is a common time when stock prices begin moving ) before buying stocks. The stocks will not be purchased if they are found to decrease in price more than they have increased in price. This means that you have less chance of losing your investment cash when the market conditions are negative.

The three major U.S. stock market indexes are the S&P 500, the Dow Jones Industrial Average, and the Nasdaq Index.

The average rate of return for each index for the past 20 years (as of December 2023) is:

S&P 500: 9.69%

Dow Jones: 8.27%

Nasdaq: 11.42%

These returns assume dividends are reinvested and are not adjusted for inflation.

You can clearly see that investing in the Nasdaq 100 is obviously the most profitable major index to invest with.

Recent facts of the US Stock Market risk assesment: Within the past 15 years, the US Stock Market only crashed in 2022 and in 2009. The stock market crashed the 1st year that an Extreme Leftist Democrat was president in 2009 and the 2nd year a similarly Extreme Leftist Democrat, close friend, and former Vice President of the 2009 Extreme Leftist Democrat was president in 2022.

( The 2009 & 2022 US Stock Market crashes that caused much sadness and many Trillions of lost investment money )

Possibly 12 Trillion dollars or more was sadly and quickly lost between the two market crashes of 2009 and 2022. Not Billion. Trillion. -$12,000,000,000,000

To explain, the 2009 Stock Market Crash was a decrease of the Dow Jones Industrial Average Index by 50% and in comparison, the 1929 Great Depression was a 53% decrease in the Dow Jones Industrial Average Index. ( Just as much of a problem as the 1929 Great Depression. )

I clearly see a market crash risk pattern definitely developed here that was associated with Extreme Leftist Democratic leadership in the USA. ( not just once, but twice the USA Stock Market Crashed under this type of a Democratic US President ) This is a 100% accurate historical Fact of US history. It is what it is. Facts are facts.

The Large List of S&P 500 stocks has been changed to include at least one US Stock Market Major Index ETF fund because I recommend that you primarily invest in Index ETF funds to be defensive against loss of profit when holding overnight stock positions. More often than not, it has been a disaster to hold custom hand-picked overnight positions in the Stock Market. In general, business stocks will be doing well during the November shopping season. Ignore most of the financial news because the fake news tells dishonest exciting stories of fiction. The very first mistake that stock market investors make is to try and hand pick stocks 1 by 1. Listen to me when I say that Billionaire stock investors have spent most of their lives trying to hand pick winning stocks, only to learn that they were almost never able to pick the right stocks. The lesson of wisdom is to buy large groups of stocks in ETF funds. Then after buying your stock, place a trailing stop sell market order for 1% below the current stock price during the daytime stock market hours. At 4:00pm Eastern time, the trailing stop sell order automatically disappears, and then you need to place a sell stop order that is GTC and 1% below the current stock price for all overnight positions. The sell orders will not work if your Daytrade count number is 3. Vanguard has some of the best ETF funds in the entire stock market. Billionaires like to wait until the market has a drop in prices before buying stocks and they do not sell stocks unless the prices drop drastically enough to cause serious concern. This is due to the fact that not even professional stock investors that are Millionaires or Billionaires are able to tell you or themselves what stocks are going to be more successful today or tomorrow. They have their favorite stocks, although they still do not know if the stocks will decrease or increase in value in the future.

***** A loss of profit when holding stock positions overnight is known as a Bear Market. It is extremely important to know if the market is currently a Bull Market or a Bear Market before deciding to hold stock positions overnight.


***** You are fortunate that I have a python script that checks if the Stock Market is currently a Bear Market or a Bull Market. I recommend running it every 24 hours to be alerted of changes from Bull Market to Bear Market conditions:

https://github.com/CodeProSpecialist/Stock-Market-Status-Check-for-a-Bear-Market-or-a-Bull-Market


I have included my most successful stocks in the list of stocks to scan.

During a recession, investing in a larger, diversified portfolio of stocks is generally considered a safer strategy than investing in individual stocks. These diversified portfolios include ETF funds like SPY, QQQ, and VTI. Most of the time in recent years QQQ would increase in value more than SPY and the other S&P 500 index ETF funds. For stock trading accounts with less than 25,000 dollars, I recommend VGT and SPY because holding these ETF funds overnight is not a problem. Diversification can help spread risk and reduce the impact of any one stock's poor performance. It's important to choose a mix of stocks across different sectors and industries to further minimize risk. However, it's also crucial to conduct thorough research or consult a financial advisor to select stocks that are relatively stable and have a history of weathering economic downturns. This strategy can provide a more balanced approach to navigate turbulent market conditions. In turbulent market conditions, it often works best to choose SPY or VTI and then hold onto it for at least 2 years. Billionaires do not recommend day trading and they recommend holding onto your ETF funds like SPY or VTI for many years.


Revolutionize Your Trading Game with the Advanced Stock Market Trading Robot 2023 Edition!

Are you ready to take your stock market trading to the next level? Introducing the cutting-edge Advanced Stock Market Trading Robot, Version 3 – a powerful Python code designed to dominate the markets, now with even more features and precision than ever before!

Unleash the Power of Technical Analysis:

Seamlessly calculate MACD, RSI, and Volume with lightning speed.
Analyze historical data to make informed and strategic trading decisions.
Stay ahead of the market trends with real-time updates.

Intelligent Trading Logic:

Buy and sell stocks with unparalleled precision based on advanced indicators.
Dynamic allocation of cash ensures optimal investment strategies.
React to market conditions intelligently, maximizing your gains in any situation.

Concurrent Buying and Selling:

Revolutionize your trading strategy with concurrent buying and selling threads.
Stay agile in the fast-paced world of stock trading, maximizing opportunities.

Secure and Reliable:

Exceptional error handling ensures the stability of your trading operations.
Safeguard your assets with secure interactions with the Alpaca API.

Built-in Database:

Keep a record of every trade in a robust database.
Analyze your trading history and fine-tune your strategy for ultimate success.

Real-Time Action, Real-Time Results:

React instantly to market changes with real-time data processing.
Witness your portfolio grow as the bot executes trades with careful precision. 

Screen-1

Screen-2

Screen-3


Important to remember: No stock list of stocks to buy will be written by the "performance stock list writer" python script if the stocks are determined to be in a current status of losing money. This is a feature to protect you and anyone else from buying stocks at the wrong times. The specific situations described would be obvious wrong times to buy stocks. I will mention that every stock sector has its favorable "buy stocks" months. For example: business stocks are the most favorable in October and November just before the Friday that follows Thanksgiving. Electricity stocks can do best May 21 through July 31. During the Winter, Natural Gas Utility Stocks are likely to be performing better than average.

This Stock Trading Robot has a strategy to buy stocks today for selling tomorrow because this allows for much more stock trading activity to take place within the stock trading rules of day trading 3 maximum times in 5 business days.

Any stocks purchased today will not begin to sell until tomorrow or until a future day when the stock price increases during stock market trading hours, Monday through Friday.

This is an Advanced buying and selling Python 3 Trading Robot to monitor a stock market symbol or a number of stock symbols that you place in the file "electricity-or-utility-stocks-to-buy-list.txt". Only place one stock symbol on each line.

To install:

You should not be the root user when installing the Python software in a virtual environment.

( First install the Anaconda python3 virtual environment. )

***** The below install commands are ONLY for a Desktop or Laptop Computer x86_64 type of install. ***** Open a command line terminal from this folder location and type:

sh install.sh

Do the following with a non-root user account: After placing your alpaca keys at the bottom of /home/nameofyourhomefolderhere/.bashrc you simply run the commands on the command line.

You will need three command line terminals open to fully operate the Advanced Stock Market Trading Robot because one terminal window is the robot and the other terminal windows are for updating the list of stocks to buy with the most successful stocks from the S&P 500.
To select different stocks to buy and allow up to 24 hours for the stocks list to update, edit the list of stocks in the files named "s-and-p-500-large-list-of-stocks.txt" and "list-of-stock-symbols-to-scan.txt". To immediatly select different stock symbols to buy, then edit the list of stocks in the file named "electricity-or-utility-stocks-to-buy-list.txt" and also in the files named "s-and-p-500-large-list-of-stocks.txt" and "list-of-stock-symbols-to-scan.txt". ***** The first command for the python file "stock-list-writer-for-list-of-stock-symbols-to-scan.py" will need about 7 to 10 hours to process the S&P 500 stock symbols. All three python commands should continue working Monday through Friday because they work together to keep up to date on the latest stock market data. ***** The second command for the python file "performance-stock-list-writer.py" will require some amount of waiting time as well, depending on how many stocks are in the list "list-of-stock-symbols-to-scan.txt".

( in a Python Anaconda environment )

( first activate Anaconda )

conda init

conda activate

Run the commands below:

python3 stock-list-writer-for-list-of-stock-symbols-to-scan.py

python3 ETF-fund-backtesting-for-profit-stock-list-writer.py

or

python3 performance-stock-list-writer.py

or

python3 new-performance-stock-list-writer.py

Your Python commands in the directory named My-Python-Virtual-Environment-Packages will be the Python commands that run this installed virtual environment's Python programs.

open an additional command line terminal and run the following command:

python3 stock-market-robot.py

( My personal new favorite stock list writer is: ETF-fund-backtesting-for-profit-stock-list-writer.py )

The performance-stock-list-writer.py python program will make sure that only successful stocks are purchased by the Advanced Stock Market Trading Robot.

Disclaimer:

This software is not affiliated with or endorsed by TradingView or Alpaca Securities, LLC. It aims to be a valuable tool for stock market trading, but all trading involves risks. Use it responsibly and consider seeking advice from financial professionals.

Ready to elevate your trading game? Download the Advanced Stock Market Trading Robot, and get started today!

Important: Don't forget to regularly update your list of stocks to buy and keep an eye on the market conditions. Happy trading!

Remember that all trading involves risks. The ability to successfully implement these strategies depends on both market conditions and individual skills and knowledge. As such, trading should only be done with funds that you can afford to lose. Always do thorough research before making investment decisions, and consider consulting with a financial advisor. This is use at your own risk software. This software does not include any warranty or guarantees other than the useful tasks that may or may not work as intended for the software application end user. The software developer shall not be held liable for any financial losses or damages that occur as a result of using this software for any reason to the fullest extent of the law. Using this software is your agreement to these terms. This software is designed to be helpful and useful to the end user.

Place your alpaca code keys in the location: /home/name-of-your-home-folder/.bashrc Be careful to not delete the entire .bashrc file. Just add the 4 lines to the bottom of the .bashrc text file in your home folder, then save the file. .bashrc is a hidden folder because it has the dot ( . ) in front of the name. Remember that the " # " pound character will make that line unavailable. To be helpful, I will comment out the real money account for someone to begin with an account that does not risk using real money. The URL with the word "paper" does not use real money. The other URL uses real money. Making changes here requires you to reboot your computer or logout and login to apply the changes.

The 4 lines to add to the bottom of .bashrc are:

export APCA_API_KEY_ID='zxzxzxzxzxzxzxzxzxzxz'

export APCA_API_SECRET_KEY='zxzxzxzxzxzxzxzxzxzxzxzxzxzxzxzxzxzxzxzx'

#export APCA_API_BASE_URL='https://api.alpaca.markets'

export APCA_API_BASE_URL='https://paper-api.alpaca.markets'

About

Advanced buying and selling robot to monitor stock market symbols from text files.

License:GNU General Public License v3.0


Languages

Language:Python 96.0%Language:Shell 4.0%