Esempio n. 1
0
        public void LoadMarketInformations()
        {
            if (OrderCache == default)
            {
                return;
            }

            OrderCache.UpdateActiveOrders();

            // Load active parent orders
            var parents = OrderCache.GetActiveParentOrders();

            foreach (var parent in parents)
            {
                var xParentOrder = new BfxParentOrder(parent);
                var txParent     = new BfxParentTransaction(this, xParentOrder);
                foreach (var xChildOrder in xParentOrder.Children.Cast <BfxChildOrder>())
                {
                    _childOrderTransactions[xChildOrder.AcceptanceId] = new BfxChildTransaction(this, xChildOrder, txParent);
                }
                _parentOrderTransactions.TryAdd(parent.AcceptanceId, txParent);
            }
            ;

            // Load standalone child orders
            var children = OrderCache.GetActiveIndependentChildOrders();

            foreach (var child in children)
            {
                var order = new BfxChildOrder(child);
                _childOrderTransactions.TryAdd(child.AcceptanceId, new BfxChildTransaction(this, order));
            }
        }
Esempio n. 2
0
        public static IBfxOrder Market(BfTradeSide side, decimal size)
        {
            var request = BfChildOrderRequest.Market(BfProductCode.Unknown, side, size, 0, BfTimeInForce.NotSpecified);
            var order   = new BfxChildOrder(request);

            return(order);
        }
 public BfxChildTransaction(BfxMarket market, BfxChildOrder order)
     : base(market)
 {
     _order = order;
 }
 public BfxChildTransaction(BfxMarket market, BfxChildOrder order, BfxParentTransaction parent)
     : base(market)
 {
     _order = order;
     Parent = parent;
 }
Esempio n. 5
0
        public void Update(IBfChildOrder[] childOrders)
        {
            if (childOrders.Length == 0) // input is empty
            {
                return;
            }
            else if (_childOrders.Length == childOrders.Length) // input it full of content
            {
                for (int childOrderIndex = 0; childOrderIndex < _childOrders.Length; childOrderIndex++)
                {
                    if (_childOrders[childOrderIndex] == default)
                    {
                        _childOrders[childOrderIndex] = new BfxChildOrder(childOrders[childOrderIndex]);
                    }
                    else
                    {
                        _childOrders[childOrderIndex].Update(childOrders[childOrderIndex]);
                    }
                }
                return;
            }
            else // matching with ID
            {
                var updatedCount = 0;
                foreach (var newOrder in childOrders)
                {
                    foreach (var currentOrder in _childOrders)
                    {
                        if (newOrder.AcceptanceId == currentOrder.AcceptanceId)
                        {
                            currentOrder.Update(newOrder);
                            updatedCount++;
                        }
                    }
                }
                if (updatedCount == childOrders.Length)
                {
                    return; // all inputs are matched
                }
            }

            if (childOrders.Length == 1)
            {
                var childOrder = childOrders[0];
                switch (OrderType)
                {
                case BfOrderType.IFD:
                    _childOrders[0].Update(childOrder);
                    if (childOrder.State == BfOrderState.Completed)
                    {
                        CompletedCount = 1;
                    }
                    return;

                case BfOrderType.OCO:
                    // Probably completed
                    break;

                case BfOrderType.IFDOCO:
                    _childOrders[0].Update(childOrder);
                    if (childOrder.State == BfOrderState.Completed)
                    {
                        CompletedCount = 1;
                    }
                    return;

                default:
                    throw new ArgumentException();
                }
            }

            if (childOrders.Length == 2)
            {
                switch (OrderType)
                {
                case BfOrderType.IFDOCO:
                    _childOrders[0].Update(childOrders[0]);
                    break;

                default:
                    throw new ArgumentException();
                }
            }
        }
Esempio n. 6
0
 public BfxChildOrderEventArgs(BfxChildOrder order)
 {
     Order = order;
 }