Skip to main content

Spot Planner

A high-performance Python library for finding optimal time periods in price sequences. Perfect for spot price analysis, cost optimization, and resource planning.

What is Spot Planner?

Spot Planner helps you identify the most cost-effective periods in a sequence of prices. Whether you're analyzing electricity spot prices, cloud computing costs, or any time-series pricing data, this library efficiently finds periods that meet your criteria.

Key Features

  • 🚀 High Performance: Core algorithm implemented in Rust for maximum speed
  • 🐍 Python Native: Seamless Python integration with automatic fallback
  • 📊 Flexible Criteria: Find periods based on price thresholds, duration, and gaps
  • 🔧 Easy Integration: Simple API that works with any price sequence
  • ⚡ Zero Dependencies: No external dependencies required

Installation

uv add spot-planner

Using pip

pip install spot-planner

Quick Start

from decimal import Decimal
from spot_planner import get_cheapest_periods

# Example: Find cheapest electricity periods
prices = [
    Decimal("50"),  # 6 AM - expensive
    Decimal("40"),  # 7 AM - moderate
    Decimal("30"),  # 8 AM - cheap
    Decimal("20"),  # 9 AM - very cheap
    Decimal("45"),  # 10 AM - expensive again
]

# Find 2 cheapest periods with price under 35
result = get_cheapest_periods(
    prices=prices,
    low_price_threshold=Decimal("35"),
    min_selections=2,
    min_consecutive_selections=1,
    max_gap_between_periods_between_periods=1,
    max_gap_between_periods_from_start=1
)

print(result)  # [2, 3] - periods starting at index 2 and 3

Use Cases

Electricity Spot Price Analysis

# Find cheapest 3-hour periods for running high-power equipment
cheap_periods = get_cheapest_periods(
    prices=hourly_prices,
    low_price_threshold=Decimal("0.05"),  # 5 cents per kWh
    min_selections=3,
    min_consecutive_selections=3,  # 3-hour minimum
    max_gap_between_periods=2      # Allow 2-hour gaps between periods
)

Cloud Computing Cost Optimization

# Find most cost-effective periods for batch processing
optimal_windows = get_cheapest_periods(
    prices=aws_spot_prices,
    low_price_threshold=Decimal("0.10"),  # $0.10 per hour
    min_selections=5,
    min_consecutive_selections=4,  # 4-hour processing windows
    max_gap_between_periods=1      # Minimal gaps between windows
)

Resource Planning

# Plan maintenance windows during low-cost periods
maintenance_slots = get_cheapest_periods(
    prices=resource_costs,
    low_price_threshold=budget_threshold,
    min_selections=2,
    min_consecutive_selections=8,  # 8-hour maintenance windows
    max_gap_between_periods=0      # No gaps allowed
)

API Reference

get_cheapest_periods(prices, low_price_threshold, min_selections, min_consecutive_selections=1, max_gap_between_periods=0, max_gap_from_start=0)

Find the cheapest periods in a price sequence.

Parameters:

  • prices (List[Decimal]): Sequence of prices to analyze
  • low_price_threshold (Decimal): Maximum price for valid periods
  • min_selections (int): Number of periods to find
  • min_consecutive_selections (int, optional): Minimum period length. Defaults to 1.
  • max_gap_between_periods (int, optional): Maximum gap between periods. Defaults to 0.
  • max_gap_from_start (int, optional): Maximum gap from start to first period. Defaults to 0.

Returns:

  • List[int]: Starting indices of the cheapest periods

Raises:

  • ValueError: If parameters are invalid or no valid periods found

Performance

Spot Planner uses Rust for the core algorithm, providing significant performance improvements over pure Python implementations:

  • 10-100x faster than naive Python approaches
  • Memory efficient with minimal allocations
  • Automatic fallback to Python implementation if Rust module unavailable

License

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

Changelog

See CHANGELOG.md for a list of changes and version history.

Metadata

Release files for spot-planner 0.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for spot-planner 0.4.1
File Size Uploaded
spot_planner-0.4.1.tar.gz 1.9 MB Details

Built distributions (wheels)

Table of built distributions (wheels) for spot-planner 0.4.1
File
spot_planner-0.4.1-cp314-cp314-manylinux_2_34_x86_64.whl CPython 3.14 CPython 3.14 Linux glibc 2.34+ x86-64 Details
spot_planner-0.4.1-cp314-cp314-manylinux_2_34_aarch64.whl CPython 3.14 CPython 3.14 Linux glibc 2.34+ ARM64 Details
spot_planner-0.4.1-cp313-cp313-manylinux_2_34_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.34+ x86-64 Details
spot_planner-0.4.1-cp313-cp313-manylinux_2_34_aarch64.whl CPython 3.13 CPython 3.13 Linux glibc 2.34+ ARM64 Details
spot_planner-0.4.1-cp312-cp312-manylinux_2_34_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.34+ x86-64 Details
spot_planner-0.4.1-cp312-cp312-manylinux_2_34_aarch64.whl CPython 3.12 CPython 3.12 Linux glibc 2.34+ ARM64 Details
spot_planner-0.4.1-cp311-cp311-manylinux_2_34_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.34+ x86-64 Details
spot_planner-0.4.1-cp311-cp311-manylinux_2_34_aarch64.whl CPython 3.11 CPython 3.11 Linux glibc 2.34+ ARM64 Details
spot_planner-0.4.1-cp310-cp310-manylinux_2_34_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.34+ x86-64 Details
spot_planner-0.4.1-cp310-cp310-manylinux_2_34_aarch64.whl CPython 3.10 CPython 3.10 Linux glibc 2.34+ ARM64 Details

Total release size: 4.6 MB

Release files / spot_planner-0.4.1.tar.gz

Download URL spot_planner-0.4.1.tar.gz
Size 1.9 MB
Tags Source
SHA-256 checksum
How to use checksums
5178b74fbb5b33f7212d8af4cdd52c49333661d07154690697c9e02221931510
BLAKE2b-256 checksum
How to use checksums
4f47959cb4d4d4fee7d30699568a92bb39efa6c8bdee88ef96f2abd05663a640
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.20 {"installer":{"name":"uv","version":"0.12.20","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / spot_planner-0.4.1-cp314-cp314-manylinux_2_34_x86_64.whl

Download URL spot_planner-0.4.1-cp314-cp314-manylinux_2_34_x86_64.whl
Size 276.4 kB
Tags CPython 3.14 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
d7c509a7b4570727a3c38943510bbe9e99520f48f69788a883edc9219d01dd42
BLAKE2b-256 checksum
How to use checksums
42d41ebc9f0f6da3197669eb68d8c19ea92b795ff088e316d9eb2ce620fcf53e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.20 {"installer":{"name":"uv","version":"0.12.20","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / spot_planner-0.4.1-cp314-cp314-manylinux_2_34_aarch64.whl

Download URL spot_planner-0.4.1-cp314-cp314-manylinux_2_34_aarch64.whl
Size 267.4 kB
Tags CPython 3.14 Linux glibc 2.34+ ARM64
SHA-256 checksum
How to use checksums
15683d02004855847938eb6b421daf9ffcd71355fe2e3858e2948a5bc4944671
BLAKE2b-256 checksum
How to use checksums
08d82c2874e4c67de65aab7226275db2c6ef68e40898dfa3c067ec75a827bafb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.20 {"installer":{"name":"uv","version":"0.12.20","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / spot_planner-0.4.1-cp313-cp313-manylinux_2_34_x86_64.whl

Download URL spot_planner-0.4.1-cp313-cp313-manylinux_2_34_x86_64.whl
Size 277.3 kB
Tags CPython 3.13 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
68bbf929f34051b16668b635e87b6b256d3184c3cbb2298934b5f2b7da2499dc
BLAKE2b-256 checksum
How to use checksums
dea00ee990f3faec4ebdae1830fabaa97ebb246fe6028939cc5b09b28d9f4f2b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.20 {"installer":{"name":"uv","version":"0.12.20","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / spot_planner-0.4.1-cp313-cp313-manylinux_2_34_aarch64.whl

Download URL spot_planner-0.4.1-cp313-cp313-manylinux_2_34_aarch64.whl
Size 268.0 kB
Tags CPython 3.13 Linux glibc 2.34+ ARM64
SHA-256 checksum
How to use checksums
a5f594d9042721b196fb3b71ec4daacbf866d0e290b372d5adc24865917219ef
BLAKE2b-256 checksum
How to use checksums
9fb473d440810f143fcc50f1f59c03382b563565c0d6812876cc45c9c9432b28
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.20 {"installer":{"name":"uv","version":"0.12.20","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / spot_planner-0.4.1-cp312-cp312-manylinux_2_34_x86_64.whl

Download URL spot_planner-0.4.1-cp312-cp312-manylinux_2_34_x86_64.whl
Size 277.2 kB
Tags CPython 3.12 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
3138b8866d0b7d29ba41c3759059b8f03def908918b6b8f5670a201faef26d60
BLAKE2b-256 checksum
How to use checksums
7d3b0531457e17cb52d3c56ac50b975a97be9f400094cfccd5052c1b78372a11
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.20 {"installer":{"name":"uv","version":"0.12.20","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / spot_planner-0.4.1-cp312-cp312-manylinux_2_34_aarch64.whl

Download URL spot_planner-0.4.1-cp312-cp312-manylinux_2_34_aarch64.whl
Size 268.0 kB
Tags CPython 3.12 Linux glibc 2.34+ ARM64
SHA-256 checksum
How to use checksums
e483581aec19855736c1293e86e622d829bf80fb6af6f627cf3b76442504c048
BLAKE2b-256 checksum
How to use checksums
97fe253fae9d3521cd02d2986a83e67acb53b98b1863d660d92dbacf96731811
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.20 {"installer":{"name":"uv","version":"0.12.20","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / spot_planner-0.4.1-cp311-cp311-manylinux_2_34_x86_64.whl

Download URL spot_planner-0.4.1-cp311-cp311-manylinux_2_34_x86_64.whl
Size 279.3 kB
Tags CPython 3.11 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
2d457c81a198b80fab0ee02d0bfa40bf4e2e38f77c4ceb818feb6a2f21a9be01
BLAKE2b-256 checksum
How to use checksums
0146f8f1b3747afb79ba4251e6b63f1fd8f4979f173dd16b2ff350fb8b5e3781
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.20 {"installer":{"name":"uv","version":"0.12.20","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / spot_planner-0.4.1-cp311-cp311-manylinux_2_34_aarch64.whl

Download URL spot_planner-0.4.1-cp311-cp311-manylinux_2_34_aarch64.whl
Size 269.1 kB
Tags CPython 3.11 Linux glibc 2.34+ ARM64
SHA-256 checksum
How to use checksums
68786beec494de338216079fa82709458eb6f1677aaacefd6a8c340e47fdb1e9
BLAKE2b-256 checksum
How to use checksums
cf2200bea2017b5c65ab49537d9b0b86f4c4f7f527c762e62d665e6f0ae3dc64
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.20 {"installer":{"name":"uv","version":"0.12.20","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / spot_planner-0.4.1-cp310-cp310-manylinux_2_34_x86_64.whl

Download URL spot_planner-0.4.1-cp310-cp310-manylinux_2_34_x86_64.whl
Size 279.2 kB
Tags CPython 3.10 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
c0de7461c99e6a5080716e42110efe0bc18a9f46e853dadc00b12778aaf71dcb
BLAKE2b-256 checksum
How to use checksums
638fc68d0d91a30618829c6f011f993a1727462656fdcf25475d943feb241d3b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.20 {"installer":{"name":"uv","version":"0.12.20","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / spot_planner-0.4.1-cp310-cp310-manylinux_2_34_aarch64.whl

Download URL spot_planner-0.4.1-cp310-cp310-manylinux_2_34_aarch64.whl
Size 269.6 kB
Tags CPython 3.10 Linux glibc 2.34+ ARM64
SHA-256 checksum
How to use checksums
d4af96fb13ba39dc230713ebed1752bfca4aba4b94ac4758f8275c3caaa0246d
BLAKE2b-256 checksum
How to use checksums
b53dcc72923b763226a93706ab1fb92d4859264dee60cb0351d5fc4d9f6c0283
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.20 {"installer":{"name":"uv","version":"0.12.20","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

0.4.1 This release

11 release files

0.3.9

11 release files

0.3.8

11 release files

0.3.7

11 release files

0.3.6

11 release files

0.3.5

3 release files

0.3.4

2 release files

0.3.3

1 release file

0.3.2

9 release files

0.3.1

9 release files

0.3.0

9 release files

0.2.11

9 release files

0.2.10

9 release files

0.2.9

9 release files

0.2.8

9 release files

0.2.7

9 release files

0.2.6

9 release files

0.2.5

9 release files

0.2.4

9 release files

0.2.3

9 release files

0.2.2

9 release files

0.2.1

9 release files

0.2.0

9 release files

0.1.2

9 release files

0.1.1

3 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page