Replies

csabz90
31 May 2022, 15:24

RE: RE: RE:

amusleh said:

csabz90 said:

amusleh said:

Hi,

If you refresh your access token you will receive a new token and your previous token will be invalidated, so your session will also end and you have to send a new account auth request with your new token.

 

 

Just help me understand one thing: how do I know my session ended after the token refresh? It seriously looks to me that my app's communication with the server continues even if I don't do a new account auth after the token refresh. I still get real-time data, can open/close trades, etc, nothing is breaking. I'd just like to understand why this happens.

Thanks.

Hi,

If you are refreshing the token then you should close the current session and start a new one, otherwise you will get a ProtoOAAccountsTokenInvalidatedEvent.

 Even if everything works it's best to start a new session immediately after receiving the new token.

Okay, noted, thanks :)


@csabz90

csabz90
30 May 2022, 16:19

RE:

amusleh said:

Hi,

If you refresh your access token you will receive a new token and your previous token will be invalidated, so your session will also end and you have to send a new account auth request with your new token.

 

 

Just help me understand one thing: how do I know my session ended after the token refresh? It seriously looks to me that my app's communication with the server continues even if I don't do a new account auth after the token refresh. I still get real-time data, can open/close trades, etc, nothing is breaking. I'd just like to understand why this happens.

Thanks.


@csabz90

csabz90
30 May 2022, 10:49

RE:

amusleh said:

Hi,

If you refresh your access token you will receive a new token and your previous token will be invalidated, so your session will also end and you have to send a new account auth request with your new token.

 

 

Got it, thanks.


@csabz90

csabz90
10 May 2022, 21:55 ( Updated at: 10 May 2022, 23:27 )

+1 on the above!

Even though I'm only on a demo account, I suspect there's something fishy going on with application and account authentications too as in the last hour I've been having trouble logging in, in one minute it works but then in the next minute I get some error message back saying 'No environment connection'. In the past few weeks it all worked fine and I changed nothing on my side.

 


@csabz90

csabz90
05 Apr 2022, 10:21

RE:

amusleh said:

Hi,

You can use the trendbar utcTimestampInMinutes fields, if it changes then it means a new bar is opened.

If there is no activity then there will be no bars.

Okay got it, thanks!


@csabz90

csabz90
04 Apr 2022, 23:18

RE:

amusleh said:

Hi,

When you subscribe to bars by using ProtoOASubscribeLiveTrendbarReq you will receive a ProtoOASpotEvent whenever a new bar opens, the OnBar method in automate API is also called whenever a new bar opens.

So If you want to run any kind of logic on bar open you can use the ProtoOASpotEvent.

 

I experimented with ProtoOASubscribeLiveTrendbarReq and ProtoOASpotEvent a bit. Is it correct to say it sends a message whenever there is a change in volume/bid/ask/high/low/close for a specific candle? If so, what part of such a message would signal that a new bar has been opened? After parsing, this is a message for example:

"symbolId": "1", "bid": "109701", "ask": "109701", "trendbar": [{"volume": "2", "period": "M1", "low": "109701", "deltaOpen": "0", "deltaHigh": "0", "utcTimestampInMinutes": 27485052}], "timestamp": "1649103135350"}

Would I just compare the "utcTimestampInMinutes" value to the previous one in order to be able to decide if there is a new bar? If there is no activity in the market, will I still get a ProtoOASpotEvent message as soon as a new bar opens or will I always have to wait for the first change in volume/bid/ask/etc of the candle to get a ProtoOASpotEvent?

Thank you!


@csabz90

csabz90
04 Apr 2022, 13:25

RE:

amusleh said:

Hi,

When you subscribe to bars by using ProtoOASubscribeLiveTrendbarReq you will receive a ProtoOASpotEvent whenever a new bar opens, the OnBar method in automate API is also called whenever a new bar opens.

So If you want to run any kind of logic on bar open you can use the ProtoOASpotEvent.

 

Thanks, okay I'll check ProtoOASubscribeLiveTrendbarReq and ProtoOASpotEvent again and see if I'm able to get and process the event messages when new bar opens.


@csabz90

csabz90
01 Apr 2022, 13:44

After a bit more digging it looks like cBots have an OnBar method that does what I'm after, so I'm really just looking for the equivalent of that in Open API.


@csabz90

csabz90
22 Mar 2022, 10:57

Thanks for checking! I had a go at it using the console sample from your repo as you suggested, same error unfortunately.

I have a demo account with IC Markets, that's what I'm trying to use. What's weird is using FIX API to communicate with cTrader I am able to open a market order, but with Open API I can't, 'TRADE permission required'... Can you imagine the broker allowing demo trading through cTrader through FIX API but not through Open API? Anyway, I'll try with another broker just to check. Please don't hold back if you have any broker suggestions for this purpose!

 


@csabz90

csabz90
21 Mar 2022, 19:22

RE:

amusleh said:

Hi,

Did you checked all the checkbox(s) on your application form under Application Usages?

If you did that then please send an email to connect@spotware.com with your application name and your cID.

Thanks, I have just sent an email to the address you provided. I ticked the checkboxes that I felt were appropriate (get own account information, trade on own behalf), and now just out of curiosity I checked all boxes, still no luck with opening a trade. Will see what response I get back to my email!


@csabz90

csabz90
21 Mar 2022, 10:40

RE:

amusleh said:

Hi,

A Symbol schedule field gives you the symbol trading sessions, each session (ProtoOAInterval) has a start time which is inclusive and end time which is exclusive.

By inclusive it means that value is included, and by exclusive it mean that value it not included.

This data for each symbol is set by your broker, and if there is a gap between two sessions then it means you can't trade that symbol during that gap period.

Got it, thanks!


@csabz90

csabz90
10 Mar 2022, 10:27

RE:

amusleh said:

Hi,

cTrader has three different APIs:

  • 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.

Now regarding your question, you can use Open API for personal use, there is nothing that limits you.

You can provide some arbitrary Company name and site and we will approve your application.

But if you want to operate only on your own trading accounts then the best option for you is to use Automate API or FIX.

Clear, thanks for the guidance!


@csabz90