public override void OnExitTrade(TransactionPairBinary comboTrade, LogicalFill fill, LogicalOrder filledOrder)
 {
     fills.Clear();
     SetFlatBidAsk();
     bestIndifferenceLine[0] = double.NaN;
     if (!comboTrade.Completed)
     {
         throw new InvalidOperationException("Trade must be completed.");
     }
     totalVolume        += comboTrade.Volume;
     maxExcursionLine[0] = double.NaN;
     if (maxDrawDown < 500.00)
     {
         lessThan100Count++;
     }
     else
     {
         var pnl = Performance.ComboTrades.CurrentProfitLoss;
         Log.Info(Math.Round(maxDrawDown, 2) + "," + Math.Round(pnl, 2) + "," + Performance.Equity.CurrentEquity + "," + lessThan100Count + "," + comboTrade.EntryTime + "," + comboTrade.ExitTime);
     }
     //if (maxTradeSize <= 100 * lotSize)
     //{
     //    lessThan100Count++;
     //}
     //else
     //{
     //    Log.Info((maxTradeSize / lotSize) + "," + lessThan100Count + "," + fill.Time);
     //}
     maxTradeSize = 0;
     LogFills("OnEnterTrade");
 }
Exemple #2
0
        private static void RefreshAllegroDataOld(object sender, EventArgs eventArgs)
        {
            ActiveList.Clear();
            SellItemStruct[] sellItems;
            SoldItemStruct[] soldItems;

            var itemsCount = _apiContext.doGetMySellItems(_login, null, null, null, 0, null, 0, 0, out sellItems);

            for (int i = 1; i < Math.Ceiling(itemsCount / 100d) + 1; i++)
            {
                foreach (var sellItem in sellItems)
                {
                    ActiveList.Add(sellItem);
                }

                _apiContext.doGetMySellItems(_login, null, null, null, 0, null, 0, i, out sellItems);
            }

            var itemsCount2 = _apiContext.doGetMySoldItems(_login, null, null, null, 0, null, 0, 0, out soldItems);

            for (int i = 1; i < Math.Ceiling(itemsCount2 / 100d) + 1; i++)
            {
                foreach (var soldItem in soldItems)
                {
                    SoldList.Add(soldItem);
                }

                _apiContext.doGetMySoldItems(_login, null, null, null, 0, null, 0, i, out soldItems);
            }
        }
Exemple #3
0
        private static void RefreshAllegroData(object sender, EventArgs eventArgs)
        {
            ActiveList.Clear();
            SoldList.Clear();


            var offers = GetOffers();
        }
 public override void OnExitTrade(TransactionPairBinary comboTrade, LogicalFill fill, LogicalOrder filledOrder)
 {
     lastMidpoint = double.NaN;
     direction    = Direction.Sideways;
     fills.Clear();
     SetFlatBidAsk();
     if (!comboTrade.Completed)
     {
         throw new InvalidOperationException("Trade must be completed.");
     }
     totalVolume += comboTrade.Volume;
 }
Exemple #5
0
        public void SetLogicalOrders(Iterable <LogicalOrder> inputLogicals)
        {
            if (trace)
            {
                int count = originalLogicals == null ? 0 : originalLogicals.Count;
                log.Trace("SetLogicalOrders() order count = " + count);
            }
            var orderCache = Factory.Engine.LogicalOrderCache(symbol);

            orderCache.SetActiveOrders(inputLogicals);
            lock ( bufferedLogicalsLocker) {
                bufferedLogicals.Clear();
                bufferedLogicals.AddLast(orderCache.ActiveOrders);
            }
        }
Exemple #6
0
 public void Clear()
 {
     createOrderQueue.Clear();
     cancelOrderQueue.Clear();
 }
Exemple #7
0
        private void PerformCompareInternal()
        {
            if (debug)
            {
                log.Debug("PerformCompare for " + symbol + " with " +
                          actualPosition + " actual " +
                          desiredPosition + " desired and " +
                          originalLogicals.Count + " logical, " +
                          originalPhysicals.Count + " physical.");
            }
            originalPhysicals.Clear();
            originalPhysicals.AddLast(physicalOrderHandler.GetActiveOrders(symbol));
            if (debug)
            {
                var next = originalLogicals.First;
                for (var node = next; node != null; node = node.Next)
                {
                    var order = node.Value;
                    log.Debug("Logical Order: " + order);
                }
            }

            if (debug)
            {
                var next = originalPhysicals.First;
                for (var node = next; node != null; node = node.Next)
                {
                    var order = node.Value;
                    log.Debug("Physical Order: " + order);
                }
            }

            if (CheckForPending())
            {
                if (debug)
                {
                    log.Debug("Found pending physical orders. Skipping compare.");
                }
                return;
            }

            lock ( bufferedLogicalsLocker) {
                if (CheckForFilledOrders(bufferedLogicals))
                {
                    if (debug)
                    {
                        log.Debug("Found already filled orders in position change event. Skipping compare.");
                    }
                    return;
                }

                originalLogicals.Clear();
                if (bufferedLogicals != null)
                {
                    originalLogicals.AddLast(bufferedLogicals);
                }
            }

            logicalOrders.Clear();
            logicalOrders.AddLast(originalLogicals);

            physicalOrders.Clear();
            if (originalPhysicals != null)
            {
                physicalOrders.AddLast(originalPhysicals);
            }

            PhysicalOrder physical;

            extraLogicals.Clear();
            while (logicalOrders.Count > 0)
            {
                var logical = logicalOrders.First.Value;
                if (TryMatchId(logical, out physical))
                {
                    ProcessMatch(logical, physical);
                    physicalOrders.Remove(physical);
                }
                else
                {
                    extraLogicals.Add(logical);
                }
                logicalOrders.Remove(logical);
            }

            // Find any pending adjustments.
            int pendingAdjustments = FindPendingAdjustments();

            if (trace)
            {
                log.Trace("Found " + physicalOrders.Count + " extra physicals.");
            }
            int cancelCount = 0;

            while (physicalOrders.Count > 0)
            {
                physical = physicalOrders.First.Value;
                if (ProcessExtraPhysical(physical))
                {
                    cancelCount++;
                }
                physicalOrders.Remove(physical);
            }

            if (cancelCount > 0)
            {
                // Wait for cancels to complete before creating any orders.
                return;
            }

            if (TrySyncPosition(pendingAdjustments))
            {
                // Wait for fill to process before creating any orders.
                return;
            }

            if (trace)
            {
                log.Trace("Found " + extraLogicals.Count + " extra logicals.");
            }
            while (extraLogicals.Count > 0)
            {
                var logical = extraLogicals[0];
                ProcessExtraLogical(logical);
                extraLogicals.Remove(logical);
            }
        }
 public void ClearOrders(int temp)
 {
     orders.Clear();
 }
Exemple #9
0
 private void ClearGameObjectTree(ActiveList<TreeNode> nodes)
 {
     foreach (var node in nodes)
     {
         ClearGameObjectTree(node.Nodes);
         if (node is IDisposable) (node as IDisposable).Dispose();
     }
     nodes.Clear();
 }