Skip to content

oafanasenko/ctrader-open-api-v2-java-example

 
 

Repository files navigation

API Reference 2.0

Introduction

The Open API 2.0 is the new version of the publicly available protobuf-based API developed by Spotware. It allows third-party service providers to integrate additional tools and applications for trading and analysis with the data and functionality from cTrader platform by getting all the required cTID data, market data and performing all possible trading operations on behalf of other cTrader users.

Documentation

Full documentation can be found on Spotware Connect website

How to start

  1. Download this project.
  2. Import the project to the chosen IDE as a Maven project.
  3. Run command mvn install to download libraries and compile Protocol Buffer classes.
  4. Register your application as described here. Set CLIENT_PUBLIC_ID and CLIENT_SECRET in application.properties.
  5. Login to Demo cTrader to create an account.
  6. Generate a token as described here. Set ACCESS_TOKEN and CTID_TRADER_ACCOUNT_ID in application.properties.
  7. Run examples from openapi2-example submodule.

Basic used libraries

  1. Google Protocol Buffers (Protobuf). Documentation reference. Official site.
  2. Netty. Official User Guide. Official site.

Content of the project

Submodule openapi2-client

This is a main codebase to open a channel to the server and send requests in the Protobuf format. Protocol files are located in protobuf directory.

Please note that Protocol Buffer classes (from the package com.xtrader.protocol.openapi.v2) are generated by the Maven plugin. So in a just downloaded project java files in this package are absent.

Submodule openapi2-example

Several examples to send often used requests:

  • authorization
  • assets list
  • symbols list
  • find symbol by ID
  • subscribe on price spots
  • process Symbol Changed Event
  • get symbol conversion chain

File application.properties contains properties to be set:

  • host It can be found on Spotware Proxy Cloud page. Default demo host is demo.ctraderapi.com
  • port Default port is 5035
  • CLIENT_PUBLIC_ID (54 chars) Client ID from Credentials of your application
  • CLIENT_SECRET (50 chars) Secret from Credentials of your application
  • ACCESS_TOKEN (43 chars) Get it in Playground of your application
  • CTID_TRADER_ACCOUNT_ID (number) It is data.accountId from "Trading Accounts" in Playground of your application

Note

Terms of Use

You can find the terms of use of Spotware Open API 2.0 here.

About

Open API 2.0 Example on Java

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%