Explore Knowledge Base

Asset Rates

26. 12. 2024

APIs to manage Asset rates

Asset rates source

There are two options for getting exchange rates for the operations (Asset rate sources):

  • “manual” source means that all asset rates should be set manually
  • “integration” source means that all asset rates will be uploaded via integration with rate provider, e.g. Currencycloud (available only if integration was implemented)

SDK.finance uses Currencycloud as a pre-integrated third-party solution for getting currency exchange rates.

The system provides the ability to switch between asset rate sources, manual or integration, without application restart

System configuration for asset rates source:

exchange-rates:
 timer:
   enabled: true
   schedule-expression: '0 0/5 * ? * * *'
 providers:
   - name: 'Manual'
     active: true
     enabled: true
     description: 'Manual currency exchange rates'
     default-ttl: 'P0D'
   - name: 'Currency-cloud'
     active: false
     enabled: true
     description: 'Currency cloud exchange provider'
     default-ttl: PT10H
currency-cloud:
 identifier: 'Currency-cloud' # must be unique and the same with exchange-rates.providers[*].name 


 url: 'https://devapi.currencycloud.com/v2'
 login-id: 'system_sdk5@sdk.finance'
 api-key: 'some-hidden-key’
 available-currencies:
   - USD
   - EUR
   - GBP
   - CHF

where:

  • default-ttl – a frequency of getting the updated rates from third-party
  • providers.enabled: true – true/false means turn on/turn off using certain provider (e.g. Manual, Currencycloud).

Clients need to create their own account in Currency Cloud in order to use it.

API to change asset rate source

Change source from “Manual” to “Integration”

  • System immediately updates values for all current rates from the integration (if the provider supports this, otherwise system keeps the current rate and set the status for asset rate “Unavailable”)
  • Next rates update will be no later than the TTL time set in the configuration for this provider
  • All asset rates (pairs) that will be added after switching will” be initialized through the integration source

Change source from “Integration” to “Manual”

  • System keeps all current rates as is

Asset rate statuses transition when changing the source

Manual to Integration Integration to Manual
Before After Before After
Created Created Created Created
Active Active Active Active
Disabled Disabled Disabled Disabled
all statuses Unavailable – if provider does not support asset Unavailable  

Manual exchange rates set up

  1. Authorize as admin or other service user with relevant permission.
  2. Get the list of currencies in the system
  3. View exchange rate
  4. Set currency exchange rate

Setup asset rates manually via Back-office UI

Get exchange rates via CurrencyCloud

If exchange-rates:providers:enabled: true for Currencycloud provider

Call API to get exchange rates

permission: EXCHANGE_MANAGER, EXCHANGE_VIEWER

POST {{baseUrl}}/exchange-rates/view

request body
{
   "ratePairs": [
       {
           "inCurrencyId": "e0b47f2d-32d2-48bb-b5d6-ae4f7416da23",
           "outCurrencyId": "5a273b77-4a0a-4ffc-b979-6f0710c13f92"
       }
   ]
}
response body
{
   "records": [
       {
           "id": "5b9f9fa4-7c5e-4fcb-8de4-3fcb4b21c2e4",
           "inCurrency": {
               "id": "e0b47f2d-32d2-48bb-b5d6-ae4f7416da23",
               "sn": "USD",
               "code": "USD",
               "symbol": "$"
           },
           "outCurrency": {
               "id": "5a273b77-4a0a-4ffc-b979-6f0710c13f92",
               "sn": "EUR",
               "code": "EUR",
               "symbol": "€"
           },
           "rate": 0.843241,
           "exchanger": {
               "id": "234c927a-366d-4195-baba-b6f48c09f6bd",
               "type": "system",
               "name": "SDK.Finance",
               "organizationStatus": "approved",
               "contract_info": {
                   "id": "5e05abcd-9123-4827-a30b-3ac5027174d9",
                   "personType": "base",
                   "name": "base contract for org system"
               }
           },
           "active": true
       }
   ]
}
  • those rates that have already been created will update their values according to the configuration no later than 10 hours from the last update (default-ttl: PT10H can be changed in configuration)
  • those rates that have not been initialized will be initialized with new values received from CurrencyCloud

Asset Rates Status

Status Transition Description
Created Active, Disabled, Unavailable Asset rate just created, set status as default automatically when creating a rate for currency pair. Status means that asset rate can NOT be used for exchange operation.

Status can NOT be set manually

Active Disabled, Unavailable Asset rate is active and can be used for exchange operation.

Service user activate asset rate manually

Disabled Active, Unavailable Asset rate is disabled and can NOT be used for exchange operation.

Service user disabled asset rate manually

Unavailable

Status for UI: “Unavailable for this type of rate source”

Active, Disabled *Asset rate is unavailable and can NOT be used for exchange operation.

*Status applicable only to Integration rate source and means that rate for current asset pair was not provided by the integration.

System set status automatically.