Beispiel #1
0
        void CalcNew(TransactionPairsBinary periodTrades)
        {
            var trade = TransactionPairBinary.Create();

            trade.Enter(1, CurrentEquity, model.Ticks[0].Time, model.Ticks[0].Time, 0, 0, 0);
            periodTrades.Add(trade);
        }
Beispiel #2
0
 public void ProfitLossException()
 {
     pair = TransactionPairBinary.Create();
     using (BinaryStore tradeData = Factory.Engine.PageStore("TradeData")) {
         TransactionPairsBinary tradesBinary = new TransactionPairsBinary(tradeData);
         tradesBinary.Add(pair);
         TransactionPairs trades = new TransactionPairs(null, new ProfitLossCallback(), tradesBinary);
         double           pnl    = trades.CalcProfitLoss(0);
     }
 }
Beispiel #3
0
        public void ProfitLoss()
        {
            Constructor();
            double ProfitLoss = (pair.ExitPrice - pair.EntryPrice) * 1;

            using (BinaryStore tradeData = Factory.Engine.PageStore("TradeData")) {
                TransactionPairsBinary tradesBinary = new TransactionPairsBinary(tradeData);
                tradesBinary.Add(pair);
                TransactionPairs trades = new TransactionPairs(null, new ProfitLossCallback(), tradesBinary);
                Assert.AreEqual(113096, trades.CalcProfitLoss(0), "ProfitLoss");
            }
        }
Beispiel #4
0
        private void calcLosers()
        {
            TransactionPairsBinary other = new TransactionPairsBinary(trades.TradeData);

            for (int i = 0; i < Trades.Count; i++)
            {
                if (Trades.CalcProfitLoss(i) <= lossBoundary)
                {
                    other.Add(Trades.GetBinary(i));
                }
            }
            losers = new BaseStats(new TransactionPairs(null, Trades.ProfitLossCalculation, other));
        }
Beispiel #5
0
        public void EnterComboTrade(LogicalFill fill)
        {
            TransactionPairBinary pair = TransactionPairBinary.Create();

            pair.Enter(fill.Position, fill.Price, fill.Time, fill.PostedTime, model.Chart.ChartBars.BarCount, fill.OrderId, fill.OrderSerialNumber);
            comboTradesBinary.Add(pair);
            if (trace)
            {
                log.Trace("Enter trade: " + pair);
            }
            if (model is Strategy)
            {
                Strategy     strategy = (Strategy)model;
                LogicalOrder filledOrder;
                if (!strategy.TryGetOrderById(fill.OrderId, out filledOrder))
                {
                    throw new ApplicationException("A fill for order id: " + fill.OrderId + " was incorrectly routed to: " + strategy.Name);
                }
                strategy.OnEnterTrade(fill, filledOrder);
            }
        }