public void PrintOffers(O2GOffersTable offers, string sInstrument)
 {
     O2GOfferTableRow offerRow = null;
     O2GTableIterator iterator = new O2GTableIterator();
     while (offers.getNextRow(iterator, out offerRow))
     {
         PrintOffer(offerRow, sInstrument);
     }
 }
        public void PrintOffers(O2GOffersTable offers, string sInstrument)
        {
            O2GOfferTableRow offerRow = null;
            O2GTableIterator iterator = new O2GTableIterator();

            while (offers.getNextRow(iterator, out offerRow))
            {
                PrintOffer(offerRow, sInstrument);
            }
        }
Example #3
0
 // Find orders by request ID and print it
 private static void FindOrders(O2GTableManager tableManager, string sRequestID)
 {
     O2GOrdersTable ordersTable = (O2GOrdersTable)tableManager.getTable(O2GTableType.Orders);
     O2GTableIterator ordersIterator = new O2GTableIterator();
     O2GOrderTableRow orderRow = null;
     while (ordersTable.getNextRowByColumnValue("RequestID", sRequestID, ordersIterator, out orderRow))
     {
         Console.WriteLine("Order:{0}, OfferID={1}, Type={2}, Rate={3:N4}, BuySell={4}, Status={5}, Limit={6:N4}, Stop={7:N4}, RequestID={8}",
                 orderRow.OrderID, orderRow.OfferID, orderRow.Type, orderRow.Rate, orderRow.BuySell, orderRow.Status,
                 orderRow.Limit, orderRow.Stop, orderRow.RequestID);
     }
 }
Example #4
0
        // Find orders by request ID and print it
        private static void FindOrders(O2GTableManager tableManager, string sRequestID)
        {
            O2GOrdersTable   ordersTable    = (O2GOrdersTable)tableManager.getTable(O2GTableType.Orders);
            O2GTableIterator ordersIterator = new O2GTableIterator();
            O2GOrderTableRow orderRow       = null;

            while (ordersTable.getNextRowByColumnValue("RequestID", sRequestID, ordersIterator, out orderRow))
            {
                Console.WriteLine("Order:{0}, OfferID={1}, Type={2}, Rate={3:N4}, BuySell={4}, Status={5}, Limit={6:N4}, Stop={7:N4}, RequestID={8}",
                                  orderRow.OrderID, orderRow.OfferID, orderRow.Type, orderRow.Rate, orderRow.BuySell, orderRow.Status,
                                  orderRow.Limit, orderRow.Stop, orderRow.RequestID);
            }
        }
Example #5
0
 /// <summary>
 /// Print accounts and get the first account
 /// </summary>
 /// <param name="session"></param>
 /// <returns></returns>
 private static O2GAccountRow GetAccount(O2GTableManager tableManager)
 {
     O2GAccountsTable accountsTable = (O2GAccountsTable)tableManager.getTable(O2GTableType.Accounts);
     O2GTableIterator accountsIterator = new O2GTableIterator();
     O2GAccountTableRow accountRow = null;
     accountsTable.getNextRow(accountsIterator, out accountRow);
     while (accountRow != null)
     {
         Console.WriteLine("AccountID: {0}, Balance: {1:N2}, Used margin: {2:N2}", accountRow.AccountID, accountRow.Balance, accountRow.UsedMargin);
         accountsTable.getNextRow(accountsIterator, out accountRow);
     }
     return accountsTable.getRow(0);
 }
Example #6
0
 // Find orders by type and buysell and print it
 private static void FindOrdersByTypeAndDirection(O2GTableManager tableManager, String sOrderType, string sBuySell)
 {
     O2GOrdersTable ordersTable = (O2GOrdersTable)tableManager.getTable(O2GTableType.Orders);
     O2GTableIterator ordersIterator = new O2GTableIterator();
     O2GOrderTableRow orderRow = null;
     while (ordersTable.getNextRowByMultiColumnValues(new String[] { "Type", "BuySell" }, new Object[] { sOrderType, sBuySell },
             ordersIterator, out orderRow))
     {
         Console.WriteLine("Order:{0}, OfferID={1}, Type={2}, Rate={3:N4}, BuySell={4}, Status={5}, Limit={6:N4}, Stop={7:N4}, RequestID={8}",
                 orderRow.OrderID, orderRow.OfferID, orderRow.Type, orderRow.Rate, orderRow.BuySell, orderRow.Status,
                 orderRow.Limit, orderRow.Stop, orderRow.RequestID);
     }
 }
        /// <summary>
        /// Print accounts and get the first account
        /// </summary>
        /// <param name="session"></param>
        /// <returns></returns>
        private static O2GAccountRow GetAccount(O2GTableManager tableManager)
        {
            O2GAccountsTable   accountsTable    = (O2GAccountsTable)tableManager.getTable(O2GTableType.Accounts);
            O2GTableIterator   accountsIterator = new O2GTableIterator();
            O2GAccountTableRow accountRow       = null;

            accountsTable.getNextRow(accountsIterator, out accountRow);
            while (accountRow != null)
            {
                Console.WriteLine("AccountID: {0}, Balance: {1}", accountRow.AccountID, accountRow.Balance);
                accountsTable.getNextRow(accountsIterator, out accountRow);
            }
            return(accountsTable.getRow(0));
        }
Example #8
0
        public static void printOffers(O2GOffersTable offers)
        {
            O2GOfferTableRow row      = null;
            O2GTableIterator iterator = new O2GTableIterator();

            while (offers.getNextRow(iterator, out row))
            {
                string sCurrentInstrument = row.Instrument;
                if ((sInstrument.Equals("")) || (sInstrument.Equals(sCurrentInstrument)))
                {
                    PrintOffer(row);
                }
            }
        }
Example #9
0
        // Find orders by type and buysell and print it
        private static void FindOrdersByTypeAndDirection(O2GTableManager tableManager, String sOrderType, string sBuySell)
        {
            O2GOrdersTable   ordersTable    = (O2GOrdersTable)tableManager.getTable(O2GTableType.Orders);
            O2GTableIterator ordersIterator = new O2GTableIterator();
            O2GOrderTableRow orderRow       = null;

            while (ordersTable.getNextRowByMultiColumnValues(new String[] { "Type", "BuySell" }, new Object[] { sOrderType, sBuySell },
                                                             ordersIterator, out orderRow))
            {
                Console.WriteLine("Order:{0}, OfferID={1}, Type={2}, Rate={3:N4}, BuySell={4}, Status={5}, Limit={6:N4}, Stop={7:N4}, RequestID={8}",
                                  orderRow.OrderID, orderRow.OfferID, orderRow.Type, orderRow.Rate, orderRow.BuySell, orderRow.Status,
                                  orderRow.Limit, orderRow.Stop, orderRow.RequestID);
            }
        }
Example #10
0
 // Find conditional orders and print it
 private static void FindConditionalOrders(O2GTableManager tableManager)
 {
     O2GOrdersTable ordersTable = (O2GOrdersTable)tableManager.getTable(O2GTableType.Orders);
     O2GTableIterator ordersIterator = new O2GTableIterator();
     O2GOrderTableRow orderRow = null;
     Object[] orderTypes = new Object[] { Constants.Orders.LimitEntry, Constants.Orders.StopEntry,
             Constants.Orders.Limit, Constants.Orders.Stop, Constants.Orders.Entry, "LTE", "STE" };
     while (ordersTable.getNextRowByColumnValues("Type", orderTypes, ordersIterator, out orderRow))
     {
         Console.WriteLine("Order:{0}, OfferID={1}, Type={2}, Rate={3:N4}, BuySell={4}, Status={5}, Limit={6:N4}, Stop={7:N4}, RequestID={8}",
                 orderRow.OrderID, orderRow.OfferID, orderRow.Type, orderRow.Rate, orderRow.BuySell, orderRow.Status,
                 orderRow.Limit, orderRow.Stop, orderRow.RequestID);
     }
 }
Example #11
0
        // Find conditional orders and print it
        private static void FindConditionalOrders(O2GTableManager tableManager)
        {
            O2GOrdersTable   ordersTable    = (O2GOrdersTable)tableManager.getTable(O2GTableType.Orders);
            O2GTableIterator ordersIterator = new O2GTableIterator();
            O2GOrderTableRow orderRow       = null;

            Object[] orderTypes = new Object[] { Constants.Orders.LimitEntry, Constants.Orders.StopEntry,
                                                 Constants.Orders.Limit, Constants.Orders.Stop, Constants.Orders.Entry, "LTE", "STE" };
            while (ordersTable.getNextRowByColumnValues("Type", orderTypes, ordersIterator, out orderRow))
            {
                Console.WriteLine("Order:{0}, OfferID={1}, Type={2}, Rate={3:N4}, BuySell={4}, Status={5}, Limit={6:N4}, Stop={7:N4}, RequestID={8}",
                                  orderRow.OrderID, orderRow.OfferID, orderRow.Type, orderRow.Rate, orderRow.BuySell, orderRow.Status,
                                  orderRow.Limit, orderRow.Stop, orderRow.RequestID);
            }
        }
Example #12
0
        //This function will fill the rates table and put it in a list to be accessed later
        internal void fillRatesGrid()
        {
            //This is to make sure the current thread is calling this function, if not call it agian
            if (INSTANCE.InvokeRequired)
            {
                try
                {
                    SetNullCallback callback = new SetNullCallback(fillRatesGrid);
                    Invoke(callback, new object[] { });
                }
                catch (Exception ex)
                {
                    logger.Error(ex.Message);
                    throw ex;
                }
            }
            else
            {
                //Get list of symbols from the offers table
                O2GTableIterator iterator = new O2GTableIterator();
                O2GOfferTableRow offerRow = null;
                if (tss != null)
                {
                    Thread.Sleep(3000);
                    O2GOffersTable offersTbl = tss.OffersTable;
                    if (offersTbl == null)
                    {
                        //Log.logMessageToFile("Login", "OfferTable null");
                        logger.Debug("OfferTable is empty");
                        return;
                    }

                    temp     = new ConcurrentDictionary <int, string>();
                    templist = new ConcurrentBag <int>();
                    while (offersTbl.getNextRow(iterator, out offerRow))
                    {
                        if (offerRow.SubscriptionStatus.Equals("T"))
                        {
                            templist.Add(Convert.ToInt32(offerRow.OfferID));
                            logger.Debug("Offer {0}; Symbol {1}", offerRow.OfferID, offerRow.Instrument);
                            temp.TryAdd(Convert.ToInt32(offerRow.OfferID), offerRow.Instrument);
                        }
                    }
                }
            }
        }
Example #13
0
        public void HandleOffers(O2GOffersTable offers)
        {
            var offerIds = new Dictionary <string, string>();

            var rows = new List <O2GOfferTableRow>();

            O2GOfferTableRow row = null;

            var iterator = new O2GTableIterator();

            while (offers.getNextRow(iterator, out row))
            {
                rows.Add(row);

                offerIds.Add(row.Instrument, row.OfferID);
            }

            OnOfferIds?.Invoke(this,
                               new GenericArgs <Dictionary <string, string> >(offerIds));

            rows.ForEach(r => RaiseOnOfferIfValid(r));
        }