Skip to content

Commit 004c800

Browse files
committed
added the web data
0 parents  commit 004c800

File tree

1,323 files changed

+65395
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,323 files changed

+65395
-0
lines changed

.gitignore

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
# Byte-compiled / optimized / DLL files
2+
../../.idea/
3+
.idea/
4+
__pycache__/
5+
6+
eattheblocks/
7+
__pycache__/
8+
*.py[cod]
9+
*$py.class
10+
.idea/
11+
# C extensions
12+
*.so
13+
14+
# Distribution / packaging
15+
.Python
16+
build/
17+
develop-eggs/
18+
dist/
19+
downloads/
20+
eggs/
21+
.eggs/
22+
lib/
23+
lib64/
24+
parts/
25+
sdist/
26+
var/
27+
wheels/
28+
pip-wheel-metadata/
29+
share/python-wheels/
30+
*.egg-info/
31+
.installed.cfg
32+
*.egg
33+
MANIFEST
34+
35+
# PyInstaller
36+
# Usually these files are written by a python script from a template
37+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
38+
*.manifest
39+
*.spec
40+
41+
# Installer logs
42+
pip-log.txt
43+
pip-delete-this-directory.txt
44+
45+
# Unit test / coverage reports
46+
htmlcov/
47+
.tox/
48+
.nox/
49+
.coverage
50+
.coverage.*
51+
.cache
52+
nosetests.xml
53+
coverage.xml
54+
*.cover
55+
*.py,cover
56+
.hypothesis/
57+
.pytest_cache/
58+
59+
# Translations
60+
*.mo
61+
*.pot
62+
63+
# Django stuff:
64+
*.log
65+
local_settings.py
66+
db.sqlite3
67+
db.sqlite3-journal
68+
69+
# Flask stuff:
70+
instance/
71+
.webassets-cache
72+
73+
# Scrapy stuff:
74+
.scrapy
75+
76+
# Sphinx documentation
77+
docs/_build/
78+
79+
# PyBuilder
80+
target/
81+
82+
# Jupyter Notebook
83+
.ipynb_checkpoints
84+
85+
# IPython
86+
profile_default/
87+
ipython_config.py
88+
89+
# pyenv
90+
.python-version
91+
92+
# pipenv
93+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
94+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
95+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
96+
# install all needed dependencies.
97+
#Pipfile.lock
98+
99+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
100+
__pypackages__/
101+
102+
# Celery stuff
103+
celerybeat-schedule
104+
celerybeat.pid
105+
106+
# SageMath parsed files
107+
*.sage.py
108+
109+
# Environments
110+
.env
111+
.venv
112+
env/
113+
venv/
114+
ENV/
115+
env.bak/
116+
venv.bak/
117+
118+
# Spyder project settings
119+
.spyderproject
120+
.spyproject
121+
122+
# Rope project settings
123+
.ropeproject
124+
125+
# mkdocs documentation
126+
/site
127+
128+
# mypy
129+
.mypy_cache/
130+
.dmypy.json
131+
dmypy.json
132+
133+
# Pyre type checker
134+
.pyre/
135+
node_modules

.vscode/launch.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "Python: Current File",
9+
"type": "python",
10+
"request": "launch",
11+
"program": "${file}",
12+
"console": "integratedTerminal"
13+
}
14+
]
15+
}

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 Danksta
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.

Procfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
web: gunicorn run:app --log-file=-

README.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# reddit-sentiment-analysis
2+
This program goes thru reddit, finds the most mentioned tickers and uses Vader SentimentIntensityAnalyzer to calculate the ticker compound value.
3+
4+
## Program Parameters
5+
<pre>
6+
subs = [] sub-reddit to search
7+
post_flairs = {} posts flairs to search || None flair is automatically considered
8+
goodAuth = {} authors whom comments are allowed more than once
9+
uniqueCmt = True allow one comment per author per symbol
10+
ignoreAuthP = {} authors to ignore for posts
11+
ignoreAuthC = {} authors to ignore for comment
12+
upvoteRatio = float upvote ratio for post to be considered, 0.70 = 70%
13+
ups = int define # of upvotes, post is considered if upvotes exceed this #
14+
limit = int define the limit, comments 'replace more' limit
15+
upvotes = int define # of upvotes, comment is considered if upvotes exceed this #
16+
picks = int define # of picks here, prints as "Top ## picks are:"
17+
picks_ayz = int define # of picks for sentiment analysis
18+
</pre>
19+
20+
## Sample Output
21+
It took 216.65 seconds to analyze 5862 comments in 80 posts in 4 subreddits.
22+
23+
Posts analyzed saved in titles
24+
25+
10 most mentioned picks:\
26+
GME: 197\
27+
BB: 72\
28+
FB: 56\
29+
PLTR: 36\
30+
TSLA: 25\
31+
PLUG: 17\
32+
RC: 15\
33+
NIO: 14\
34+
SPCE: 10\
35+
TLRY: 10
36+
37+
&nbsp; &nbsp; &nbsp; &nbsp; Bearish &nbsp; Neutral &nbsp; Bullish &nbsp; Total/Compound\
38+
GME &nbsp; 0.087 &nbsp;0.763 &nbsp; &nbsp;0.150 &nbsp; &nbsp; &nbsp;0.161\
39+
BB &nbsp; 0.058 &nbsp; 0.768 &nbsp; &nbsp; 0.175 &nbsp; &nbsp; &nbsp;0.261\
40+
FB &nbsp; 0.119 &nbsp;0.708 &nbsp; &nbsp;0.173 &nbsp; &nbsp; &nbsp;0.127\
41+
PLTR &nbsp;0.062 &nbsp;0.804 &nbsp; &nbsp; 0.134 &nbsp; &nbsp; &nbsp;0.235\
42+
TSLA &nbsp;0.124 &nbsp;0.690 &nbsp; &nbsp;0.187 &nbsp; &nbsp; &nbsp;0.195\
43+
![](mentioned.png)
44+
![](sentiment.png)
45+
46+
## Data:
47+
Includes US stocks with market cap > 100 Million, and price above $3. It doesn't include penny stocks.\
48+
You can download data from here:\
49+
Source (US stocks): https://www.nasdaq.com/market-activity/stocks/screener?exchange=nasdaq&letter=0&render=download\
50+
51+
52+
53+
Limitations:
54+
It depends mainly on the defined parameters for current implementation:
55+
It completely ignores the heavily downvoted comments, and there can be a time when
56+
the most mentioned ticker is heavily downvoted, but you can change that in upvotes variable.
57+
58+

Runtime.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
python-3.6.10

app/__init__.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# -*- encoding: utf-8 -*-
2+
"""
3+
Copyright (c) 2019 - present AppSeed.us
4+
"""
5+
6+
from flask import Flask, url_for
7+
from flask_login import LoginManager
8+
from flask_sqlalchemy import SQLAlchemy
9+
from importlib import import_module
10+
from logging import basicConfig, DEBUG, getLogger, StreamHandler
11+
from os import path
12+
13+
db = SQLAlchemy()
14+
login_manager = LoginManager()
15+
16+
def register_extensions(app):
17+
db.init_app(app)
18+
login_manager.init_app(app)
19+
20+
def register_blueprints(app):
21+
for module_name in ('base', 'home'):
22+
module = import_module('app.{}.routes'.format(module_name))
23+
app.register_blueprint(module.blueprint)
24+
25+
def configure_database(app):
26+
27+
@app.before_first_request
28+
def initialize_database():
29+
db.create_all()
30+
31+
@app.teardown_request
32+
def shutdown_session(exception=None):
33+
db.session.remove()
34+
35+
def create_app(config):
36+
app = Flask(__name__, static_folder='base/static')
37+
app.config['TEMPLATES_AUTO_RELOAD'] = True
38+
app.config.from_object(config)
39+
register_extensions(app)
40+
register_blueprints(app)
41+
configure_database(app)
42+
return app

app/base/__init__.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# -*- encoding: utf-8 -*-
2+
"""
3+
Copyright (c) 2019 - present AppSeed.us
4+
"""
5+
6+
from flask import Blueprint
7+
8+
blueprint = Blueprint(
9+
'base_blueprint',
10+
__name__,
11+
url_prefix='',
12+
template_folder='templates',
13+
static_folder='static'
14+
)

app/base/forms.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# -*- encoding: utf-8 -*-
2+
"""
3+
Copyright (c) 2019 - present AppSeed.us
4+
"""
5+
6+
from flask_wtf import FlaskForm
7+
from wtforms import TextField, PasswordField
8+
from wtforms.validators import InputRequired, Email, DataRequired
9+
10+
## login and registration
11+
12+
class LoginForm(FlaskForm):
13+
username = TextField ('Username', id='username_login' , validators=[DataRequired()])
14+
password = PasswordField('Password', id='pwd_login' , validators=[DataRequired()])
15+
16+
class CreateAccountForm(FlaskForm):
17+
username = TextField('Username' , id='username_create' , validators=[DataRequired()])
18+
email = TextField('Email' , id='email_create' , validators=[DataRequired(), Email()])
19+
password = PasswordField('Password' , id='pwd_create' , validators=[DataRequired()])

app/base/models.py

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# -*- encoding: utf-8 -*-
2+
"""
3+
Copyright (c) 2019 - present AppSeed.us
4+
"""
5+
6+
from flask_login import UserMixin
7+
from sqlalchemy import Binary, Column, Integer, String
8+
from sqlalchemy.sql.sqltypes import Date, PickleType
9+
import time
10+
from app import db, login_manager
11+
import datetime
12+
from app.base.util import hash_pass
13+
14+
class User(db.Model, UserMixin):
15+
16+
__tablename__ = 'User'
17+
18+
id = Column(Integer, primary_key=True)
19+
username = Column(String, unique=True)
20+
email = Column(String, unique=True)
21+
password = Column(Binary)
22+
23+
def __init__(self, **kwargs):
24+
for property, value in kwargs.items():
25+
# depending on whether value is an iterable or not, we must
26+
# unpack it's value (when **kwargs is request.form, some values
27+
# will be a 1-element list)
28+
if hasattr(value, '__iter__') and not isinstance(value, str):
29+
# the ,= unpack of a singleton fails PEP8 (travis flake8 test)
30+
value = value[0]
31+
32+
if property == 'password':
33+
value = hash_pass( value ) # we need bytes here (not plain str)
34+
35+
setattr(self, property, value)
36+
37+
def __repr__(self):
38+
return str(self.username)
39+
40+
41+
@login_manager.user_loader
42+
def user_loader(id):
43+
return User.query.filter_by(id=id).first()
44+
45+
@login_manager.request_loader
46+
def request_loader(request):
47+
username = request.form.get('username')
48+
user = User.query.filter_by(username=username).first()
49+
return user if user else None
50+
51+
class Picks(db.Model):
52+
53+
__tablename__ = 'Picks'
54+
55+
id = Column(Integer, primary_key=True)
56+
pick = Column(PickleType)
57+
direction = Column(String, unique=True)
58+
bearish = Column(Integer)
59+
neutral = Column(Integer)
60+
bullish = Column(Integer)
61+
total = Column(Integer)
62+
time= Column(Date, default=datetime.datetime.utcnow())
63+
64+
#def __init__(self, **kwargs):
65+
# for property, value in kwargs.items():
66+
# if hasattr(value, '__iter__') and not isinstance(value, str):
67+
# value = value[0]
68+
# if property == 'time':
69+
# value = time.ctime() # we need bytes here (not plain str)
70+
# setattr(self, property, value)
71+
def __repr__(self):
72+
return "class picks id is " + str(self.id)

0 commit comments

Comments
 (0)