void StartConfirmOrder()
        {
            // Get ParentOrderDetail to get PagingId and ParentOrderId from ParentOrderAcceptanceId
            BfParentOrderDetail detail = null;

            while (true)
            {
                var resp = Client.GetParentOrder(State.ProductCode, parentOrderAcceptanceId: State.AcceptanceId);
                if (resp.IsErrorOrEmpty)
                {
                    Thread.Sleep(_market.Config.OrderRetryInterval);
                    continue;
                }
                detail = resp.GetResult();
                break;
            }

            _stateLock.EnterWriteLock();
            State.OnParentOrderConfirmed(detail);
            _stateLock.ExitWriteLock();

            // Get ParentOrder to get parent order state
            Observable.Timer(TimeSpan.Zero, Config.ParentOrderConfirmInterval).Subscribe(_ =>
            {
                try
                {
                    _stateLock.EnterWriteLock();
                    State.OnParentOrderConfirmed(Client.GetParentOrders(State.ProductCode, count: 1, before: State.PagingId + 1).GetResult());
                    if (State.ParentOrderState != BfOrderState.Active && State.ParentOrderState != BfOrderState.Unknown)
                    {
                        _disposables.Dispose();
                    }
                }
                catch (Exception ex) { DebugEx.Trace(ex.Message); }
                finally { _stateLock.ExitWriteLock(); }
            }).AddTo(_disposables);

            // Start child order monitoring
            Observable.Timer(TimeSpan.Zero, Config.ChildOrderConfirmInterval).Subscribe(_ =>
            {
                try
                {
                    _stateLock.EnterWriteLock();
                    State.OnChildOrderConfirmed(Client.GetChildOrders(State.ProductCode, parentOrderId: State.OrderId).GetResult()); // parent order acceptance ID is not allowed.
                }
                catch (Exception ex) { DebugEx.Trace(ex.Message); }
                finally { _stateLock.ExitWriteLock(); }
            }).AddTo(_disposables);
        }
Exemplo n.º 2
0
 // Order detail confirmation is only called single time
 public override void OnParentOrderConfirmed(BfParentOrderDetail order)
 {
     OrderingStatus = RequestingState.Confirmed;
     base.OnParentOrderConfirmed(order);
     NotifyStateChanged(BfxOrderTransactionEventKind.OrderConfirmed, _market.ServerTime);
 }
Exemplo n.º 3
0
 public virtual void OnParentOrderConfirmed(BfParentOrderDetail order)
 {
     OrderDetail = order;
     order.ChildOrders.Zip(ChildOrders, (o2, o1) => (o1, o2))
     .ForEach(e => e.o1.OnOrderConfirmed(e.o2));
 }