How to get APIKey for receiving the current price and placing orders via python code

Created at 30 Mar 2024, 06:00
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!
PR

pr.rajanbabu

Joined 30.03.2024

How to get APIKey for receiving the current price and placing orders via python code
30 Mar 2024, 06:00


Hi, What should be filled in the Description and Redirect URIs below to get APIKey for my each Account. I also want buy, sell, limit, market, order codes in python to place orders using APIkeys.


@pr.rajanbabu
Replies

PanagiotisCharalampous
30 Mar 2024, 10:11

Hi there,

In the description, please add a description of your strategy

In the Redirect URIs, you need to put a URI where the user will be redirected after authentication. If this is not applicable, just put any site e.g. ctrader.com

You can find a Python example below

https://github.com/spotware/OpenApiPy

Best regards,

Panagiotis


@PanagiotisCharalampous

pr.rajanbabu
31 Mar 2024, 11:52 ( Updated at: 01 Apr 2024, 06:32 )

RE: How to get APIKey for receiving the current price and placing orders via python code

PanagiotisCharalampous said: 

Hi there,

In the description, please add a description of your strategy

In the Redirect URIs, you need to put a URI where the user will be redirected after authentication. If this is not applicable, just put any site e.g. ctrader.com

You can find a Python example below

https://github.com/spotware/OpenApiPy

Best regards,

Panagiotis


@pr.rajanbabu

pr.rajanbabu
31 Mar 2024, 12:14 ( Updated at: 01 Apr 2024, 06:32 )

RE: How to get APIKey for receiving the current price and placing orders via python code

PanagiotisCharalampous said: 

Hi there,

In the description, please add a description of your strategy

In the Redirect URIs, you need to put a URI where the user will be redirected after authentication. If this is not applicable, just put any site e.g. ctrader.com

You can find a Python example below

https://github.com/spotware/OpenApiPy

Best regards,

Panagiotis


@pr.rajanbabu

pr.rajanbabu
31 Mar 2024, 12:57 ( Updated at: 01 Apr 2024, 06:32 )

RE: RE: How to get APIKey for receiving the current price and placing orders via python code

pr.rajanbabu said: 

PanagiotisCharalampous said: 

Hi there,

In the description, please add a description of your strategy

In the Redirect URIs, you need to put a URI where the user will be redirected after authentication. If this is not applicable, just put any site e.g. ctrader.com

You can find a Python example below

https://github.com/spotware/OpenApiPy

Best regards,

Panagiotis


@pr.rajanbabu

pr.rajanbabu
31 Mar 2024, 13:54 ( Updated at: 01 Apr 2024, 06:32 )

RE: How to get APIKey for receiving the current price and placing orders via python code

PanagiotisCharalampous said: 

Hi there,

In the description, please add a description of your strategy

In the Redirect URIs, you need to put a URI where the user will be redirected after authentication. If this is not applicable, just put any site e.g. ctrader.com

You can find a Python example below

https://github.com/spotware/OpenApiPy

Best regards,

Panagiotis

 

Thank you. I got "ClientId" , "Secret" and the “AccessToken” using Trade option

I checked your link and Now I want to fill the below credentials in "credentials-dev.json"

{
 "ClientId": "",
 "Secret": "",
 "HostType": "demo",
 "AccessToken": "",
 "AccountId": 0
}

I am getting below error While runing “main.ipynb” in JupyterNotebook

host = EndPoints.PROTOBUF_LIVE_HOST if credentials["HostType"].lower() == "live" else EndPoints.PROTOBUF_DEMO_HOST
client = Client(host, EndPoints.PROTOBUF_PORT, TcpProtocol)

NameError: name 'CertificateOptions' is not defined.

Please help me to resolve this . Thanks


@pr.rajanbabu

PanagiotisCharalampous
01 Apr 2024, 06:33

RE: RE: How to get APIKey for receiving the current price and placing orders via python code

pr.rajanbabu said: 

PanagiotisCharalampous said: 

Hi there,

In the description, please add a description of your strategy

In the Redirect URIs, you need to put a URI where the user will be redirected after authentication. If this is not applicable, just put any site e.g. ctrader.com

You can find a Python example below

https://github.com/spotware/OpenApiPy

Best regards,

Panagiotis

 

Thank you. I got "ClientId" , "Secret" and the “AccessToken” using Trade option

I checked your link and Now I want to fill the below credentials in "credentials-dev.json"

{
 "ClientId": "",
 "Secret": "",
 "HostType": "demo",
 "AccessToken": "",
 "AccountId": 0
}

I am getting below error While runing “main.ipynb” in JupyterNotebook

host = EndPoints.PROTOBUF_LIVE_HOST if credentials["HostType"].lower() == "live" else EndPoints.PROTOBUF_DEMO_HOST
client = Client(host, EndPoints.PROTOBUF_PORT, TcpProtocol)

NameError: name 'CertificateOptions' is not defined.

Please help me to resolve this . Thanks

Unfortunately I cannot help you with this since I am not a python developer


@PanagiotisCharalampous

pr.rajanbabu
01 Apr 2024, 07:56 ( Updated at: 02 Apr 2024, 06:19 )

RE: RE: RE: How to get APIKey for receiving the current price and placing orders via python code

PanagiotisCharalampous said: 

pr.rajanbabu said: 

PanagiotisCharalampous said: 

Hi there,

In the description, please add a description of your strategy

In the Redirect URIs, you need to put a URI where the user will be redirected after authentication. If this is not applicable, just put any site e.g. ctrader.com

You can find a Python example below

https://github.com/spotware/OpenApiPy

Best regards,

Panagiotis

 

Thank you. I got "ClientId" , "Secret" and the “AccessToken” using Trade option

I checked your link and Now I want to fill the below credentials in "credentials-dev.json"

{
 "ClientId": "",
 "Secret": "",
 "HostType": "demo",
 "AccessToken": "",
 "AccountId": 0
}

I am getting below error While runing “main.ipynb” in JupyterNotebook

host = EndPoints.PROTOBUF_LIVE_HOST if credentials["HostType"].lower() == "live" else EndPoints.PROTOBUF_DEMO_HOST
client = Client(host, EndPoints.PROTOBUF_PORT, TcpProtocol)

NameError: name 'CertificateOptions' is not defined.

Please help me to resolve this . Thanks

Unfortunately I cannot help you with this since I am not a python developer

OK. Thanks


@pr.rajanbabu