Skip to content

Private Security

The "Private Security" entity allows for the customized registration of fixed income instruments, covering data such as issue date, maturity, issue price, and the calculation method (SELIC, IPCA, Private). This enables the creation or simulation of private assets, adjusting various specific characteristics.

To start using the Private Security entity, run the following import statement:

from everysk.sdk.entities import PrivateSecurity

Below we have the most common attributes used in the Private Security entity:

  • symbol: The symbol of the private security. The symbol attribute is prefixed with the string PRIVATE:.

  • name: The name of the private security.

  • tags: The tags of the private security. Used for filtering and searching.

  • description: The description of the private security.

  • currency: The currency of the private security.

  • data: The data contained inside the private security.

  • instrument_type: The type of instrument of the private security.

Creating a Private Security Entity

To create a new Private Security entity, we can use the following code snippet, where we manually set the attributes:

private_security = PrivateSecurity()
private_security.symbol = 'PRIVATE:ABC'
private_security.name = 'ABC Private Security'
private_security.tags = ['tag1', 'tag2']
private_security.description = 'This is a private security'
private_security.currency = 'USD'
private_security.data = {'key1': 'value1', 'key2': 'value2'}
private_security.instrument_type = 'EQUITY'

Validate Private Security Entity

To validate the Private Security entity, we can use the validate() method, in the case of getting an invalid entity, the method will raise either a FieldValueError or a RequiredFieldError depending on the case.

private_security = PrivateSecurity()
private_security.validate()
# True

Below we have an example of a FieldValueError exception:

private_security = PrivateSecurity()
private_security.symbol = '123'
# FieldValueError: The value "123" for field "symbol" must match this regex: ^PRIVATE:[A-Z0-9_]*$.

Convert Private Security to a Dictionary

Most times when working with entities, there might be a point where we need to convert the entity to a dictionary, and to achieve this we simply use the to_dict() method:

private_security = PrivateSecurity()
type(private_security)
everysk.sdk.entities.private_security.base.PrivateSecurity

to_dict = private_security.to_dict()
type(to_dict)
# dict