A Streamlit web application to view and analyze commodity prices in China over the past 5 years. The app fetches real-time and historical data from Chinese commodity exchanges (SHFE and DCE) with prices displayed in RMB.
- Interactive Price Charts: View time-series price data with interactive Plotly charts
- Multiple Commodities: Track copper, PVC, aluminum, steel, and zinc prices
- Price Comparisons: Compare multiple commodities on the same chart
- Statistics Panel: View key metrics including average, min/max prices, volatility, and percentage changes
- Trend Analysis: Moving averages and trend indicators
- Data Caching: Local caching to improve performance and reduce API calls
- RMB Pricing: All prices displayed in Chinese Yuan (RMB)
- Copper (cu) - Shanghai Futures Exchange (SHFE)
- Aluminum (al) - Shanghai Futures Exchange (SHFE)
- Zinc (zn) - Shanghai Futures Exchange (SHFE)
- Steel/Rebar (rb) - Shanghai Futures Exchange (SHFE)
- PVC (v) - Dalian Commodity Exchange (DCE)
-
Clone or download this repository
-
Install required dependencies:
pip install -r requirements.txt- Run the Streamlit application:
streamlit run app.py-
The app will open in your default web browser
-
Use the sidebar to:
- Select commodities to display
- Choose date range (default: last 5 years)
- Toggle statistics and trend analysis
- Adjust moving average period
-
View interactive charts, statistics, and trend analysis in the main panel
This application uses the akshare library to fetch commodity futures data from:
- Shanghai Futures Exchange (SHFE): For metals (copper, aluminum, zinc, steel)
- Dalian Commodity Exchange (DCE): For PVC
All prices are in RMB (Chinese Yuan) as provided by the exchanges.
The application caches fetched data locally in the data_cache/ directory to:
- Reduce API calls
- Improve load times
- Work offline with previously fetched data
Cache files are automatically created and reused when the same commodity and date range are requested.
- Python 3.7+
- streamlit >= 1.28.0
- pandas >= 2.0.0
- plotly >= 5.17.0
- akshare >= 1.11.0
- requests >= 2.31.0
- Internet connection required for initial data fetching
- Data availability depends on akshare library and exchange data availability
- Some historical data may have limitations based on exchange records
- The app handles API rate limits and errors gracefully
This project is provided as-is for educational and informational purposes.