Psd
This commit is contained in:
committed by
Hendrik Dreesmann
parent
cb3fe7399b
commit
bff78f1e72
@@ -2,9 +2,18 @@
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"execution_count": 3,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"ename": "SyntaxError",
|
||||
"evalue": "invalid character '📈' (U+1F4C8) (3606104645.py, line 1)",
|
||||
"output_type": "error",
|
||||
"traceback": [
|
||||
" \u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[3]\u001b[39m\u001b[32m, line 1\u001b[39m\n\u001b[31m \u001b[39m\u001b[31m1. 📈 Market Prices & Volume\u001b[39m\n ^\n\u001b[31mSyntaxError\u001b[39m\u001b[31m:\u001b[39m invalid character '📈' (U+1F4C8)\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"\t1. 📈 Market Prices & Volume\n",
|
||||
"\t\t○ Yahoo Finance API → Futures Prices # via yfinance or yahoo_fin\n",
|
||||
@@ -38,9 +47,24 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"execution_count": 4,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"ename": "ModuleNotFoundError",
|
||||
"evalue": "No module named 'pkg_resources'",
|
||||
"output_type": "error",
|
||||
"traceback": [
|
||||
"\u001b[31m---------------------------------------------------------------------------\u001b[39m",
|
||||
"\u001b[31mModuleNotFoundError\u001b[39m Traceback (most recent call last)",
|
||||
"\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[4]\u001b[39m\u001b[32m, line 6\u001b[39m\n\u001b[32m 4\u001b[39m \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01malpha_vantage\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mtimeseries\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mimport\u001b[39;00m TimeSeries\n\u001b[32m 5\u001b[39m \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mfredapi\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mimport\u001b[39;00m Fred\n\u001b[32m----> \u001b[39m\u001b[32m6\u001b[39m \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mpyowm\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mowm\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mimport\u001b[39;00m OWM\n\u001b[32m 7\u001b[39m \u001b[38;5;28;01mimport\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mdatetime\u001b[39;00m\n\u001b[32m 8\u001b[39m \u001b[38;5;28;01mimport\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mjson\u001b[39;00m\n",
|
||||
"\u001b[36mFile \u001b[39m\u001b[32mc:\\Users\\ziran\\Desktop\\Test\\materia\\.venv\\Lib\\site-packages\\pyowm\\__init__.py:4\u001b[39m\n\u001b[32m 1\u001b[39m \u001b[38;5;66;03m#!/usr/bin/env python\u001b[39;00m\n\u001b[32m 2\u001b[39m \u001b[38;5;66;03m# -*- coding: utf-8 -*-\u001b[39;00m\n\u001b[32m----> \u001b[39m\u001b[32m4\u001b[39m \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mpyowm\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mowm\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mimport\u001b[39;00m OWM\n",
|
||||
"\u001b[36mFile \u001b[39m\u001b[32mc:\\Users\\ziran\\Desktop\\Test\\materia\\.venv\\Lib\\site-packages\\pyowm\\owm.py:14\u001b[39m\n\u001b[32m 12\u001b[39m \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mpyowm\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01muvindexapi30\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mimport\u001b[39;00m uvindex_manager\n\u001b[32m 13\u001b[39m \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mpyowm\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mutils\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mimport\u001b[39;00m config \u001b[38;5;28;01mas\u001b[39;00m cfg\n\u001b[32m---> \u001b[39m\u001b[32m14\u001b[39m \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mpyowm\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mcommons\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mimport\u001b[39;00m cityidregistry\n\u001b[32m 15\u001b[39m \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mpyowm\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mweatherapi25\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mimport\u001b[39;00m weather_manager\n\u001b[32m 18\u001b[39m \u001b[38;5;28;01mclass\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mOWM\u001b[39;00m:\n",
|
||||
"\u001b[36mFile \u001b[39m\u001b[32mc:\\Users\\ziran\\Desktop\\Test\\materia\\.venv\\Lib\\site-packages\\pyowm\\commons\\cityidregistry.py:7\u001b[39m\n\u001b[32m 5\u001b[39m \u001b[38;5;28;01mimport\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01msqlite3\u001b[39;00m\n\u001b[32m 6\u001b[39m \u001b[38;5;28;01mimport\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mtempfile\u001b[39;00m\n\u001b[32m----> \u001b[39m\u001b[32m7\u001b[39m \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mpkg_resources\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mimport\u001b[39;00m resource_filename\n\u001b[32m 8\u001b[39m \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mpyowm\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mweatherapi25\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mlocation\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mimport\u001b[39;00m Location\n\u001b[32m 10\u001b[39m CITY_ID_DB_PATH = \u001b[33m'\u001b[39m\u001b[33mcityids/cities.db.bz2\u001b[39m\u001b[33m'\u001b[39m\n",
|
||||
"\u001b[31mModuleNotFoundError\u001b[39m: No module named 'pkg_resources'"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"#Example Code for API Requests\n",
|
||||
"import requests\n",
|
||||
@@ -159,6 +183,906 @@
|
||||
"# Alternative: USDA GAIN reports: https://apps.fas.usda.gov/gainsearch/\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 18,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<div>\n",
|
||||
"<style scoped>\n",
|
||||
" .dataframe tbody tr th:only-of-type {\n",
|
||||
" vertical-align: middle;\n",
|
||||
" }\n",
|
||||
"\n",
|
||||
" .dataframe tbody tr th {\n",
|
||||
" vertical-align: top;\n",
|
||||
" }\n",
|
||||
"\n",
|
||||
" .dataframe thead th {\n",
|
||||
" text-align: right;\n",
|
||||
" }\n",
|
||||
"</style>\n",
|
||||
"<table border=\"1\" class=\"dataframe\">\n",
|
||||
" <thead>\n",
|
||||
" <tr style=\"text-align: right;\">\n",
|
||||
" <th></th>\n",
|
||||
" <th>0</th>\n",
|
||||
" <th>1</th>\n",
|
||||
" <th>2</th>\n",
|
||||
" <th>3</th>\n",
|
||||
" <th>4</th>\n",
|
||||
" <th>5</th>\n",
|
||||
" <th>6</th>\n",
|
||||
" <th>7</th>\n",
|
||||
" <th>8</th>\n",
|
||||
" <th>9</th>\n",
|
||||
" <th>10</th>\n",
|
||||
" <th>11</th>\n",
|
||||
" <th>12</th>\n",
|
||||
" <th>13</th>\n",
|
||||
" <th>14</th>\n",
|
||||
" </tr>\n",
|
||||
" </thead>\n",
|
||||
" <tbody>\n",
|
||||
" <tr>\n",
|
||||
" <th>0</th>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>1</th>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>2</th>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>3</th>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>4</th>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>5</th>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>6</th>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>7</th>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>8</th>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>9</th>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>10</th>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" <td>{'commodityCode': '0440000', 'countryCode': '0...</td>\n",
|
||||
" </tr>\n",
|
||||
" </tbody>\n",
|
||||
"</table>\n",
|
||||
"</div>"
|
||||
],
|
||||
"text/plain": [
|
||||
" 0 \\\n",
|
||||
"0 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"1 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"2 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"3 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"4 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"5 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"6 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"7 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"8 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"9 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"10 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"\n",
|
||||
" 1 \\\n",
|
||||
"0 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"1 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"2 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"3 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"4 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"5 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"6 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"7 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"8 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"9 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"10 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"\n",
|
||||
" 2 \\\n",
|
||||
"0 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"1 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"2 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"3 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"4 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"5 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"6 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"7 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"8 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"9 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"10 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"\n",
|
||||
" 3 \\\n",
|
||||
"0 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"1 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"2 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"3 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"4 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"5 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"6 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"7 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"8 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"9 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"10 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"\n",
|
||||
" 4 \\\n",
|
||||
"0 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"1 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"2 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"3 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"4 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"5 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"6 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"7 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"8 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"9 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"10 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"\n",
|
||||
" 5 \\\n",
|
||||
"0 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"1 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"2 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"3 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"4 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"5 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"6 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"7 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"8 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"9 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"10 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"\n",
|
||||
" 6 \\\n",
|
||||
"0 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"1 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"2 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"3 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"4 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"5 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"6 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"7 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"8 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"9 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"10 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"\n",
|
||||
" 7 \\\n",
|
||||
"0 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"1 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"2 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"3 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"4 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"5 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"6 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"7 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"8 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"9 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"10 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"\n",
|
||||
" 8 \\\n",
|
||||
"0 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"1 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"2 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"3 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"4 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"5 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"6 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"7 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"8 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"9 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"10 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"\n",
|
||||
" 9 \\\n",
|
||||
"0 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"1 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"2 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"3 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"4 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"5 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"6 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"7 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"8 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"9 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"10 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"\n",
|
||||
" 10 \\\n",
|
||||
"0 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"1 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"2 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"3 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"4 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"5 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"6 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"7 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"8 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"9 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"10 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"\n",
|
||||
" 11 \\\n",
|
||||
"0 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"1 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"2 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"3 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"4 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"5 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"6 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"7 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"8 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"9 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"10 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"\n",
|
||||
" 12 \\\n",
|
||||
"0 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"1 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"2 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"3 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"4 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"5 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"6 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"7 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"8 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"9 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"10 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"\n",
|
||||
" 13 \\\n",
|
||||
"0 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"1 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"2 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"3 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"4 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"5 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"6 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"7 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"8 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"9 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"10 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"\n",
|
||||
" 14 \n",
|
||||
"0 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"1 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"2 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"3 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"4 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"5 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"6 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"7 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"8 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"9 {'commodityCode': '0440000', 'countryCode': '0... \n",
|
||||
"10 {'commodityCode': '0440000', 'countryCode': '0... "
|
||||
]
|
||||
},
|
||||
"execution_count": 18,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import requests\n",
|
||||
"import pandas as pd\n",
|
||||
"\n",
|
||||
"# Define the commodity code for corn\n",
|
||||
"commodity_code = '0440000'\n",
|
||||
"\n",
|
||||
"# Define the years of interest\n",
|
||||
"years = range(2010, 2021)\n",
|
||||
"\n",
|
||||
"# Initialize an empty list to store the data\n",
|
||||
"data = []\n",
|
||||
"\n",
|
||||
"# Loop through each year and fetch the data\n",
|
||||
"for year in years:\n",
|
||||
" url = f'https://api.fas.usda.gov/api/psd/commodity/{commodity_code}/world/year/{year}?api_key=n1cDatmPp2b18qqKOgDKVndjdrUk4oUgB9HALoVA'\n",
|
||||
" response = requests.get(url)\n",
|
||||
" if response.status_code == 200:\n",
|
||||
" data.append(response.json())\n",
|
||||
" else:\n",
|
||||
" print(f'Failed to fetch data for {year}')\n",
|
||||
"\n",
|
||||
"# Convert the list of data into a DataFrame\n",
|
||||
"df = pd.DataFrame(data)\n",
|
||||
"\n",
|
||||
"# Display the DataFrame\n",
|
||||
"df\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
" commodityCode countryCode marketYear calendarYear month attributeId \\\n",
|
||||
"0 0440000 00 2011 2025 04 4 \n",
|
||||
"1 0440000 00 2011 2025 04 20 \n",
|
||||
"2 0440000 00 2011 2025 04 28 \n",
|
||||
"3 0440000 00 2011 2025 04 57 \n",
|
||||
"4 0440000 00 2011 2025 04 81 \n",
|
||||
"\n",
|
||||
" unitId value \n",
|
||||
"0 4 175808.0 \n",
|
||||
"1 8 115328.0 \n",
|
||||
"2 8 910355.0 \n",
|
||||
"3 8 100631.0 \n",
|
||||
"4 8 101710.0 \n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import requests\n",
|
||||
"import pandas as pd\n",
|
||||
"\n",
|
||||
"# Define the URL for the USDA API\n",
|
||||
"url = \"https://api.fas.usda.gov/api/psd/commodity/0440000/world/year/2011?api_key=n1cDatmPp2b18qqKOgDKVndjdrUk4oUgB9HALoVA\"\n",
|
||||
"\n",
|
||||
"# Fetch the data\n",
|
||||
"response = requests.get(url)\n",
|
||||
"data = response.json()\n",
|
||||
"\n",
|
||||
"# Convert the JSON data to a pandas DataFrame\n",
|
||||
"df = pd.DataFrame(data)\n",
|
||||
"\n",
|
||||
"# Display the DataFrame\n",
|
||||
"print(df.head())\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
" commodityCode countryCode marketYear calendarYear month attributeId \\\n",
|
||||
"0 0440000 00 2011 2025 04 4 \n",
|
||||
"1 0440000 00 2011 2025 04 20 \n",
|
||||
"2 0440000 00 2011 2025 04 28 \n",
|
||||
"3 0440000 00 2011 2025 04 57 \n",
|
||||
"4 0440000 00 2011 2025 04 81 \n",
|
||||
"\n",
|
||||
" unitId value \n",
|
||||
"0 4 175808.0 \n",
|
||||
"1 8 115328.0 \n",
|
||||
"2 8 910355.0 \n",
|
||||
"3 8 100631.0 \n",
|
||||
"4 8 101710.0 \n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import requests\n",
|
||||
"import pandas as pd\n",
|
||||
"\n",
|
||||
"# Define the URL for the USDA API\n",
|
||||
"url = \"https://api.fas.usda.gov/api/psd/commodity/0440000/world/year/2011?api_key=n1cDatmPp2b18qqKOgDKVndjdrUk4oUgB9HALoVA\"\n",
|
||||
"\n",
|
||||
"# Fetch the data\n",
|
||||
"response = requests.get(url)\n",
|
||||
"data = response.json()\n",
|
||||
"\n",
|
||||
"# Convert the JSON data to a pandas DataFrame\n",
|
||||
"df = pd.DataFrame(data)\n",
|
||||
"\n",
|
||||
"# Display the DataFrame\n",
|
||||
"print(df.head())\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 16,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Status code: 200\n",
|
||||
"Number of entries: 63\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import requests\n",
|
||||
"\n",
|
||||
"API_KEY = \"n1cDatmPp2b18qqKOgDKVndjdrUk4oUgB9HALoVA\"\n",
|
||||
"url = f\"https://api.fas.usda.gov/api/psd/commodities?api_key={API_KEY}\"\n",
|
||||
"\n",
|
||||
"resp = requests.get(url)\n",
|
||||
"print(\"Status code:\", resp.status_code)\n",
|
||||
"resp.raise_for_status()\n",
|
||||
"\n",
|
||||
"data = resp.json()\n",
|
||||
"print(\"Number of entries:\", len(data))\n",
|
||||
"\n",
|
||||
"# Print each commodity code\n",
|
||||
"for item in data:\n",
|
||||
" code = item.get(\"commodity_code\") or item.get(\"Commodity_Code\")\n",
|
||||
" if code:\n",
|
||||
" print(code)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 17,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Status code: 200\n",
|
||||
"Total commodity entries found: 63\n",
|
||||
"None\n",
|
||||
"None\n",
|
||||
"None\n",
|
||||
"None\n",
|
||||
"None\n",
|
||||
"None\n",
|
||||
"None\n",
|
||||
"None\n",
|
||||
"None\n",
|
||||
"None\n",
|
||||
"None\n",
|
||||
"None\n",
|
||||
"None\n",
|
||||
"None\n",
|
||||
"None\n",
|
||||
"None\n",
|
||||
"None\n",
|
||||
"None\n",
|
||||
"None\n",
|
||||
"None\n",
|
||||
"None\n",
|
||||
"None\n",
|
||||
"None\n",
|
||||
"None\n",
|
||||
"None\n",
|
||||
"None\n",
|
||||
"None\n",
|
||||
"None\n",
|
||||
"None\n",
|
||||
"None\n",
|
||||
"None\n",
|
||||
"None\n",
|
||||
"None\n",
|
||||
"None\n",
|
||||
"None\n",
|
||||
"None\n",
|
||||
"None\n",
|
||||
"None\n",
|
||||
"None\n",
|
||||
"None\n",
|
||||
"None\n",
|
||||
"None\n",
|
||||
"None\n",
|
||||
"None\n",
|
||||
"None\n",
|
||||
"None\n",
|
||||
"None\n",
|
||||
"None\n",
|
||||
"None\n",
|
||||
"None\n",
|
||||
"None\n",
|
||||
"None\n",
|
||||
"None\n",
|
||||
"None\n",
|
||||
"None\n",
|
||||
"None\n",
|
||||
"None\n",
|
||||
"None\n",
|
||||
"None\n",
|
||||
"None\n",
|
||||
"None\n",
|
||||
"None\n",
|
||||
"None\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import requests\n",
|
||||
"\n",
|
||||
"API_KEY = \"n1cDatmPp2b18qqKOgDKVndjdrUk4oUgB9HALoVA\"\n",
|
||||
"url = f\"https://api.fas.usda.gov/api/psd/commodities?api_key={API_KEY}\"\n",
|
||||
"\n",
|
||||
"resp = requests.get(url)\n",
|
||||
"print(\"Status code:\", resp.status_code)\n",
|
||||
"resp.raise_for_status()\n",
|
||||
"\n",
|
||||
"payload = resp.json()\n",
|
||||
"\n",
|
||||
"# Detect where the list of commodities lives\n",
|
||||
"if isinstance(payload, dict):\n",
|
||||
" for wrap_key in (\"data\", \"value\", \"commodities\"):\n",
|
||||
" if wrap_key in payload and isinstance(payload[wrap_key], list):\n",
|
||||
" entries = payload[wrap_key]\n",
|
||||
" break\n",
|
||||
" else:\n",
|
||||
" entries = []\n",
|
||||
"else:\n",
|
||||
" entries = payload\n",
|
||||
"\n",
|
||||
"print(\"Total commodity entries found:\", len(entries))\n",
|
||||
"\n",
|
||||
"# Print each code\n",
|
||||
"for item in entries:\n",
|
||||
" code = item.get(\"commodity_code\") or item.get(\"Commodity_Code\")\n",
|
||||
" print(code)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 28,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"0577400 Almonds, Shelled Basis\n",
|
||||
"0011000 Animal Numbers, Cattle\n",
|
||||
"0013000 Animal Numbers, Swine\n",
|
||||
"0574000 Apples, Fresh\n",
|
||||
"0430000 Barley\n",
|
||||
"0579305 Cherries (Sweet&Sour), Fresh\n",
|
||||
"0711100 Coffee, Green\n",
|
||||
"0440000 Corn\n",
|
||||
"2631000 Cotton\n",
|
||||
"0230000 Dairy, Butter\n",
|
||||
"0240000 Dairy, Cheese\n",
|
||||
"0224400 Dairy, Dry Whole Milk Powder\n",
|
||||
"0223000 Dairy, Milk, Fluid\n",
|
||||
"0224200 Dairy, Milk, Nonfat Dry\n",
|
||||
"0572220 Grapefruit, Fresh\n",
|
||||
"0575100 Grapes, Fresh Table\n",
|
||||
"0572120 Lemons/Limes, Fresh\n",
|
||||
"0813700 Meal, Copra\n",
|
||||
"0813300 Meal, Cottonseed\n",
|
||||
"0814200 Meal, Fish\n",
|
||||
"0813800 Meal, Palm Kernel\n",
|
||||
"0813200 Meal, Peanut\n",
|
||||
"0813600 Meal, Rapeseed\n",
|
||||
"0813100 Meal, Soybean\n",
|
||||
"0813101 Meal, Soybean (Local)\n",
|
||||
"0813500 Meal, Sunflowerseed\n",
|
||||
"0111000 Meat, Beef and Veal\n",
|
||||
"0115000 Meat, Chicken\n",
|
||||
"0113000 Meat, Swine\n",
|
||||
"0459100 Millet\n",
|
||||
"0459900 Mixed Grain\n",
|
||||
"0452000 Oats\n",
|
||||
"4242000 Oil, Coconut\n",
|
||||
"4233000 Oil, Cottonseed\n",
|
||||
"4235000 Oil, Olive\n",
|
||||
"4243000 Oil, Palm\n",
|
||||
"4244000 Oil, Palm Kernel\n",
|
||||
"4234000 Oil, Peanut\n",
|
||||
"4239100 Oil, Rapeseed\n",
|
||||
"4232000 Oil, Soybean\n",
|
||||
"4232001 Oil, Soybean (Local)\n",
|
||||
"4236000 Oil, Sunflowerseed\n",
|
||||
"2231000 Oilseed, Copra\n",
|
||||
"2223000 Oilseed, Cottonseed\n",
|
||||
"2232000 Oilseed, Palm Kernel\n",
|
||||
"2221000 Oilseed, Peanut\n",
|
||||
"2226000 Oilseed, Rapeseed\n",
|
||||
"2222000 Oilseed, Soybean\n",
|
||||
"2222001 Oilseed, Soybean (Local)\n",
|
||||
"2224000 Oilseed, Sunflowerseed\n",
|
||||
"0585100 Orange Juice\n",
|
||||
"0571120 Oranges, Fresh\n",
|
||||
"0579309 Peaches & Nectarines, Fresh\n",
|
||||
"0579220 Pears, Fresh\n",
|
||||
"0577907 Pistachios, Inshell Basis\n",
|
||||
"0114200 Poultry, Meat, Broiler\n",
|
||||
"0422110 Rice, Milled\n",
|
||||
"0451000 Rye\n",
|
||||
"0459200 Sorghum\n",
|
||||
"0612000 Sugar, Centrifugal\n",
|
||||
"0571220 Tangerines/Mandarins, Fresh\n",
|
||||
"0577901 Walnuts, Inshell Basis\n",
|
||||
"0410000 Wheat\n",
|
||||
"First entry keys: ['commodityCode', 'commodityName']\n",
|
||||
"\n",
|
||||
"First entry full content:\n",
|
||||
"{\n",
|
||||
" \"commodityCode\": \"0577400\",\n",
|
||||
" \"commodityName\": \"Almonds, Shelled Basis\"\n",
|
||||
"}\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import requests, json\n",
|
||||
"\n",
|
||||
"API_KEY = \"n1cDatmPp2b18qqKOgDKVndjdrUk4oUgB9HALoVA\"\n",
|
||||
"url = f\"https://api.fas.usda.gov/api/psd/commodities?api_key={API_KEY}\"\n",
|
||||
"\n",
|
||||
"resp = requests.get(url)\n",
|
||||
"resp.raise_for_status()\n",
|
||||
"payload = resp.json()\n",
|
||||
"for item in payload:\n",
|
||||
" print(item[\"commodityCode\"] + \" \"+ item[\"commodityName\"])\n",
|
||||
" \n",
|
||||
"# Inspect the keys of the first entry\n",
|
||||
"print(\"First entry keys:\", list(payload[0].keys()))\n",
|
||||
"print(\"\\nFirst entry full content:\")\n",
|
||||
"print(json.dumps(payload[0], indent=2))\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 23,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Returned 63 commodities:\n",
|
||||
"\n",
|
||||
"None – None\n",
|
||||
"None – None\n",
|
||||
"None – None\n",
|
||||
"None – None\n",
|
||||
"None – None\n",
|
||||
"None – None\n",
|
||||
"None – None\n",
|
||||
"None – None\n",
|
||||
"None – None\n",
|
||||
"None – None\n",
|
||||
"None – None\n",
|
||||
"None – None\n",
|
||||
"None – None\n",
|
||||
"None – None\n",
|
||||
"None – None\n",
|
||||
"None – None\n",
|
||||
"None – None\n",
|
||||
"None – None\n",
|
||||
"None – None\n",
|
||||
"None – None\n",
|
||||
"None – None\n",
|
||||
"None – None\n",
|
||||
"None – None\n",
|
||||
"None – None\n",
|
||||
"None – None\n",
|
||||
"None – None\n",
|
||||
"None – None\n",
|
||||
"None – None\n",
|
||||
"None – None\n",
|
||||
"None – None\n",
|
||||
"None – None\n",
|
||||
"None – None\n",
|
||||
"None – None\n",
|
||||
"None – None\n",
|
||||
"None – None\n",
|
||||
"None – None\n",
|
||||
"None – None\n",
|
||||
"None – None\n",
|
||||
"None – None\n",
|
||||
"None – None\n",
|
||||
"None – None\n",
|
||||
"None – None\n",
|
||||
"None – None\n",
|
||||
"None – None\n",
|
||||
"None – None\n",
|
||||
"None – None\n",
|
||||
"None – None\n",
|
||||
"None – None\n",
|
||||
"None – None\n",
|
||||
"None – None\n",
|
||||
"None – None\n",
|
||||
"None – None\n",
|
||||
"None – None\n",
|
||||
"None – None\n",
|
||||
"None – None\n",
|
||||
"None – None\n",
|
||||
"None – None\n",
|
||||
"None – None\n",
|
||||
"None – None\n",
|
||||
"None – None\n",
|
||||
"None – None\n",
|
||||
"None – None\n",
|
||||
"None – None\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import requests\n",
|
||||
"\n",
|
||||
"API_KEY = \"n1cDatmPp2b18qqKOgDKVndjdrUk4oUgB9HALoVA\"\n",
|
||||
"url = f\"https://api.fas.usda.gov/api/psd/commodities?api_key={API_KEY}\"\n",
|
||||
"\n",
|
||||
"resp = requests.get(url)\n",
|
||||
"resp.raise_for_status()\n",
|
||||
"data = resp.json()\n",
|
||||
"\n",
|
||||
"print(f\"Returned {len(data)} commodities:\\n\")\n",
|
||||
"for item in data:\n",
|
||||
" code = item.get(\"commodity_code\") or item.get(\"Commodity_Code\")\n",
|
||||
" desc = item.get(\"commodity_desc\") or item.get(\"Commodity_Desc\")\n",
|
||||
" # If the description key is different, inspect one entry with `print(item.keys())` to find the right name\n",
|
||||
" print(f\"{code} – {desc}\")\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
@@ -168,8 +1092,22 @@
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": ".venv",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"name": "python"
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.13.3"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
||||
31
notebooks/PSD Commodities.txt
Normal file
31
notebooks/PSD Commodities.txt
Normal file
@@ -0,0 +1,31 @@
|
||||
PSD Data API - Production, Supply and Distribution Forecast Data of World Agricultural Commodities
|
||||
|
||||
Valid markets with futures trading on CME or ICE:
|
||||
|
||||
0011000 – Animal Numbers, Cattle (CME Live Cattle, LE)
|
||||
|
||||
0013000 – Animal Numbers, Swine (CME Lean Hogs, HE)
|
||||
|
||||
0711100 – Coffee, Green (ICE “Coffee C”, KC)
|
||||
|
||||
0440000 – Corn (CBOT Corn, ZC)
|
||||
|
||||
2631000 – Cotton (ICE Cotton No. 2, CT)
|
||||
|
||||
0813100 – Meal, Soybean (CBOT Soybean Meal, ZM)
|
||||
|
||||
0813101 – Meal, Soybean (Local) (same as CBOT Soybean Meal, ZM)
|
||||
|
||||
0422110 – Rice, Milled (CBOT Rough Rice, ZR)
|
||||
|
||||
0452000 – Oats (CBOT Oats, ZO)
|
||||
|
||||
0612000 – Sugar, Centrifugal (ICE Sugar No. 11, SB)
|
||||
|
||||
0410000 – Wheat (CBOT Wheat, ZW)
|
||||
|
||||
4232000 – Oil, Soybean (CBOT Soybean Oil, ZL)
|
||||
|
||||
4239100 – Oil, Rapeseed (ICE Rapeseed, RS)
|
||||
|
||||
0585100 – Orange Juice (ICE Frozen Concentrated Orange Juice, OJ)
|
||||
@@ -8,8 +8,11 @@ authors = [
|
||||
]
|
||||
requires-python = ">=3.13"
|
||||
dependencies = [
|
||||
"alpha-vantage>=3.0.0",
|
||||
"fredapi>=0.5.2",
|
||||
"httpx>=0.28.1",
|
||||
"ipykernel>=6.29.5",
|
||||
"pyowm>=3.3.0",
|
||||
"yfinance>=0.2.54",
|
||||
]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user