public Agent0xA(IBlauPoint coordinates, IAgentFactory creator, int id) : base(coordinates, creator, id, 0.0) { _G = coordinates.getCoordinate(coordinates.Space.getAxisIndex(GainCutoff_PROPERTYNAME)); //SingletonLogger.Instance().DebugLog(typeof(Agent0x1), "I have set my aggressiveness to: "+_aggressiveness); SetMetricValue(GainCutoff_PROPERTYNAME, _G); _L = coordinates.getCoordinate(coordinates.Space.getAxisIndex(LossCutoff_PROPERTYNAME)); //SingletonLogger.Instance().DebugLog(typeof(Agent0x1), "I have set my optimism to: "+_optimism); SetMetricValue(LossCutoff_PROPERTYNAME, _L); _Tdouble = coordinates.getCoordinate(coordinates.Space.getAxisIndex(Type_PROPERTYNAME)); //SingletonLogger.Instance().DebugLog(typeof(Agent0x1), "I have set my optimism to: "+_optimism); if (_Tdouble < 0.0) { _T = -1; } else { _T = +1; } SetMetricValue(Type_PROPERTYNAME, _T); _myTrades = 0; SetMetricValue(TotalTrades_METRICNAME, (double)_myTrades); _myOrders = 0; SetMetricValue(TotalOrders_METRICNAME, (double)_myOrders); //SingletonLogger.Instance().DebugLog(typeof(Agent0x1), "I have iniitialized TotalTrades metric to: "+GetMetricValue(TotalTrades_METRICNAME)); }
public Agent0xB(IBlauPoint coordinates, IAgentFactory creator, int id) : base(coordinates, creator, id, 0.0) { _G = coordinates.getCoordinate(coordinates.Space.getAxisIndex(GainCutoff_PROPERTYNAME)); //SingletonLogger.Instance().DebugLog(typeof(Agent0x1), "I have set my aggressiveness to: "+_aggressiveness); SetMetricValue(GainCutoff_PROPERTYNAME, _G); if (_G < 0.0) { throw new Exception("Gain cutoff must be positive!"); } _L = coordinates.getCoordinate(coordinates.Space.getAxisIndex(LossCutoff_PROPERTYNAME)); //SingletonLogger.Instance().DebugLog(typeof(Agent0x1), "I have set my optimism to: "+_optimism); SetMetricValue(LossCutoff_PROPERTYNAME, _L); if (_L < 0.0) { throw new Exception("Loss cutoff must be positive!"); } _TypeDouble = coordinates.getCoordinate(coordinates.Space.getAxisIndex(Type_PROPERTYNAME)); //SingletonLogger.Instance().DebugLog(typeof(Agent0x1), "I have set my optimism to: "+_optimism); /* * double toss = SingletonRandomGenerator.Instance.NextDouble (); * * if (toss < _TypeDouble) { * _Type = -1; // play short * // Move myself in BlauSpace * coordinates.setCoordinate(coordinates.Space.getAxisIndex (Type_PROPERTYNAME), (double)0.0); * } else { * _Type = +1; // play long * // Move myself in BlauSpace * coordinates.setCoordinate(coordinates.Space.getAxisIndex (Type_PROPERTYNAME), (double)1.0); * } */ /* * if (this.ID % 2 == 0) _Type = -1; // play short * else _Type = +1; // play long */ SetMetricValue(Type_PROPERTYNAME, _Type); _clock = coordinates.getCoordinate(coordinates.Space.getAxisIndex(Clock_PROPERTYNAME)); SetMetricValue(Clock_PROPERTYNAME, _clock); ResetMetrics(); _burninResetCompleted = false; _startTime = 0.0; //SingletonLogger.Instance().DebugLog(typeof(Agent0x1), "I have iniitialized TotalTrades metric to: "+GetMetricValue(TotalTrades_METRICNAME)); }
public Agent0x2(IBlauPoint coordinates, IAgentFactory creator, int id) : base(coordinates, creator, id, 0.0) { _aggressiveness = coordinates.getCoordinate(coordinates.Space.getAxisIndex(Aggressiveness_PROPERTYNAME)); //SingletonLogger.Instance().DebugLog(typeof(Agent0x1), "I have set my aggressiveness to: "+_aggressiveness); SetMetricValue(Aggressiveness_PROPERTYNAME, _aggressiveness); _optimism = coordinates.getCoordinate(coordinates.Space.getAxisIndex(Optimism_PROPERTYNAME)); //SingletonLogger.Instance().DebugLog(typeof(Agent0x1), "I have set my optimism to: "+_optimism); SetMetricValue(Optimism_PROPERTYNAME, _optimism); _myTrades = 0; SetMetricValue(TotalTrades_METRICNAME, (double)_myTrades); _myOrders = 0; SetMetricValue(TotalOrders_METRICNAME, (double)_myOrders); //SingletonLogger.Instance().DebugLog(typeof(Agent0x1), "I have iniitialized TotalTrades metric to: "+GetMetricValue(TotalTrades_METRICNAME)); }
public AgentZx0(IBlauPoint coordinates, IAgentFactory creator, int id) : base(coordinates, creator, id, 0.0) { _clock = coordinates.getCoordinate(coordinates.Space.getAxisIndex(Clock_PROPERTYNAME)); SetMetricValue(Clock_PROPERTYNAME, _clock); _priceOffset = coordinates.getCoordinate(coordinates.Space.getAxisIndex(PriceOffset_PROPERTYNAME)); SetMetricValue(PriceOffset_PROPERTYNAME, _priceOffset); _volumeOffset = coordinates.getCoordinate(coordinates.Space.getAxisIndex(VolumeOffset_PROPERTYNAME)); SetMetricValue(VolumeOffset_PROPERTYNAME, _volumeOffset); _myTrades = 0; SetMetricValue(AgentTrades_METRICNAME, (double)_myTrades); _myOrders = 0; SetMetricValue(AgentOrders_METRICNAME, (double)_myOrders); //SingletonLogger.Instance().DebugLog(typeof(Agent0x1), "I have iniitialized TotalTrades metric to: "+GetMetricValue(TotalTrades_METRICNAME)); }
// copy constructor public BlauPoint(IBlauPoint orig) { _space = orig.Space; _coords = new double [orig.Space.Dimension]; for (int i = 0; i < orig.Space.Dimension; i++) { _coords[i] = orig.getCoordinate(i); } _dirty = true; }
public void Distribution_Gaussian2DTest() { Console.WriteLine("Distribution_Gaussian2DTest"); double mean = 70.0; double std = 1.0; double mean2 = 20.0; double std2 = 1.0; IDistribution g2d = create2DGaussian(mean, std, mean2, std2); for (int i = 0; i < 100; i++) { IBlauPoint p = g2d.getSample(); SingletonLogger.Instance().DebugLog(typeof(Main_dist), "=> " + p); Assert.AreEqual((Math.Abs(p.getCoordinate(0) - mean) > 10.0 * std), false); Assert.AreEqual((Math.Abs(p.getCoordinate(1) - mean2) > 10.0 * std2), false); } }
public Agent0xA(IBlauPoint coordinates, IAgentFactory creator, int id) : base(coordinates, creator, id, 0.0) { _G = coordinates.getCoordinate(coordinates.Space.getAxisIndex(GainCutoff_PROPERTYNAME)); //SingletonLogger.Instance().DebugLog(typeof(Agent0x1), "I have set my aggressiveness to: "+_aggressiveness); SetMetricValue(GainCutoff_PROPERTYNAME, _G); if (_G < 0.0) { throw new Exception("Gain cutoff must be positive!"); } _L = coordinates.getCoordinate(coordinates.Space.getAxisIndex(LossCutoff_PROPERTYNAME)); //SingletonLogger.Instance().DebugLog(typeof(Agent0x1), "I have set my optimism to: "+_optimism); SetMetricValue(LossCutoff_PROPERTYNAME, _L); if (_L < 0.0) { throw new Exception("Loss cutoff must be positive!"); } _TypeDouble = coordinates.getCoordinate(coordinates.Space.getAxisIndex(Type_PROPERTYNAME)); //SingletonLogger.Instance().DebugLog(typeof(Agent0x1), "I have set my optimism to: "+_optimism); if (_TypeDouble < 0.0) { _Type = -1; // play short } else { _Type = +1; // play long } SetMetricValue(Type_PROPERTYNAME, _Type); _clock = coordinates.getCoordinate(coordinates.Space.getAxisIndex(Clock_PROPERTYNAME)); SetMetricValue(Clock_PROPERTYNAME, _clock); ResetMetrics(); _burninResetCompleted = false; _startTime = 0.0; //SingletonLogger.Instance().DebugLog(typeof(Agent0x1), "I have iniitialized TotalTrades metric to: "+GetMetricValue(TotalTrades_METRICNAME)); }
private void FillTemplateDistributionParameters(IBlauPoint parms) { for (int i = 0; i < parms.Space.Dimension; i++) { //SingletonLogger.Instance().DebugLog(typeof(DistributionSpaceIterator), "now filling param "+i+" with "+parms.getCoordinate(i)); _templateDistribution.setParam(i, parms.getCoordinate(i)); //Console.WriteLine("Now filling param "+i+" with "+parms.getCoordinate(i)); } //Console.WriteLine("the template dist is now: "+_templateDistribution); }
public void Distribution_GaussianMixtureTest() { Console.WriteLine("Distribution_GaussianMixtureTest"); double mean = 70.0; double std = 1.0; double mean2 = 20.0; double std2 = 1.0; IDistribution d = createGaussianMixture(mean, std, mean2, std2); SingletonLogger.Instance().DebugLog(typeof(dist_tests), "distribution: " + d); for (int i = 0; i < 1000; i++) { IBlauPoint p = d.getSample(); SingletonLogger.Instance().DebugLog(typeof(dist_tests), "=> " + p); double diff = Math.Abs(p.getCoordinate(0) - mean); double diff2 = Math.Abs(p.getCoordinate(0) - mean2); Assert.AreEqual((diff > 5.0 * std) && (diff2 > 5.0 * std2), false); } }
public void Distribution_Interval1DTest() { Console.WriteLine("Distribution_Interval1DTest"); 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); double min = 10.0; double max = 30.0; IDistribution d = new Distribution_Interval(s, min, max); SingletonLogger.Instance().DebugLog(typeof(dist_tests), "distribution: " + d); for (int i = 0; i < 1000; i++) { IBlauPoint p = d.getSample(); SingletonLogger.Instance().DebugLog(typeof(dist_tests), "=> " + p); for (int x = 0; x < dim; x++) { double diff = p.getCoordinate(x) - min; Assert.AreEqual(diff < 0.0, false); diff = max - p.getCoordinate(x); Assert.AreEqual(diff < 0.0, false); } } }
public Agent0x1(IBlauPoint coordinates, IAgentFactory creator, int id) : base(coordinates, creator, id, 0.0) { SingletonLogger.Instance().InfoLog(typeof(Agent0x1), "creating agent " + id); _aggressiveness = coordinates.getCoordinate(coordinates.Space.getAxisIndex(Aggressiveness_PROPERTYNAME)); SetMetricValue(Aggressiveness_PROPERTYNAME, _aggressiveness); SingletonLogger.Instance().DebugLog(typeof(Agent0x1), "I am " + this.ID + " have set my aggressiveness to: " + GetMetricValue(Aggressiveness_PROPERTYNAME)); SetMetricValue(TotalTrades_METRICNAME, 0.0); SetMetricValue(NetWorth_METRICNAME, 0.0); SetMetricValue(TotalOrders_METRICNAME, 0.0); validateMetrics(7); SingletonLogger.Instance().InfoLog(typeof(Agent0x1), "done creating agent " + id); }
// quantize a blaupoint with respect to this lattice public IBlauPoint quantize(IBlauPoint p) { if (p.Space != this.BlauSpace) { throw new Exception("BlauSpaceLattice is being requested to quantize a BlauPoint which lies in a foreign BlauSpace"); } IBlauPoint qp = new QuantizedBlauPoint(p.Space, this); for (int i = 0; i < p.Space.Dimension; i++) { double px = p.getCoordinate(i); // qp will quantize coordinates to this lattice qp.setCoordinate(i, px); } return(qp); }
public override IBlauPoint getSample() { if (!_completed) { throw new Exception("Attempt to sample from Product distribution that has not been completed"); } IBlauPoint p = new BlauPoint(this.SampleSpace); foreach (IDistribution d in _factor) { IBlauPoint q = d.getSample(); for (int i = 0; i < q.Space.Dimension; i++) { p.setCoordinate(p.Space.getAxisIndex(q.Space.getAxis(i).Name), q.getCoordinate(i)); } } return(p); }
public Agent1x0(IBlauPoint coordinates, IAgentFactory creator, int id, double lambda, double gamma, double burnin) : base(coordinates, creator, id, burnin) { SingletonLogger.Instance().InfoLog(typeof(Agent1x0), "creating agent "+id); _clock = coordinates.getCoordinate( coordinates.Space.getAxisIndex(Clock_PROPERTYNAME) ); _aggressiveness = coordinates.getCoordinate( coordinates.Space.getAxisIndex(Aggressiveness_PROPERTYNAME) ); _patience = coordinates.getCoordinate( coordinates.Space.getAxisIndex(Patience_PROPERTYNAME) ); _trendiness = coordinates.getCoordinate( coordinates.Space.getAxisIndex(Trendiness_PROPERTYNAME) ); _optimism = coordinates.getCoordinate( coordinates.Space.getAxisIndex(Optimism_PROPERTYNAME) ); _riskiness = coordinates.getCoordinate( coordinates.Space.getAxisIndex(Riskiness_PROPERTYNAME) ); SetMetricValue(Clock_PROPERTYNAME, _clock); SetMetricValue(Aggressiveness_PROPERTYNAME, _aggressiveness); SetMetricValue(Patience_PROPERTYNAME, _patience); SetMetricValue(Trendiness_PROPERTYNAME, _trendiness); SetMetricValue(Optimism_PROPERTYNAME, _optimism); SetMetricValue(Riskiness_PROPERTYNAME, _riskiness); SingletonLogger.Instance().DebugLog(typeof(Agent1x0), "I am "+this.ID+" have set my clock to: "+GetMetricValue(Clock_PROPERTYNAME)); SingletonLogger.Instance().DebugLog(typeof(Agent1x0), "I am "+this.ID+" have set my aggressiveness to: "+GetMetricValue(Aggressiveness_PROPERTYNAME)); SingletonLogger.Instance().DebugLog(typeof(Agent1x0), "I am "+this.ID+" have set my patience to: "+GetMetricValue(Patience_PROPERTYNAME)); SingletonLogger.Instance().DebugLog(typeof(Agent1x0), "I am "+this.ID+" have set my trendiness to: "+GetMetricValue(Trendiness_PROPERTYNAME)); SingletonLogger.Instance().DebugLog(typeof(Agent1x0), "I am "+this.ID+" have set my optimism to: "+GetMetricValue(Optimism_PROPERTYNAME)); SingletonLogger.Instance().DebugLog(typeof(Agent1x0), "I am "+this.ID+" have set my riskiness to: "+GetMetricValue(Riskiness_PROPERTYNAME)); ResetMetrics(); _haveOrder = false; _lastBidVolume = 0.0; _lastAskVolume = 0.0; _lambda = lambda; _gamma = gamma; _burninResetCompleted = false; _startTime = 0.0; SingletonLogger.Instance().InfoLog(typeof(Agent1x0), "done creating agent "+id); }