Skip to main content

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: requests for HTTP calls to shipping & price services.
  • Data: pandas for logging, exporting reports, and trends.
  • Optional Dashboard: Streamlit, Dash or Flask for real-time monitoring.
  • Database: SQLite, PostgreSQL, or any relational DB for storing deals.

🚀 How It Works (Flow)

  1. STEP 1: User inputs product details (name, SKU, VIN, year, weight, memory, size, quantity, destination, shipping method).
  2. STEP 2: System fetches market retail prices, shipping costs, and FX rates.
  3. STEP 3: Calculates total landed costs, profit margin, and walk-away price.
  4. STEP 4: Compares multiple supplier offers and ranks them.
  5. STEP 5: Approves or rejects the deal; sends alerts and negotiation suggestions.
  6. STEP 6: Calculates final logistics costs, generates contract/PO.
  7. STEP 7: (If agri-export) Matches local suppliers/farmers to international buyers.
  8. STEP 8: Real-time dashboard and exportable reports.
  9. 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

robust_average-0.1.0.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

robust_average-0.1.0-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

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

Hashes for robust_average-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1d8d5a43c7e588f8b8966463bc76539b7d2b9ba2fde7867e80d49b0b557dac85
MD5 08b73b334311c0781036131ee9cb5a6e
BLAKE2b-256 a31eea602f9c0266d483b7b767f209a163600f476d2bc495963bf5af25ffd41c

See more details on using hashes here.

Provenance

The following attestation bundles were made for robust_average-0.1.0.tar.gz:

Publisher: publish.yml on Bensha93/Global-Sourcing-Intelligence-main

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for robust_average-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4c039f1a0b4638655e87638a2ab3fbe68587f5c245850faf3ee882245323e7ab
MD5 2a1abf02b72343b5762448ffe220dfc9
BLAKE2b-256 be567eb5f7e8fbab73c091ee27c79144d31777e047c197a71a5b6c34dde91b3a

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page