예제 #1
0
        public void LinearHurstTest()
        {
            Console.WriteLine("LinearHurstTest");
            LoggerInitialization.SetThreshold(typeof(hurst_tests), LogLevel.Debug);
            LoggerInitialization.SetThreshold(typeof(TrajectoryTransformer_Hurst), LogLevel.Debug);
            double m = 0.1;
            double b = 0.0;

            ITrajectory traj = new Trajectory("data", 1.0, 0.0, 0.0);
            double      INC  = 1.0;

            for (double x = 0.0; x < WINDOW; x += INC)
            {
                double NOISE_SCALE = 0.0001;
                double noise       = 2.0 * NOISE_SCALE * SingletonRandomGenerator.Instance.NextDouble() - NOISE_SCALE;

                double y = m * INC + noise;

                traj.add(x, y);
            }

            ITrajectoryTransformer tx        = new TrajectoryTransformer_Hurst(WINDOW, 1.0);
            ITrajectory            trajHurst = tx.eval(traj);

            SingletonLogger.Instance().DebugLog(typeof(hurst_tests), "Hurst of y = " + m + " x + " + b + "\n");
            SingletonLogger.Instance().DebugLog(typeof(hurst_tests), "" + trajHurst.ToStringLong());
        }
예제 #2
0
        public void RandomWalkTest()
        {
            Console.WriteLine("RandomWalkTest");
            LoggerInitialization.SetThreshold(typeof(hurst_tests), LogLevel.Debug);
            LoggerInitialization.SetThreshold(typeof(TrajectoryTransformer_Hurst), LogLevel.Info);
            double y = 0.0;

            ITrajectory traj = new Trajectory("data", 1.0, 0.0, 0.0);

            for (double x = 0.0; x < WINDOW; x += 1.0)
            {
                double STEP;
                if (SingletonRandomGenerator.Instance.NextDouble() <= 0.5)
                {
                    STEP = 0.1;
                }
                else
                {
                    STEP = -0.1;
                }
                y = y + STEP;
                // traj.add(x,y);
                traj.add(x, STEP);
            }

            ITrajectoryTransformer tx        = new TrajectoryTransformer_Hurst(WINDOW, 1.0);
            ITrajectory            trajHurst = tx.eval(traj);

            SingletonLogger.Instance().DebugLog(typeof(hurst_tests), "Hurst of RandomWalk\n");
            SingletonLogger.Instance().DebugLog(typeof(hurst_tests), "" + trajHurst.ToStringLong());
        }
예제 #3
0
        public void RandomBinaryTest()
        {
            Console.WriteLine("RandomBinaryTest");
            LoggerInitialization.SetThreshold(typeof(hurst_tests), LogLevel.Debug);
            LoggerInitialization.SetThreshold(typeof(TrajectoryTransformer_Hurst), LogLevel.Debug);
            double y = 0.0;

            ITrajectory traj = new Trajectory("data", 1.0, 0.0, 0.0);

            bool pos = true;

            for (double x = 0.0; x < WINDOW; x += 1.0)
            {
                if (pos)
                {
                    y = 1.0;
                    traj.add(x, y);
                    pos = false;
                }
                else
                {
                    y = -1.0;
                    traj.add(x, y);
                    pos = true;
                }
            }

            ITrajectoryTransformer tx        = new TrajectoryTransformer_Hurst(WINDOW, 1.0);
            ITrajectory            trajHurst = tx.eval(traj);

            SingletonLogger.Instance().DebugLog(typeof(hurst_tests), "Hurst of Random Alternating\n");
            SingletonLogger.Instance().DebugLog(typeof(hurst_tests), "" + trajHurst.ToStringLong());
        }
예제 #4
0
        public void ZeroTest()
        {
            Console.WriteLine("ZeroTest");
            LoggerInitialization.SetThreshold(typeof(hurst_tests), LogLevel.Debug);
            LoggerInitialization.SetThreshold(typeof(TrajectoryTransformer_Hurst), LogLevel.Info);
            double y = 0.0;

            ITrajectory traj = new Trajectory("data", 1.0, 0.0, 0.0);

            for (double x = 0.0; x < WINDOW; x += 1.0)
            {
                y = 0.005 * SingletonRandomGenerator.Instance.NextDouble();
                traj.add(x, y);
            }

            ITrajectoryTransformer tx        = new TrajectoryTransformer_Hurst(WINDOW, 1.0);
            ITrajectory            trajHurst = tx.eval(traj);

            SingletonLogger.Instance().DebugLog(typeof(hurst_tests), "Hurst of Zero\n");
            SingletonLogger.Instance().DebugLog(typeof(hurst_tests), "" + trajHurst.ToStringLong());
        }
예제 #5
0
        public void Agent0x1Simulation_TrajectoryBundles()
        {
            Console.WriteLine("Agent0x1Simulation_TrajectoryBundles");
            LoggerInitialization.SetThreshold(typeof(sim_tests), LogLevel.Debug);
            //LoggerInitialization.SetThreshold(typeof(Agent0x1), LogLevel.Info);
            //LoggerInitialization.SetThreshold(typeof(AbstractAgent), LogLevel.Info);
            //LoggerInitialization.SetThreshold(typeof(SimulationBundle), LogLevel.Debug);
            //LoggerInitialization.SetThreshold(typeof(Scheduler), LogLevel.Debug);
            //LoggerInitialization.SetThreshold(typeof(Trajectory), LogLevel.Debug);

            int dim = 0;

            string []     names = new string [0];
            double []     mins  = new double [0];
            double []     maxs  = new double [0];
            IBlauSpace    s     = BlauSpace.create(dim, names, mins, maxs);
            IBlauPoint    mean  = new BlauPoint(s);
            IBlauPoint    std   = new BlauPoint(s);
            IDistribution d     = new Distribution_Gaussian(s, mean, std);

            IAgentFactory afact     = new Agent0x0_Factory(d);
            int           NUMAGENTS = 25;
            IPopulation   pop       = PopulationFactory.Instance().create(afact, NUMAGENTS);

            foreach (IAgent ag in pop)
            {
                SingletonLogger.Instance().DebugLog(typeof(metrics_tests), "agent: " + ag);
            }

            string PATH = "" + ApplicationConfig.EXECDIR + "orderbooks/orderbook.csv";
            AgentOrderbookLoader loader = MakeAgentOrderbookLoader(PATH);

            pop.addAgent(loader);

            IOrderbook_Observable ob = new Orderbook();

            string PROPERTY = "NetWorth";

            // 1 hours
            ISimulationBundle simb = new SimulationBundle(pop, ob, 0.0, 3600.0);

            IAgentEvaluationFactory metricEF = new NamedMetricAgentEvaluationFactory(PROPERTY);

            simb.add(metricEF);

            ITrajectoryFactory priceTF = new TrajectoryFactory_Price(10.0, 0.8);

            simb.add(priceTF);

            ITrajectoryFactory spreadTF = new TrajectoryFactory_Spread(10.0, 0.0);

            simb.add(spreadTF);

            int NUMTRIALS = 25;

            SingletonLogger.Instance().DebugLog(typeof(sim_tests), "Running Simulation");
            ISimulationResultsBundle resb = simb.run(NUMTRIALS);

            SingletonLogger.Instance().DebugLog(typeof(sim_tests), "Stopping Simulation");

            SingletonLogger.Instance().DebugLog(typeof(sim_tests), "resb: " + resb.ToString());

            int STEPS = 1;

            int [] STEPSarray = new int[s.Dimension]; for (int j = 0; j < s.Dimension; j++)
            {
                STEPSarray[j] = STEPS;
            }
            IBlauSpaceLattice bsl = BlauSpaceLattice.create(s, STEPSarray);

            foreach (IAgentEvaluationBundle aeb in resb.getAgentEvaluationBundles())
            {
                IBlauSpaceEvaluation meanEval = aeb.MeanEvaluation(bsl);
                IBlauSpaceEvaluation stdEval  = aeb.StdEvaluation(bsl);
                SingletonLogger.Instance().DebugLog(typeof(sim_tests), "meanEval: " + meanEval.ToStringLong());
                SingletonLogger.Instance().DebugLog(typeof(sim_tests), "stdEval: " + stdEval.ToStringLong());
            }

            foreach (ITrajectoryBundle tb in resb.getTrajectoryBundles())
            {
                SingletonLogger.Instance().DebugLog(typeof(sim_tests), "Computing meanTraj");
                ITrajectory meanTraj = tb.MeanTrajectory;
                SingletonLogger.Instance().DebugLog(typeof(sim_tests), "Computing stdTraj");
                ITrajectory stdTraj = tb.StdTrajectory;

                SingletonLogger.Instance().DebugLog(typeof(sim_tests), "meanTraj: " + meanTraj.ToStringLong());
                SingletonLogger.Instance().DebugLog(typeof(sim_tests), "stdTraj: " + stdTraj.ToStringLong());
            }

            Assert.AreEqual(resb.Valid, true);
        }