https://github.com/spotware/ctrader-open-api-v2-java-example
Java examples using protobuf-based implementation of OpenAPI v2.0 for cTrader platform
https://github.com/spotware/ctrader-open-api-v2-java-example
Last synced: 4 months ago
JSON representation
Java examples using protobuf-based implementation of OpenAPI v2.0 for cTrader platform
- Host: GitHub
- URL: https://github.com/spotware/ctrader-open-api-v2-java-example
- Owner: spotware
- License: apache-2.0
- Created: 2018-09-25T11:12:37.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-09-19T16:24:09.000Z (over 1 year ago)
- Last Synced: 2025-12-01T12:53:29.956Z (6 months ago)
- Language: Java
- Homepage: https://connect.spotware.com/
- Size: 98.6 KB
- Stars: 20
- Watchers: 10
- Forks: 16
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# 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 Open API website](https://help.ctrader.com/open-api/)
## How to start
1. Download this project.
1. Import the project to the chosen IDE as a Maven project.
1. Run command `mvn install` to download libraries and compile Protocol Buffer classes.
1. Register your application as described [here](https://help.ctrader.com/open-api/creating-new-app/). Set `CLIENT_PUBLIC_ID` and `CLIENT_SECRET` in [application.properties](./openapi2-example/src/main/resources/application.properties).
1. Login to [Demo cTrader](https://ct.spotware.com/) to create an account.
1. Generate a token as described [here](https://help.ctrader.com/open-api/account-authentication/). Set `ACCESS_TOKEN` and `CTID_TRADER_ACCOUNT_ID` in [application.properties](./openapi2-example/src/main/resources/application.properties).
1. Run examples from `openapi2-example` submodule.
## Basic used libraries
1. Google Protocol Buffers (Protobuf). [Documentation reference](https://help.ctrader.com/open-api/protocol-buffers-json/). [Official site](https://developers.google.com/protocol-buffers/).
2. Netty. [Official User Guide](https://netty.io/wiki/user-guide-for-4.x.html). [Official site](https://netty.io/).
## 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](./openapi2-client/src/main/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](./openapi2-example/src/main/resources/application.properties) contains properties to be set:
- `host` It can be found on [Proxies/Endpoints page](https://help.ctrader.com/open-api/proxies-endpoints/).
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
- For more information, you may contact us: connect@spotware.com.
## Terms of Use
You can find the terms of use of Spotware Open API 2.0 [here](https://help.ctrader.com/open-api/terms-of-use/).