Received: ProtoMessage{ErrorResponse{errorCode:INVALID_REQUEST, description:Trading account is not authorized}}

Created at 17 Feb 2019, 20:28
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
NE

netread2004

Joined 26.12.2017

Received: ProtoMessage{ErrorResponse{errorCode:INVALID_REQUEST, description:Trading account is not authorized}}
17 Feb 2019, 20:28


I am using OPEN_API_2.0 Sample application. I have appropriately created ClientID, Secret and token from SpotWare Connect App. I updated the code with new  _clientId, _clientSecret, ,, _token. Also I used _apiHost = "demo.ctraderapi.com";, _apiPort = 5035; and _accountID = as one of my cTrader demo accounts.

When I run this and through GUI I use "Autherize Application" and then Click on "Get Symbol" I get the responses as follows:

Send: ProtoMessage{AppAuthRequest{clientId:XXXXXX  clientSecret:XXXXXXXX}}
Received: ProtoMessage{ApAuthResponse}
Received: ProtoMessage{Heartbeat}
Received: ProtoMessage{Heartbeat}

Send: ProtoMessage{AppAuthRequest{clientId:XXXXX, clientSecret:XXXXX}}
Received: ProtoMessage{ErrorResponse{errorCode:ALREADY_LOGGED_IN, description:Open API application is already authorized}}
Send: ProtoMessage{GetSymbolsList}
Received: ProtoMessage{ErrorResponse{errorCode:INVALID_REQUEST, description:Trading account is not authorized}}
Received: ProtoMessage{Heartbeat}
 

Also, When I click on Get Accounts List application Hangs.

Not sure what is wrong here. Looks like it is usage issue. If someone can help me how to use this correctly I would appreciate it.

 

Thanks

 


@netread2004
Replies

PanagiotisCharalampous
18 Feb 2019, 12:00

Hi netread2004,

You cannot get Symbols if you do not get an account authorized first. So 1) Authorize your application 2) Get Accounts List 3) Get Symbols. Get Accounts List does not hang, it just takes some time if you have a lot of accounts.

Best Regards,

Panagiotis


@PanagiotisCharalampous

netread2004
18 Feb 2019, 12:53

Thanks.

It took some time to get all account numbers.

However, when I see the account number I got from OPEN API they do not match with cTrader Account nmber those are linked to my CTId.

I assume the list I get from OpenAPI is the list of cTrader account that are linked to my cTID and the same account that I can see in Apps-> PlayGround ->Account Info menu,

Could you please let me know why there is a mismatch like this?

Thanks again.

 

 

 

 


@netread2004

PanagiotisCharalampous
18 Feb 2019, 14:47

Hi netread2004,

You should get either live or demo accounts depending on which proxy you have been connected to, demo.ctraderapi.com or live.ctraderapi.com.

Best Regards,

Panagiotis


@PanagiotisCharalampous

netread2004
19 Feb 2019, 06:09

I am getting both Live as well as Demo account numbers and none of them belong to me.

As I mentioned in my earleir message I used _apiHost = "demo.ctraderapi.com";, _apiPort = 5035

So, I should get the list of all Demo account linked to my cTID. But I am getting the list of accounts those are not linked to my cTID at all.

I am not sure where these account numbers are coming from.

Can you please suggest how I can get the account number linked ot my cTID and what could be the possible reason I am getting these random account numbers?

 


@netread2004

PanagiotisCharalampous
19 Feb 2019, 10:00

Hi netread2004,

Did you replace the token found in the sample application with one for your own accounts? If not, you need to generate a token for your accounts.

Best Regards,

Panagiotis


@PanagiotisCharalampous

netread2004
19 Feb 2019, 10:19

Yes, I did. 

This is what  I have done to get new token

Application -> PlayGround  select scope Accounts
Get Toekn -> I see the list of my accounts
Clicked on "Allow Acess" with all accounts selected with checkmarks
This took me back to accountinfo page . I copied access_token and used in OPEN API Sample program in _token =.

_apiHost = "demo.ctraderapi.com";, _apiPort = 5035  is this correct?

I am following everything mentioned in the document.  Not sure where these random account numbers I am getting.

Any suggestions on how to fix this issue?

 


@netread2004

netread2004
20 Feb 2019, 02:27

Tried to get new tokens several time and repeating this same thing again and agian I get the same list of accounts, I am not sure where these account numbers are coming. They are not mine. Can you please investigate this? I can send you list of accounts to your email to investigate further on this .

Please let me know.,

 


@netread2004

PanagiotisCharalampous
20 Feb 2019, 09:59

Hi netread2004,

The numbers you are getting are account ids, not account numbers. If you want to get the trading account number as displyed in your cTrader application, you should use the TraderLogin parameter.

Best Regards,

Panagiotis


@PanagiotisCharalampous

netread2004
20 Feb 2019, 10:52

Few questions :

1) How do  I associate account IDs with account number?

2)All I want is to login to my account number and send /receive FIX message for trading my cTrader account. I am not sure these accoun IDs will help in doing that. Looks like things are confusing and not sure where to find these account IDs.

3)What do you mean by Trader Login detials if that means trader account number and password then your sample Open API does not mention anywhere Trade account number and password where I can substitute my account info and start runing to place orders. Not sure what is achieved by using Account IDs as opposed to Account number.

4)Is there any document which mentions simple flow on how to use of Open API to trade cTrader account with FIX messages?

Thanks

 


@netread2004

PanagiotisCharalampous
20 Feb 2019, 11:22

Hi netread2004,

Every account has an ID and a Trader Login (trading account number). They are both part of the ProtoOATrader message and this is how they are assosiated. See below ProtoOATrader definition and documentation.

message ProtoOATrader {
    required int64 ctidTraderAccountId = 1; // The unique Trader's Account ID used to match the responses to the Trader's Account.
    required int64 balance = 2; // Current account balance in cents (e.g. If USD 100.00 then value = 10000).
    optional int64 balanceVersion = 3; // Balance version used to identify the final balance. Increments each time when the trader's account balance is changed.
    optional int64 managerBonus = 4; // Amount of broker's bonus allocated to the account in cents.
    optional int64 ibBonus = 5; // Amount of introducing broker bonus allocated to the account cents.
    optional int64 nonWithdrawableBonus = 6; // Broker's bonus that cannot be withdrew from the account as cash.
    optional ProtoOAAccessRights accessRights = 7 [default = FULL_ACCESS]; // Access rights that an owner has to the account in cTrader platform. See ProtoOAAccessRights for details.
    required int64 depositAssetId = 8; // Deposit currency of the account.
    optional bool swapFree = 9; // If TRUE than account is Shariah compliant.
    optional uint32 leverageInCents = 10; // Account leverage (e.g. If leverage = 1:50 then value = 5000).
    optional ProtoOATotalMarginCalculationType totalMarginCalculationType = 11; // Margin computation type for the account (MAX, SUM, NET).
    optional uint32 maxLeverage = 12; // Maximum allowed leverage for the account. Used as validation when a Trader can change leverage value.
    optional bool frenchRisk = 13; // If TRUE then account is AMF compliant.
    optional int64 traderLogin = 14; // ID of the account that is unique per server (Broker).
    optional ProtoOAAccountType accountType = 15 [default = HEDGED]; // Account type: HEDGED, NETTED, etc.
    optional string brokerName = 16; // Some whitelabel assigned to trader by broker at the moment of account creation.
    optional int64 registrationTimestamp = 17; // Unix timestamp of the account registration. Should be used as minimal date in historical data requests.
}

Trader Login is the account number you see in cTrader. Account ID is used for Open API messages.

There is no document about sending FIX messages using Open API since this is not the purpose of Open API.

Best Regards,

Panagiotis


@PanagiotisCharalampous

hpangeletta
29 Jul 2020, 11:54

RE:

PanagiotisCharalampous said:

Hi netread2004,

Every account has an ID and a Trader Login (trading account number). They are both part of the ProtoOATrader message and this is how they are assosiated. See below ProtoOATrader definition and documentation.

message ProtoOATrader {
    required int64 ctidTraderAccountId = 1; // The unique Trader's Account ID used to match the responses to the Trader's Account.
    required int64 balance = 2; // Current account balance in cents (e.g. If USD 100.00 then value = 10000).
    optional int64 balanceVersion = 3; // Balance version used to identify the final balance. Increments each time when the trader's account balance is changed.
    optional int64 managerBonus = 4; // Amount of broker's bonus allocated to the account in cents.
    optional int64 ibBonus = 5; // Amount of introducing broker bonus allocated to the account cents.
    optional int64 nonWithdrawableBonus = 6; // Broker's bonus that cannot be withdrew from the account as cash.
    optional ProtoOAAccessRights accessRights = 7 [default = FULL_ACCESS]; // Access rights that an owner has to the account in cTrader platform. See ProtoOAAccessRights for details.
    required int64 depositAssetId = 8; // Deposit currency of the account.
    optional bool swapFree = 9; // If TRUE than account is Shariah compliant.
    optional uint32 leverageInCents = 10; // Account leverage (e.g. If leverage = 1:50 then value = 5000).
    optional ProtoOATotalMarginCalculationType totalMarginCalculationType = 11; // Margin computation type for the account (MAX, SUM, NET).
    optional uint32 maxLeverage = 12; // Maximum allowed leverage for the account. Used as validation when a Trader can change leverage value.
    optional bool frenchRisk = 13; // If TRUE then account is AMF compliant.
    optional int64 traderLogin = 14; // ID of the account that is unique per server (Broker).
    optional ProtoOAAccountType accountType = 15 [default = HEDGED]; // Account type: HEDGED, NETTED, etc.
    optional string brokerName = 16; // Some whitelabel assigned to trader by broker at the moment of account creation.
    optional int64 registrationTimestamp = 17; // Unix timestamp of the account registration. Should be used as minimal date in historical data requests.
}

Trader Login is the account number you see in cTrader. Account ID is used for Open API messages.

There is no document about sending FIX messages using Open API since this is not the purpose of Open API.

Best Regards,

Panagiotis

Hi Mr.Panagiotis,

I have the same trouble. Can you guide me to find my _apiHost, _apiPort and _accountID?

Thank you!


@hpangeletta