public static ZooData Calculate(
            String instKey, AdjTable adjTable, DateTime from, DateTime until, double investAmount)
        {
            SortedList<DateTime, double> adjs = adjTable.Data[instKey];
            SortedList<DateTime, double> investAmts = CreateInvestAmount(adjs, investAmount);
            SortedList<DateTime, double> instData = MarketDataManager.Ins().GetData(instKey);
            SortedList<DateTime, double> increments = ConvertUtil.ToIncrement(instData);

            // create pivot dates
            List<DateTime> pivotDates = CreatePivotDates(from, until, instData);

            // create ZooData, Set adj and instData
            ZooData zoo = new ZooData();
            zoo.SetPivotDates(pivotDates);
            zoo.Append("insts", instData); // instruments market data
            zoo.Append("increments", increments);
            zoo.Append("adjs", adjs, 1.0);
            zoo.Append("investAmts", investAmts);

            SortedList<DateTime, double> pnls = CalculatePnl(zoo, investAmount);
            SortedList<DateTime, double> sum = ConvertUtil.ToSum(pnls);

            zoo.Append("pnls", pnls);
            zoo.Append("sum", sum);

            return zoo;
        }
예제 #2
0
        AdjTable CreateAdjTable(AdjTradingInput input)
        {
            AdjTable adjTable = new AdjTable();

            // Get InstrumentKeys
            foreach (String instKey in input.InstKeyAdjDict.Keys)
            {
                // For each InstrumentKey, Calculate Adj
                List<IAdjLogic> adjLogics = input.InstKeyAdjDict[instKey];
                SortedList<DateTime, double> result =
                    AdjCalculator.Calculate(adjLogics, this.From, this.Until);
                adjTable.Data.Add(instKey, result);
            }
            return adjTable;
        }
예제 #3
0
        AdjTradingResultTable CreateTradingResultTable(AdjTable adjTable, AdjTradingInput input)
        {
            AdjTradingResultTable resultTable = new AdjTradingResultTable(this.From, this.Until);
            double investAmount = input.InvestAmount;

            foreach (String instKey in adjTable.Data.Keys)
            {
                ZooData zoo =
                    AdjTradingResultCalculator.Calculate(instKey, adjTable, this.From, this.Until, investAmount);

                resultTable.EachTradingResult.Add(instKey, zoo);
            }
            resultTable.CalculateTotal();

            return resultTable;
        }