Dynamic Pricing API Reference
This page documents the API for the business KPIs module in Pypulate.
Dynamic Pricing Module
This module provides functions for calculating dynamic pricing adjustments.
PricingRule
A class for managing custom pricing rules.
This class provides methods for: - Adding custom pricing rules - Applying custom pricing rules - Managing rule metadata
__init__()
Initialize the PricingRule class.
add_rule(rule_name, calculation_function, description='')
Add a custom pricing rule.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rule_name
|
str
|
Name of the custom pricing rule |
required |
calculation_function
|
callable
|
Function that implements the custom pricing logic |
required |
description
|
str
|
Description of the pricing rule |
''
|
apply_rule(rule_name, *args, **kwargs)
Apply a custom pricing rule.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rule_name
|
str
|
Name of the custom pricing rule |
required |
*args
|
Any
|
Arguments to pass to the custom pricing function |
()
|
**kwargs
|
Any
|
Arguments to pass to the custom pricing function |
()
|
Returns:
Type | Description |
---|---|
float
|
Price calculated using the custom rule |
Raises:
Type | Description |
---|---|
KeyError
|
If the specified rule_name doesn't exist |
get_rule_description(rule_name)
Get the description of a pricing rule.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rule_name
|
str
|
Name of the pricing rule |
required |
Returns:
Type | Description |
---|---|
str
|
Description of the pricing rule |
Raises:
Type | Description |
---|---|
KeyError
|
If the specified rule_name doesn't exist |
list_rules()
List all available pricing rules and their descriptions.
Returns:
Type | Description |
---|---|
dict
|
Dictionary of rule names and their descriptions |
apply_dynamic_pricing(base_price, demand_factor, competition_factor, seasonality_factor=1.0, min_price=None, max_price=None)
Calculate dynamically adjusted price based on market factors.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
base_price
|
float
|
Base price before adjustments |
required |
demand_factor
|
float
|
Demand multiplier (1.0 is neutral) |
required |
competition_factor
|
float
|
Competition multiplier (1.0 is neutral) |
required |
seasonality_factor
|
float
|
Seasonal adjustment factor |
1.0
|
min_price
|
float
|
Minimum price floor |
None
|
max_price
|
float
|
Maximum price ceiling |
None
|
Returns:
Type | Description |
---|---|
float
|
Dynamically adjusted price |
Examples: