Пример #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);
        }
Пример #2
0
 public void OnInitialize()
 {
     comboTradesBinary      = new TransactionPairsBinary(model.Context.TradeData);
     comboTradesBinary.Name = "ComboTrades";
     profitLoss             = model.Data.SymbolInfo.ProfitLoss;
     comboTrades            = new TransactionPairs(GetCurrentPrice, profitLoss, comboTradesBinary);
     profitLoss.Symbol      = model.Data.SymbolInfo;
 }
Пример #3
0
 void CalcEnd(TransactionPairsBinary periodTrades)
 {
     if (periodTrades.Count > 0)
     {
         var pair = periodTrades[periodTrades.Count - 1];
         pair.Exit(CurrentEquity, model.Ticks[0].Time, model.Ticks[0].Time, 0, 0, 0);
         periodTrades[periodTrades.Count - 1] = pair;
     }
 }
Пример #4
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);
     }
 }
Пример #5
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");
            }
        }
Пример #6
0
 public void OnInitialize()
 {
     dailyBinary = new TransactionPairsBinary(model.Context.TradeData);
     portfolio   = model as PortfolioInterface;
     if (portfolio != null && portfolio.PortfolioType == PortfolioType.MultiSymbol)
     {
         isMultiSymbolPortfolio = true;                 // portfolio.PortfolioType == PortfolioType.MultiSymbol;
     }
     model.AddInterceptor(EventType.OpenInterval, this);
     model.AddInterceptor(EventType.Close, this);
     model.AddInterceptor(EventType.CloseInterval, this);
 }
Пример #7
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));
        }
Пример #8
0
        public void OnPostInitialize()
        {
            closedEquity       = startingEquity;
            daily              = new TransactionPairs(GetCurrentEquity, equityProfitLoss, dailyBinary);
            dailyBinary.Name   = "Daily";
            weeklyBinary       = new TransactionPairsBinary(model.Context.TradeData);
            weekly             = new TransactionPairs(GetCurrentEquity, equityProfitLoss, weeklyBinary);
            weeklyBinary.Name  = "Weekly";
            monthlyBinary      = new TransactionPairsBinary(model.Context.TradeData);
            monthly            = new TransactionPairs(GetCurrentEquity, equityProfitLoss, monthlyBinary);
            monthlyBinary.Name = "Monthly";
            yearlyBinary       = new TransactionPairsBinary(model.Context.TradeData);
            yearly             = new TransactionPairs(GetCurrentEquity, equityProfitLoss, yearlyBinary);
            yearlyBinary.Name  = "Yearly";

            if (graphEquity)
            {
                equity = new IndicatorCommon();
                equity.Drawing.IsVisible = true;
                equity.Drawing.PaneType  = PaneType.Secondary;
                equity.Drawing.GraphType = GraphType.FilledLine;
                equity.Drawing.Color     = Color.Green;
                equity.Drawing.GroupName = "SimpleEquity";
                equity.Name = "SimpleEquity";
                model.AddIndicator(equity);
            }

            if (enableYearlyStats)
            {
                model.RequestUpdate(Intervals.Year1);
            }
            if (enableMonthlyStats)
            {
                model.RequestUpdate(Intervals.Month1);
            }
            if (enableWeeklyStats)
            {
                model.RequestUpdate(Intervals.Week1);
            }
            if (enableDailyStats)
            {
                model.RequestUpdate(Intervals.Day1);
            }

            isInitialized = true;
        }