Exemplo n.º 1
0
 public void GetLastOrder()
 {
     // Last order
     Assert.IsNull(emptyRecord.GetLastOrder());
     Assert.AreEqual(Order.buyAt(7, Decimals.NaN, Decimals.NaN), openedRecord.GetLastOrder());
     Assert.AreEqual(Order.sellAt(8, Decimals.NaN, Decimals.NaN), closedRecord.GetLastOrder());
     // Last BUY order
     Assert.IsNull(emptyRecord.GetLastOrder(OrderType.BUY));
     Assert.AreEqual(Order.buyAt(7, Decimals.NaN, Decimals.NaN), openedRecord.GetLastOrder(OrderType.BUY));
     Assert.AreEqual(Order.buyAt(7, Decimals.NaN, Decimals.NaN), closedRecord.GetLastOrder(OrderType.BUY));
     // Last SELL order
     Assert.IsNull(emptyRecord.GetLastOrder(OrderType.SELL));
     Assert.AreEqual(Order.sellAt(3, Decimals.NaN, Decimals.NaN), openedRecord.GetLastOrder(OrderType.SELL));
     Assert.AreEqual(Order.sellAt(8, Decimals.NaN, Decimals.NaN), closedRecord.GetLastOrder(OrderType.SELL));
 }
Exemplo n.º 2
0
        public override bool IsSatisfied(int index, ITradingRecord tradingRecord)
        {
            bool satisfied = false;

            // No trading history, no need to wait
            if (tradingRecord != null)
            {
                Order lastOrder = tradingRecord.GetLastOrder(_orderType);
                if (lastOrder != null)
                {
                    int currentNumberOfBars = index - lastOrder.getIndex();
                    satisfied = currentNumberOfBars >= _numberOfBars;
                }
            }

            traceIsSatisfied(index, satisfied);
            return(satisfied);
        }