├── .github └── FUNDING.yml ├── LICENSE ├── README.md ├── SPX500.csv └── main.py /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | patreon: dopevog 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Vedant Kothari 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Short Term Stockmarket AI For American SPX Stocks 2 | ## Check It Out! 3 | ![t](https://user-images.githubusercontent.com/82938580/118754665-27a1ac00-b885-11eb-8ad6-954fa97d0fcb.gif) 4 | ## Run It Locally 5 | You must add your email and password in ```main.py``` on line ```35``` & ```36```: 6 | ``` 7 | sender = "" ##Your Email 8 | password = "" ## Your Email Password 9 | ``` 10 | Before doing so, you must activate [Less Secure Apps](https://myaccount.google.com/lesssecureapps) for your google account. 11 | ``` 12 | git clone https://github.com/dopevog/stockmarket-ai.git 13 | cd stockmarket-ai 14 | pip3 install smtplib, pandas, pandas_ta, pandas_datareader, datetime, yfinance, colorama, rich 15 | python3 main.py 16 | ``` 17 | 18 | ## How Accurate Is It? 19 | I __backtested__ it and it proved to have __100 % ROI__! Below is the backtested result: 20 | ![68747470733a2f2f73746f726167652e676f6f676c65617069732e636f6d2f7265706c69742f696d616765732f313632313330393930363634355f33353366653533356531376233343564363832663937323164646133376234632e706e67](https://user-images.githubusercontent.com/82938580/118754684-2e302380-b885-11eb-9598-bb78bd8b457a.png) 21 | 22 | 23 | ## License 24 | This Project is [MIT Licensed](https://github.com/dopevog/stockmarket-ai/blob/main/LICENSE) 25 | -------------------------------------------------------------------------------- /SPX500.csv: -------------------------------------------------------------------------------- 1 | Symbols 2 | MMM 3 | AOS 4 | ABT 5 | ABBV 6 | ABMD 7 | ACN 8 | ATVI 9 | ADBE 10 | AAP 11 | AMD 12 | AES 13 | AFL 14 | A 15 | APD 16 | AKAM 17 | ALK 18 | ALB 19 | ARE 20 | ALXN 21 | ALGN 22 | ALLE 23 | LNT 24 | ALL 25 | GOOGL 26 | GOOG 27 | MO 28 | AMZN 29 | AMCR 30 | AEE 31 | AAL 32 | AEP 33 | AXP 34 | AIG 35 | AMT 36 | AWK 37 | AMP 38 | ABC 39 | AME 40 | AMGN 41 | APH 42 | ADI 43 | ANSS 44 | ANTM 45 | AON 46 | APA 47 | AAPL 48 | AMAT 49 | APTV 50 | ADM 51 | ANET 52 | AJG 53 | AIZ 54 | T 55 | ATO 56 | ADSK 57 | ADP 58 | AZO 59 | AVB 60 | AVY 61 | BKR 62 | BLL 63 | BAC 64 | BAX 65 | BDX 66 | BRK-B 67 | BBY 68 | BIO 69 | BIIB 70 | BLK 71 | BA 72 | BKNG 73 | BWA 74 | BXP 75 | BSX 76 | BMY 77 | AVGO 78 | BR 79 | BF-B 80 | CHRW 81 | COG 82 | CDNS 83 | CZR 84 | CPB 85 | COF 86 | CAH 87 | KMX 88 | CCL 89 | CARR 90 | CTLT 91 | CAT 92 | CBOE 93 | CBRE 94 | CDW 95 | CE 96 | CNC 97 | CNP 98 | CERN 99 | CF 100 | SCHW 101 | CHTR 102 | CVX 103 | CMG 104 | CB 105 | CHD 106 | CI 107 | CINF 108 | CTAS 109 | CSCO 110 | C 111 | CFG 112 | CTXS 113 | CME 114 | CMS 115 | KO 116 | CTSH 117 | CL 118 | CMCSA 119 | CMA 120 | CAG 121 | COP 122 | ED 123 | STZ 124 | CPRT 125 | GLW 126 | CTVA 127 | COST 128 | CCI 129 | CSX 130 | CMI 131 | CVS 132 | DHI 133 | DHR 134 | DRI 135 | DVA 136 | DE 137 | DAL 138 | XRAY 139 | DVN 140 | DXCM 141 | FANG 142 | DLR 143 | DFS 144 | DISCA 145 | DISCK 146 | DISH 147 | DG 148 | DLTR 149 | D 150 | DPZ 151 | DOV 152 | DOW 153 | DTE 154 | DUK 155 | DRE 156 | DD 157 | DXC 158 | EMN 159 | ETN 160 | EBAY 161 | ECL 162 | EIX 163 | EW 164 | EA 165 | EMR 166 | ENPH 167 | ETR 168 | EOG 169 | EFX 170 | EQIX 171 | EQR 172 | ESS 173 | EL 174 | ETSY 175 | RE 176 | EVRG 177 | ES 178 | EXC 179 | EXPE 180 | EXPD 181 | EXR 182 | XOM 183 | FFIV 184 | FB 185 | FAST 186 | FRT 187 | FDX 188 | FIS 189 | FITB 190 | FRC 191 | FE 192 | FISV 193 | FLT 194 | FLIR 195 | FMC 196 | F 197 | FTNT 198 | FTV 199 | FBHS 200 | FOXA 201 | FOX 202 | BEN 203 | FCX 204 | GPS 205 | GRMN 206 | IT 207 | GNRC 208 | GD 209 | GE 210 | GIS 211 | GM 212 | GPC 213 | GILD 214 | GPN 215 | GL 216 | GS 217 | GWW 218 | HAL 219 | HBI 220 | HIG 221 | HAS 222 | HCA 223 | PEAK 224 | HSIC 225 | HES 226 | HPE 227 | HLT 228 | HFC 229 | HOLX 230 | HD 231 | HON 232 | HRL 233 | HST 234 | HWM 235 | HPQ 236 | HUM 237 | HBAN 238 | HII 239 | IEX 240 | IDXX 241 | INFO 242 | ITW 243 | ILMN 244 | INCY 245 | IR 246 | INTC 247 | ICE 248 | IBM 249 | IFF 250 | IP 251 | IPG 252 | INTU 253 | ISRG 254 | IVZ 255 | IPGP 256 | IQV 257 | IRM 258 | JBHT 259 | JKHY 260 | J 261 | SJM 262 | JNJ 263 | JCI 264 | JPM 265 | JNPR 266 | KSU 267 | K 268 | KEY 269 | KEYS 270 | KMB 271 | KIM 272 | KMI 273 | KLAC 274 | KHC 275 | KR 276 | LB 277 | LHX 278 | LH 279 | LRCX 280 | LW 281 | LVS 282 | LEG 283 | LDOS 284 | LEN 285 | LLY 286 | LNC 287 | LIN 288 | LYV 289 | LKQ 290 | LMT 291 | L 292 | LOW 293 | LUMN 294 | LYB 295 | MTB 296 | MRO 297 | MPC 298 | MKTX 299 | MAR 300 | MMC 301 | MLM 302 | MAS 303 | MA 304 | MXIM 305 | MKC 306 | MCD 307 | MCK 308 | MDT 309 | MRK 310 | MET 311 | MTD 312 | MGM 313 | MCHP 314 | MU 315 | MSFT 316 | MAA 317 | MHK 318 | TAP 319 | MDLZ 320 | MPWR 321 | MNST 322 | MCO 323 | MS 324 | MSI 325 | MSCI 326 | NDAQ 327 | NTAP 328 | NFLX 329 | NWL 330 | NEM 331 | NWSA 332 | NWS 333 | NEE 334 | NLSN 335 | NKE 336 | NI 337 | NSC 338 | NTRS 339 | NOC 340 | NLOK 341 | NCLH 342 | NOV 343 | NRG 344 | NUE 345 | NVDA 346 | NVR 347 | NXPI 348 | ORLY 349 | OXY 350 | ODFL 351 | OMC 352 | OKE 353 | ORCL 354 | OTIS 355 | PCAR 356 | PKG 357 | PH 358 | PAYX 359 | PAYC 360 | PYPL 361 | PENN 362 | PNR 363 | PBCT 364 | PEP 365 | PKI 366 | PRGO 367 | PFE 368 | PM 369 | PSX 370 | PNW 371 | PXD 372 | PNC 373 | POOL 374 | PPG 375 | PPL 376 | PFG 377 | PG 378 | PGR 379 | PLD 380 | PRU 381 | PEG 382 | PSA 383 | PHM 384 | PVH 385 | QRVO 386 | QCOM 387 | PWR 388 | DGX 389 | RL 390 | RJF 391 | RTX 392 | O 393 | REG 394 | REGN 395 | RF 396 | RSG 397 | RMD 398 | RHI 399 | ROK 400 | ROL 401 | ROP 402 | ROST 403 | RCL 404 | SPGI 405 | CRM 406 | SBAC 407 | SLB 408 | STX 409 | SEE 410 | SRE 411 | NOW 412 | SHW 413 | SPG 414 | SWKS 415 | SNA 416 | SO 417 | LUV 418 | SWK 419 | SBUX 420 | STT 421 | STE 422 | SYK 423 | SIVB 424 | SYF 425 | SNPS 426 | SYY 427 | TMUS 428 | TROW 429 | TTWO 430 | TPR 431 | TGT 432 | TEL 433 | TDY 434 | TFX 435 | TER 436 | TSLA 437 | TXN 438 | TXT 439 | BK 440 | CLX 441 | COO 442 | HSY 443 | MOS 444 | TRV 445 | DIS 446 | TMO 447 | TJX 448 | TSCO 449 | TT 450 | TDG 451 | TRMB 452 | TFC 453 | TWTR 454 | TYL 455 | TSN 456 | USB 457 | UDR 458 | ULTA 459 | UAA 460 | UA 461 | UNP 462 | UAL 463 | UPS 464 | URI 465 | UNH 466 | UHS 467 | UNM 468 | VLO 469 | VAR 470 | VTR 471 | VRSN 472 | VRSK 473 | VZ 474 | VRTX 475 | VFC 476 | VIAC 477 | VTRS 478 | V 479 | VNO 480 | VMC 481 | WRB 482 | WBA 483 | WMT 484 | WM 485 | WAT 486 | WEC 487 | WFC 488 | WELL 489 | WST 490 | WDC 491 | WU 492 | WAB 493 | WRK 494 | WY 495 | WHR 496 | WMB 497 | WLTW 498 | WYNN 499 | XEL 500 | XLNX 501 | XYL 502 | YUM 503 | ZBRA 504 | ZBH 505 | ZION 506 | ZTS 507 | -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | import subprocess 2 | import sys 3 | def install(package): 4 | subprocess.check_call([sys.executable, "-m", "pip", "install", package]) 5 | install("pandas-ta") 6 | install("rich") 7 | 8 | import smtplib 9 | from subprocess import call 10 | import os 11 | import pandas as pd 12 | import pandas_ta 13 | from pandas_datareader import data as pdr 14 | from datetime import date 15 | import datetime 16 | import yfinance as yf 17 | from colorama import Fore, init 18 | init() 19 | from rich import print as rprint 20 | from time import sleep 21 | yf.pdr_override() 22 | 23 | exiting = Fore.RED + 'Exiting...' 24 | e =[] 25 | e = [] + [" "] 26 | stock_list = pd.read_csv("SPX500.csv") 27 | x = 1 28 | number_of_stocks = 505 29 | def listToString(e): 30 | 31 | seprator = "\n- " 32 | 33 | return (seprator.join(e)) 34 | 35 | sender = "" ##Your Email 36 | password = "" ## Your Email Password 37 | 38 | def clear(): 39 | # check and make call for specific operating system 40 | _ = call('clear' if os.name =='posix' else 'cls') 41 | 42 | clear() 43 | i=0 44 | while i < 1: 45 | exit = Fore.RED+"*Enter 'exit' at any point to exit" 46 | inpt = Fore.GREEN+'>> ' 47 | opt = input(Fore.GREEN+f''' 48 | █▀ ▀█▀ █▀█ █▀▀ █▄▀ █▀▄▀█ ▄▀█ █▀█ █▄▀ █▀▀ ▀█▀   ▄▀█ █ 49 | ▄█ ░█░ █▄█ █▄▄ █░█ █░▀░█ █▀█ █▀▄ █░█ ██▄ ░█░   █▀█ █ 50 | 51 | Chose an option: 52 | a - about 53 | s - run the program 54 | c - credits 55 | {exit} 56 | {inpt}''') 57 | 58 | if opt == "a": 59 | print(''' 60 | This program uses an algorithm which has been backtested and proven to give 61 | one hundred percent ROI. Yet, it is advisory to do your OWN research before investing. 62 | All stocks chosen beloing to the american American SPX index. If you decide to buy the 63 | stocks chosen by the program, then it is advisory to spend the same principle amount 64 | on each of them to minimise the risk. 65 | ''') 66 | rprint(''' 67 | Check out the backtested result here: https://bit.ly/3bkh9QB 68 | ''') 69 | wait = input("") 70 | if wait == 'exit': 71 | clear() 72 | print(exiting) 73 | sleep(0.5) 74 | clear() 75 | break 76 | clear() 77 | 78 | elif opt == "c": 79 | print(''' 80 | The program and algorithm are both developed by Vedant k. 81 | ''') 82 | wait = input("") 83 | if wait == 'exit': 84 | clear() 85 | print(exiting) 86 | sleep(0.5) 87 | clear() 88 | break 89 | clear() 90 | 91 | elif opt == "s": 92 | email = input(''' 93 | What is you email ID (The Stocks Chosen Will Be Sent To You Here): ''') 94 | if email == 'exit': 95 | clear() 96 | print(exiting) 97 | sleep(0.5) 98 | clear() 99 | break 100 | while x != number_of_stocks: 101 | ticker = stock_list.iloc[x]["Symbols"] 102 | today = date.today() 103 | start_date = today - datetime.timedelta(days = 365) 104 | data = pdr.get_data_yahoo(ticker, start=start_date, end=today) 105 | openrate = data["Open"] 106 | close = data["Adj Close"] 107 | high = data["High"] 108 | low = data["Low"] 109 | data["RSI"] = pandas_ta.momentum.rsi(close, length=None, scalar=None, drift=None, offset=None) 110 | stoch = pandas_ta.momentum.stoch(high, low, close, k=None, d=None, smooth_k=None, offset=None) 111 | data["K"] = stoch.STOCHk_14_3_3 112 | data["D"] = stoch.STOCHd_14_3_3 113 | 114 | data['Up'] = data.RSI>60 115 | data['StochUp'] = (data.K>60) & (data.D>60) & (data.K<80) & (data.D<80) 116 | df = data.iloc[-3:] 117 | 118 | df.to_csv('df.csv') 119 | df = pd.read_csv('df.csv') 120 | 121 | cu = df.at[2,'Up'] 122 | cy = df.at[1,'Up'] 123 | cd = df.at[0,'Up'] 124 | su = df.at[2,'StochUp'] 125 | sy = df.at[1,'StochUp'] 126 | sd = df.at[0,'StochUp'] 127 | 128 | if cu == True & su == True: 129 | x = x+1 130 | if cy == False & cd == False: 131 | Buy = True 132 | e = e+[ticker] 133 | 134 | else: 135 | x = x+1 136 | 137 | clear() 138 | print(Fore.BLUE + "Sending Email...") 139 | out = listToString(e) 140 | s = smtplib.SMTP('smtp.gmail.com', 587) 141 | s.starttls() 142 | s.login(sender, password) 143 | message = f''' 144 | List Of Stocks With A Buy Signal: 145 | {out} 146 | ''' 147 | s.sendmail(sender, email, message) 148 | s.quit() 149 | print(Fore.BLUE + "Email Sent!") 150 | sleep(2) 151 | clear() 152 | break 153 | 154 | elif opt == "exit": 155 | clear() 156 | print(exiting) 157 | sleep(0.5) 158 | clear() 159 | break 160 | 161 | else: 162 | wait = input(Fore.RED+''' 163 | Please Enter A Valid Option''') 164 | if wait == 'exit': 165 | clear() 166 | print(exiting) 167 | sleep(0.5) 168 | clear() 169 | break 170 | clear() 171 | 172 | 173 | 174 | 175 | 176 | #df = pd.DataFrame() 177 | #help(df.ta) 178 | #df.ta.indicators() 179 | #help(pandas_ta.atr) 180 | --------------------------------------------------------------------------------