-
Notifications
You must be signed in to change notification settings - Fork 8
/
6_medium_sour_floating_storage.py
51 lines (43 loc) · 1.71 KB
/
6_medium_sour_floating_storage.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
"""
Let's see how much Medium-Sour Crude is in long term floating storage, in January 2019.
The below script returns:
| | key | value | count |
|----:|:-------------------------|---------:|--------:|
| 0 | 2019-01-01T00:00:00.000Z | 7381 | 9 |
| 1 | 2019-01-02T00:00:00.000Z | 8127 | 23 |
| 2 | 2019-01-03T00:00:00.000Z | 2333 | 32 |
| 3 | 2019-01-04T00:00:00.000Z | 447759 | 43 |
| 4 | 2019-01-05T00:00:00.000Z | 7777144 | 4 |
...
"""
from datetime import datetime
from docs.utils import to_markdown
from vortexasdk import CargoTimeSeries, Products
if __name__ == "__main__":
# Find Medium Sour ID
medium_sour = [
p.id
for p in Products().search(term="Medium-Sour").to_list()
if p.name == "Medium-Sour"
]
# Check we've only got one ID
assert len(medium_sour) == 1
# Query API
search_result = CargoTimeSeries().search(
# We're looking at daily storage levels
timeseries_frequency="day",
# We want 'b' for barrels here
timeseries_unit="b",
# We're only interested in storage of Medium-Sour Crude
filter_products=medium_sour,
# We're only included in cargo's that were in floating storage
filter_activity="storing_state",
# We're only interested in floating storage that lasted longer than 14 days
timeseries_activity_time_span_min=1000 * 60 * 60 * 24 * 14,
# Let's limit the search to January 2019 storage events
filter_time_min=datetime(2019, 1, 1),
filter_time_max=datetime(2019, 2, 1),
)
# Convert search result to dataframe
df = search_result.to_df()
print(to_markdown(df.head()))