Пример #1
0
        public override void SimulationEndNotification()
        {
            // Console.WriteLine("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX "+this+";  time now is: "+TimeNow);

            SingletonLogger.Instance().DebugLog(typeof(TrajectoryFactory_Price), "SimulationEndNotification");
            MyTrajectory.add(TimeNow, Orderbook.getPrice());
        }
Пример #2
0
 public override void CancelOrderNotification(IOrder cancelledOrder)
 {
     SingletonLogger.Instance().DebugLog(typeof(TrajectoryFactory_Price), "CancelOrderNotification");
     if (Orderbook.isNonDegenerate())
     {
         MyTrajectory.add(TimeNow, Orderbook.getPrice());
     }
 }
Пример #3
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.getPrice());
     }
 }
Пример #4
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));
		}
Пример #5
0
		protected override double GetAskPrice() {
			double logNormal = getLogNormal();
			double price = Orderbook.getHighestBid() + logNormal + _optimism * Orderbook.getPrice();
			double roundedPrice = Math.Round(price*100.0)/100.0;
			
				SingletonLogger.Instance().DebugLog(typeof(Agent1x0), "XXX I am "+this.ID+" ASK time is "+Scheduler.GetTime()+
			                                    " myAskPrice: "+roundedPrice+
			                                    " OBprice: "+Orderbook.getPrice()+
			                                    " OBspread: "+Orderbook.getSpread() );
			return roundedPrice;
		}
Пример #6
0
        protected override double GetAskPrice()
        {
            double mean = Orderbook.getLowestAsk();
            double std  = Orderbook.getPrice() - Orderbook.getHighestBid();

            std = 0.02;
            double price        = SingletonRandomGenerator.Instance.NextGaussianPositive(mean, std);
            double roundedPrice = Math.Round(price * 100.0) / 100.0;

            roundedPrice += 0.03;
            return(roundedPrice);
        }
        private double GetPriceNormalizedAlphaSpread()
        {
            double normalizer = Orderbook.getPrice();

            //Console.WriteLine("GetPriceNormalizedAlphaSpread I am running alpha = "+_alpha+" and _askBased = "+_askBased);

            if (_askBased)
            {
                return((GetPricing() - GetDualPricing()) / normalizer);
            }
            else
            {
                return((GetDualPricing() - GetPricing()) / normalizer);
            }
        }
Пример #8
0
        protected override double GetAskPrice()
        {
            if (_market)
            {
                return(Orderbook.getHighestBid());
            }

            // limit order
            double off          = getOffset();
            double basePrice    = Orderbook.getPrice();          // Orderbook.getHighestBid(); //Orderbook.getLowestAsk()
            double price        = basePrice + off;
            double roundedPrice = Math.Round(price * 100.0) / 100.0;

            /*
             * SingletonLogger.Instance().DebugLog(typeof(Agent1x0), "XXX I am "+this.ID+" time is "+Scheduler.GetTime() +" myAskPrice: "+roundedPrice+
             *                                  " OBprice: "+Orderbook.getPrice()+
             *                                  " OBspread: "+Orderbook.getSpread() + " I have "+OpenOrdersCount ()+ " open orders");
             */

            return(roundedPrice);
        }
Пример #9
0
        protected override double GetAskPrice()
        {
            if (_market)
            {
                if (Orderbook.getNumBids() > 0)
                {
                    return(Orderbook.getHighestBid());
                }
                else
                {
                    return(Orderbook.getPrice());
                }
            }
            double price        = _pe.getAskPrice(Orderbook);
            double roundedPrice = price;             // Math.Round(price*100.0)/100.0;

/*
 *                      SingletonLogger.Instance().DebugLog(typeof(Agent1x0), "XXX I am "+this.ID+" time is "+Scheduler.GetTime() +" myAskPrice: "+roundedPrice+
 *                                                          " OBprice: "+Orderbook.getPrice()+
 *                                                          " OBspread: "+Orderbook.getSpread() + " I have "+OpenOrdersCount ()+ " open orders");
 */

            return(roundedPrice);
        }
Пример #10
0
        protected override bool DecideToMakeOrder()
        {
            //SingletonLogger.Instance().DebugLog(typeof(Agent1x0), "XXX DecideToMakeOrder: I am "+this.ID+" time is "+Scheduler.GetTime() + " I have "+OpenOrdersCount ()+ " open orders");

            if (OpenOrdersCount() > 0)
            {
                // SingletonLogger.Instance().DebugLog(typeof(Agent1x0), "XXX I am "+this.ID+" time is "+Scheduler.GetTime() + " NOT making an order because I have "+OpenOrdersCount ()+ " open orders");
                return(false);
            }

            bool choice = false;

            _market = false;

            double currentPrice = Orderbook.getPrice();

            if (_Type > 0)               // long player
            {
                double gainAbs = currentPrice - _Pstar;
                double relGain = gainAbs / _Pstar;
                if (relGain > 0)
                {
                    double p    = relGain <= EPSILON ? 0.0 : Math.Exp(_G * Math.Log(GPERC) / relGain);
                    double toss = SingletonRandomGenerator.Instance.NextUniform(0.0, 1.0);
                    if (toss < p)
                    {
                        if (_holdings > 0)                           // long player with holdings... time to lock in profit by sell
                        {
                            _bid = false;
                            decideMarketOrLimit(p);
                        }
                        else                             // time to get in on the runup by buying
                        {
                            _bid = true;
                            decideMarketOrLimit(p);
                        }
                        choice = true;
                    }
                }
                else
                {
                    double relLoss = -1.0 * relGain;
                    double p       = relLoss <= EPSILON ? 0.0 : Math.Exp(_L * Math.Log(LPERC) / relLoss);
                    double toss    = SingletonRandomGenerator.Instance.NextUniform(0.0, 1.0);
                    if (toss < p)
                    {
                        if (_holdings > 0)                           // long player with holdings... time to cut losses
                        {
                            _bid = false;
                            decideMarketOrLimit(p);
                        }
                        else                             // time to get in on the low priced stock
                        {
                            _bid = true;
                            decideMarketOrLimit(p);
                        }
                        choice = true;
                    }
                }
            }
            else                 // short player
            {
                double gainAbs = _Pstar - currentPrice;
                double relGain = gainAbs / _Pstar;
                if (relGain > 0)
                {
                    double p    = relGain <= EPSILON ? 0.0 : Math.Exp(_G * Math.Log(GPERC) / relGain);
                    double toss = SingletonRandomGenerator.Instance.NextUniform(0.0, 1.0);
                    if (toss < p)
                    {
                        if (_holdings < 0)                           // short player with holdings.. time to lock in profit by buying
                        {
                            _bid = true;
                            decideMarketOrLimit(p);
                        }
                        else                             // time to get in on the price fall by selling
                        {
                            _bid = false;
                            decideMarketOrLimit(p);
                        }
                        choice = true;
                    }
                }
                else
                {
                    double relLoss = -1.0 * relGain;
                    double p       = relLoss <= EPSILON ? 0.0 : Math.Exp(_L * Math.Log(LPERC) / relLoss);
                    double toss    = SingletonRandomGenerator.Instance.NextUniform(0.0, 1.0);
                    if (toss < p)
                    {
                        if (_holdings < 0)                           // short player with holdings... time to cut losses by buying
                        {
                            _bid = true;
                            decideMarketOrLimit(p);
                        }
                        else                             // time to get in on the over priced stock by selling
                        {
                            _bid = false;
                            decideMarketOrLimit(p);
                        }
                        choice = true;
                    }
                }
            }

            if (choice)
            {
                // SingletonLogger.Instance().DebugLog(typeof(Agent1x0), "XXX I am "+this.ID+" time is "+Scheduler.GetTime() + " MAKING an order due to PRICE flux / market = "+this._market);
            }

            // if we have not made an order based on price flux, we still need to
            // consider orders being placed due to time since last fill
            if (choice == false)
            {
                double DT   = Scheduler.GetTime() - _Tstar;
                double p    = DT <= EPSILON ? 0.0 : Math.Exp(_clock * Math.Log(TPERC) / DT);
                double toss = SingletonRandomGenerator.Instance.NextUniform(0.0, 1.0);
                if (toss < p)
                {
                    // its been too long...

                    if (_Type > 0)                       // long player
                    {
                        if (_holdings > 0)               // have holdings
                        {
                            _bid = false;                // sell
                            decideMarketOrLimit(p);
                        }
                        else
                        {
                            _bid = true;                             // buy
                            decideMarketOrLimit(p);
                        }
                    }
                    else                         // short player
                    {
                        if (_holdings < 0)       // have holdings
                        {
                            _bid = true;         // buy
                            decideMarketOrLimit(p);
                        }
                        else
                        {
                            _bid = false;                             // sell
                            decideMarketOrLimit(p);
                        }
                    }
                    choice = true;
                }

                if (choice)
                {
                    // SingletonLogger.Instance().DebugLog(typeof(Agent1x0), "XXX I am "+this.ID+" time is "+Scheduler.GetTime() + " MAKING an order due to TIME flux / market = "+this._market);
                }
            }

            if (choice)
            {
                IncrementTotalOrders();
            }

            return(choice);
        }
Пример #11
0
        protected override double GetAskPrice()
        {
            double mean = (Orderbook.getNumAsks() > 0 ? Orderbook.getLowestAsk() : (Orderbook.getNumBids() > 0 ? Orderbook.getHighestBid() : Orderbook.getPrice()));
            double std  = Orderbook.getSpread();
            //std = 0.02;
            double price        = SingletonRandomGenerator.Instance.NextGaussianPositive(mean, std);
            double roundedPrice = Math.Round(price * 100.0) / 100.0;

            roundedPrice += 0.03;
            validateMetrics(7);
            SingletonLogger.Instance().DebugLog(typeof(Agent0x1), "I am " + this.ID + " GetAskPrice: " + roundedPrice + " -- price = " + price + " ; mean = " + mean + " spread = " + Orderbook.getSpread());
            return(roundedPrice);
        }
Пример #12
0
        protected override double GetAskPrice()
        {
            double logNormal    = getLogNormal();
            double price        = Orderbook.getHighestBid() + logNormal + _optimism * Orderbook.getPrice();
            double roundedPrice = Math.Round(price * 100.0) / 100.0;

            return(roundedPrice);
        }