Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Repository files navigation

Trade Stocks

Table of Contents
  1. Description
  2. About Trade Stocks app
  3. Code-base structure
  4. Libraries used
  5. Prerequisites
  6. Motivation for Project
  7. About CS50

Description:

The app helps the user to trade shares as well as monitor and update their investment, account and profile.

Please include GUI programming in python course it helps to grasps the knowledge of functions, arguments, wrappers and passing of variables and functions in objects and functions and object oriented programming in more intuitive way. the problem sets of python course were easier and faster to solve than CS50x course which had more logic build into solving them so please make the problem sets as similarly challenging to CS50x course for python course as well

About Trade Stocks app

Objective of the app design

Make the navigation faster,responsive, smoother, simpler and self explanatory for the user to provide engaging and comfortable user experience.

Features of the app:

  • user authentication using regular expression and database authentication
  • changing the color mode of the app using dictionary to store all color and font and then changing the mode of the app only by changing the colors in the dictionary as the keys are referenced by the widgets
  • customized widgets: enhanced aesthetics and reponsiveness of standard widgets through designed wrapper functions
  • Access and update of profile details of the user
  • Data visualization through tables and charts for transaction and portfolio records
  • Modals for transactions grabs the attention to the transaction in the moment and keeps the user on the dashboard post-transaction so user can see the changes to his investment and portfolio instantly from transactions
  • Concurrent programming by threading fetch the share details in real time from the iexcloud api and update the portfolio in the background
  • image caching
    caching colored and resized images used in the widgets of the app to access the images directly to update the widget rather than resizing the same image everytime on app navigation for faster latency

App Walkthroughs

New user walkthrough
New user walkthrough
Color mode change walkthrough Transaction table walkthrough
color mode change walkthrough Transaction table walkthrough

Future recommendations

  • Plotting trend and candlestick charts showing the real time changes in the share prices in animation
  • Showing complete share history,trends and details on clicking on the shares in the portfolio window
  • Implement asynchronous programming over concurrent threading for fetching and updating share details in the background since asynchronouse programming provides relatively lower overhead in latency and space over concurrent threads and are more easier to shutdown than threads
  • More detailed simulation of user action events over the widgets of the app for automated testing
  • Profiling app to identify areas which makes the app slow because right now app does have slower loading time and gets slower on some features like matplotlib charts or manipulating pixels of large image at the registration page which are computationally intensive work so finding ways to either reduce computation without affecting quality, or bypassing/outsourcing computation in the background through threading or asynchronouse programming which does not hinder the working of the app and at the same time allows for faster and smoother navigation of the app

Code-base structure

The app is designed and coded inspired by the MVC pattern. An intuitive structure is presented below:

< PROJECT ROOT >
    |
    |-- images/           # contains images used in the app
    |
    |--dashboard.py       # handles all the app routes to transaction,visualization and profile
    |
    |--helpers.py         # provides helper function for multiple modules
    |
    |--models.py          # executes all database related functions
    |
    |--project.py         # instantiates app, handles login and registration routes
    |
    |--test_project.py    # test functions for the functions in the app
    |
    |--window.py          # creates and executes top-level windows used in the app
    |
    |--models.db          # database to store user,transaction and portfolio records
    |
    |--.env               # api key and color mode key to be injected via environment
    |
    |--requirements.txt   # App dependencies
    |
    |-- ************************************************************************

Libraries used

The application is build primarily using the tkinter library and framework of python and below are the major librarires used:

  • tkinter : manages the front-end GUI, backend requests and responses
  • sqlite : database that stores user,transaction,portfolio details
  • threading and concurrent.futures : gets and updates share details in the background
  • pandas : prepares data for matplotlib charts
  • matplotlib : shows the bar graph and pie chart for user portfolio
  • pillow : pillow libary for image manipulation
  • pytest :for testing the functions in the app

Prerequisites

Download and clone the repository

$ git clone https://github
$ cd project

Installation Setup

For Linux, MacOS

Install modules via virtual environment VENV

$ pip install virtualenv
$ virtualenv env
$ source env/bin/activate
$ pip install -r requirements.txt

Set Up Environment API Key

$ export API_KEY=your API key

Start the app

$ python project.py
# OR
$ ./project.py

For Windows

Install modules via virtual environment VENV (windows)

> pip install virtualenv
> virtualenv env
> .\env\Scripts\activate
> pip install -r requirements.txt

Set Up Environment API key

 # For CMD 
> set API_KEY=your API key

 # For Powershell
> $env:API_KEY="your API key"

Start the app

> python project.py
# OR
> .\project.py

Iexcloud activation

Activate your iexcloud account through registration to generate your API key API_KEY: the key through which app can interact with iexcloud api to fetch share details In terminal window type:

$ code .env   # to open.env file
# write API_KEY=your API key in the .env file
# you will never have to use export/set/$env command everytime before running the app

Motivation for Project

Research motivation

  • Learning about GUI development,implementation and functioning, layout management in GUI and understanding event driven programming.
  • Learning about concurrency and threading to run multiple functions and processes together while transferring data between them safely without blocking each other significantly
  • Creating pipelines for the data for automated data generation, data updation and data retrieval interchangeably at different places leading to automatic feature changes on the app.
  • data visualization and data analysis using matplotlib and pandas library of python

What i learned from building and researching about the project

  • Object Oriented Programming: classes abstracts and encapsulates attributes and methods of different windows which simplifies their identification in the app and that helps in passing the objects for the windows for navigation purposes easily in the app using event driven programming the methods of object instances are executed on user events without needing to specifically call the methods of the objects outside of the class itself.

  • GUI layout management: design decisions to use grid,pack or place geometry manager for specific widgets

  • Event loop and Event handling: usage of callbacks on event binding for event handling, utilizing tkinter mainloop to manipulate data using .after methods using event generation to create simulation of user inputs for automated test

  • Creating custom widgets: creating custom ttk widgets using elements getting elements from other themes and then arranging style layout and configuring style of the custom elements in order to make the appearance of custom ttk widgets as per the theme of the app creating custom responsive widgets through wrapper functions based on theme of the app and configuring style changes user's mouse and keyboard movements

  • Transaction in database: implementing Atomic transaction to maintain the consistency of the database implementing CRUD functionalities

  • Concurrent programming using threading: producer-worker pattern, locks,joins,events,queue implementation in threads which also helps to understand GIL-global interpreter lock of python, passing the data between the threads, thread-safety

  • Matplotlib charts: transformations from data coordinates to pixel coordinates. matplotlibs chart graphic implementation using artist, renderer. embedding of matplotlib charts in tkinter, subplotting charts. manipulating legend handles for making custom legends, creating custom legends using Path geometry, manipulating axis and ticks to show and hide elements or data from chart. custom tooltip annotation on hover pandas dataframe manipulation and usage with matplotlib charts

  • Image manipulation: coloring image through pixel RGBA values manipulation,caching the resized and colored image used for widgets on the directory for faster retrieval of the image to save time on app navigation

  • Exception and error handling: design decision on catching or passing the exception

  • Implementations of closures,decorator functions,context managers, generators,function stack frame and traceback.

About CS50p

CS50’s Introduction to Programming with Python is a openware course from Havard University and taught by David J. Malan. This course helps the students learn programming by teaching how to read and write code as well as how to test and 'debug' code using Python language.The course teaches the students about functions,arguments,return values; variables and types;loops,conditionals and boolean expressions; handle exceptions;find and fix bugs; write unit tests; use third-party libraries; validate and extract data with regular expressions; model real-world entities with classes, objects, methods, and properties; and read and write files. Exercises are inspired by real-world programming problems This Was CS50.

Where to look for CS50 course? https://cs50.harvard.edu/python/2022/

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages