The order queue

Working with the order queue

The following methods are available for working with the application queue in the ISecurity interface:

  • GetBuyQueue (int barNum) - Get the order queue for purchases.

  • GetSellQueue (int barNum) - Get the order queue for sales.

  • UpdateQueueData () - Update a cached quotes (does not affect FinInfo.Ask / FinInfo.Bid).

The GetBuyQueue and GetSellQueue methods list the IQueueData objects. At the moment, these methods always return the current queue, i.e. independent of the passed parameter barNum.

Example, output the data of the queues to the log:

using System;
using System.Text;
using System.Linq;
using TSLab.Script;
using TSLab.Script.Handlers;

namespace MyLib
{
    public class GetQueues : IExternalScript
    {
        public void Execute(IContext ctx, ISecurity sec)
        {
            var level = 5;

            // Get queues
            var queueBuy = sec.GetBuyQueue(0).ToArray();
            var queueSell = sec.GetSellQueue(0).ToArray();

            var sb = new StringBuilder();
            var n = level;

            // We display information on the sales order (5 levels) in the log
            foreach (var item in queueSell.Take(level).Reverse())
            {
                sb.AppendFormat("Sell {0}: {1} - {2}\r\n", n--, item.Price, item.Quantity);
            }

            n = 1;
            // We display information on the order of purchases in the log (5 levels)
            foreach (var item in queueBuy.Take(level))
            {
                sb.AppendFormat("Buy {0}: {1} - {2}\r\n", n++, item.Price, item.Quantity);
            }

            ctx.Log(sb.ToString());
        }
    }
}

The information from TSLab matches the data from the terminal.

Last updated