Ejemplo n.º 1
0
        protected double determinePurchaseQuantity(Market bazaar, String commodity_)
        {
            var mean          = bazaar.getAverageHistoricalPrice(commodity_, _lookback); //double
            var trading_range = observeTradingRange(commodity_, 10);                     //Point

            if (trading_range != null)
            {
                var favorability = Quick.positionInRange(mean, trading_range.x, trading_range.y);            //double
                favorability = 1 - favorability;
                //do 1 - favorability to see how close we are to the low end

                double amount_to_buy = Math.Round(favorability * _inventory.shortage(commodity_));            //double
                if (amount_to_buy < 1)
                {
                    amount_to_buy = 1;
                }
                return(amount_to_buy);
            }
            return(0);
        }
Ejemplo n.º 2
0
        protected double determineSaleQuantity(Market bazaar, String commodity_)
        {
            var mean          = bazaar.getAverageHistoricalPrice(commodity_, _lookback); //double
            var trading_range = observeTradingRange(commodity_, 10);                     //point

            if (trading_range != null && mean > 0)
            {
                var favorability = Quick.positionInRange(mean, trading_range.x, trading_range.y);           //double
                //position_in_range: high means price is at a high point

                double amount_to_sell = Math.Round(favorability * _inventory.surplus(commodity_));             //double
                amount_to_sell = _inventory.query(commodity_);
                if (amount_to_sell < 1)
                {
                    amount_to_sell = 1;
                }
                return(amount_to_sell);
            }
            return(0);
        }