Skip to content

Package Documentation

Vessel Valuations API Package.

Classes:

Name Description
VesselValuationsAPI

Represents Signal's Vessel Valuations API.

Valuation

Valuation for a specific vessel.

Valuation dataclass

A valuation for a specific vessel.

Attributes:

Name Type Description
imo int

The IMO number of the vessel the valuation applies to.

valuation_price float

The price of the valuation.

scrap_price float

The estimated scrapped valuation of the vessel.

updated_date str

Date and time at which the valuation was updated.

Source code in signal_ocean/vessel_valuations/models.py
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
@dataclass(frozen=True)
class Valuation:
    """A valuation for a specific vessel.

    Attributes:
        imo: The IMO number of the vessel the valuation applies to.
        valuation_price: The price of the valuation.
        scrap_price: The estimated scrapped valuation of the vessel.
        updated_date: Date and time at which the valuation was updated.
    """
    imo: int
    valuation_price: float
    scrap_price: float
    updated_date: str

    def to_dict(self) -> Dict[Any, Any]:
        """Cast Valuation object to dict.

        Returns:
            Dict representation of Valuation model

        """
        return asdict(
            self,
            dict_factory=lambda x: {
                _to_camel_case_custom(k): v
                for (k, v) in x if v is not None
            })

to_dict()

Cast Valuation object to dict.

Returns:

Type Description
Dict[Any, Any]

Dict representation of Valuation model

Source code in signal_ocean/vessel_valuations/models.py
47
48
49
50
51
52
53
54
55
56
57
58
59
def to_dict(self) -> Dict[Any, Any]:
    """Cast Valuation object to dict.

    Returns:
        Dict representation of Valuation model

    """
    return asdict(
        self,
        dict_factory=lambda x: {
            _to_camel_case_custom(k): v
            for (k, v) in x if v is not None
        })

VesselValuationsAPI

Represents Signal's Vessel Valuation API.

Source code in signal_ocean/vessel_valuations/vessel_valuations_api.py
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
class VesselValuationsAPI:
    """Represents Signal's Vessel Valuation API."""

    relative_url = "valuationsv2/api/v2/valuations"

    def __init__(self, connection: Optional[Connection] = None):
        """Initializes Vessels Valuations API.

        Args:
            connection: API connection configuration. If not provided, the
                default connection method is used.
        """
        if connection is not None:
            em_connection = copy.deepcopy(connection)
            func_type = type(
                em_connection._Connection__get_headers  # type: ignore
            )
            em_connection._Connection__get_headers = func_type(  # type: ignore
                custom_headers, em_connection
            )
            self.__connection = em_connection
        else:
            connection = Connection()
            func_type = type(
                connection._Connection__get_headers  # type: ignore
            )
            connection._Connection__get_headers = func_type(  # type: ignore
                custom_headers, connection
            )
            self.__connection = connection

    def get_all_historical_valuations_by_imo(
            self,
            imo: int,
            from_date: Optional[str] = None,
            to_date: Optional[str] = None,
    ) -> Optional[List[HistoricalValuation]]:
        """Retrieves the latest valuation price (in $M) for a specific vessel.

        Args:
            imo: The IMO number of the vessel.
            from_date: The first date of valuation (optional).
            to_date: The last date of valuation (optional).

        Returns:
            A List of Historical Valuations for this vessel.
        """
        params_dict = {}
        if from_date is not None:
            params_dict['FromDate'] = from_date
        if to_date is not None:
            params_dict['ToDate'] = to_date
        query_url = make_url(VesselValuationsAPI.relative_url,
                             imo,
                             'historical',
                             **params_dict)
        historical_valuations = [
            i for i in get_multiple(
                self.__connection,
                query_url,
                HistoricalValuation
            )
        ]
        return historical_valuations

    def get_latest_valuation_by_imo(self, imo: int) -> Optional[Valuation]:
        """Retrieves the latest valuation for a specific vessel.

        Args:
            imo: The IMO number of the vessel.

        Returns:
            A valuation or None if a vessel with the given IMO number does not
            exist or has no valuation.
        """
        url = make_url(VesselValuationsAPI.relative_url,
                       imo,
                       'latest')
        valuation = get_single(self.__connection, url, Valuation)
        return valuation

    def get_latest_valuations_by_page(self,
                                      page: Optional[int] = None,
                                      page_size: Optional[int] = None,
                                      changed_since: Optional[str] = None
                                      ) -> Optional[PageValuations]:
        """Retrieves all valuations for a specific vessel.

        Args:
            page:  The page number you are requesting.
            page_size:  The maximum number of results per
            page to be returned.
            Range between 1 and 500, by default 100.
            changed_since: The date since the
            last time of update (optional).

        Returns:
            A tuple of valuations or None if a vessel with the given IMO number
            does not exist.
        """
        params_dict = {}
        if page is not None:
            params_dict['Page'] = str(page)
        if page_size is not None:
            params_dict['PageSize'] = str(page_size)
        if changed_since is not None:
            params_dict['ChangedSince'] = str(changed_since)
        url = make_url(VesselValuationsAPI.relative_url,
                       'latest',
                       '',
                       **params_dict)
        return get_single(self.__connection, url, PageValuations)

    def get_latest_valuations_for_list_of_vessels(
            self,
            imo_list: List[int]
    ) -> List[Optional[Valuation]]:
        """Retrieves the latest estimated valuations for a list of vessels.

        Args:
            imo_list: The list of IMO numbers of the vessels.

        Returns:
            A list of latest valuations
            for the requested imo numbers.
        """
        data = post_multiple(
            connection=self.__connection,
            relative_url=f"{VesselValuationsAPI.relative_url}/latest",
            cls=Valuation,
            query_string=imo_list  # type: ignore
        )
        return [i for i in data]

__init__(connection=None)

Initializes Vessels Valuations API.

Parameters:

Name Type Description Default
connection Optional[Connection]

API connection configuration. If not provided, the default connection method is used.

None
Source code in signal_ocean/vessel_valuations/vessel_valuations_api.py
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
def __init__(self, connection: Optional[Connection] = None):
    """Initializes Vessels Valuations API.

    Args:
        connection: API connection configuration. If not provided, the
            default connection method is used.
    """
    if connection is not None:
        em_connection = copy.deepcopy(connection)
        func_type = type(
            em_connection._Connection__get_headers  # type: ignore
        )
        em_connection._Connection__get_headers = func_type(  # type: ignore
            custom_headers, em_connection
        )
        self.__connection = em_connection
    else:
        connection = Connection()
        func_type = type(
            connection._Connection__get_headers  # type: ignore
        )
        connection._Connection__get_headers = func_type(  # type: ignore
            custom_headers, connection
        )
        self.__connection = connection

get_all_historical_valuations_by_imo(imo, from_date=None, to_date=None)

Retrieves the latest valuation price (in $M) for a specific vessel.

Parameters:

Name Type Description Default
imo int

The IMO number of the vessel.

required
from_date Optional[str]

The first date of valuation (optional).

None
to_date Optional[str]

The last date of valuation (optional).

None

Returns:

Type Description
Optional[List[HistoricalValuation]]

A List of Historical Valuations for this vessel.

Source code in signal_ocean/vessel_valuations/vessel_valuations_api.py
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
def get_all_historical_valuations_by_imo(
        self,
        imo: int,
        from_date: Optional[str] = None,
        to_date: Optional[str] = None,
) -> Optional[List[HistoricalValuation]]:
    """Retrieves the latest valuation price (in $M) for a specific vessel.

    Args:
        imo: The IMO number of the vessel.
        from_date: The first date of valuation (optional).
        to_date: The last date of valuation (optional).

    Returns:
        A List of Historical Valuations for this vessel.
    """
    params_dict = {}
    if from_date is not None:
        params_dict['FromDate'] = from_date
    if to_date is not None:
        params_dict['ToDate'] = to_date
    query_url = make_url(VesselValuationsAPI.relative_url,
                         imo,
                         'historical',
                         **params_dict)
    historical_valuations = [
        i for i in get_multiple(
            self.__connection,
            query_url,
            HistoricalValuation
        )
    ]
    return historical_valuations

get_latest_valuation_by_imo(imo)

Retrieves the latest valuation for a specific vessel.

Parameters:

Name Type Description Default
imo int

The IMO number of the vessel.

required

Returns:

Type Description
Optional[Valuation]

A valuation or None if a vessel with the given IMO number does not

Optional[Valuation]

exist or has no valuation.

Source code in signal_ocean/vessel_valuations/vessel_valuations_api.py
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
def get_latest_valuation_by_imo(self, imo: int) -> Optional[Valuation]:
    """Retrieves the latest valuation for a specific vessel.

    Args:
        imo: The IMO number of the vessel.

    Returns:
        A valuation or None if a vessel with the given IMO number does not
        exist or has no valuation.
    """
    url = make_url(VesselValuationsAPI.relative_url,
                   imo,
                   'latest')
    valuation = get_single(self.__connection, url, Valuation)
    return valuation

get_latest_valuations_by_page(page=None, page_size=None, changed_since=None)

Retrieves all valuations for a specific vessel.

Parameters:

Name Type Description Default
page Optional[int]

The page number you are requesting.

None
page_size Optional[int]

The maximum number of results per

None
changed_since Optional[str]

The date since the

None

Returns:

Type Description
Optional[PageValuations]

A tuple of valuations or None if a vessel with the given IMO number

Optional[PageValuations]

does not exist.

Source code in signal_ocean/vessel_valuations/vessel_valuations_api.py
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
def get_latest_valuations_by_page(self,
                                  page: Optional[int] = None,
                                  page_size: Optional[int] = None,
                                  changed_since: Optional[str] = None
                                  ) -> Optional[PageValuations]:
    """Retrieves all valuations for a specific vessel.

    Args:
        page:  The page number you are requesting.
        page_size:  The maximum number of results per
        page to be returned.
        Range between 1 and 500, by default 100.
        changed_since: The date since the
        last time of update (optional).

    Returns:
        A tuple of valuations or None if a vessel with the given IMO number
        does not exist.
    """
    params_dict = {}
    if page is not None:
        params_dict['Page'] = str(page)
    if page_size is not None:
        params_dict['PageSize'] = str(page_size)
    if changed_since is not None:
        params_dict['ChangedSince'] = str(changed_since)
    url = make_url(VesselValuationsAPI.relative_url,
                   'latest',
                   '',
                   **params_dict)
    return get_single(self.__connection, url, PageValuations)

get_latest_valuations_for_list_of_vessels(imo_list)

Retrieves the latest estimated valuations for a list of vessels.

Parameters:

Name Type Description Default
imo_list List[int]

The list of IMO numbers of the vessels.

required

Returns:

Type Description
List[Optional[Valuation]]

A list of latest valuations

List[Optional[Valuation]]

for the requested imo numbers.

Source code in signal_ocean/vessel_valuations/vessel_valuations_api.py
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
def get_latest_valuations_for_list_of_vessels(
        self,
        imo_list: List[int]
) -> List[Optional[Valuation]]:
    """Retrieves the latest estimated valuations for a list of vessels.

    Args:
        imo_list: The list of IMO numbers of the vessels.

    Returns:
        A list of latest valuations
        for the requested imo numbers.
    """
    data = post_multiple(
        connection=self.__connection,
        relative_url=f"{VesselValuationsAPI.relative_url}/latest",
        cls=Valuation,
        query_string=imo_list  # type: ignore
    )
    return [i for i in data]