Skip to main content

Some wrappers for python utilities.

Project description

Odd Kernel

Some wrappers for python utilities.

Overview

This package provides a collection of utility functions and classes to simplify common tasks in Python, including data fetching from financial markets, sending emails, and other miscellaneous utilities.

Documentation

Full documentation is available at https://odd-kernel.readthedocs.io

Installation

pip install odd-kernel

Usage

Datasets

MarketDataProvider

The MarketDataProvider class allows you to fetch and manage financial time series from Yahoo Finance.

from odd_kernel.datasets.marketdata import MarketDataProvider, DataType, MarketDataPeriod, MarketDataTimeUnit

# Initialize the provider
provider = MarketDataProvider()

# Get a summary of available data for a ticker
summary = provider.get_summary("AAPL")
print(summary)

# Get raw closing prices
raw_data, metadata = provider.get_raw("AAPL", DataType.CLOSE)
print(raw_data.head())

# Get interpolated data
interpolated_data, metadata = provider.get_interpolated(
    tickers="AAPL",
    start="2023-01-01",
    end="2023-12-31",
    field=DataType.CLOSE,
    resolution=MarketDataPeriod(1, MarketDataTimeUnit.DAY)
)
print(interpolated_data["AAPL"].head())

BinanceClient

The BinanceClient class provides an interface to the Binance API for fetching cryptocurrency data.

from odd_kernel.datasets.cryptocurrencies import BinanceClient, CryptoCurrenciesPeriod, CryptoCurrenciesTimeUnit
from datetime import datetime

# Initialize the client
client = BinanceClient()

# Get all available tickers
all_tickers = client.get_all_tickers()
print(all_tickers[:5])

# Get historical k-lines
klines = client.get_historical_klines(
    symbol="BTCUSDT",
    period=CryptoCurrenciesPeriod(1, CryptoCurrenciesTimeUnit.DAY),
    start_time=datetime(2023, 1, 1)
)
print(klines[0])

Utilities

Timing

The timed decorator can be used to measure the execution time of a function.

from odd_kernel.util.timing import timed
import time

@timed
def my_function():
    time.sleep(1)

my_function()

General

The wait_some_time function waits for a random amount of time within a given range.

from odd_kernel.util.general import wait_some_time

wait_some_time(0.1, 0.5)

Miscellaneous

The ding function plays a sound, which can be useful to signal the end of a long-running process.

from odd_kernel.util.misc import ding

ding()

Charts

The get_colors function generates a list of colors for plotting.

from odd_kernel.util.charts import get_colors

colors = get_colors(5)
print(colors)

Interpolation

The odd_kernel.util.interpolation module provides functions for interpolating data.

Gaussian KDE Interpolation

import numpy as np
from odd_kernel.util.interpolation.gaussian_kde import gaussian_kde_interpolate_mesh

x = np.random.rand(50)
y = np.random.rand(50)
z = np.sin(x*10) + np.cos(y*10)
xg, yg, X, Y, Z = gaussian_kde_interpolate_mesh(x, y, z, mesh_size=100)

K-Nearest Neighbors Interpolation

import numpy as np
from odd_kernel.util.interpolation.knn import knn_interpolate_mesh

x = np.random.rand(50)
y = np.random.rand(50)
z = np.sin(x*10) + np.cos(y*10)
xg, yg, X, Y, Z = knn_interpolate_mesh(x, y, z, mesh_size=100)

License

This project is licensed under the MIT License - see the LICENSE file for details.

Project details


Download files

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

Source Distribution

odd_kernel-0.1.37.tar.gz (254.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

odd_kernel-0.1.37-py3-none-any.whl (249.9 kB view details)

Uploaded Python 3

File details

Details for the file odd_kernel-0.1.37.tar.gz.

File metadata

  • Download URL: odd_kernel-0.1.37.tar.gz
  • Upload date:
  • Size: 254.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.11

File hashes

Hashes for odd_kernel-0.1.37.tar.gz
Algorithm Hash digest
SHA256 ea57d98d56dbc0a23b3c980da4ff6133545888022af83d159d9742bf1c2bf06a
MD5 b6e4b24235f0fd850292dbe486581901
BLAKE2b-256 c2a4ca9356e6a3b66cc3adf4b8ca27914437484aab1145b67f58413a7f328f84

See more details on using hashes here.

File details

Details for the file odd_kernel-0.1.37-py3-none-any.whl.

File metadata

  • Download URL: odd_kernel-0.1.37-py3-none-any.whl
  • Upload date:
  • Size: 249.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.11

File hashes

Hashes for odd_kernel-0.1.37-py3-none-any.whl
Algorithm Hash digest
SHA256 487e8b199785cee750792dcc85a7778d4f9483818cbbcb5826f8e967a7673c10
MD5 68f7fd81187babc1b979b22d46cc51d3
BLAKE2b-256 530fb3824c86bd8ce08583cd17976dbc4394742125d7ee023b30463da7d4a2e8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page