Client utilities for fetching market data from Nasdaq
Project description
NSDQ
-
Interacts with the NASDAQ API to retrieve asset-related data (quotes, historical data, option chains, etc.).
-
Retrieves real-time trade data and both raw and processed option chain data.
-
Calculates implied volatility and option Greeks using pricing models (e.g., Black-Scholes-Merton).
-
Provides dedicated functions to plot 2D & 3D representations of Greeks, option prices & implied volatilities over strike and time to expiry.
-
Guide is available here.
Requirements & Installation :
- Requirements:
requests,datetime,pandas,numpy,scipy,py_vollib_vectorized,matplotlib,re. - Install using:
pip install NSDQ(https://pypi.org/project/NSDQ/)
Example:
import NSDQ
# Retrieve asset information (e.g., for AAPL)
Apple = NSDQ.Asset("AAPL", "stocks")
print(Apple.Informations())
# >>> {'Symbol': 'AAPL', 'Exchange': 'NASDAQ', 'Sector': 'Technology', ...}
# Get the asset's historical data as a DataFrame
historical_data = Apple.HistoricalData()
print(historical_data.head())
# Retrieve the most recent real-time trades (e.g., the last 5 trades)
RealtimeTrades = Apple.RealTime(NumberOfTrades=5)
print(RealtimeTrades)
# Retrieve the processed option chain data (for both calls and puts)
Options = Apple.Options(
DataType="processed",
ExchangeCode="oprac",
Strategy="callput",
RiskFreeRate=0.04375,
)
print(OptionsChain.Data.head())
# Create and display 2D plots of Greeks vs Strike & Time to Expiry:
Options.Plot2D(Type='call')
# Create and display 3D plots of Greeks vs Strike & Time to Expiry:
Options.Plot3D(Type='call', ViewAngle=(15,45))
Note:
- Implied Volatilities are calculated using the `py_vollib` library.
- Outliers are identified using Median Absolute deviation (MAD).
- An Implied Volatility Value is considered an outlier if:
\frac{X_i - \tilde{X}}{\mathrm{MAD}} > 3, \quad \text{where } \mathrm{MAD} = \mathrm{median}\left(|X_i - \tilde{X}|\right)
When plotting:
- "Years Until Expiry" is converted into months and then rounded to the nearest multiple of 3.
- "Contract Strike" is rounded down to the nearest multiple of 10.
- The data is then grouped by these two new columns, and the mean of the specified column is computed for each group.
- Important: This is a basic visualization; therefore, the results should be interpreted with caution.
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 nasdaqfetcher-1.0.0.tar.gz.
File metadata
- Download URL: nasdaqfetcher-1.0.0.tar.gz
- Upload date:
- Size: 14.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
53c60b93d29476f7f857a55cca9a863aba1b44e31830bca2631a388cfdf87589
|
|
| MD5 |
95bb0baefd98208d6a9bd0dc3019c105
|
|
| BLAKE2b-256 |
2864a8163615f59c2dd94ff19edfda1e1e6c66c92bfe4667a1b66ca544e7afc6
|
File details
Details for the file nasdaqfetcher-1.0.0-py3-none-any.whl.
File metadata
- Download URL: nasdaqfetcher-1.0.0-py3-none-any.whl
- Upload date:
- Size: 15.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
467ec63b989146148c6235144229d3ed63ccb59e55136c4f617a11461ebfd839
|
|
| MD5 |
1e744d83817e1eded441d75fb8095211
|
|
| BLAKE2b-256 |
b061e7512f4a20e7e1816e8d1b16af96af4a1108cf6b85184a45ead967f36805
|