In [ ]:
Copied!
!pip install signal-ocean
!pip install signal-ocean
Set your subscription key, acquired here: https://apis.signalocean.com/profile
In [2]:
Copied!
signal_ocean_api_key = '' # replace with your subscription key
signal_ocean_api_key = '' # replace with your subscription key
Description¶
In order to perform our analysis, we will query historical tonnage lists for vessels that were "on subs" in the last 5 days in the area of Houston:
In [3]:
Copied!
from datetime import timedelta, date
from signal_ocean import Connection
from signal_ocean.tonnage_list import (
TonnageListAPI,
VesselClassFilter,
PortFilter,
VesselFilter,
MarketDeployment,
CommercialStatus,
VesselSubclass,
DateRange,
)
connection = Connection(signal_ocean_api_key)
api = TonnageListAPI(connection)
vessel_class_filter = VesselClassFilter(name_like="aframax")
vessel_class = api.get_vessel_classes(vessel_class_filter)[0]
port_filter = PortFilter(name_like="houston")
port = api.get_ports(port_filter)[0]
laycan_end_in_days = 10
start_date = date.today() - timedelta(days=5)
end_date = date.today()
vessel_filter = VesselFilter(
market_deployments=[MarketDeployment.RELET, MarketDeployment.SPOT],
vessel_subclass=VesselSubclass.DIRTY,
commercial_statuses=[CommercialStatus.ON_SUBS],
latest_ais_since=5,
)
htl_for_supply_trend = api.get_historical_tonnage_list(
port,
vessel_class,
laycan_end_in_days,
DateRange(start_date, end_date),
vessel_filter=vessel_filter,
)
from datetime import timedelta, date
from signal_ocean import Connection
from signal_ocean.tonnage_list import (
TonnageListAPI,
VesselClassFilter,
PortFilter,
VesselFilter,
MarketDeployment,
CommercialStatus,
VesselSubclass,
DateRange,
)
connection = Connection(signal_ocean_api_key)
api = TonnageListAPI(connection)
vessel_class_filter = VesselClassFilter(name_like="aframax")
vessel_class = api.get_vessel_classes(vessel_class_filter)[0]
port_filter = PortFilter(name_like="houston")
port = api.get_ports(port_filter)[0]
laycan_end_in_days = 10
start_date = date.today() - timedelta(days=5)
end_date = date.today()
vessel_filter = VesselFilter(
market_deployments=[MarketDeployment.RELET, MarketDeployment.SPOT],
vessel_subclass=VesselSubclass.DIRTY,
commercial_statuses=[CommercialStatus.ON_SUBS],
latest_ais_since=5,
)
htl_for_supply_trend = api.get_historical_tonnage_list(
port,
vessel_class,
laycan_end_in_days,
DateRange(start_date, end_date),
vessel_filter=vessel_filter,
)
Now, we can use the data to generate a supply trend:
In [4]:
Copied!
from signal_ocean.tonnage_list import IndexLevel
supply_trend_data_frame = htl_for_supply_trend.to_data_frame()
aggregated_data = supply_trend_data_frame.groupby(
IndexLevel.DATE, sort=True
).size()
ax = aggregated_data.plot(
markerfacecolor="blue",
color="skyblue",
linewidth=4,
label="Spot",
figsize=(12, 9),
)
ax.set_ylabel("Vessel count")
ax.legend()
from signal_ocean.tonnage_list import IndexLevel
supply_trend_data_frame = htl_for_supply_trend.to_data_frame()
aggregated_data = supply_trend_data_frame.groupby(
IndexLevel.DATE, sort=True
).size()
ax = aggregated_data.plot(
markerfacecolor="blue",
color="skyblue",
linewidth=4,
label="Spot",
figsize=(12, 9),
)
ax.set_ylabel("Vessel count")
ax.legend()
Out[4]:
<matplotlib.legend.Legend at 0x7f180fe015b0>