The purpose of the project is provide the user with a number of technical indcators for bitcoins price action and encourage them to pay to access the premium metric. The premium metric is a risk indicator, combining the other metrics into one and indicating optimal buying and selling oportinities.
The project contains the following apps:
-
Dashboard
- Explains the purpose of the site and encourages the user to register.
-
Login / registration
- Allows user to create an account and login.
-
Metrics
- Displays all of the currently available metrics.
-
Metric Details
- Renders a Plotly chart with Bitcoins price and selected indicator.
-
Admin CRUD
- Administrators can add price data as required (currently this is not automated)
- Administrators can edit the details of existing metrics
-
Checkout
- Users can purchase lifetime access to the premium indicator
-
As a user, I want to be able to register to the site, so that I can securely login.
-
As a user, I want to be able to sign into my account, so that I have access to the metrics available.
-
As a user, I would like the user experience on the website to be intuitive, so that I can quickly navigate to the metric I wish.
-
As a user, I want to be able to view bitcoin price data, so that I can spot trends in the price action.
-
As a user, I want to be able to view my chosen metric overlayed onto the chart, so that I can easily comprehend the metric.
-
As an administrator, I want full CRUD functionality of the price data, so that the metrics are kept up to date.
-
As the site owner, I want the checkout functionality to be secure, so that a user cannot access the premium metric without paying.
Goal: Show the user how valuable technical indicators can be when predicating Bitcoin price movements and encourage them to purchase the premium metric.
- A dynmic web app that implements the Plotly API to display Bitcoin price data in conjunction with relvent technical indicators.
- background: #1F2833;
- font: #C5C6C7;
- header: #66FCF1;
- navbar: #C5C6C7;
To display the price charts, the Plotly API for Python was used.
- HTML5
- CSS3
- JavaScript
- Python
- SQL
- Heroku for hosting the deployed application
- Django for the project configuration
- Jinja2 as a templating engine
- Plotly for graphing the data with Python
- Stripe for payments
- Psycopg2 as database adapter
- Gunicorn as a python web server
- VSCode as the IDE
- Git for version control
- Github remote git storage service
- W3C Validator Used to check the validity of my HTML and CSS.
- PEP 8 Online Validator Used to validate the Python code.
- Balsamiq for creating the wireframes.
- AWS S3 Bucket for storage of static files
- Boto3 to make use of Amazon S3
- Bootstrap for developing a responsive, mobile-first website
- jQuery JavaScript library
- Google Fonts
- FontAwesome
- SQlite3 django database queries
- PostgreSQL Heroku database service
-
HTML was validated using W3C Markup Validation Service.
-
CSS was validated using W3C CSS Validation Service - Jigsaw
-
JavaScript was passed through the linter jshint with no warnings
Num | Test | Action | Outcome image | Result |
---|---|---|---|---|
1 | As a user, I want to be able to register to the site, so that I can securely login. | Navigate to registration page and attempt to register with a valid email and password | Image | Pass |
2 | As a user, I want to be able to sign into my account, so that I have access to the metrics available. | Navigate to the login page and attempt to login with the previously registered user | Image | Pass |
3 | As a user, I would like the user experience on the website to be intuitive, so that I can quickly navigate to the metric I wish. | Once logged in, click on the metrics icon in the navbar | Image | Pass |
4 | As a user, I want to be able to view bitcoin price data, so that I can spot trends in the price action. | Select an indicator from the metrics page and view the chart displayed | Image | Pass |
5 | As a user, I want to be able to view my chosen metric overlayed onto the chart, so that I can easily comprehend the metric. | Navigate to a given metric and assess whether the moving average lines are visible | Image | Pass |
6 | As an administrator, I want full CRUD functionality of the price data, so that the metrics are kept up to date. | Login as super user, navigate to the edit price data page and attmept to add, edit and delete a given price | Image | Pass |
7 | As the site owner, I want the checkout functionality to be secure, so that a user cannot access the premium metric without paying. | Login as non-super user and attempt to access endpoints which are restricted to super users | Image | Pass |
Num | Browser | Test result |
---|---|---|
1 | Chrome | Passed |
2 | Opera | Passed |
3 | Mozzilla | Passed |
-
Chrome developer tools was used to test a wide variety of device sizes and resolutions.
-
The website has been tested on a Samsung Galaxy s10, Lenovo Legion and a desktop PC with a 1080p and 4k monitor, respectfully.
-
Follow this link to my Repository on Github and open it.
-
Click
Clone or Download
. -
In the Clone with HTTPs section, click the
copy
icon. -
In your local IDE open Git Bash.
-
Change the current working directory to where you want the cloned directory to be made.
-
Type
git clone
, and then paste the URL you copied earlier. -
Press enter and your local clone will be ready.
-
Create and start a new environment:
python -m .venv venv
source env/bin/activate -
Install the project dependencies:
pip install -r requirements.txt -
Create a new file, called
env.py
and add your environment variables:
import os
os.environ.setdefault("DJANGO_SECRET_KEY", "secret key here")
os.environ.setdefault("DATABASE_URL", "secret key here")
os.environ.setdefault("SQLITE_URL", "secret key here")
os.environ.setdefault("CACHE_URL", "secret key here")
os.environ.setdefault("REDIS_URL", "secret key here")
os.environ.setdefault("STRIPE_PUBLIC_KEY", "secret key here")
os.environ.setdefault("STRIPE_SECRET_KEY", "secret key here")
os.environ.setdefault("STRIPE_WH_SECRET", "secret key here")
os.environ.setdefault("DATABASE_URL", "secret key here")
os.environ.setdefault("EMAIL_HOST_USER", "secret key here")
os.environ.setdefault("EMAIL_HOST_PASS", "secret key here")
os.environ.setdefault("DEFAULT_FROM_EMAIL", "secret key here")
-
Go to
settings.py
file and add your environment variables. -
Add
env.py
to .gitignore file -
Go to terminal and run the following:
python3 manage.py makemigrations
, thenpython3 manage.py migrate
to migrate all existing migrations to postgres database. -
Create a superuser:
python3 manage.py createsuperuser
-
Run it with the following command:
python manage.py runserver
-
Open
localhost:8000
on your browser -
Add
/admin
to the end of the url address and login with your superuser account to edit the models.
The following steps were taken in order to deploy this site to Heroku:
-
Created a new app in
Heroku
with a unique name, chose my region -
Went to
Resources
, within Add-ons searchedHeroku Postgres
, chose Hobby Dev - Free version, then clickedProvision
button. -
In
Settings
clicked onReveal Config Vars
button, and copied the value ofDATABASE_URL
-
Returned to terminal window and run
sudo pip3 install dj_database_url
-
Also run
sudo pip3 install psycopg2
. Created a requirements.txt file using the terminal commandpip3 freeze > requirements.txt
-
Went to
settings.py
and addedimport dj_database_url
and updatedDATABASES = {'default': dj_database_url.parse(os.environ.get('DATABASE_URL'))}
also updatedenv.py
withos.environ.setdefault("DATABASE_URL", "postgres://postgres key - copied earlier from Heroku")
-
I run
python3 manage.py makemigrations
, thenpython3 manage.py migrate
to migrate all existing migrations to postgres database. -
I created a superuser:
python3 manage.py createsuperuser
-
Logged in to
Amazon AWS
, went toS3
and created a newS3
bucket. -
Returned to terminal window and run
sudo pip3 install django-storages
andsudo pip3 install boto3
. Went tosettings.py
and addedstorages
toINSTALLED_APPS
. -
Also in
settings.py
the following lines are added:
AWS_S3_OBJECT_PARAMETERS = { "Expires": "Thu, 31 Dec 2099 20:00:00 GMT", "CacheControl": "max-age=94608000", }
AWS_STORAGE_BUCKET_NAME = "bitcoin-technical-indicators" AWS_S3_REGION_NAME = "eu-west-1" AWS_ACCESS_KEY_ID = os.environ.get("AWS_ACCESS_KEY_ID") AWS_SECRET_ACCESS_KEY = os.environ.get("AWS_SECRET_ACCESS_KEY") AWS_S3_CUSTOM_DOMAIN = f"{AWS_STORAGE_BUCKET_NAME}.s3.amazonaws.com"
STATICFILES_STORAGE = "custom_storages.StaticStorage" STATICFILES_LOCATION = "static" DEFAULT_FILE_STORAGE = "custom_storages.MediaStorage" MEDIAFILES_LOCATION = "media"
STATIC_URL = f"https://{AWS_S3_CUSTOM_DOMAIN}/{STATICFILES_LOCATION}/" MEDIA_URL = f"https://{AWS_S3_CUSTOM_DOMAIN}/{MEDIAFILES_LOCATION}/"
-
Updated
env.py
withAWS
keys (these keys are fromS3
). -
Created
custom_storages.py
at the top level containing the following code:
from django.conf import settings from storages.backends.s3boto3 import S3Boto3Storage
class StaticStorage(S3Boto3Storage): location = settings.STATICFILES_LOCATION
class MediaStorage(S3Boto3Storage): location = settings.MEDIAFILES_LOCATION
- Went to
settings.py
and added:
STATICFILES_STORAGE = 'custom_storages.StaticStorage' STATICFILES_LOCATION = 'static'
DEFAULT_FILE_STORAGE = 'custom_storages.MediaStorage' MEDIAFILES_LOCATION = 'media'
-
Returned to terminal window and run
python3 manage.py collectstatic
-
Returned to
Heroku
. InSettings
clicked onReveal Config Vars
button, and added all the following config vars fromenv.py
:
Key | Value |
---|---|
AWS_ACCESS_KEY_ID | secret key here |
AWS_SECRET_ACCESS_KEY | secret key here |
DATABASE_URL | secret key here |
DISABLE_COLLECTSTATIC | 1 |
SECRET_KEY | secret key here |
STRIPE_PUBLISHABLE | secret key here |
STRIPE_SECRET | secret key here |
-
Clicked to
Deploy
, thenGitHub
, searched for my repository and clicked toConnect
button. -
Returned to terminal window and run
sudo pip3 install gunicorn
and added torequirements.txt
-
Created a
Procfile
using the following command:echo web: gunicorn ms4.wsgi:application
-
Ran
git add .
,git commit -m "my commit message"
andgit push
commands to push all changes to my GitHub repository. -
Return to
Heroku
and clickDeploy Branch
-
Once the build is complete, click on
Open app
-
Went to
settings.py
and addedbitcoin-technical-indicators.herokuapp.com
toALLOWED_HOSTS
-
Ran
git add .
,git commit -m "my commit message"
andgit push
commands to push all changes to my GitHub repository. -
Returned to
Heroku
and hitDeploy Branch
again.
-
Follow this link to my Github Repository.
-
Click 'Clone or Download'.
-
In the Clone with HTTPs section, click the 'copy' icon.
-
In your local Integrated Development Environment open Git Bash.
-
Change the current working directory to where you want the cloned directory to be located.
-
Type 'git clone', and paste the URL you copied before.
-
Press enter and your local clone will be available.
-
download bitcoin historical data csv from prefered source (e.g. investing.com)
-
edit csv to include the following cols: date, price
-
delete header row (just include the data rows)
-
set the date col to the format Y-m-d
-
set all other cols to a type of number (otherwise prices may have ',' symbol which can cause errors)
-
install sqlite extension for visual studio code
-
load the csv to the project root directory
-
use the following commands to load the data into the postgres database: .\sqlite3.exe metrics_bitcoin_price .mode csv .import <path/to/csv> metrics_bitcoin_price;
Note if using postgres, the copy command is: \copy metrics_bitcoinprice from '<path/to/csv>' csv header;
- Login to the site with the username and and password of '[email protected]' and 'Atlantic99' respectfully.
- Click 'Edit Price Data' in the navbar.
A huge thanks to my mentor Brian Macharia for his invaluable guidance throughout this project and the entire program.