Example #1
0
        public void AgentEvaluationTest()
        {
            Console.WriteLine("AgentEvaluationTest");

            int dim = 3;

            string [] names = new string [3] {
                "x", "y", "z"
            };
            double [] mins = new double [3] {
                0.0, 0.0, 0.0
            };
            double [] maxs = new double [3] {
                100.0, 100.0, 100.0
            };
            IBlauSpace s = BlauSpace.create(dim, names, mins, maxs);

            string           PROPERTY = "NetWorth";
            IAgentEvaluation ae       = new AgentEvaluation(PROPERTY, null);

            IBlauPoint mean = new BlauPoint(s);

            mean.setCoordinate(0, 10.0);
            mean.setCoordinate(1, 20.0);
            mean.setCoordinate(2, 30.0);

            IBlauPoint std = new BlauPoint(s);

            std.setCoordinate(0, 2.0);
            std.setCoordinate(1, 4.0);
            std.setCoordinate(2, 6.0);

            IDistribution d = new Distribution_Gaussian(s, mean, std);

            IAgentFactory afact = new AgentDummy_Factory(d);

            int NUMAGENTS = 100;

            IAgent[] agents = new IAgent[NUMAGENTS];

            for (int i = 0; i < NUMAGENTS; i++)
            {
                agents[i] = afact.create();
                SingletonLogger.Instance().DebugLog(typeof(metrics_tests), "agent[" + i + "]: " + agents[i]);
            }

            double VAL = 1.0;

            for (int i = 0; i < NUMAGENTS; i++)
            {
                ae.set(agents[i], VAL);
            }

            for (int i = 0; i < NUMAGENTS; i++)
            {
                Assert.AreEqual(ae.eval(agents[i]), VAL);
            }

            SingletonLogger.Instance().DebugLog(typeof(metrics_tests), "ae: " + ae.ToStringLong());
        }
Example #2
0
        public ISimEventHandle Register(ISimEntity sender, ISimEntity target, ISimEvent simEvent, double t)
        {
            if (t < 0)
            {
                Console.WriteLine("Cannot register an event in the past!");
                System.Diagnostics.StackTrace st = new StackTrace(true);
                Console.WriteLine(st.ToString());
                Environment.Exit(-1);
            }

            SingletonLogger.Instance().DebugLog(typeof(Scheduler), "@ " + Scheduler.GetTime() + " Register src:" + sender + " dst:" + target + " ev:" + simEvent + " t:" + t);

            double          deliveryTime = Scheduler.GetTime() + t;
            ISimEventHandle eventHandle  = new SimEventHandle(sender, target, simEvent, new UniqueDouble(deliveryTime));

            HashSet <ISimEventHandle> eventsFrom = Instance().GetEventsFrom(eventHandle.Sender);

            eventsFrom.Add(eventHandle);

            HashSet <ISimEventHandle> eventsTo = Instance().GetEventsTo(eventHandle.Target);

            eventsTo.Add(eventHandle);

            Instance()._ud2ehandle.Add(eventHandle.UDT, eventHandle);

            return(eventHandle);
        }
Example #3
0
        protected override IAgent create(IBlauPoint pt, IAgentFactory creator, int id)
        {
            SingletonLogger.Instance().InfoLog(typeof(Agent1x0), "Agent1x0_Factory creating agent " + id);
            IAgent dupe = new Agent1x0(pt, creator, id, _lambda, _gamma, _burnin);

            return(dupe);
        }
Example #4
0
        public void Run()
        {
            SingletonLogger.Instance().DebugLog(typeof(Scheduler), "Scheduler: At start of Run() _ud2ehandle.Size(): " + _ud2ehandle.Count);

            _done = false;

            do
            {
                if (_ud2ehandle.Count == 0)
                {
                    _done = true;
                }
                else
                {
                    KeyValuePair <IUniqueDouble, ISimEventHandle> kvp = _ud2ehandle.FindMin();
                    IUniqueDouble   udt         = kvp.Key;
                    ISimEventHandle eventHandle = kvp.Value;

                    _timeNow = udt.Value;

                    eventHandle.Sim_Event.Entering(eventHandle.Target);
                    eventHandle.Target.Recv(eventHandle.Sender, eventHandle.Sim_Event);
                    eventHandle.Sender.DeliveryAck(eventHandle);

                    Deregister(eventHandle);
                }
            }while (!_done);
            KillAll();

            Reset();
            SingletonLogger.Instance().DebugLog(typeof(Scheduler), "Scheduler: At end of Run() _ud2ehandle.Size(): " + _ud2ehandle.Count);
        }
Example #5
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());
        }
Example #6
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());
        }
Example #7
0
        public override void SimulationEndNotification()
        {
            // Console.WriteLine("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX "+this+";  time now is: "+TimeNow);

            SingletonLogger.Instance().DebugLog(typeof(TrajectoryFactory_Price), "SimulationEndNotification");
            MyTrajectory.add(TimeNow, Orderbook.getNumBids());
        }
Example #8
0
        public void TrajectoryTest()
        {
            LoggerInitialization.SetThreshold(typeof(signal_tests), LogLevel.Debug);
            LoggerInitialization.SetThreshold(typeof(Trajectory), LogLevel.Debug);

            Trajectory t = new Trajectory("test trajectory", 0.0, 0.0, 0.0);

            Assert.AreEqual(t.Name, "test trajectory");
            t.add(0.0, 2.0);
            SingletonLogger.Instance().DebugLog(typeof(signal_tests), "traj: " + t);

            Assert.AreEqual(t.Times.Count, 1);
            Assert.AreEqual(t.eval(-1.0), 2.0);
            Assert.AreEqual(t.eval(+3.0), 2.0);
            Assert.AreEqual(t.MaximumTime, 0.0);
            Assert.AreEqual(t.MinimumTime, 0.0);
            Assert.AreEqual(t.Times.Count, 1);

            t.add(2.0, 0.0);
            SingletonLogger.Instance().DebugLog(typeof(signal_tests), "traj: " + t);

            Assert.AreEqual(t.Times.Count, 2);
            Assert.AreEqual(t.eval(-1.0), 2.0);
            Assert.AreEqual(t.eval(+3.0), 0.0);
            Assert.AreEqual(t.eval(+1.0), 1.0);
            Assert.AreEqual(t.MaximumTime, 2.0);
            Assert.AreEqual(t.MinimumTime, 0.0);
            Assert.AreEqual(t.Times.Count, 2);
        }
Example #9
0
        // validate blauspace for required axes
        protected bool ValidateSampleSpace(IBlauSpace space)
        {
            bool valid = true;

            foreach (string s in _requiredAxes)
            {
                if (!_dist.SampleSpace.hasAxis(s))
                {
                    if (LoggerDiags.Enabled)
                    {
                        SingletonLogger.Instance().ErrorLog(typeof(AbstractAgentFactory), "AbstractAgentFactory requires " + s + " but it is not present in the BlauSpace of distribution " + _dist);
                    }
                    valid = false;
                }
            }

            /*
             * if (_requiredAxes.Count != _dist.SampleSpace.Dimension) {
             *      if (LoggerDiags.Enabled) SingletonLogger.Instance().WarningLog(typeof(AbstractAgentFactory), "AbstractAgentFactory requires "+_requiredAxes.Count+" but the BlauSpace has dimension: "+_dist.SampleSpace.Dimension);
             *      valid = false;
             * }
             */

            return(valid);
        }
Example #10
0
        // receive a signal from the Matcher (via the Simulation, via the Population) that an order has been filled
        public void recvOrderNotification(IOrderbook_Agent ob, IOrderbookEvent evt)
        {
            // Fill order events
            if (evt is IOrderbookEvent_FillOrder)
            {
                IOrderbookEvent_FillOrder fillEvent = (IOrderbookEvent_FillOrder)evt;
                IOrder filledOrder = fillEvent.getOrder();

                SingletonLogger.Instance().InfoLog(typeof(AbstractAgent), "AbstractAgent " + GetName() + " Fill " + filledOrder + " @ " + Scheduler.GetTime());

                if (filledOrder.isBid())
                {
                    AccumulateHoldings(+1 * fillEvent.getVolume());
                }
                else
                {
                    AccumulateHoldings(-1 * fillEvent.getVolume());
                }

                if (fillEvent.orderFilled())
                {
                    RemoveFromOpenOrderList(filledOrder);
                    FilledOrderNotification(filledOrder, fillEvent.getExecutionPrice(), fillEvent.getVolume());
                }
                else
                {
                    PartialFilledOrderNotification(filledOrder, fillEvent.getExecutionPrice(), fillEvent.getVolume());
                }
            }
            // Add and Cancel events are not forwarded to agents by the Population class
        }
Example #11
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());
        }
Example #12
0
        public void recvOrderbookNotification(IOrderbook_Matcher ob, IOrderbookEvent evt)
        {
            SingletonLogger.Instance().DebugLog(typeof(Simulation), "recvOrderbookNotification");

            if (ob == _ob)
            {
                SimulationEvent se = new SimulationEvent(evt);
                if (evt is IOrderbookEvent_AddOrder)
                {
                    notifyAllTrajectoryFactories(se);
                    notifyAllAgentEvaluationFactories(se);
                }
                else if (evt is IOrderbookEvent_CancelOrder)
                {
                    notifyAllTrajectoryFactories(se);
                    notifyAllAgentEvaluationFactories(se);
                }
                else if (evt is IOrderbookEvent_FillOrder)
                {
                    SingletonLogger.Instance().DebugLog(typeof(Simulation), "IOrderbookEvent_FillOrder");
                    notifyPopulation(se);
                    notifyAllTrajectoryFactories(se);
                    notifyAllAgentEvaluationFactories(se);
                }
            }
        }
Example #13
0
        protected override IAgent create(IBlauPoint pt, IAgentFactory creator, int id)
        {
            SingletonLogger.Instance().InfoLog(typeof(Agent0x1), "Agent0x1_Factory creating agent " + id);
            IAgent dupe = new Agent0x1(pt, creator, id);

            return(dupe);
        }
Example #14
0
        public void AgentOrderbookLoaderTest()
        {
            Console.WriteLine("AgentOrderbookLoaderTest");
            LoggerInitialization.SetThreshold(typeof(sim_tests), LogLevel.Debug);
            LoggerInitialization.SetThreshold(typeof(AbstractAgent), LogLevel.Info);
            LoggerInitialization.SetThreshold(typeof(AgentOrderbookLoader), LogLevel.Info);

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

            SingletonLogger.Instance().DebugLog(typeof(metrics_tests), "AgentOrderbookLoader: " + loader);

            IOrderbook_Observable ob  = new Orderbook();
            IPopulation           pop = new Population();

            pop.addAgent(loader);

            ISimulation sim = new Simulation(pop, ob, 0.0, 100.0);

            SingletonLogger.Instance().DebugLog(typeof(sim_tests), "Running Simulation");
            ISimulationResults res = sim.run();

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

            SingletonLogger.Instance().DebugLog(typeof(sim_tests), "ob: " + ob.ToStringLong());
            SingletonLogger.Instance().DebugLog(typeof(sim_tests), "res: " + res.ToStringLong());

            Assert.AreEqual(res.Valid, true);
        }
Example #15
0
 public static void ThreadLogger()
 {
     for (int nIter = 0; nIter < 100; nIter++)
     {
         SingletonLogger.GetInstance().LogMsg(String.Format("Writing Message {0}", nIter));
     }
 }
Example #16
0
        public void validateMetrics(int expected)
        {
            if (_metrics.Count != expected)
            {
                if (LoggerDiags.Enabled)
                {
                    SingletonLogger.Instance().InfoLog(typeof(AbstractAgent), "AbstractAgent " + GetName() + " we got a problem with the number of metrics present");
                }

                if (LoggerDiags.Enabled)
                {
                    SingletonLogger.Instance().InfoLog(typeof(AbstractAgent), "AbstractAgent " + GetName() + ", # of _metrics present: " + _metrics.Count);
                }

                foreach (string x in _metrics.Keys)
                {
                    if (LoggerDiags.Enabled)
                    {
                        SingletonLogger.Instance().InfoLog(typeof(AbstractAgent), "AbstractAgent " + GetName() + " _metric: " + x + " which has value " + _metrics[x]);
                    }
                }

                throw new Exception("AbstractAgent " + GetName() + " validateMetrics failed, expected " + expected + " but found " + _metrics.Count);
            }
        }
Example #17
0
        public void recvSimulationNotification(ISimulationParameters sim, ISimulationEvent se)
        {
            SingletonLogger.Instance().DebugLog(typeof(AbstractPassiveTrajectoryFactory), "AbstractPassiveTrajectoryFactory recvSimulationNotification");

            // events received from ISimulation

            if (se.OrderbookEvent == null)
            {
                if (se is ISimulationStart)
                {
                    SingletonLogger.Instance().DebugLog(typeof(AbstractPassiveTrajectoryFactory), "AbstractPassiveTrajectoryFactory SET Sim!");
                    _sim = sim;
                    reset();
                    SimulationStartNotification();
                }

                if (se is ISimulationEnd)
                {
                    SimulationEndNotification();
                    SingletonLogger.Instance().DebugLog(typeof(AbstractPassiveTrajectoryFactory), "AbstractPassiveTrajectoryFactory CLEAR Sim!");
                    _sim = null;
                }
            }
            else
            {
                if (_sim == null)
                {
                    // too late
                    SingletonLogger.Instance().DebugLog(typeof(AbstractPassiveTrajectoryFactory), "AbstractPassiveTrajectoryFactory Too Late!");
                    return;
                }

                if (se.OrderbookEvent is IOrderbookEvent_FillOrder)
                {
                    IOrderbookEvent_FillOrder fillEvent = (IOrderbookEvent_FillOrder)se.OrderbookEvent;
                    IOrder filledOrder = fillEvent.getOrder();
                    if (fillEvent.orderFilled())
                    {
                        FilledOrderNotification(filledOrder, fillEvent.getExecutionPrice(), fillEvent.getVolume());
                    }
                    else
                    {
                        PartialFilledOrderNotification(filledOrder, fillEvent.getExecutionPrice(), fillEvent.getVolume());
                    }
                }
                else if (se.OrderbookEvent is IOrderbookEvent_AddOrder)
                {
                    IOrderbookEvent_AddOrder addEvent = (IOrderbookEvent_AddOrder)se.OrderbookEvent;
                    IOrder newOrder = addEvent.getOrder();
                    NewOrderNotification(newOrder);
                }
                else if (se.OrderbookEvent is IOrderbookEvent_CancelOrder)
                {
                    IOrderbookEvent_CancelOrder cancelEvent = (IOrderbookEvent_CancelOrder)se.OrderbookEvent;
                    IOrder cancelledOrder = cancelEvent.getOrder();
                    CancelOrderNotification(cancelledOrder);
                }
            }
        }
Example #18
0
        public void DistributionSpaceIterator_GaussianMixtureTest()
        {
            Console.WriteLine("DistributionSpaceIterator_GaussianMixtureTest");

            double        mean  = 70.0;
            double        std   = 1.0;
            IDistribution d1    = create1DGaussian(mean, std);
            double        mean2 = 20.0;
            double        std2  = 1.0;
            IDistribution d2    = create1DGaussian(mean2, std2);

            int dim = 1;

            string [] names = new string [1] {
                "x"
            };
            double [] mins = new double [1] {
                0.00
            };
            double [] maxs = new double [1] {
                100.0
            };
            IBlauSpace s = BlauSpace.create(dim, names, mins, maxs);
            Mixture    d = new Mixture(s);

            d.Add(d1, 0.75);
            d.Add(d2, 0.25);
            d.DistributionComplete();


            SingletonLogger.Instance().DebugLog(typeof(dist_tests), "original distribution: " + d);
            DistributionSpace ds = new DistributionSpace(d);

            int [] steps = new int[ds.ParamSpace.Dimension];

            for (int N = 3; N <= 5; N++)
            {
                for (int i = 0; i < ds.ParamSpace.Dimension; i++)
                {
                    steps[i] = N;
                }

                IDistributionSpaceIterator it = ds.iterator(steps);

                int count   = 0;
                int validCt = 0;
                foreach (IDistribution diter in it)
                {
                    if (diter.IsValid())
                    {
                        validCt++;
                        SingletonLogger.Instance().DebugLog(typeof(dist_tests), "iterator distribution: " + diter);
                    }
                    count++;
                }
                Assert.AreEqual((N + 1) * (N + 1) * (N + 1) * (N + 1) * (N + 1) * (N + 1), count);
                SingletonLogger.Instance().InfoLog(typeof(dist_tests), "N=" + N + "  valid distributions: " + validCt + " / total: " + count);
            }
        }
Example #19
0
 public override void PartialFilledOrderNotification(IOrder partialOrder, double price, int volume)
 {
     SingletonLogger.Instance().DebugLog(typeof(TrajectoryFactory_Price), "PartialFilledOrderNotification");
     if (Orderbook.isNonDegenerate())
     {
         MyTrajectory.add(TimeNow, Orderbook.getNumBids());
     }
 }
Example #20
0
 internal void register(StreamingContext context)
 {
     if (LoggerDiags.Enabled)
     {
         SingletonLogger.Instance().InfoLog(typeof(BlauSpace), "REGISTERING BLAUSPACE");
     }
     BlauSpaceRegistry.Instance().add(this);
 }
Example #21
0
 private void notifyAllTrajectoryFactories(ISimulationEvent se)
 {
     foreach (IPassiveTrajectoryFactory tf in _tflist)
     {
         SingletonLogger.Instance().DebugLog(typeof(Simulation), "notifyAllTrajectoryFactories");
         tf.recvSimulationNotification(this, se);
     }
 }
Example #22
0
        protected override int GetAskVolume()
        {
            validateMetrics(7);
            int answer = AskVolume_CONSTANT;

            SingletonLogger.Instance().DebugLog(typeof(Agent0x1), "I am " + this.ID + " GetAskVolume: " + answer);
            return(answer);
        }
Example #23
0
        protected override bool DecideToSubmitBid()
        {
            validateMetrics(7);
            bool answer = (SingletonRandomGenerator.Instance.NextDouble() <= DecideToSubmitBid_PROBABILITY);

            SingletonLogger.Instance().DebugLog(typeof(Agent0x1), "I am " + this.ID + " DecideToSubmitBid: " + answer);
            return(answer);
        }
Example #24
0
 public override void CancelOrderNotification(IOrder cancelledOrder)
 {
     SingletonLogger.Instance().DebugLog(typeof(TrajectoryFactory_Price), "CancelOrderNotification");
     if (Orderbook.isNonDegenerate())
     {
         MyTrajectory.add(TimeNow, Orderbook.getNumBids());
     }
 }
Example #25
0
 internal void register(StreamingContext context)
 {
     if (LoggerDiags.Enabled)
     {
         SingletonLogger.Instance().InfoLog(typeof(BlauSpaceLattice), "BSL OnDeserialized ...");
     }
     BlauSpaceLatticeRegistry.Instance().add(this);
 }
Example #26
0
        public void Agent0x1Simulation_ZeroDimensional()
        {
            Console.WriteLine("Agent0x1Simulation_ZeroDimensional");
            LoggerInitialization.SetThreshold(typeof(sim_tests), LogLevel.Debug);
            LoggerInitialization.SetThreshold(typeof(AbstractAgent), LogLevel.Info);
            LoggerInitialization.SetThreshold(typeof(AgentOrderbookLoader), LogLevel.Info);
            LoggerInitialization.SetThreshold(typeof(Agent0x0), LogLevel.Info);

            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 = 10;
            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";
            IAgentEvaluationBundle aeb = new AgentEvaluationBundle(PROPERTY);

            // 1 hours
            ISimulation sim = new Simulation(pop, ob, 0.0, 3600.0);
            NamedMetricAgentEvaluationFactory metricEF = new NamedMetricAgentEvaluationFactory(PROPERTY);

            sim.add(metricEF);

            SingletonLogger.Instance().DebugLog(typeof(sim_tests), "Running Simulation");
            ISimulationResults res = sim.run();

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

            IAgentEvaluation ae = metricEF.create();

            aeb.addAgentEvaluation(ae);

            SingletonLogger.Instance().DebugLog(typeof(sim_tests), "ob: " + ob.ToStringLong());
            SingletonLogger.Instance().DebugLog(typeof(sim_tests), "aeb: " + aeb.ToStringLong());
            SingletonLogger.Instance().DebugLog(typeof(sim_tests), "res: " + res.ToStringLong());

            Assert.AreEqual(res.Valid, true);
        }
Example #27
0
		protected override bool DecideToCancelOpenOrder(IOrder openOrder) {
			bool cancel = false;
			if (_haveOrder) {
				cancel = (SingletonRandomGenerator.Instance.NextDouble() <= _patience);
				SingletonLogger.Instance().DebugLog(typeof(Agent1x0), "I am "+this.ID+" CANCEL: "+cancel);
				if (cancel) _haveOrder = false;
			}
			return cancel;
		}
Example #28
0
 // constructor
 public Population()
 {
     _agents     = new List <IAgent>();
     _name2agent = new Dictionary <string, IAgent>();
     if (LoggerDiags.Enabled)
     {
         SingletonLogger.Instance().InfoLog(typeof(Population), "Population constructed");
     }
 }
Example #29
0
		public override void PartialFilledOrderNotification(IOrder partialOrder, double price, int volume) {
			AccumulateNetWorth( ValuateTransaction(partialOrder, price, volume) );
			
				SingletonLogger.Instance().DebugLog(typeof(Agent1x0), "XXX I am "+this.ID+" PARTLYEXECUTED time is "+Scheduler.GetTime()+
			                                    " filledOrder: "+partialOrder+
			                                    " Filled "+volume+" AT : "+price+
			                                    " OBprice: "+Orderbook.getPrice()+
			                                    " OBspread: "+Orderbook.getSpread() +
			                                    " My net worth is "+GetMetricValue(NetWorth_METRICNAME));
		}
Example #30
0
        // deserializer consults the blauspace registry to avoid duplicate instantiations
        public Object GetRealObject(StreamingContext context)
        {
            IBlauSpace s_validated = BlauSpaceRegistry.Instance().validate(this);

            if (LoggerDiags.Enabled)
            {
                SingletonLogger.Instance().InfoLog(typeof(BlauSpace), "VALIDATING BLAUSPACE");
            }
            return(s_validated);
        }