Skip to content
This repository has been archived by the owner on Dec 8, 2024. It is now read-only.

Commit

Permalink
Update - Version 1.14.0 - Good
Browse files Browse the repository at this point in the history
  • Loading branch information
REPNOT committed Apr 8, 2024
1 parent aa32540 commit 7ee15be
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 28 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@

## Description

Quickfin is a [Python](https://www.python.org/) module providing instant access to live and historical stock market price data, automated [Plotly](https://github.com/plotly/plotly.py) data visualization generators, live stock ticker visualization for [Streamlit](https://streamlit.io/) applications and a data catalog for referencing equities, stock symbols, sector, and industry information.
Quickfin is a [Python](https://www.python.org/) module providing instant access to live and historical stock market price data, automated [Plotly](https://github.com/plotly/plotly.py) data visualization generators and a data catalog for referencing equities, stock symbols, sector, and industry information.


## Dependencies

| Library | Language | Link |
| --------- | -------- | ------------------------------------------------------------------ |
| Plotly | Python | https://github.com/plotly/plotly.py |
| Streamlit | Python | https://github.com/streamlit/streamlit |


## Installation
Expand Down
41 changes: 15 additions & 26 deletions quickfin.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
and industry information.
"""

__version__ = "1.13.0"
__version__ = "1.14.1"
__author__ = "Derek Evans <https://github.com/REPNOT>"
__date__ = "28 March 2024"

Expand All @@ -21,6 +21,8 @@
from datetime import datetime
from urllib.request import Request, urlopen
import plotly.graph_objects as go
from pathlib import Path
import os


class FinInfo():
Expand Down Expand Up @@ -67,6 +69,7 @@ def equity(self, symbol, payload=True):
else:

pprint(self.data["equities"][self.symbol])
return


def equities(self, payload=True):
Expand Down Expand Up @@ -94,6 +97,7 @@ def equities(self, payload=True):
else:

pprint(self.payload)
return


def industries(self, payload=True):
Expand All @@ -115,7 +119,7 @@ def industries(self, payload=True):
else:

pprint(self.data["meta_data"]["industries"])

return

def sectors(self, payload=True):

Expand All @@ -136,7 +140,7 @@ def sectors(self, payload=True):
else:

pprint(self.data["meta_data"]["sectors"])

return

def sector_industries(self, sector=None, payload=True):

Expand Down Expand Up @@ -258,7 +262,7 @@ def symbols(self, payload=True):
else:

pprint(list(self.data["equities"].keys()))

return

def industry_symbols(self, industry=None, payload=True):

Expand Down Expand Up @@ -351,12 +355,10 @@ def __init__(self):
self.base_url = "https://query1.finance.yahoo.com/v7/finance/download/"
self.tail_url = f"?period1={str(epoch_start)}&period2={str(epoch_target)}&interval=1d&events=history&includeAdjustedClose=true"


def current(self, symbol):

"""
Return data payload containing the
most recent stock price data available
Return the most recent stock price data available
for the stock symbol passed to the `symbol`
parameter. Method will return live market
price quotes during trading hours.
Expand Down Expand Up @@ -420,43 +422,34 @@ def current(self, symbol):
self.data["current"]['Volume'] = ''

try:
self.data["current"]['Change Amount'] = round((self.data["current"]['Open'] - self.data["current"]['Close']), 2)
self.data["current"]['Change Amount'] = round((self.data["current"]['Close'] - self.data["current"]['Open']), 2)
except:
self.data["current"]['Change Amount'] = ''

try:
if self.data["current"]['Change Amount'] != 0:
self.data["current"]['Change Rate'] = round((self.data["current"]['Change Amount'] / self.data["current"]['Open']), 2)
self.data["current"]['Change Rate'] = round((self.data["current"]['Change Amount'] / self.data["current"]['Open']), 4)
else:
self.data["current"]['Change Rate'] = 0
except:
self.data["current"]['Change Rate'] = ''

try:
self.data["current"]['Day Range'] = round((self.data["current"]['Low'] - self.data["current"]['High']), 2)

if self.data["current"]['Day Range'] < 0:
self.data["current"]['Day Range'] = self.data["current"]['Day Range'] * -1
else:
pass

except:

self.data["current"]['Day Range'] = ''


try:
return self.data
except:
return '=== SYMBOL DATA TYPE ERROR OR SYMBOL UNAVAILABLE ==='


def history(self, symbol, days=None, date=None, date_start=None, date_end=None):

"""
Return data payload containing all historical
stock price data available for the stock symbol
passed to the `symbol` parameter.
Return all historical stock price data available
for the stock symbol passed to the `symbol` parameter.
Passing a positive integer value to the `days`
parameter will filter the historical data to include
Expand Down Expand Up @@ -489,7 +482,6 @@ def history(self, symbol, days=None, date=None, date_start=None, date_end=None):

self.symbol = symbol


try:
url = self.base_url + self.symbol + self.tail_url
self.rawData = urlopen(Request(url)).readlines()
Expand Down Expand Up @@ -549,13 +541,13 @@ def history(self, symbol, days=None, date=None, date_start=None, date_end=None):
self.row_data['Volume'] = ''

try:
self.row_data['Change Amount'] = round((self.row_data['Open'] - self.row_data['Close']), 2)
self.row_data['Change Amount'] = round((self.row_data['Close'] - self.row_data['Open']), 2)
except:
self.row_data['Change Amount'] = ''

try:
if self.row_data['Change Amount'] != 0:
self.row_data['Change Rate'] = round((self.row_data['Change Amount'] / self.row_data['Open']), 2)
self.row_data['Change Rate'] = round((self.row_data['Change Amount'] / self.row_data['Open']), 4)
else:
self.row_data['Change Rate'] = 0
except:
Expand Down Expand Up @@ -614,7 +606,6 @@ def history(self, symbol, days=None, date=None, date_start=None, date_end=None):

return self.data


def candlestick(self, symbol, days):

"""
Expand Down Expand Up @@ -672,7 +663,6 @@ def candlestick(self, symbol, days):
except:
return f'=== SYMBOL DATA TYPE ERROR OR INVALID SYMBOL ==='


def line(self, symbol, days, param):

"""
Expand Down Expand Up @@ -746,7 +736,6 @@ def line(self, symbol, days, param):
except:
return f'=== SYMBOL DATA TYPE ERROR OR INVALID SYMBOL ==='


def table(self, symbol, days):

"""
Expand Down

0 comments on commit 7ee15be

Please sign in to comment.