A Python package that intelligently selects the most robust average (mean, median, or mode) for price analysis
Project description
Global-Sourcing-Intelligence
An Intelligent Sourcing & Profitability Platform for Global SME Traders
📌 Overview
Smart Sourcing Hub is a modular software solution designed for import/export businesses, global traders, and SME resellers who need better control over supplier deals, shipping costs, market pricing, and profit margins.
The goal is simple: Buy smart, sell smart, and protect your margins.
✅ Key Features
-
Supplier Comparison
- Compare offers from auctions, manufacturers, and distributors.
- Rank deals by price, reliability score, and delivery time.
-
Real-Time Market Data
- Pull retail prices in the destination market using local marketplaces, price comparison APIs, or Google Shopping SERP data.
- Fetch live shipping rates (air, sea, courier) via integrations with Freightos, SeaRates, DHL, and others.
- Convert foreign currencies using real-time exchange rates.
-
Profitability Protection
- Calculate total landed cost per unit.
- Automatically check profit margins against your target threshold.
- Generate a “walk-away price” so you never overpay.
-
Deal Decision & Alerts
- Approve or reject deals automatically based on profit margin.
- Generate negotiation templates for suppliers.
- Send instant alerts to the procurement team.
-
Logistics & Contracting
- Calculate shipping weight/volume x quantity.
- Add local delivery and warehousing costs.
- Auto-generate purchase orders (POs) with clear terms.
-
Reporting & Dashboard
- Real-time dashboard to track profit vs. costs.
- Export deal reports for management review.
- Keep a historical log of all suppliers and deals.
-
Future-Ready Add-ons
- Traceability tools for supplier compliance.
- Forecasting with historical data + ML.
- Fraud detection and risk scoring for trusted partners.
📊 Robust Average for Price Analysis
What is Robust Average?
The robust_average function is a reusable Python module that intelligently selects the most meaningful average (mean, median, or mode) for a set of prices. It analyzes the data for outliers and skewness, then chooses the best statistical measure to represent the "typical" price, ensuring results are not distorted by extreme values or unusual distributions.
Why Integrate Robust Average?
- Real-world price data is often messy: Scraped prices from APIs or the web can include outliers, errors, or highly skewed distributions.
- Standard mean can be misleading: A few very high or low prices can distort the mean, making it unrepresentative of what most buyers actually pay.
- Business and legal accuracy: In contracts, reporting, or compliance, using a misleading average can have legal or financial consequences. The robust average ensures you report the most defensible and meaningful value.
Benefits
- Automatic selection: No need to manually inspect data for outliers or skewness—the function does it for you.
- Transparency: Returns the method used (mean, median, or mode) and supporting statistics, so you can justify your results.
- Reusability: Can be used in any project or analysis where robust, reliable price statistics are needed.
- Better decision-making: Ensures that pricing, negotiation, and reporting are based on the most representative data, not distorted by anomalies.
Example Usage
from robust_average import robust_average
prices = [97.87, 109.99, 129.99, 89.99, 119.99, 500.00]
result = robust_average(prices)
print(result)
# Output: {'value': 109.99, 'method': 'median', ...}
⚙️ Tech Stack
This is a Python-based project blueprint — simple to expand with:
- APIs:
requestsfor HTTP calls to shipping & price services. - Data:
pandasfor logging, exporting reports, and trends. - Optional Dashboard:
Streamlit,DashorFlaskfor real-time monitoring. - Database: SQLite, PostgreSQL, or any relational DB for storing deals.
🚀 How It Works (Flow)
- STEP 1: User inputs product details (name, SKU, VIN, year, weight, memory, size, quantity, destination, shipping method).
- STEP 2: System fetches market retail prices, shipping costs, and FX rates.
- STEP 3: Calculates total landed costs, profit margin, and walk-away price.
- STEP 4: Compares multiple supplier offers and ranks them.
- STEP 5: Approves or rejects the deal; sends alerts and negotiation suggestions.
- STEP 6: Calculates final logistics costs, generates contract/PO.
- STEP 7: (If agri-export) Matches local suppliers/farmers to international buyers.
- STEP 8: Real-time dashboard and exportable reports.
- STEP 9: Future enhancements like traceability, forecasting, fraud detection.
🔗 APIs & Integrations
- Shipping: Freightos, SeaRates, DHL, UPS, Aramex.
- Price Comparison: Local marketplaces (Jumia, Noon, Takealot, Konga), Google Shopping via SerpAPI.
- FX Rates: Free services like exchangerate.host or premium FX APIs.
- Notifications: Can integrate with email, Slack, or WhatsApp for team alerts.
🚦 Project Progress
✅ Completed
- Environment variable management for API keys (.env, python-dotenv)
- Integration with SerpAPI for product price scraping
- Country/domain lookup using Wikidata and DuckDB
- Flexible, case-insensitive country matching
- Product filtering based on user-specified criteria (name, memory, color)
- Robust average function for meaningful price analysis (mean/median/mode selection)
- Demo and playground scripts for data analysis and testing
- requirements.txt updated for all dependencies
🔜 To Do
- Generate and format analysis reports (Step 3 in demo_env.py)
- Save reports to files (Step 4)
- Implement user notification or report delivery (Step 5)
- Add more comprehensive error handling and logging
- Expand data validation and integrity checks
- Build a user interface or dashboard (optional/future)
- Add more unit and integration tests
- Improve documentation and usage examples
📁 File Structure (Example)
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file robust_average-0.1.0.tar.gz.
File metadata
- Download URL: robust_average-0.1.0.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1d8d5a43c7e588f8b8966463bc76539b7d2b9ba2fde7867e80d49b0b557dac85
|
|
| MD5 |
08b73b334311c0781036131ee9cb5a6e
|
|
| BLAKE2b-256 |
a31eea602f9c0266d483b7b767f209a163600f476d2bc495963bf5af25ffd41c
|
Provenance
The following attestation bundles were made for robust_average-0.1.0.tar.gz:
Publisher:
publish.yml on Bensha93/Global-Sourcing-Intelligence-main
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
robust_average-0.1.0.tar.gz -
Subject digest:
1d8d5a43c7e588f8b8966463bc76539b7d2b9ba2fde7867e80d49b0b557dac85 - Sigstore transparency entry: 264371717
- Sigstore integration time:
-
Permalink:
Bensha93/Global-Sourcing-Intelligence-main@83998cb0558d106d1144c70214393aa0fcb47105 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Bensha93
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@83998cb0558d106d1144c70214393aa0fcb47105 -
Trigger Event:
release
-
Statement type:
File details
Details for the file robust_average-0.1.0-py3-none-any.whl.
File metadata
- Download URL: robust_average-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4c039f1a0b4638655e87638a2ab3fbe68587f5c245850faf3ee882245323e7ab
|
|
| MD5 |
2a1abf02b72343b5762448ffe220dfc9
|
|
| BLAKE2b-256 |
be567eb5f7e8fbab73c091ee27c79144d31777e047c197a71a5b6c34dde91b3a
|
Provenance
The following attestation bundles were made for robust_average-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on Bensha93/Global-Sourcing-Intelligence-main
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
robust_average-0.1.0-py3-none-any.whl -
Subject digest:
4c039f1a0b4638655e87638a2ab3fbe68587f5c245850faf3ee882245323e7ab - Sigstore transparency entry: 264371718
- Sigstore integration time:
-
Permalink:
Bensha93/Global-Sourcing-Intelligence-main@83998cb0558d106d1144c70214393aa0fcb47105 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Bensha93
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@83998cb0558d106d1144c70214393aa0fcb47105 -
Trigger Event:
release
-
Statement type: