Example #1
0
        /// <summary>
        /// Find valid account
        /// </summary>
        /// <param name="tableManager"></param>
        /// <returns>account</returns>
        private static O2GAccountRow GetAccount(O2GTableManager tableManager, string sAccountID)
        {
            bool             bHasAccount   = false;
            O2GAccountRow    account       = null;
            O2GAccountsTable accountsTable = (O2GAccountsTable)tableManager.getTable(O2GTableType.Accounts);

            for (int i = 0; i < accountsTable.Count; i++)
            {
                account = accountsTable.getRow(i);
                string sAccountKind = account.AccountKind;
                if (sAccountKind.Equals("32") || sAccountKind.Equals("36"))
                {
                    if (account.MarginCallFlag.Equals("N"))
                    {
                        if (string.IsNullOrEmpty(sAccountID) || sAccountID.Equals(account.AccountID))
                        {
                            bHasAccount = true;
                            break;
                        }
                    }
                }
            }
            if (!bHasAccount)
            {
                return(null);
            }
            else
            {
                return(account);
            }
        }
Example #2
0
        private IEnumerable <BaseRow> GetRows(O2GAccountsTable table)
        {
            var rows = new List <AccountTableRow>();

            for (var i = 0; i < table.Count; i++)
            {
                // AccountTableRowEx - so we can get hold of O2GAccountRow internally when needed.
                rows.Add(this.GetRow <AccountTableRowEx, O2GAccountTableRow>(table.getRow(i)));
            }

            return(rows);
        }
        /// <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));
        }
        public void UnsubscribeEvents(O2GTableManager manager)
        {
            O2GAccountsTable     accountsTable     = (O2GAccountsTable)manager.getTable(O2GTableType.Accounts);
            O2GOrdersTable       ordersTable       = (O2GOrdersTable)manager.getTable(O2GTableType.Orders);
            O2GTradesTable       tradesTable       = (O2GTradesTable)manager.getTable(O2GTableType.Trades);
            O2GMessagesTable     messagesTable     = (O2GMessagesTable)manager.getTable(O2GTableType.Messages);
            O2GClosedTradesTable closedTradesTable = (O2GClosedTradesTable)manager.getTable(O2GTableType.ClosedTrades);

            accountsTable.unsubscribeUpdate(O2GTableUpdateType.Update, this);
            ordersTable.unsubscribeUpdate(O2GTableUpdateType.Insert, this);
            ordersTable.unsubscribeUpdate(O2GTableUpdateType.Delete, this);
            tradesTable.unsubscribeUpdate(O2GTableUpdateType.Insert, this);
            tradesTable.unsubscribeUpdate(O2GTableUpdateType.Update, this);
            closedTradesTable.unsubscribeUpdate(O2GTableUpdateType.Insert, this);
            messagesTable.unsubscribeUpdate(O2GTableUpdateType.Insert, this);
        }
Example #5
0
        public Accounts(MainForm CurrentForm, O2GTableManager mTblMgr)
        {
            CreateTable();

            CurrentForm.PopulateTable(AccountsTable);


            while (mTblMgr.getStatus() != O2GTableManagerStatus.TablesLoaded && mTblMgr.getStatus() != O2GTableManagerStatus.TablesLoadFailed)
            {
                Thread.Sleep(50);
            }
            O2GAccountsTable   table    = (O2GAccountsTable)mTblMgr.getTable(O2GTableType.Accounts);
            AccountsListener   listener = new AccountsListener();
            O2GAccountTableRow row      = null;

            for (int i = 0; i < table.Count; i++)
            {
                DataRow CurrentRow = AccountsTable.NewRow();
                AccountsTable.Rows.Add(CurrentRow);
            }

            CurrentForm.GetTableData(table, listener, row, mTblMgr);
        }