Package for analyzing and visualizing financial time-series data
Developed by Poonam Deshmukh (c) 2023.
Requirements
pyfin_trading would need the following libraries to be installed
pandasnumpyyfinancedatetime
Installation
You can install it via pip:
pip install pyfin-trading
Modules
stock_datastatsindicators
1. stock_data
This module majorly helps with getting stock data and can be accessed as follows:
from pyfin_trading import stock_data as sd
df = sd.get_data(ticker, start_date, end_date, interval)
- Input ticker symbol along with its corresponding exchange.
- Format for start_date & end_date must be "%Y-%m-%d"
- By default end_date is set to today
- Interval can take values like "1m", "2m", "5m", "15m", "30m", "60m", "90m", "1h", "1d", "5d", "1wk", "1mo", "3mo"
where m = minute, h = hour, d = day, wk = week, mo = month
- By default interval is set to "1d"
Example
df = sd.get_data("ITC.NS", "2023-11-06")
This will return ITC's data from NSE spanning from 6th Nov 2023 to present day with interval set to daily
2. stats
It helps with calculating returns as well as some financial ratios:
from pyfin_trading import stats as st
returns = st.calculate_returns(df) # Calculates Daily & Cumulative Returns
st.beta(df, market, interval)
st.volatility(df, trading_days = 252) # Calculates SD & Annualized Volatility
st.sharpe(df, risk, trading_days = 252) # Sharpe Ratio
st.sortino(df, risk, trading_days = 252) # Sortino Ratio
st.alpha(df, market, interval, beta, risk)
st.treynor(df, beta, risk, trading_days = 252) # Treynor Ratio
st.info(df, market, interval, risk, trading_days = 252) # Information Ratio
- By default Nifty 50 is used as a proxy for the market i.e. "^NSEI"
3. indicators
For calculating technical indicators:
from pyfin_trading import indicators as pt
pt.sma(df, sma_period = 15)
pt.ema(df, ema_period = 15, adjust = False)
pt.rsi(df, rsi_period = 14)
pt.connors_rsi(df, rsi_period = 14, updown_length = 2)
pt.stoch(df, k = 14, d = 3) # Stochastic Oscillator
pt.bollinger_bands(df, sma_period = 20, std_dev = 2) # Bollinger Bands
pt.aroon(df, aroon_period = 25) # Aroon Oscillator
pt.macd(df, short_period = 12, long_period = 26, signal = 9, adjust = False) # Moving Average Convergence Divergence
pt.ichimoku_cloud(df, conversion = 9, base = 26, lead_b = 52) # Ichimoku Cloud
Metadata
Release files for pyfin-trading 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pyfin_trading-1.0.0.tar.gz | 5.0 kB | Without provenance | Details for pyfin_trading-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pyfin_trading-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for pyfin_trading-1.0.0-py3-none-any.whl |
Total release size: 10.9 kB
Release files / pyfin_trading-1.0.0.tar.gz
| Download URL | pyfin_trading-1.0.0.tar.gz |
|---|---|
| Size | 5.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7ef6d806fbeba9dc7bfd9beb3535942091a0efee907ba820a3550a4e3bccb36c
|
|
BLAKE2b-256 checksum How to use checksums |
e67674db70f780b72950324de5f0c68d6ec839bdfe32e655eed814d3a76615c1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.8
|
Release files / pyfin_trading-1.0.0-py3-none-any.whl
| Download URL | pyfin_trading-1.0.0-py3-none-any.whl |
|---|---|
| Size | 6.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
612510050ea358ad486483c55fb587384e46d5f393bb773234ea6cb16a1a8454
|
|
BLAKE2b-256 checksum How to use checksums |
e6c746bd979e23527578eb70cd19e741cabeba3632a84fba999066fe8a5740f4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.8
|
Security for pyfin-trading 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.