Skip to content

Latest commit

 

History

History

pricing-template-dotnet

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Caplin Pricing Adapter Template for DotNet

This template project provides a starting point for writing pricing integration adapters based on Caplin's C# DataSource API.

Getting started

Follow the instructions below to create a new adapter project based on the Pricing Adapter Template for DotNet.

Copy and customise the template

  1. 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
      
  2. 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
    
  3. Edit the file ~/src/MyPricingAdapter/settings.gradle, and change the value of the rootProject.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.

  4. Edit the file ~/src/MyPricingAdapter/blade/blade_config/bootstrap.conf. Set the value of the configuration variable ROUTE_VIA_TRANSFORMER to TRUE (default) to configure Liberator to route requests to the adapter via Transformer or FALSE 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.

  5. 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:

    1. 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>
      
  6. 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:

    1. In this project's build.gradle file, comment out the maven block for https://repository.caplin.com:

      /*maven {
          credentials {
              username "$caplinNexusUser"
              password "$caplinNexusSecret"
          }
          url "https://repository.caplin.com"
      }*/
    2. In this project's build.gradle add artifactory as a dependency source :

      repositories {
          mavenCentral()
          maven { url "http://artifactory.caplin.com:8081/artifactory/caplin-qa" }
      }

Import your new project into Visual Studio

To import your project into Visual Studio, follow the steps below:

  1. In Visual Studio, click File > Open > Project/Solution. The File Manager should appear.

  2. Navigate to the DotNet Template in your project templates, Go into Project.

  3. Select the TemplatePricingAdapter.csproj.

  4. Click Open.

Reference the DataSource.NET In your solution

You will need to link your DSDK dll to use the IDE to build/run your adapter without Gradle.

Follow the steps below:

  1. Download the latest .NET DataSource API from the Caplin Website: https://www.caplin.com/developer/downloads

  2. Create a directory in your Project folder for the DSDK. For example, Project/Lib/

  3. Extract your DataSource.NET to your new directory

  4. Copy all files from the kit with a ".dll" extension to the bin/Debug or bin/Release directory (depending on the Configuration you are working on)

  5. In Visual Studio's Solution Explorer, right-click the References icon, and select Add Reference

  6. Click the Browse option and navigate to your new lib directory where you have extracted the DataSource.NET kit

  7. Include the DataSource.NET.dll and Click Ok

Building and deploying the adapter blade

Follow the steps below to build and deploy your adapter.

  1. From the root of your project, run ./gradlew assemble. This command packages your adapter in an adapter blade under build/distributions/.

  2. 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.

Running your adapter with a local Liberator or Transformer

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:

  1. 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 under build/distributions/.

  2. Copy the config-only blade to the kits directory of your local DFW.

  3. From the root of the local DFW, run the command ./dfw deploy to deploy the config-only blade.

  4. 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:

  1. In your Solution Explorer, right click your solution, Properties > Debug :

    1. Set the run configuration's working directory to dfw_location/active_blades/adapter_name/DataSource, where dfw_location is the path to your local DFW, and adapter_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

    2. 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.

  2. Run the adapter using the new run configuration.

Running your adapter with a remote Liberator or Transformer

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:

  1. 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 under build/distributions/.

  2. Copy the config-only blade to the kits directory of the remote DFW.

  3. From the root of the remote DFW, run the command ./dfw deploy to deploy the config-only blade.

  4. 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:

  1. 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 under build/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 to 1. Change this if you want to connect to the failover leg.

    • -PliberatorHost=value: defaults to localhost. This must be changed to the host that Liberator runs on.

    • -PliberatorDsPort=value: defaults to 15001. Change this if the Liberator uses a different DataSource port number.

    • -PtransformerHost=value: defaults to localhost. This must be changed to the host Transformer runs on.

    • -PtransformerDsPort=value: defaults to 15002. Change this if the Transformer uses a different DataSource port number.

  2. 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.

  3. In your IDE, create a run configuration with the working directory set to build/env/DataSource.

  4. Run the adapter using the new run configuration.

Note: if you change your adapter's configuration, you must repeat the steps above.

How to report issues with the template

To report an issue with the template, please contact Caplin Support or raise an issue on GitHub.