Jump to content
Sign in to follow this  
Vincent

Streaming Data > Orders

Recommended Posts

Hi,

 

For some reason, the data returned by this order stream is very inconsistent:

http://docs.labs.cityindex.com/#Streaming%20Data/Orders.htm%3FTocPath%3DCIAPI%2520Reference|Streaming%2520Data|_____4

 

Please let me explain what I mean:

If I place a trade order with a stop order and a limit order like shown in picture in the attachment file, the orders stream will always push two sets of data to me. The two sets of data could be "new trade order" and "new stop order" info, OR "new stop order" and "new limit order" info.

 

I like to know if this is normal and why didn't it push back three set of data : "new trade order", "new stop order" and "new limit order". Since it seem to me that three orders has been created.

 

 

Raw data return by order stream:

Case 1:

"new trade order" and "new stop order"

==============================================

519674241

400616114

400332911

400473108

6

 

1

false

\/Date(1421412694000)\/

17255.0

\/Date(1421412694000)\/

1

1

1

Trade

Open

1

==============================================

==============================================

519674242

400616114

400332911

400473108

6

 

2

false

\/Date(1421412694000)\/

0

\/Date(1421412694000)\/

1

1

1

Limit

Accepted

1

==============================================

 

 

 

 

Case 2:

"new stop order" and "new limit order"

==============================================

519674494

400616114

400332911

400473108

6

 

2

false

\/Date(1421412871000)\/

0

\/Date(1421412871000)\/

1

1

1

Limit

Accepted

1

==============================================

 

==============================================

519674495

400616114

400332911

400473108

6

 

2

false

\/Date(1421412871000)\/

0

\/Date(1421412871000)\/

1

1

1

Stop

Accepted

1

==============================================

post-3673-0-14738000-1421413161_thumb.png

Share this post


Link to post

Hi Vincent,

 

Our development team has investigated the Order stream and in all cases, we received back 3 sets of data. It is as you suspected, there should be 3 sets of data on the stream: one each for the trade, stop and limit orders.

 

We haven't been able to reproduce the anomalous 2 sets of variable data that you are seeing. The screenshot below shows the data that we always receive every time we tried placing a trade with attached stop and limit orders.

 

We're not sure what adaptor you've written to listen in on the order stream so this is difficult for us to further trouble shoot on our end. It's worth mentioning that the third (missing) order information can also be pushed into another bind session data push. That may be where it has disappeared to?

 

 

fb0O2MV.png

Share this post


Link to post

Hi Physicsman,


 


Thank you for your answer. But I am still stuck on this problem.


 


Could you provide some information/method on how your developement team test this? I like to replicate it.


 


I have also been monitoring the trafic of CI platform using my demo account:


https://trade.loginandtrade.com/advantageweb/home.html?ts=1422256044884


But I didn't get the similar result as shown in your screenshots when I am openning a new trade.


There were no "bind_session.txt" was push back at all on CI Platform.


 


Another thing I don't understand is why I am able to received two sets of data, but not all the data.


 


================================================================


Here is my .NET code:


 


ConnectionInfo


 


        private ConnectionInfo buildNewConnectionInfo(string username, string sessionToken)


        {


            var connInfo = new ConnectionInfo


            {


                PushServerUrl = "https://push.cityindex.com",


                Adapter = "STREAMINGALL",


                User = username,


                Password = sessionToken,


                Constraints = { MaxBandwidth = 999999 },


                Polling = false //,PollingIdleMillis = 250,PollingMillis = 250


            };


 


            return connInfo;


        }


 


-------------------------------------------------------------------------------------------------


 


Use ConnectionInfo to build the LsClient


 


        private LSClient createNewLsClient(ConnectionInfo connInfo, LsConnectionListener lsConnectionListener)


        {


            _lsClient = new LSClient();


 


            try


            {


                _lsClient.OpenConnection(connInfo, lsConnectionListener);


            }


            //username or sessionToken in ConnectionInfo is incorrect.


            catch (PushUserException)


            {


                var ciEx = new CiStreamConnLoginFailException(


                    string.Format("Unable to establish stream connection because username '{0}'or sessionToken '{1}' is incorrect",


                    connInfo.User,


                    connInfo.Password));


 


                throw ciEx;


            }


 


            return _lsClient;


        }


 


 


-------------------------------------------------------------------------------------------------


 


Use LsClient to subscribe to order stream


 


public class OrdersApi : BaseApi<OrderDTO>


    {


        private const string _schema = "OrderId MarketId ClientAccountId TradingAccountId CurrencyId CurrencyISO Direction AutoRollover LastChangedTime OpenPrice OriginalLastChangedDateTime OriginalQuantity PositionMethodId Quantity Type Status ReasonId";


 


        public OrdersApi(LSClient client) : base(client) { }


        


        public void Subscribe()


        {


            if (_isSubscribed)


                Unsubscribe();


 


            var tableInfo = buildTableInfo();


 


            var tbListener = new LsTableListener();


            tbListener.UpdateReceivedHandler += onUpdateReceived;


 


            _tbKey = _lsClient.SubscribeTable(


                tableInfo,


                tbListener,


                false


                );


 


            _isSubscribed = true;


        }


 


        private static SimpleTableInfo buildTableInfo()


        {


            string group = "ORDERS";


 


            SimpleTableInfo tableInfo = new SimpleTableInfo(


                group,


                "MERGE",


                _schema,


                true


                ) { DataAdapter = "ORDERS" };


 


            return tableInfo;


        }


    }


 


 


 


 


 


 


-------------------------------------------------------------------------------------------------


BaseApi


 


 


    public abstract class BaseApi<T>


    {


        public EventHandler<CiUpdateReceivedEventArgs<T>> UpdateReceivedHandler;


 


        protected LSClient _lsClient;


        protected SubscribedTableKey _tbKey;


 


        public SubscribedTableKey SubscribedTableKey


        {


            get { return _tbKey; }


        }


        protected SimpleTableInfo _tableInfo;


        protected bool _isSubscribed = false;


 


        protected BaseApi(LSClient client)


        {


            _lsClient = client;


        }


 


        public void Unsubscribe()


        {


            if (_tbKey != null)


                _lsClient.UnsubscribeTable(_tbKey);


 


            _isSubscribed = false;


        }


 


        protected void onUpdateReceived(object sender, CiUpdateReceivedEventArgs<LsUpdate> e)


        {


            if (isUpdateNull(e.Update.UpdateInfo))


                return;


 


            var update = e.Update.UpdateInfo;


            Debug.WriteLine("==============================================");


            for (int i = 1; i < update.NumFields + 1; i++)


            {


                Debug.WriteLine(update.IsValueChanged(i) ? update.GetNewValue(i) : update.GetOldValue(i));


            }


            Debug.WriteLine("==============================================");


 


            var dto = Deserializer<T>.Deserialize(e.Update.UpdateInfo);


            var eventArgs = new CiUpdateReceivedEventArgs<T>(dto);


 


            UpdateReceivedHandler.SafeInvoke(this, eventArgs);


        }


 


 


        /// <summary>


        /// It seems some streams have a 'spin-up' process that can return an all null update


        /// until the data starts streaming. We were not catching this and null updates were


        /// sometimes throwing exceptions that were logged and then swallowed by LS. I think


        /// a better way is to determine if the update is emtpy (null) and simply not fire if so.


        ///


        /// Follows is a very simple check


        /// </summary>


        /// <param name="update"></param>


        /// <returns></returns>


        private static bool isUpdateNull(IUpdateInfo update)


        {


            for (int i = 1; i < update.NumFields + 1; i++)


            {


                object value = update.IsValueChanged(i) ? update.GetNewValue(i) : update.GetOldValue(i);


                if (value != null)


                {


                    return false;


                }


            }


            return true;


        }


    }

Share this post


Link to post

Hi Vincent,

 

To test and check what information is returned on the Order Stream, we used our Web platform Advantage Web (AW) to place the trade with attached stops and limits. The FireFox browser was used so that we can monitor all the web traffic to and from AW using the Firebug plugin. 

 

This is where the top screen shot was obtained. The lower screenshot is the Debug console from the Flex IDE that is used to develop AW. This was used as the second check to see that the order stream did indeed return 3 packets of data. 

 

All our front end trading platforms use the API to connect into our backend. Our platforms don't see more (or less) information than any other user with their own custom front end using the API. 

 

I've just checked again right now by logging in using AW. The default layout of AW shows a popular markets watchlist and Firebug shows the "bind_session.txt" pushed from LightStreamer with the Price, Orders etc stream subscriptions.

 

To proceed, I think we should start by ensuring that you can see the "bind_session.txt". Can you use FireFox browser with Firebug plugin to login to your test account using AW? Do you see the "bind_session.txt" in the Firebug plugin?

 

Once you can see "bind_session.txt", the next step is to place a trade with attached stop/limit. You can view the streamed information by looking in the Responses tab for "bind_session.txt" in Firebug. You will see the trade, stop and limit order returned data packets returned in the stream. 

 

When we get you this far we'll then look at our next steps in order to troubleshoot.

Share this post


Link to post

Hi Physicsman,

 

I have able to replicate your result. Thanks.

 

But I havn't able to resolve my problem yet. I am still getting only two or one updated for a trade with limit or stop.

 

By the way, my code don't have problem getting prices updates. Therefore the code should work with order update as well.

 

Thanks for your help.

Share this post


Link to post

Hi Vincent,

 

We're making progress and that is good. 

 

1) We know it is not a bug in the Orders stream - it is functioning 100% as expected. Myself, the developers and yourself have been able to monitor and see the 3 data packets.

 

2) We know that your firewall/network is not blocking data from the Orders stream. You've reported you see all 3 data packets when using Firefox with Firebug.

 

3) This narrows down where the problem lies - most likely somewhere in your connector or LS listener. 

 

I've forwarded your code snippets that you pasted earlier to our developers and asked them to take a look. Hopefully, they can spot something. However, it is possible that they can't help since they didn't write the code are not familiar with it. They may not be able to find anything. 

 

Still, at least we know where to start looking now! I'll post again when I receive a reply from the developers.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
×