No project description provided
Project description
Library Documentation
Overview
This library provides a set of functions for financial analysis using the yfinance and ta libraries. It includes functionalities for retrieving stock prices, calculating financial indicators, and sending notifications.
Functions
last(ticker)
Fetches the last closing price of the specified ticker.
- Parameters:
ticker(str): The ticker symbol of the stock.
- Returns:
float: The last closing price, orNoneif an error occurs.
roi(ticker, buy)
Calculates the Return on Investment (ROI) for the specified ticker and buy price.
- Parameters:
ticker(str): The ticker symbol of the stock.buy(float): The buy price of the stock.
- Returns:
float: The ROI in percentage, orNoneif an error occurs.
rsi(ticker, periods, chart_data, timeframe)
Calculates the Relative Strength Index (RSI) for the specified ticker.
- Parameters:
ticker(str): The ticker symbol of the stock.periods(int): The number of periods to use for the RSI calculation.chart_data(str): The period of chart data to use.timeframe(str): The interval of the chart data.
- Returns:
float: The RSI value, orNoneif an error occurs.
ema(ticker, periods, chart_data, timeframe)
Calculates the Exponential Moving Average (EMA) for the specified ticker.
- Parameters:
ticker(str): The ticker symbol of the stock.periods(int): The number of periods to use for the EMA calculation.chart_data(str): The period of chart data to use.timeframe(str): The interval of the chart data.
- Returns:
float: The EMA value, orNoneif an error occurs.
profit(ticker, buy, qty)
Calculates the profit for the specified ticker, buy price, and quantity.
- Parameters:
ticker(str): The ticker symbol of the stock.buy(float): The buy price of the stock.qty(float): The quantity of the stock.
- Returns:
float: The profit, orNoneif an error occurs.
invested(buy, qty)
Calculates the invested amount for the specified buy price and quantity.
- Parameters:
buy(float): The buy price of the stock.qty(float): The quantity of the stock.
- Returns:
float: The invested amount, orNoneif an error occurs.
telegram(token, id, message)
Sends a message via Telegram.
- Parameters:
token(str): The Telegram bot token.id(str): The chat ID.message(str): The message to send.
- Returns:
dict: The response from the Telegram API, orNoneif an error occurs.
ychart(ticker)
Opens the Yahoo Finance chart for the specified ticker in a web browser.
- Parameters:
ticker(str): The ticker symbol of the stock.
ynews()
Opens the Yahoo Finance news page in a web browser.
change(pair)
Fetches the exchange rate for the specified currency pair.
- Parameters:
pair(str): The currency pair (e.g., "USDJPY").
- Returns:
float: The exchange rate, orNoneif an error occurs.
ath(ticker)
Fetches the all-time high (ATH) for the specified ticker.
- Parameters:
ticker(str): The ticker symbol of the stock.
- Returns:
float: The all-time high value, orNoneif an error occurs.
get_currency(ticker)
Fetches the currency in which the specified ticker is traded.
- Parameters:
ticker(str): The ticker symbol of the stock.
- Returns:
str: The currency, orNoneif an error occurs.
get_exchange(ticker)
Fetches the exchange where the specified ticker is traded.
- Parameters:
ticker(str): The ticker symbol of the stock.
- Returns:
str: The exchange, orNoneif an error occurs.
clean()
Clears the console screen.
- Parameters: None
- Returns: None
Usage Examples
Here are a few examples to help you get started:
# Get the last closing price of AAPL
print(last("AAPL"))
# Calculate the ROI for AAPL with a buy price of 120
print(roi("AAPL", 120))
# Calculate the RSI for AAPL
print(rsi("AAPL", 14, "2y", "1h"))
# Calculate the EMA for AAPL
print(ema("AAPL", 200, "2y", "1h"))
# Calculate the profit for AAPL
print(profit("AAPL", 120, 10))
# Calculate the invested amount
print(invested(120, 10))
# Send a Telegram message
telegram("<your_token>", "<your_chat_id>", "Hello from the bot!")
# Open Yahoo Finance chart for AAPL
ychart("AAPL")
# Open Yahoo Finance news page
ynews()
# Get the exchange rate for USD to EUR
print(change("USD"))
# Get the all-time high for AAPL
print(ath("AAPL"))
# Get the currency in which AAPL is traded
print(get_currency("AAPL"))
# Get the exchange where AAPL is traded
print(get_exchange("AAPL"))
# Clear the console screen
clean()
Additional Information
-
Dependencies: This library requires the
yfinance,requests,ta,pandas, andwebbrowsermodules. -
Installation: You can install the necessary modules using:
pip install yfinance requests ta pandas
-
Created by Francesco Vito Giotta (LemonPower21)
-
LinkedIn: https://www.linkedin.com/in/francesco-vito-giotta-969938314/
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gfinancelib-1.6.tar.gz.
File metadata
- Download URL: gfinancelib-1.6.tar.gz
- Upload date:
- Size: 3.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5d11c609c14614e1b746558ad557bef0ca3ea9cf2a8ae1545a2cde25788a4a2c
|
|
| MD5 |
3393896f1c24a0e0bdefaf370f37b21c
|
|
| BLAKE2b-256 |
253ed7fe885c1ff4b841b3e1bd48c513e83c31d707eee1650977afb87e3df51d
|
File details
Details for the file gfinancelib-1.6-py3-none-any.whl.
File metadata
- Download URL: gfinancelib-1.6-py3-none-any.whl
- Upload date:
- Size: 3.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
83df083dcf131b74a6f466c29f4f7e14446a74156a5767ba9f3938b107c45289
|
|
| MD5 |
918497358230098e698c58934443d9f6
|
|
| BLAKE2b-256 |
20178b97bb4aae320c9127ef7c8095bb1f0a0ed84a244646d05dda1b726d96f0
|