This template project provides a starting point for writing pricing integration adapters based on Caplin's C# DataSource API.
Follow the instructions below to create a new adapter project based on the Pricing Adapter Template for DotNet.
-
Clone, or download and extract the latest version of the Caplin Project Templates repository:
-
Clone:
$ git clone https://github.com/caplin/project-templates.git
-
Download:
$ wget http://github.com/caplin/project-templates/archive/master.zip $ unzip -qoa master.zip
-
-
Copy the template directory
pricing-template
and you may rename it to the name of your new project (for example, MyPricingAdapter):$ cp -r ./pricing-template-dotnet ~/src/MyPricingAdapter
-
Edit the file
~/src/MyPricingAdapter/settings.gradle
, and change the value of therootProject.name
variable to the name of your adapter project (MyPricingAdapter). When you later export your project as an adapter blade, the project name will be used as the name for the blade. -
Edit the file
~/src/MyPricingAdapter/blade/blade_config/bootstrap.conf
. Set the value of the configuration variableROUTE_VIA_TRANSFORMER
toTRUE
(default) to configure Liberator to route requests to the adapter via Transformer orFALSE
to configure Liberator to route requests directly to the adapter.Note: to route trade messages to the adapter via Transformer requires Transformer version 7.0.3 or later.
-
If you have a Caplin website account and Internet access to https://repository.caplin.com, follow the steps below to enable automatic downloading of this project's Caplin dependencies:
-
In your
~/.gradle/gradle.properties
file (create it if it does not exist), add the following lines, replacing<username>
and<password>
with your Caplin credentials:caplinNexusUser=<username> caplinNexusSecret=<password>
-
-
If you don't have a Caplin website account and Internet access to https://repository.caplin.com, follow the steps below to manage this project's Caplin dependencies manually:
-
In this project's
build.gradle
file, comment out themaven
block for https://repository.caplin.com:/*maven { credentials { username "$caplinNexusUser" password "$caplinNexusSecret" } url "https://repository.caplin.com" }*/
-
In this project's
build.gradle
add artifactory as a dependency source :repositories { mavenCentral() maven { url "http://artifactory.caplin.com:8081/artifactory/caplin-qa" } }
-
To import your project into Visual Studio, follow the steps below:
-
In Visual Studio, click File > Open > Project/Solution. The File Manager should appear.
-
Navigate to the DotNet Template in your project templates, Go into Project.
-
Select the TemplatePricingAdapter.csproj.
-
Click Open.
You will need to link your DSDK dll to use the IDE to build/run your adapter without Gradle.
Follow the steps below:
-
Download the latest .NET DataSource API from the Caplin Website: https://www.caplin.com/developer/downloads
-
Create a directory in your Project folder for the DSDK. For example,
Project/Lib/
-
Extract your DataSource.NET to your new directory
-
Copy all files from the kit with a ".dll" extension to the
bin/Debug
orbin/Release
directory (depending on the Configuration you are working on) -
In Visual Studio's Solution Explorer, right-click the References icon, and select Add Reference
-
Click the Browse option and navigate to your new
lib
directory where you have extracted the DataSource.NET kit -
Include the DataSource.NET.dll and Click Ok
Follow the steps below to build and deploy your adapter.
-
From the root of your project, run
./gradlew assemble
. This command packages your adapter in an adapter blade underbuild/distributions/
. -
Deploy the adapter blade to each Deployment Framework in your deployment infrastructure. For instructions on how to deploy an adapter blade to a Deployment Framework, see Deploy a custom blade.
This section describes how to connect an adapter in an IDE to a Liberator or Transformer in a Deployment Framework (DFW) on your local machine.
To provide Liberator or Transformer with your adapter's configuration, follow the steps below:
-
From the root of your project, run
./gradlew assemble -PconfigOnly
. This command packages your adapter's configuration (but not the binary) within a config-only blade underbuild/distributions/
. -
Copy the config-only blade to the
kits
directory of your local DFW. -
From the root of the local DFW, run the command
./dfw deploy
to deploy the config-only blade. -
From the root of the local DFW, run the command
./dfw versions
to confirm that the config blade has been deployed.
Note: if you change your adapter's configuration, you must repeat the steps above.
To provide your adapter with a working directory and the configuration of the Liberator or Transformer it connects to, follow the steps below:
-
In your Solution Explorer, right click your solution, Properties > Debug :
-
Set the run configuration's working directory to
dfw_location/active_blades/adapter_name/DataSource
, wheredfw_location
is the path to your local DFW, andadapter_name
is the name of your adapter.Note: on Microsoft Windows, which does not recognise Unix-style symbolic links, use the path
dfw_location\kits\adapter_name\adapter_name-version\DataSource
-
You will then need to create an OS level custom Environment Variable for CONFIG_BASE, pointing to your deployment framework's global_config folder.
Note: the value of
CONFIG_BASE
must end with a trailing slash.
-
-
Run the adapter using the new run configuration.
This section describes how to connect an adapter in an IDE to a Liberator or Transformer in a Deployment Framework (DFW) on a remote host.
To provide Liberator or Transformer with your adapter's configuration, follow the steps below:
-
From the root of your project, run
./gradlew assemble -PconfigOnly
. This command packages your adapter's configuration (but not the binary) within a config-only blade underbuild/distributions/
. -
Copy the config-only blade to the
kits
directory of the remote DFW. -
From the root of the remote DFW, run the command
./dfw deploy
to deploy the config-only blade. -
From the root of the remote DFW, run the command
./dfw versions
to confirm that the config blade has been deployed.
To provide your adapter with a working directory and the configuration of the Liberator or Transformer it connects to, follow the steps below:
-
From the root of your project, run
./gradlew setupWorkingDirectory
, specifying one or more of the properties listed below.The
setupWorkingDirectory
task creates a minimal execution environment for your adapter underbuild/env
. The environment includes a working directory and the minimal configuration required to connect to the remote Liberator or Transformer.The
setupWorkingDirectory
build task accepts the following Gradle properties:-
-PthisLeg=value
: defaults to1
. Change this if you want to connect to the failover leg. -
-PliberatorHost=value
: defaults tolocalhost
. This must be changed to the host that Liberator runs on. -
-PliberatorDsPort=value
: defaults to15001
. Change this if the Liberator uses a different DataSource port number. -
-PtransformerHost=value
: defaults tolocalhost
. This must be changed to the host Transformer runs on. -
-PtransformerDsPort=value
: defaults to15002
. Change this if the Transformer uses a different DataSource port number.
-
-
Open the generated configuration file
build/env/blade_config/environment-ide.conf
and check that the configuration has been generated correctly. Make manual corrections to the file as required. -
In your IDE, create a run configuration with the working directory set to
build/env/DataSource
. -
Run the adapter using the new run configuration.
Note: if you change your adapter's configuration, you must repeat the steps above.
To report an issue with the template, please contact Caplin Support or raise an issue on GitHub.