Topics
30 Aug 2017, 11:07
 0
 3168
 3
28 Apr 2017, 14:00
 2126
 2
31 Mar 2017, 09:27
 2663
 3
30 Mar 2017, 11:50
 3392
 7
29 Mar 2017, 16:02
 2634
 7
29 Mar 2017, 10:48
 2084
 3
12 Mar 2017, 13:53
 2207
 2
01 Mar 2017, 22:40
 1753
 4
22 Feb 2017, 21:02
 2092
 1
22 Feb 2017, 19:48
 2485
 5
08 Feb 2017, 13:58
 5957
 14
03 Feb 2017, 10:03
 0
 2056
 1
Replies

mindbreaker
17 Sep 2017, 12:59

RE:

Spotware said:

Dear Jensenbreck093,

All positions should be sent with the first message. Therefore the issue might be related to the way you read the incoming stream. Do you allow enough time for all the information to arrive. Do you keep reading the stream until all messages arrived? A code sample of how you read the incoming stream would be helpful to advise further.

Best Regards,

cTrader Team

 

Dear Spotware :D

Spotware does not make idiots out of users, just write an example how to get the functionality you are writing about!!!

What an idiot wrote an example that does not work as it should on his own servers !

Since they themselves can not write something meaningful, how others have to build an active application.

 


@mindbreaker

mindbreaker
30 Aug 2017, 18:15

RE:

Spotware said:

Hi mindbreaker,

Thanks for your suggestions. Trading API was developed using Google Protocol Buffers protocol for performance reasons, since it is a lighter and faster protocol than JSON. Protocol Buffers is just a protocol and it is not binded to any programming language. Quoting Google below

"Protocol buffers are Google's language-neutral, platform-neutral, extensible mechanism for serializing structured data – think XML, but smaller, faster, and simpler. You define how you want your data to be structured once, then you can use special generated source code to easily write and read your structured data to and from a variety of data streams and using a variety of languages."

Google supports Protocol Buffers for many languages like C#, Java, C++, Go, Objective C, Python, JavaNano and Ruby with more languages coming. 

Currenlty, we do not have any plans offering Trading API through JSON. On the contrary, the next version of the API might feature a Protocol Buffers Accounts API that will offer significant performance improvements to Accounts API users.

Best Regards,

cTrader Team

Hi :)

It is that google writes nonsense I am still able to understand ;).

But I do not know why reproduce these nonsense.

Thank you for your answer.

 


@mindbreaker

mindbreaker
27 Jun 2017, 18:56

RE: RE: RE: RE: RE: RE: RE: RE: RE: RE: RE:
        static string ReadMessage(SslStream sslStream)
        {
            // Read the  message sent by the server.
            // The end of the message is signaled using the
            // "" marker.
            byte[] buffer = new byte[2048];
            StringBuilder messageData = new StringBuilder();
            int bytes = -1;
            do
            {
                bytes = sslStream.Read(buffer, 0, buffer.Length);

                // Use Decoder class to convert from bytes to UTF8
                // in case a character spans two buffers.
                Decoder decoder = Encoding.UTF8.GetDecoder();
                char[] chars = new char[decoder.GetCharCount(buffer, 0, bytes)];
                decoder.GetChars(buffer, 0, bytes, chars, 0);
                messageData.Append(chars);
                // Check for EOF.
                if (messageData.ToString().IndexOf("") != -1)
                {
                    break;
                }
            } while (bytes != 0);

            return messageData.ToString();
        }

 


@mindbreaker

mindbreaker
28 Apr 2017, 14:01

I dont want example with framework.


@mindbreaker

mindbreaker
06 Apr 2017, 11:43

RE: RE: RE: RE: RE: RE: RE: RE: RE:

#EOL said:

mindbreaker said:

But sometimes show  one positions sometimes 2 or somtimes all positions.

Is should return json string with all positions. Thats it.

I don't understand what json you talk about.

FIX is not json and json is never mentioned in your code.

If you have any doubts about the server -- check first with MiniFIX and if it works with it, it's not server fault, but your application

JSON string (https://pl.wikipedia.org/wiki/JSON) if you dont know what is it.

Positions should be recived with json (it simple idea)

Just testing an example from github! I do not use my code or application just this simple example.

Written by Spotware. Unfortunately it does not work as it should.

And I do not use frameworks.


@mindbreaker

mindbreaker
05 Apr 2017, 19:39

RE: RE: RE: RE: RE: RE: RE: RE:

How many positions do you acually have and see in cTreader/cTrader Web?

 I have only one positions now.

Fuck it. It sith.


@mindbreaker

mindbreaker
05 Apr 2017, 19:37

RE: RE: RE: RE: RE: RE: RE:

#EOL said:

mindbreaker said:

Hi i've got 727=4

And in my example buffer is 4096 but it send what want (why this does not display positions in json format !!!!!!????).

Ok it doesn't matter.

Thanks for the help.

Do you receive 4 position reports? Can you put a breakpoint to see the buffer? How many positions do you acually have and see in cTreader/cTrader Web?

Buffer size does not matter if the reports have not received yet. From my point of view, it should be separate thread that reads the stream, separates business messages (like execution reports, position reports, etc) from connection messages (like logon, heartbeats, test requests), stores the first ones to queue, raise specific events and maintains connection messages by itself. But implementing such framework would be re-inventing QuickFIX or similar engine.

But sometimes show  one positions sometimes 2 or somtimes all positions.

Is should return json string with all positions. Thats it.

Thanks


@mindbreaker

mindbreaker
05 Apr 2017, 13:03

RE: RE: RE: RE: RE:

#EOL said:

mindbreaker said:

Then why sometimes send all positions? It is server error!

I show everything from stream with MessageBox.Show()

I test it on two different servers and two different visual studio (2012 and 2010)

(i just download example from FIX-API-sample without changes)

Have you worked with FIX before?

Have you tried any third-party FIX clients other than FIX-API-sample or homebrew clients based on FIX-API-sample? (For example MiniFIX?)

Could you provide any FIX logs?

What do you have in tag 727 in the report?

How many positions do you expect?

When you receive your position partially, are all the FIX messages complete? (end with |10=[checksum])

        private string SendMessage(string message, SslStream stream, bool readResponse = true)
        {
            var byteArray = Encoding.ASCII.GetBytes(message);
            stream.Write(byteArray, 0, byteArray.Length);
            var buffer = new byte[1024];
            if (readResponse)
            {
                Thread.Sleep(100);
                stream.Read(buffer, 0, 1024);
            }
            _messageSequenceNumber++;
            var returnMessage = Encoding.ASCII.GetString(buffer);
            return returnMessage;
        }

I'm not a developer, but this looks ugly to me. Meaning that size of average FIX position report is 200 bytes, only 5.12 reports will be shown and I have no idea what will happen with the other. And this is true only in ideal zero-latency world, since it waits only for 100 ms from sending the request. What is you round-trip round-trip delay time to the server?

So I would not be trust to FIX-API-sample. It's a sample, not a production-ready solution.

Hi i've got 727=4

And in my example buffer is 4096 but it send what want (why this does not display positions in json format !!!!!!????).

Ok it doesn't matter.

Thanks for the help.

 

 

 


@mindbreaker

mindbreaker
05 Apr 2017, 12:30

Maybe add movie with error to youtube? If you cant tell me what is wrong?


@mindbreaker

mindbreaker
05 Apr 2017, 12:10

Error messages (bottom of the page):

https://connect.spotware.com/docs/api-reference/accounts-api


@mindbreaker

mindbreaker
04 Apr 2017, 21:54

RE: RE: RE:

#EOL said:

mindbreaker said:

 

When I send a query again I never get all opened positions.!

Something is wrong with this server.

Just opened 1990 positions and got them all on the Request for positions. If there is an error it's not in the server.

You may want to refer TotalNumPosReports (tag 727) from the first position report to get know how many reports to expect

Then why sometimes send all positions? It is server error!

I show everything from stream with MessageBox.Show()

I test it on two different servers and two different visual studio (2012 and 2010)

(i just download example from FIX-API-sample without changes)


@mindbreaker

mindbreaker
04 Apr 2017, 21:49

RE:

ycomp said:

I'd still like to know how to handle the error message when the token is about to expire. That way I won't have to keep track of when the token was initially generated (which I would prefer not to have to do)

Test it! its my old token:
g0gjr3jzeaNqsPXx-AaHv6Ef_SH9E0jRoU8Ut03hmzw



{"error":{"errorCode":"CH_ACCESS_TOKEN_INVALID","description":"Invalid access token"}}

 


@mindbreaker

mindbreaker
03 Apr 2017, 12:01

RE: RE:

ycomp said:

mindbreaker said:

Save time (timestamp - php function: time() ) when you create token and then add expired time (286666) in seconds and you know wen token will expire (it is 30 days time).

so I can just request a new token @ 29 days and all is good?

Even that day in which the token was generated (Always you can refresh token) old token will work until expire


@mindbreaker

mindbreaker
02 Apr 2017, 17:18

Save time (timestamp - php function: time() ) when you create token and then add expired time (286666) in seconds and you know wen token will expire (it is 30 days time).


@mindbreaker

mindbreaker
31 Mar 2017, 17:31

RE:

Thanks for the help.

I'm not interested anymore. I already have another solution

Ps. At this rate it will not work for the next 10 years.

Regards


@mindbreaker

mindbreaker
31 Mar 2017, 15:18

RE:

Spotware said:

We have checked the example project and all positions are streamed without a problem. 

I do not think so (I test it on yours example).

When I send a query again I never get all opened positions.!

Something is wrong with this server.


@mindbreaker

mindbreaker
31 Mar 2017, 12:16

Everthing is missing in these systems.

Waste of time !!!!!!

Something does not work forever or something is missing.

This is the Spotware motto!

Thanks and bye.


@mindbreaker

mindbreaker
31 Mar 2017, 12:12

RE:

Spotware said:

Hi mindbreaker,

In case you have multiple positions open, the server will stream multiple position reports. Therefore you will need to keep reading your stream for incoming data.

In prev  FIX API sample version  works fine and send all messages. What is wrong now (where is working example)?


@mindbreaker

mindbreaker
30 Mar 2017, 22:32

RE:

there is mistake but it does not matter:

        private string SendPriceMessage(string message, bool readResponse = true)
        {
            xQueuePrice.Enqueue(message);
            string o = "";
            string msg = "";
            while (xQueuePrice.Count > 0)
            {
                msg = xQueuePrice.Dequeue().ToString();
                o = o + SendMessage(msg, _priceStreamSSL, readResponse) + "<|>";
            }
            return o; 
        }

I ask only about Trade part


@mindbreaker

mindbreaker
30 Mar 2017, 19:10

RE:

#EOL said:

Have you tried your code with Spotware account? I can't connect to h20.p.ctrader.com:5211 neither, maybe the problem is only with this one server.

Works on h23


@mindbreaker