simnexus 0.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
simnexus-0.1.1/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Michael Borck
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,82 @@
1
+ Metadata-Version: 2.1
2
+ Name: simnexus
3
+ Version: 0.1.1
4
+ Summary: This Python package provides a set of classes for simulating various business-related scenarios. It is designed for educational use, allowing students to experiment with modeling, analysis, and decision-making in different contexts.
5
+ Author: Michael Borck
6
+ Author-email: michael@borck.me
7
+ Requires-Python: >=3.10,<4.0
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Programming Language :: Python :: 3.10
10
+ Classifier: Programming Language :: Python :: 3.11
11
+ Classifier: Programming Language :: Python :: 3.12
12
+ Requires-Dist: numpy (>=1.26.4,<2.0.0)
13
+ Requires-Dist: poetry-plugin-export (>=1.7.1,<2.0.0)
14
+ Requires-Dist: pycparser (>=2.22,<3.0)
15
+ Requires-Dist: pymdown-extensions (>=10.8.1,<11.0.0)
16
+ Project-URL: Documentation, https://simnexus.readthedocs.io/en/latest/
17
+ Project-URL: Homepage, http://yourhomepage.com
18
+ Project-URL: Repository, https://github.com/teaching-repositories/simnexus
19
+ Description-Content-Type: text/markdown
20
+
21
+ # SimNexus: Business Simulation Toolkit
22
+
23
+ This Python package provides a set of classes for simulating various
24
+ business-related scenarios. It is designed for educational use, allowing
25
+ students to experiment with modeling, analysis, and decision-making in different
26
+ contexts.
27
+
28
+ ## Installation
29
+
30
+ To install SimNexus
31
+
32
+ ```bash
33
+ pip install simnexus
34
+ ```
35
+
36
+ ## Available Simulations
37
+
38
+ - **Stock Market Simulation:** Simulate stock price fluctuations, incorporate
39
+ technical indicators, and develop simple trading strategies.
40
+ - **Resource Fluctuations Simulation:** Model changes in the price of a
41
+ resource, analyze supply/demand dynamics, and implement hedging strategies.
42
+ - **Product Popularity Simulation:** Simulate the rise and fall of product
43
+ demand, investigate virality factors, and examine different marketing
44
+ strategies.
45
+
46
+ ## Documentation
47
+
48
+ For more detailed information about using SimNexus, see the [documentation](https://yourproject.readthedocs.io/).
49
+
50
+
51
+ ## Basic Usage Example
52
+
53
+ Here is an example of how to use the Resource Fluctuations Simulation:
54
+
55
+ ```python
56
+ from simnexus import ResourceFluctuationsSimulation
57
+
58
+ # Create a resource simulation
59
+ sim = ResourceFluctuationsSimulation(start_price=100, days=365, volatility=0.05, drift=0.01,
60
+ supply_disruption_day=180, disruption_severity=0.2)
61
+
62
+ # Run the simulation and get results
63
+ prices = sim.run_simulation()
64
+
65
+ # Visualize or analyze the results here
66
+ ```
67
+
68
+ ## Project Goals (For Students)
69
+
70
+ - Gain familiarity with using simulations to model dynamic systems.
71
+ - Understand the impact of different parameters on simulation outcomes.
72
+ - Develop data analysis and visualization skills in the context of business problems.
73
+ - Practice translating business concepts into simulation parameters.
74
+
75
+ ## Contributing
76
+
77
+ We welcome contributions to the SimNexus project! If you have suggestions or improvements, feel free to fork the repository and submit a pull request. Please ensure your code adheres to the existing style, and include tests for new features or bug fixes.
78
+
79
+ ## License
80
+
81
+ This project is licensed under the MIT License. See the LICENSE file for more details.
82
+
@@ -0,0 +1,61 @@
1
+ # SimNexus: Business Simulation Toolkit
2
+
3
+ This Python package provides a set of classes for simulating various
4
+ business-related scenarios. It is designed for educational use, allowing
5
+ students to experiment with modeling, analysis, and decision-making in different
6
+ contexts.
7
+
8
+ ## Installation
9
+
10
+ To install SimNexus
11
+
12
+ ```bash
13
+ pip install simnexus
14
+ ```
15
+
16
+ ## Available Simulations
17
+
18
+ - **Stock Market Simulation:** Simulate stock price fluctuations, incorporate
19
+ technical indicators, and develop simple trading strategies.
20
+ - **Resource Fluctuations Simulation:** Model changes in the price of a
21
+ resource, analyze supply/demand dynamics, and implement hedging strategies.
22
+ - **Product Popularity Simulation:** Simulate the rise and fall of product
23
+ demand, investigate virality factors, and examine different marketing
24
+ strategies.
25
+
26
+ ## Documentation
27
+
28
+ For more detailed information about using SimNexus, see the [documentation](https://yourproject.readthedocs.io/).
29
+
30
+
31
+ ## Basic Usage Example
32
+
33
+ Here is an example of how to use the Resource Fluctuations Simulation:
34
+
35
+ ```python
36
+ from simnexus import ResourceFluctuationsSimulation
37
+
38
+ # Create a resource simulation
39
+ sim = ResourceFluctuationsSimulation(start_price=100, days=365, volatility=0.05, drift=0.01,
40
+ supply_disruption_day=180, disruption_severity=0.2)
41
+
42
+ # Run the simulation and get results
43
+ prices = sim.run_simulation()
44
+
45
+ # Visualize or analyze the results here
46
+ ```
47
+
48
+ ## Project Goals (For Students)
49
+
50
+ - Gain familiarity with using simulations to model dynamic systems.
51
+ - Understand the impact of different parameters on simulation outcomes.
52
+ - Develop data analysis and visualization skills in the context of business problems.
53
+ - Practice translating business concepts into simulation parameters.
54
+
55
+ ## Contributing
56
+
57
+ We welcome contributions to the SimNexus project! If you have suggestions or improvements, feel free to fork the repository and submit a pull request. Please ensure your code adheres to the existing style, and include tests for new features or bug fixes.
58
+
59
+ ## License
60
+
61
+ This project is licensed under the MIT License. See the LICENSE file for more details.
@@ -0,0 +1,31 @@
1
+ [tool.poetry]
2
+ name = "simnexus"
3
+ version = "0.1.1"
4
+ description = "This Python package provides a set of classes for simulating various business-related scenarios. It is designed for educational use, allowing students to experiment with modeling, analysis, and decision-making in different contexts."
5
+ authors = ["Michael Borck <michael@borck.me>"]
6
+ readme = "README.md"
7
+
8
+ [tool.poetry.dependencies]
9
+ python = "^3.10"
10
+ numpy = "^1.26.4"
11
+ pymdown-extensions = "^10.8.1"
12
+ pycparser = "^2.22"
13
+ poetry-plugin-export = "^1.7.1"
14
+
15
+ [tool.poetry.group.dev.dependencies]
16
+ pytest = "^8.2.0"
17
+ mkdocs = "^1.6.0"
18
+ mkdocstrings = "^0.25.0"
19
+ mypy = "^1.10.0"
20
+ flake8 = "^7.0.0"
21
+ mkdocs-material = "^9.5.20"
22
+ mkdocstrings-python = "^1.10.0"
23
+
24
+ [build-system]
25
+ requires = ["poetry-core"]
26
+ build-backend = "poetry.core.masonry.api"
27
+
28
+ [tool.poetry.urls]
29
+ "Homepage" = "http://yourhomepage.com"
30
+ "Documentation" = "https://simnexus.readthedocs.io/en/latest/"
31
+ "Repository" = "https://github.com/teaching-repositories/simnexus"
@@ -0,0 +1,9 @@
1
+ from .product_popularity_simulation import ProductPopularitySimulation
2
+ from .resource_fluctuations_simulation import ResourceFluctuationsSimulation
3
+ from .stock_market_simulation import StockMarketSimulation
4
+
5
+ __all__ = [
6
+ "ProductPopularitySimulation",
7
+ "ResourceFluctuationsSimulation",
8
+ "StockMarketSimulation"
9
+ ]
@@ -0,0 +1,71 @@
1
+ import numpy as np
2
+ from typing import List, Optional
3
+
4
+
5
+ class ProductPopularitySimulation:
6
+ """
7
+ A simulation class to model the dynamics of product popularity over time,
8
+ incorporating factors like natural growth, marketing impact, and promotional campaigns.
9
+
10
+ Attributes:
11
+ start_demand (int): Initial demand for the product.
12
+ days (int): Duration of the simulation in days.
13
+ growth_rate (float): Natural growth rate of product demand.
14
+ marketing_impact (float): Impact of ongoing marketing efforts on demand.
15
+ promotion_day (Optional[int]): Day on which a major marketing campaign starts (default is None).
16
+ promotion_effectiveness (float): Effectiveness of the marketing campaign.
17
+ random_seed (Optional[int]): The seed for the random number generator to ensure reproducibility (default is None).
18
+
19
+ Methods:
20
+ run_simulation(): Runs the simulation and returns a list of demand values over time.
21
+ """
22
+
23
+ def __init__(
24
+ self, start_demand: float, days: int, growth_rate: float, marketing_impact: float,
25
+ promotion_day: Optional[int] = None, promotion_effectiveness: float = 0,
26
+ random_seed: Optional[int] = None
27
+ ) -> None:
28
+ """
29
+ Initializes the ProductPopularitySimulation with all necessary parameters.
30
+
31
+ Parameters:
32
+ start_demand (int): The initial level of demand for the product.
33
+ days (int): The total number of days to simulate.
34
+ growth_rate (float): The natural daily growth rate of demand, as a decimal.
35
+ marketing_impact (float): Daily impact of marketing on demand, as a decimal.
36
+ promotion_day (Optional[int]): The specific day on which a promotional event occurs (defaults to None).
37
+ promotion_effectiveness (float): Multiplicative impact of the promotion on demand.
38
+ random_seed (Optional[int]): Seed for the random number generator to ensure reproducible results (defaults to None).
39
+ """
40
+ self.start_demand = start_demand
41
+ self.days = days
42
+ self.growth_rate = growth_rate
43
+ self.marketing_impact = marketing_impact
44
+ self.promotion_day = promotion_day
45
+ self.promotion_effectiveness = promotion_effectiveness
46
+ self.random_seed = random_seed
47
+
48
+ def run_simulation(self) -> List[float]:
49
+ """
50
+ Simulates the demand for a product over a specified number of days based on the initial settings.
51
+
52
+ Returns:
53
+ List[int]: A list containing the demand for the product for each day of the simulation.
54
+ """
55
+ if self.random_seed is not None:
56
+ np.random.seed(self.random_seed)
57
+
58
+ demand = [self.start_demand]
59
+ for day in range(1, self.days):
60
+ previous_demand = demand[-1]
61
+ natural_growth = previous_demand * (1 + self.growth_rate)
62
+ marketing_influence = previous_demand * self.marketing_impact
63
+
64
+ new_demand = natural_growth + marketing_influence
65
+
66
+ if day == self.promotion_day:
67
+ new_demand = (natural_growth + marketing_influence) * (1 + self.promotion_effectiveness)
68
+
69
+ demand.append(new_demand)
70
+
71
+ return demand
@@ -0,0 +1,63 @@
1
+ import numpy as np
2
+ from typing import List, Optional
3
+
4
+
5
+ class ResourceFluctuationsSimulation:
6
+ """
7
+ A simulation class to model the fluctuations of resource prices over time,
8
+ considering factors like volatility, market trends (drift), and supply disruptions.
9
+
10
+ Attributes:
11
+ start_price (float): The initial price of the resource.
12
+ days (int): The duration of the simulation in days.
13
+ volatility (float): The volatility of price changes, representing day-to-day variability.
14
+ drift (float): The average daily price change, indicating the trend over time.
15
+ supply_disruption_day (Optional[int]): The specific day a supply disruption occurs (default is None).
16
+ disruption_severity (float): The magnitude of the disruption's impact on price (default is 0).
17
+ random_seed (Optional[int]): The seed for the random number generator to ensure reproducibility (default is None).
18
+ """
19
+ def __init__(self, start_price: float, days: int, volatility: float, drift: float,
20
+ supply_disruption_day: Optional[int] = None, disruption_severity: float = 0,
21
+ random_seed: Optional[int] = None) -> None:
22
+ """
23
+ Initializes the ResourceSimulation with all necessary parameters.
24
+
25
+ Parameters:
26
+ start_price (float): The initial price of the resource.
27
+ days (int): The total number of days to simulate.
28
+ volatility (float): The volatility of the resource price, representing the randomness of day-to-day price changes.
29
+ drift (float): The expected daily percentage change in price, which can be positive or negative.
30
+ supply_disruption_day (Optional[int]): Day on which a supply disruption occurs (defaults to None).
31
+ disruption_severity (float): The severity of the supply disruption, affecting prices multiplicatively.
32
+ random_seed (Optional[int]): Seed for the random number generator to ensure reproducible results (defaults to None).
33
+ """
34
+ self.start_price = start_price
35
+ self.days = days
36
+ self.volatility = volatility
37
+ self.drift = drift
38
+ self.supply_disruption_day = supply_disruption_day
39
+ self.disruption_severity = disruption_severity
40
+ self.random_seed = random_seed
41
+
42
+ def run_simulation(self) -> List[float]:
43
+ """
44
+ Simulates the price of the resource over a specified number of days based on the initial settings.
45
+
46
+ Returns:
47
+ List[float]: A list containing the price of the resource for each day of the simulation.
48
+ """
49
+ if self.random_seed is not None:
50
+ np.random.seed(self.random_seed)
51
+
52
+ prices = [self.start_price]
53
+ for day in range(1, self.days):
54
+ previous_price = prices[-1]
55
+ random_change = np.random.normal(self.drift, self.volatility)
56
+ new_price = previous_price * (1 + random_change)
57
+
58
+ if day == self.supply_disruption_day:
59
+ new_price = previous_price * (1 + self.disruption_severity)
60
+
61
+ prices.append(new_price)
62
+
63
+ return prices
@@ -0,0 +1,69 @@
1
+ import numpy as np
2
+ from typing import List, Optional
3
+
4
+
5
+ class StockMarketSimulation:
6
+ """
7
+ A simulation class to model the fluctuations of stock prices over time, accounting for volatility,
8
+ general market trends (drift), and specific market events.
9
+
10
+ Attributes:
11
+ start_price (float): The initial price of the stock.
12
+ days (int): The duration of the simulation in days.
13
+ volatility (float): The volatility of stock price changes, representing day-to-day variability.
14
+ drift (float): The average daily price change, indicating the trend over time.
15
+ event_day (Optional[int]): The specific day a major market event occurs (default is None).
16
+ event_impact (float): The magnitude of the event's impact on stock prices (default is 0).
17
+ random_seed (Optional[int]): The seed for the random number generator to ensure reproducibility (default is None).
18
+
19
+ Methods:
20
+ run_simulation(): Runs the simulation and returns a list of stock prices over the simulation period.
21
+ """
22
+
23
+ def __init__(
24
+ self, start_price: float, days: int, volatility: float, drift: float,
25
+ event_day: Optional[int] = None, event_impact: float = 0,
26
+ random_seed: Optional[int] = None
27
+ ) -> None:
28
+ """
29
+ Initializes the StockMarketSimulation with all necessary parameters.
30
+
31
+ Parameters:
32
+ start_price (float): The initial stock price.
33
+ days (int): The total number of days to simulate.
34
+ volatility (float): The volatility of the stock price, representing the randomness of day-to-day price changes.
35
+ drift (float): The expected daily percentage change in price, which can be positive or negative.
36
+ event_day (Optional[int]): Day on which a major market event occurs (defaults to None).
37
+ event_impact (float): The severity of the market event, affecting prices multiplicatively.
38
+ random_seed (Optional[int]): Seed for the random number generator to ensure reproducible results (defaults to None).
39
+ """
40
+ self.start_price = start_price
41
+ self.days = days
42
+ self.volatility = volatility
43
+ self.drift = drift
44
+ self.event_day = event_day
45
+ self.event_impact = event_impact
46
+ self.random_seed = random_seed
47
+
48
+ def run_simulation(self) -> List[float]:
49
+ """
50
+ Simulates the stock price over a specified number of days based on the initial settings.
51
+
52
+ Returns:
53
+ List[float]: A list containing the stock prices for each day of the simulation.
54
+ """
55
+ if self.random_seed is not None:
56
+ np.random.seed(self.random_seed)
57
+
58
+ prices = [self.start_price]
59
+ for day in range(1, self.days):
60
+ previous_price = prices[-1]
61
+ random_change = np.random.normal(self.drift, self.volatility)
62
+ new_price = previous_price * (1 + random_change)
63
+
64
+ if day == self.event_day:
65
+ new_price = previous_price * (1 + self.event_impact)
66
+
67
+ prices.append(new_price)
68
+
69
+ return prices