Skip to main content

A small example package

Project description

cl-stocks

Stocks is a command line application where you can buy and sell stocks. It doesn't connect to a bank so it doesn't use real money. Signing up starts you off with $5,000. It's a fun project if you want to try out buying and selling stocks without the risk of losing any real money. Uses SQLite and creates a local database to use

Install with Git

$ git clone https://github.com/breakthatbass/cl-stocks.git

or with pip

to do

Get an API key from IEX

Data provided for free by IEX. View IEX's terms of use. (I have to add that per their website 🤷‍♂️)

You'll need to set the API key before running the program each time

$ export API_KEY=api-key

or you can set it once on your system as a global variable in your .bash_profile and always have it available

Commands

There are many commands for different actions.

create

create users and transactions tables in databse

$ python stocks.py create

sign-up

signs up a username to the db and starts you off with $5,000.

$ python stocks.py sign-up 'username'

sign-up will return

your username is set to 'username'
you have $5,000

lookup

look up current data on a stock

$ python stocks.py lookup 'stock-symbol'
  • example:
$ python stocks.py lookup tsla

would return something like:

symbol: TSLA
name: Tesla, Inc.
price: 800.03
52 week high: 968.99
52 week low: 176.99
volume: 15,675,035
average vol: 23,422,636

buy

$ python stocks.py buy 'stock-symbol' 'amount'
  • example
$ python stocks.py buy tsla 2

it will then prompt for your username. If you enter the username correctly, two TSLA shares will be added to the database under your username and the amount of money it costs will be substracted from the database under your username.

TODO: not require 'amount' argument. if blank, have it equal 1 by default

sell

$ python stocks.py sell 'stock-symbol' 'amount'
  • example
$ python stocks.py sell tsla 2

it will then prompt for your username. If you enter the username correctly, two TSLA shares will be subtracted to the database under your username and the amount of money it costs will be added from the database under your username.

TODO: not require 'amount' argument. if blank, have it equal 1 by default

add-funds

$ python stocks.py add-funds amount

-example

$ python stocks.py add-funds 1000

portfolio

$ python stocks.py portfolio

it will prompt for your username and return current funds, stocks owned and share amount for each, and net worth.

current funds: $2,046.97

TSLA: 5
NFLX: 1
FB: 1
ORCL: 1

net worth: $12,978.90

Project details


Release history Release notifications

This version

0.0.2

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for fstocks, version 0.0.2
Filename, size File type Python version Upload date Hashes
Filename, size fstocks-0.0.2-py3-none-any.whl (10.0 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size fstocks-0.0.2.tar.gz (5.6 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page