Trading API is a realtime API supporting full-duplex communication channels over TCP and Web socket connection.
This section contains useful links to get started with this kind of API quickly.
Generate Classes using Protobuf tools
Protobuf Protocol Introduction
Download Trading API protocol Protobuf Sources
Read the Protobuf Developers Guide from Google
Read how to:
Open SSL Connection
Establish SSL connection with our Trading API server:
Using following host address and port: sandbox-tradeapi.spotware.com:5032
Get Access to Trader's Account using OAuth Services
How it works? When a trader decides to allow a 3rd party application to get access to their trading account they should be taken to Open API oAuth authorization server. The trader will enter his cTrader ID credentials there to be logged in and then will be asked for what kind of resources he would like to grant. After the permissions are taken the oAuth backend generates an access token which relates to allowed resources. Then the access token is sent back to the 3rd party's backend.
After 3rd party's application gets the access token it can use all of the granted resources of the trader without any additional requests for that.
NOTE: before start using OAuth services please read following section of the guide: OAuth Services Description for more details.
Request Trader for access to his Account
You may play with OAuth services on the Playgound page.
Trading scope of permissions
There are two scopes available:
- accounts - to request for access to Account Info (trading history, positions, pending order, etc.)
- trading - to request for permissions to trade on behalf of Account owner (Send market and pending orders, receive trading events, etc.)
Trading scope includes all available permissions. You don't have to combine it with accounts scope to get access to Trade Info.
Using Previously Generated Classes:
- Authorize established connection. You can do this using following request: ProtoOAAuthReq. Use your Partner's Credentials (Client Public ID / Client Secret) as your login and password.
- Subscribe for Trader's Account events. To subscribe for receiving account's events please use following request: ProtoOASubscribeForTradingEventsReq. To get the list subscribed accounts please use following request: ProtoOAGetSubscribedAccountsReq
- Receive & Process incoming trading events
Find here list of all available recources to play with trading accounts and investigate the API behaviour.
Find here description of many common cases and what exact response should be expected from the trading events feed.
Also you can find here description of all available events:
Unsubscribe from Trader's Account events
To unsubscribe from receiving account's events please use following request:
Or just drop the connection to unsubscribe from all previously subscribed accounts.
Step By Step Guide: How to build your own App
How to Get Started your own app in C#
How to Get Started your own app in Java
For more details please check out "Developer Library" section.
If you have any questions feel free to contact us.
Please direct all your questions to email@example.com