Пример #1
0
 public override void CancelOrderNotification(IOrder cancelledOrder)
 {
     if (Orderbook.isNonDegenerate())
     {
         MyTrajectory.add(TimeNow, Orderbook.getNumBids() + Orderbook.getNumAsks());
     }
 }
Пример #2
0
 public override void FilledOrderNotification(IOrder filledOrder, double price, int volume)
 {
     if (Orderbook.isNonDegenerate())
     {
         MyTrajectory.add(TimeNow, Orderbook.getNumBids() + Orderbook.getNumAsks());
     }
 }
Пример #3
0
 public override void CancelOrderNotification(IOrder cancelledOrder)
 {
     SingletonLogger.Instance().DebugLog(typeof(TrajectoryFactory_Price), "CancelOrderNotification");
     if (Orderbook.isNonDegenerate())
     {
         MyTrajectory.add(TimeNow, Orderbook.getNumBids());
     }
 }
Пример #4
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());
     }
 }
Пример #5
0
 public override void CancelOrderNotification(IOrder cancelledOrder)
 {
     if (Orderbook.isNonDegenerate())
     {
         if (Orderbook.getSpread() >= 0.0)
         {
             MyTrajectory.add(TimeNow, Orderbook.getSpread());
         }
     }
 }
Пример #6
0
 public override void FilledOrderNotification(IOrder filledOrder, double price, int volume)
 {
     if (Orderbook.isNonDegenerate())
     {
         if (Orderbook.getSpread() >= 0.0)
         {
             MyTrajectory.add(TimeNow, Orderbook.getSpread());
         }
     }
 }
        public override void FilledOrderNotification(IOrder filledOrder, double price, int volume)
        {
            if (Orderbook.getSpread() <= 0.0)
            {
                return;
            }

            SingletonLogger.Instance().DebugLog(typeof(TrajectoryFactory_Price), "FilledOrderNotification");
            if (Orderbook.isNonDegenerate() && MyTrajectory.ThresholdTimePassed(TimeNow))
            {
                MyTrajectory.add(TimeNow, GetPriceNormalizedAlphaSpread());
            }
        }
Пример #8
0
		protected override bool DecideToMakeOrder() {
			
			if ( ! Orderbook.isNonDegenerate()) {
				SingletonLogger.Instance().DebugLog(typeof(Agent1x0), "XXXXXXXXX OB: " + Orderbook.ToStringLong());
				return false;
			}
			if (_haveOrder) {
				// SingletonLogger.Instance().DebugLog(typeof(Agent1x0), "I cannot make a new order, I have one");
				return false;
			}
				
			bool makeorder = (SingletonRandomGenerator.Instance.NextDouble() <= _aggressiveness);
			
			// SingletonLogger.Instance().DebugLog(typeof(Agent1x0), "I am "+this.ID+" DecideToMakeOrder: "+makeorder);
			if (makeorder) {
				IncrementTotalOrders();
				_haveOrder = true;
			}
			return makeorder;
		}
Пример #9
0
        // receive a signal from the Simulation (via the Population)
        public override void Recv(ISimEntity src, ISimEvent simEvent)
        {
            if (Orderbook == null)
            {
                return;
            }

            if (LoggerDiags.Enabled)
            {
                SingletonLogger.Instance().DebugLog(typeof(AbstractAgent), "AbstractAgent " + GetName() + "recv ISimEvent " + simEvent + " @ " + Scheduler.GetTime());
            }

            // events received from the DES
            if (simEvent is ActionPrompt)
            {
                if (DecideToAct())
                {
                    if (LoggerDiags.Enabled)
                    {
                        SingletonLogger.Instance().DebugLog(typeof(AbstractAgent), "AbstractAgent " + GetName() + "acts @ " + Scheduler.GetTime() + " I have " + _orders.Count + " orders open");
                    }

                    EvaluateAllOpenOrders();
                    if (DecideToMakeOrder())
                    {
                        if (LoggerDiags.Enabled)
                        {
                            SingletonLogger.Instance().DebugLog(typeof(AbstractAgent), "AbstractAgent " + GetName() + "makes order @ " + Scheduler.GetTime());
                        }

                        if (!Orderbook.isNonDegenerate())
                        {
                            SingletonLogger.Instance().WarningLog(typeof(AbstractAgent), "AbstractAgent " + GetName() + " witnesses Orderbook blowup @ " + Scheduler.GetTime() + "\n" + Orderbook.ToStringLong());
                        }

                        IOrder newOrder = null;
                        if (DecideToSubmitBid())
                        {
                            if (LoggerDiags.Enabled)
                            {
                                SingletonLogger.Instance().DebugLog(typeof(AbstractAgent), "AbstractAgent " + GetName() + " submits bid @ " + Scheduler.GetTime());
                            }


                            // bid
                            double price  = GetBidPrice();
                            int    volume = GetBidVolume();

                            if (volume > 0)
                            {
                                newOrder = Orderbook.addBid(price, volume, this);
                            }
                            else
                            {
                                if (LoggerDiags.Enabled)
                                {
                                    SingletonLogger.Instance().WarningLog(typeof(AbstractAgent), "AbstractAgent " + GetName() + " attempts unsuccessful zero sized bid @ " + Scheduler.GetTime());
                                }
                            }
                        }
                        else
                        {
                            if (LoggerDiags.Enabled)
                            {
                                SingletonLogger.Instance().DebugLog(typeof(AbstractAgent), "AbstractAgent " + GetName() + " submits ask @ " + Scheduler.GetTime());
                            }

                            // ask
                            double price  = GetAskPrice();
                            int    volume = GetAskVolume();

                            if (volume > 0)
                            {
                                newOrder = Orderbook.addAsk(price, volume, this);
                            }
                            else
                            {
                                if (LoggerDiags.Enabled)
                                {
                                    SingletonLogger.Instance().WarningLog(typeof(AbstractAgent), "AbstractAgent " + GetName() + " attempts unsuccessful zero sized ask @ " + Scheduler.GetTime());
                                }
                            }
                        }

                        if (newOrder != null)
                        {
                            // may be null if dual volume is 0 preventing creation of new orders
                            AddToOpenOrderList(newOrder);

                            if (LoggerDiags.Enabled)
                            {
                                SingletonLogger.Instance().DebugLog(typeof(AbstractAgent), "AbstractAgent " + GetName() + " submitted " + newOrder + " @ " + Scheduler.GetTime());
                            }
                        }
                        else
                        {
                            throw new Exception("We got a problem");
                        }
                    }
                }

                double timeToNextPrompt = GetTimeToNextActionPrompt();
                if (timeToNextPrompt < 0.0)
                {
                    // agent checks out of ecosystem by indicating a negative time
                    if (LoggerDiags.Enabled)
                    {
                        SingletonLogger.Instance().WarningLog(typeof(AbstractAgent), "AbstractAgent " + GetName() + " leaves simulation by indicating negative prompt time @ " + Scheduler.GetTime());
                    }
                }
                else
                {
                    this.Send(this, simEvent, timeToNextPrompt);
                }
            }
        }