Trying to calculate optimum order quantity from supplier, based on forecasted demand python

38 Views Asked by At

below are my demand forecast, based on this, i will like to determine the optimum quantity to order from my supplier.

2016-06-30    3196.276292
2016-07-31    2963.649104
2016-08-31    2695.774926
2016-09-30    2595.090061
2016-10-31    2963.573648
2016-11-30    2767.602512
2016-12-31    2947.536752
2017-01-31    2907.608736
2017-02-28    3101.192581
2017-03-31    3105.799599
2017-04-30    3192.416920
2017-05-31    3260.181956
2017-06-30    3196.769778
2017-07-31    3546.028570
2017-08-31    2854.070753
2017-09-30    3234.990407
2017-10-31    3021.252371
2017-11-30    3129.856535
2017-12-31    2967.641519
2018-01-31    3089.990677
2018-02-28    2713.715199
2018-03-31    3014.362837
2018-04-30    3219.258500
2018-05-31    3212.581639
2018-06-30    3473.809863
2018-07-31    3309.952544
2018-08-31    2991.958277
2018-09-30    2948.191574
2018-10-31    3247.865622
2018-11-30    3087.890549
2018-12-31    3227.388069
2019-01-31    3206.638691
2019-02-28    3332.874030
2019-03-31    3372.468443
2019-04-30    3473.064424
2019-05-31    3532.031586
2019-06-30    3506.986853
2019-07-31    3795.603304
2019-08-31    3147.842160
2019-09-30    3478.570494
2019-10-31    3325.509779
2019-11-30    3402.372055
2019-12-31    3275.814767
2020-01-31    3381.251904
2020-02-29    3064.365387

I tried running to run a few code but I get error, please find the code i used below, I am not sure if I am doing right. PLease does anyone know how i can achieve this? I am still a novice at this. I used ARIMA for my forecast. Many thanks in advance!

I will like to get out

"Optimal Order Quantity:", order_quantity
"Reorder Point:", reorder_point
"Safety Stock:", safety_stock
# Create date indices for the future predictions
future_steps=10
future_dates = pd.date_range(start=past_Demand.index[-1] + pd.DateOffset(days=30), periods=future_steps, freq='D')

# Create a pandas Series with the predicted values and date indices
forecasted_demand = pd.Series(predictions, index=future_dates)

# Initial inventory level
initial_inventory = 10860

# Lead time (number of days it takes to replenish inventory) 
lead_time = 10 

# Service level (probability of not stocking out)
service_level = 0.95 

# Calculate the optimal order quantity using the Newsvendor formula
z = np.abs(np.percentile(forecasted_demand, 100 * (10 - service_level)))
order_quantity = np.ceil(forecasted_demand.mean() + z).astype(int)

# Calculate the reorder point
reorder_point = forecasted_demand.mean() * lead_time + z
print("Optimal Order Quantity:", order_quantity)
print("Reorder Point:", reorder_point)
print("Safety Stock:", safety_stock)

error message i get is ValueError: Percentiles must be in the range [0, 100]

0

There are 0 best solutions below