OpenApiPy and cBot/cTrader
OpenApiPy and cBot/cTrader
22 Jan 2022, 12:25
Hi to all!
I would like to ask, in regards to OpenApiPy, if I need to use the whole code on Github as it is in order to get connected programmatically with cTrader account, as I am not totally clear as to how exactly I could it and if so is there a way to parse cBot/cTrader indicator data to OpenApiPy script as means to variable validation that will ultimately lead to order execution? So in all if I have a complete cAlgo how can combine it with OpenApiPy for creating an algo trading system based on Python?
Thank you!
Replies
AnthonyY
24 Jan 2022, 14:07
( Updated at: 24 Jan 2022, 14:09 )
RE:
amusleh said:
Hi,
Let me first make some things clear for you, cTrader have three different types of APIs, each serve a different purpose:
- cTrader Automate API: It's part of cTrader desktop app, you can use it to create indicators and cBots for cTrader desktop app.
- FIX API: It's the standard FIX API implementation that is available for cTrader trading accounts, you can use it to trade and get price data of your cTrader trading account, but the FIX standard is very limited and old, you can get your trading account FIX API credentials from cTrader app settings section, we have some samples on our Github that you can use.
- Open API: This is another API cTrader provides, it's not dependent on cTrader desktop/web/mobile apps and it's fully separate from the two abovementioned APIs, this is the API that you can use to create fully featured trading platforms or trading algorithms that will operate on your or any other cTrader users trading accounts. if you want to create an app or a trading algorithm outside cTrader official provided apps that will be your go to option. we have plenty of rich samples for this API on our Github for different programming languages, we have developed SDKs for this and also some third party developers made lots of contribution to develop different packages/wrappers for this cTrader API, you can check our OpenAPI.NET or OpenApiPy Github repositories.
So regarding your question, I don't recommend you to use Open API inside cTrader automate API, if you want to build a trading strategy then use cTrader automate API.
In case you want to build something more complicated and feature rich use Open API.
And use FIX API only if you know what you are doing.
OpenApiPy is a Pyhton package that allows you to use the Open API easily inside a Python app or environment, it's developed and maintained by Spotware.
If you want to use OpenApiPy please check it's documentation.
And if you are interested in Open API take a look on it's documentation.
Hi Amusleh and thank you for your reply
Ctrader automate is based on C# and OpenApiPy on Python.
What I am thinking based on the documentations I read, is that I could write cBot with all its indicators and all and then connect it with the OpenApiPy with referencing I believe??
The goal is cBot indicator data, to be transferred to OpenApiPy which will be the one that will contain the logic behind order execution based on the data given.
I read on the documentations that for that I will need to make a .dll to reference these two. Am I correct on those points?
I think in all we talk about making ctrader automate and OpenApiPy to communicate with each other I suppose.
Than you!
@AnthonyY
amusleh
25 Jan 2022, 08:21
Hi,
Why you want to use Open API on your cBot? you have all the things you need in automate API.
As I said automate API is separate from Open API, you should use one not both at the same time.
But if you want to you can use Open API inside cTrader automate API environment, you don't have to use the Python package you can do it with .NET C#.
@amusleh
AnthonyY
25 Jan 2022, 10:04
RE:
amusleh said:
Hi,
Why you want to use Open API on your cBot? you have all the things you need in automate API.
As I said automate API is separate from Open API, you should use one not both at the same time.
But if you want to you can use Open API inside cTrader automate API environment, you don't have to use the Python package you can do it with .NET C#.
Hi!
Yes, I think sometimes I just make it more difficult for myself for no particular reason.
I am trying this approach because I find python better than C# as it is dynamic language, also OpenApiPy uses Twisted which I think I can work with based on your Github examples instead of protobuffers which I find complicate to understand how to use them from the documentation which is limited on other online places.
I just finished uni so I am not like the best programmer out there. I thought that my approach will be best because later on I am thinking to implement machine learning to my system which requires python as well as the data from indicators which are given from cAlgo. So I need the various indicator data from ctrader sent to a enother environment better situated for AI, evaluate the data given and whatever the outcome buy/sell order will be given back to ctrader. I guess the very first step would be ctrader automate anyway. Do you thing referencing from ctrader automate would work with OpenApiPy?
Thank you again!!
@AnthonyY
amusleh
25 Jan 2022, 10:17
Hi,
Then you don't have to use cTrader Automate API at all, you can do everything with Open API.
You can get the bars/tick data with Open API, calculate your indicators, and feed the data to your ML model.
And you can execute the trading operations with Open API, you don't automate API in whole process at all.
You can do all in Python.
You can't reference OpenApiPy from a .NET environment unless you use something like IronPython which I don't have any experience with it at all.
We have a Jupyter sample in OpenApiPy Github repository that gets bars data and uses Python sklearn package to train a machine learning model, please check it: OpenApiPy/samples/jupyter at main · spotware/OpenApiPy (github.com)
@amusleh
AnthonyY
25 Jan 2022, 10:58
RE:
amusleh said:
Hi,
Then you don't have to use cTrader Automate API at all, you can do everything with Open API.
You can get the bars/tick data with Open API, calculate your indicators, and feed the data to your ML model.
And you can execute the trading operations with Open API, you don't automate API in whole process at all.
You can do all in Python.
You can't reference OpenApiPy from a .NET environment unless you use something like IronPython which I don't have any experience with it at all.
We have a Jupyter sample in OpenApiPy Github repository that gets bars data and uses Python sklearn package to train a machine learning model, please check it: OpenApiPy/samples/jupyter at main · spotware/OpenApiPy (github.com)
Yes, already passing through all the material days now! Researching everything as all is new to me as well.
This is brilliant! So it is possible to parse data from all ctrader indicators I may have like Harmonics, Financial Markets pivots and all through OpenApiPy, which can hold data evaluation and order execution logic as well as the AI later on.
In the samples folder on github, I see a picture of the web page with the commands. As I haven't reached that stage myself yet, is ProtoOAAssetClassList or asset list referring to active ctrader indicators? Or assume that there is enother command for that?
A last one and thank you for the assistance, OAuth2.0, do I need that in my system as well? Please assume that at least for the start I exclusively base my code on your github for openapipy.
Thank you Amusleh
@AnthonyY
amusleh
25 Jan 2022, 11:23
RE: RE:
instylereality2 said:
Yes, already passing through all the material days now! Researching everything as all is new to me as well.
This is brilliant! So it is possible to parse data from all ctrader indicators I may have like Harmonics, Financial Markets pivots and all through OpenApiPy, which can hold data evaluation and order execution logic as well as the AI later on.
In the samples folder on github, I see a picture of the web page with the commands. As I haven't reached that stage myself yet, is ProtoOAAssetClassList or asset list referring to active ctrader indicators? Or assume that there is enother command for that?
A last one and thank you for the assistance, OAuth2.0, do I need that in my system as well? Please assume that at least for the start I exclusively base my code on your github for openapipy.
Thank you Amusleh
Hi,
You can't use your cTrader desktop indicators on Open API, as I said before these are two different environments.
But you can calculate your current indicators by using price data that you get from Open API.
You can get OHLC time frame bars data from Open API and calculate anything you want to from them.
The ProtoOAAssetClassList gives you your account assets list, not indicators, please check the Open API documentation for a complete list of API messages and their detail.
@amusleh
amusleh
24 Jan 2022, 08:47
Hi,
Let me first make some things clear for you, cTrader have three different types of APIs, each serve a different purpose:
So regarding your question, I don't recommend you to use Open API inside cTrader automate API, if you want to build a trading strategy then use cTrader automate API.
In case you want to build something more complicated and feature rich use Open API.
And use FIX API only if you know what you are doing.
OpenApiPy is a Pyhton package that allows you to use the Open API easily inside a Python app or environment, it's developed and maintained by Spotware.
If you want to use OpenApiPy please check it's documentation.
And if you are interested in Open API take a look on it's documentation.
@amusleh