private void SessionOnAccountChanged(eAccountChangeType changeType, CQGAccount cqgAccount, CQGPosition cqgPosition)
		{

		}
예제 #2
0
        /// <summary>
        /// This event is fired when the account or position information is changed.
        /// </summary>
        /// <param name="change">Account change type which allows to differentiate the occurred changes.</param>
        /// <param name="account">A CQGAccount object representing the account
        /// to which the current change refers.</param>
        /// <param name="position">A CQGPosition object representing the position
        /// to which the current change refers.</param>
        private void cel_AccountChanged(eAccountChangeType change, CQGAccount account, CQGPosition position)
        {
            try
            {
                switch (change)
                {
                    case eAccountChangeType.actAccountChanged:
                        // no action
                        break;
                    case eAccountChangeType.actAccountsReloaded:
                        FillAccountsMap();
                        try
                        {
                            driverLog.Info("cel_AccountChanged:Will requiery orders");
                            foreach (CQGAccount acc in m_CQGHostForm.CQGApp.Accounts)
                            {
                                CQGOrdersQuery oq = m_CQGHostForm.CQGApp.QueryOrders(acc);
                            }
                        }
                        catch
                        {
                        }

                        break;
                    case eAccountChangeType.actPositionChanged:
                    case eAccountChangeType.actPositionAdded:
                        if (position != null)
                        {
                            handlePosition(position);
                        }
                        break;
                    case eAccountChangeType.actPositionsReloaded:
                        if (account != null)
                        {
                            foreach (CQGPosition posn in account.Positions)
                            {
                                handlePosition(posn);
                            }
                        }
                        break;
                    default:
                        driverLog.Error("cel_AccountChanged: Change type not processed:" + change.ToString());
                        break;
                }

            }
            catch (Exception ex)
            {
                log.Error("cel_AccountChanged", ex);
            }
        }
 private void SessionOnAccountChanged(eAccountChangeType changeType, CQGAccount cqgAccount, CQGPosition cqgPosition)
 {
 }
예제 #4
0
        private void handlePosition(CQGPosition position)
        {
            try
            {

                KaiTrade.Interfaces.IPosition posn = new K2DataObjects.Position();
                posn.AccountCode = position.Account.GWAccountName;
                posn.Mnemonic = position.InstrumentName;
                posn.AvgPrice = (decimal)position.AveragePrice;
                posn.MVO = (decimal)position.MVO;
                posn.OTE = (decimal)position.OTE;
                posn.PnL = (decimal)position.ProfitLoss;
                posn.Quantity = position.Quantity;
                if (position.Quantity < 0)
                {
                    posn.Side = KaiTrade.Interfaces.Side.SELL;
                }
                else
                {
                    posn.Side = KaiTrade.Interfaces.Side.BUY;
                }

                posn.UpdateTime = DateTime.Now;

                Facade.ProcessPositionUpdate(posn);

                //string info = posn.ToString();
                //driverLog.Info("handlePosition:" + info);
            }
            catch  (Exception ex)
            {
                log.Error("handlePosition", ex);
            }
        }