Skip to content

Working with currencies

Currency & CurrencySet Modules

Changelog

Version Description
5.3.0 Add name_of_cents attribute to Currency class, and parse it from 'nameOfCents' column of 'currency.csv' file when available.
3.0.0 Constructor doesn't read anymore from pandas.DataFrame, use CurrencySet to build the object.
1.0.0 Class Currency added.

Documentation

Currency Class

A Currency object contains key data pertaining to a currency as defined on the KYOS platform. Currency objects should be constructed using CurrencySet.from_csv(), which returns a currency_set = CurrencySet object. The individual currency object can be obtained using currency_set.get_currency(currency_id) method. See examples from CurrencySet class.

Attributes:

Name Type Description
id int

Currency ID number

name str

Name of the currency

base_currency bool

Indicates if a currency is the platform base (default) currency. Note: can be different from KySim model currency.

commodity_id int

Commodity ID number of the commodity corresponding to the FX pair that represents the exchange rate between this currency and the platform base currency.

commodity_group_id int

Id of the group number to which the relevant FX pair belongs, typically the id of the FX-rate group.

fwd_curve_id int

Id number of the forward curve of FX rates corresponding to this currency/FX pair.

settle_curve_id int

ID number of the settlement curve of FX rates corresponding to this currency/FX pair.

unit_id int

ID number corresponding to the unit of the currency, as defined on the KYOS platform. Typically, the generic "Currency" unit is applied to all FX-rates.

name_of_cents

Name of currency cents (e.g. EUR cents, GBP pence, etc.)

Helpers

Returns a list of all available currency objects in the input currency.csv file generated by the KYOS platform.

Parameters:

Name Type Description Default
currency_dir str

path to the directory

'./Input/'

Returns:

Type Description
list

List of currency objects

Note

CSV file called currency.csv must exist within the current working (project) directory. This file contains the relevant currency data.

Examples:

>>> from kyoslib_py.settings import make_currency
>>> currencies = make_currency()
>>> currencies[0].name
'EUR'
>>> next((x for x in currencies if x.get_id() == 2), None)

CurrencySet Class

This is the manager object of the currency class. This class loads the set of all available currencies.

Attributes:

Name Type Description
currencies list

list of objects

Examples:

>>> from kyoslib_py.settings import CurrencySet
>>> currency_set = CurrencySet.from_csv()
>>> currency = currency_set.get_currency(1)
>>> currency.get_name()
'EUR'

__init__(currency_info_list=None)

Parameters:

Name Type Description Default
currency_info_list list

list of dictionaries. Each dictionary has correct Currency format

None

from_csv(csv_path='./Input/currency.csv') staticmethod

This static method builds the CurrencySet object from xml.

Parameters:

Name Type Description Default
csv_path str

path to currency.csv

'./Input/currency.csv'

Returns:

Type Description
object

kyoslib.CurrencySet object

from_json(json_path) staticmethod

This static method builds the CurrencySet object from xml.

Parameters:

Name Type Description Default
json_path str

path to currency.json

required

Returns:

Type Description
object

kyoslib.CurrencySet object

get_currency(requested_currency_id)

Parameters:

Name Type Description Default
requested_currency_id int

the currency id from the server

required

Returns:

Type Description
object

kyoslib.Currency object