Skip to main content

SPGCI is an API Client for the S&P Commodity Insights REST API

Project description

SPGCI

Python Client for the S&P Global Commodity Insights API.

Installation

Requires Python >= 3.8.10.

pip install spgci

Getting Started

Open In Colab

    import spgci as ci

    ci.set_credentials(<username>, <password>, <appkey>)
    mdd = ci.MarketData()

    symbols = ["PCAAS00", "PCAAT00"]
    mdd.get_assessments_by_symbol_current(symbol=symbols)

SPGCI


Alternatively, you can set your credentials via Environment Variables and omit the set_credentials call:

Environment Variable Description
SPGCI_USERNAME Your Username
SPGCI_PASSWORD Your Password
SPGCI_APPKEY Your AppKey

Features

  • Automatically generates token prior to making request.
  • Returns data as a pandas DataFrame (set raw=False to get the raw request.response object).
  • Can auto-paginate response and concatenates into a single DataFrame (set paginate=True to enable).
  • Sets datatype for date and datetime fields in DataFrame.
  • Composes nicely with native python/pandas types. Arguments support lists and pd.Series which are automatically converted into filter expressions.

Datasets Supported

Market Data

import spgci as ci

mdd = ci.MarketData()

mdd.get_symbols(commodity="Crude oil")
# DataFrame of symbols with commodity = "Crude oil"

mdd.get_mdcs(subscribed_only=True)
# DataFrame of all Market Data Categories you are subscribed to

mdd.get_assessments_by_mdc_current(mdc="ET")
# DataFrame of current assessments for all symbols in the Market Data Category "ET"

Forward Curves

import spgci as ci

fc = ci.ForwardCurves()

fc.get_curves(
    commodity=["Benzene", "Crude oil"],
    derivative_maturity_frequency="Month"
    )
# DataFrame of all curves with commodity in ("Benzene", "Crude Oil") and have a Monthly frequency

fc.get_assessments(curve_code=["CN003", "CN006"])
# DataFrame of the latest assessments for all symbols in the curves ("CN003", "CN006")

Energy Price Forecast

import spgci as ci

epf = ci.EnergyPriceForecast()

epf.get_prices_shortterm(symbol="PCAAS00", month=[10, 11, 12])
# DataFrame of monthly forecasts for the symbol "PCAAS00" in the last 3 months of the year

epf.get_prices_longterm(year=[2020, 2021], sector="Energy Transition", delivery_region="Europe")
# DataFrame of the annual forecasts for the years 2020, 2021, where the sector is "Energy Transition" and the delivery region is "Europe"

EWindow Market Data

import spgci as ci
from datetime import date

ewmd = ci.EWindowMarketData()

ewmd.get_markets()
# DataFrame of Markets

d = date(2023,2,13)
ewmd.get_botes(market=["EU BFOE", "US MidWest"], order_time=d)
# DataFrame of all BOTes in the markets ("EU BFOE", "US MidWest") on Feb 13, 2023

World Oil Supply

import spgci as ci

wos = ci.WorldOilSupply()

countries = wos.get_reference_data(type=wos.RefType.Countries)
# DataFrame of all countries

wos.get_ownership(country=countries['countryName'][:3], year=2040)
# DataFrame of Ownership for the first three countries from the countries endpoint and year 2040

World Refinery Database

import spgci as ci

wrd = ci.WorldRefineryDatabase()

wrd.get_yields(year=2020, owner="BP")
# DataFrame of yields for the year 2020 where BP is the refinery owner.

Disclaimer

Please note that by using this Alpha offering, you agree that you are participating in a prototype to develop these software development kits (“Alpha SDKs”) and that your participation and use of the Alpha SDKs is at your own risk. You will be liable for all activities by anyone using your application in connection with the Alpha SDKs.

If you are dissatisfied with the Alpha SDKs, your sole remedy is to stop using it, and S&P Global Commodity Insights (“SPGCI”) will not pay you any damages (direct, indirect, special, or consequential) in connection with your use of the Alpha SDKs. Commodity Insights SPGCI disclaims any and all representations and warranties, express or implied, including but not limited to any warranties of merchantability or fitness for a particular purpose or use as to the Alpha SDKs, and does not guarantee the adequacy, accuracy, timeliness or completeness of the Alpha SDKs or any component of them.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

spgci-0.0.6.tar.gz (22.2 kB view details)

Uploaded Source

Built Distribution

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

spgci-0.0.6-py3-none-any.whl (26.9 kB view details)

Uploaded Python 3

File details

Details for the file spgci-0.0.6.tar.gz.

File metadata

  • Download URL: spgci-0.0.6.tar.gz
  • Upload date:
  • Size: 22.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.8.10 Windows/10

File hashes

Hashes for spgci-0.0.6.tar.gz
Algorithm Hash digest
SHA256 cc400edce1b2bfe9461fa685fc9ac4dbc40eacbab3505aa9b1aac45e74bf861e
MD5 b4e8b2603f5af5fb915ca275df90abbf
BLAKE2b-256 7ddd65befe77caba215c252269779170d75ea6eb942acd8ec50b2cfc8c3f1c61

See more details on using hashes here.

File details

Details for the file spgci-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: spgci-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 26.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.8.10 Windows/10

File hashes

Hashes for spgci-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 a11be47ee639a685fe117a288e23ad48879c23dc1fa9b136ccd42c25dca7371e
MD5 49587070ff9e0316b323ac8c0d4e22f6
BLAKE2b-256 18e4aac082728358c31d8315f2bc296f5088af1e9f6ab6712e591a4528ad28f2

See more details on using hashes here.

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