Ejemplo n.º 1
0
        public object run(LogicProcess process)
        {
            bool            success  = false;
            IMarketResponse response = process.comm.SendSellRequest(process.price, process.commodity, process.amount);

            if (response.getType() == ResponseType.buySell)
            {
                success = true;
                MBuySell resp = (MBuySell)response;
                process.id = resp.getID();
            }
            next(process, success);
            return(response);
        }
Ejemplo n.º 2
0
        public override bool runAction(AlgoProcess list)
        {
            //Attempt to buy the commodity
            bool            success  = false;
            IMarketResponse response = list.comm.SendBuyRequest(list.buyPrice,
                                                                list.commodity, list.amount);

            //If buy request is succssful - update the buyRequestID of the list
            if (response.getType() == ResponseType.buySell)
            {
                success = true;
                MBuySell resp = (MBuySell)response;
                list.buyRequestID = resp.getID();
            }
            return(success);
        }
Ejemplo n.º 3
0
        public override bool runAction(AlgoProcess list)
        {
            if (list.buyRequestID == -1)
            {
            }

            IMarketResponse response = list.comm.SendSellRequest(list.sellPrice,
                                                                 list.commodity, list.amount);

            //Currently not in use, but might be useful
            if (response.getType() == ResponseType.buySell)
            {
                MBuySell resp = (MBuySell)response;
                list.sellRequestID = resp.getID();
            }
        }
Ejemplo n.º 4
0
        public bool runAction(AlgoProcess process)
        {
            //Get available amount from process
            IDictionary <string, int> userCommodities = process.agent.userData.getCommodities();
            string commodity = process.commodity.ToString();
            int    amount    = userCommodities[commodity];

            //Calculate the buy price:
            //currentAsk + priceBuffer
            int priceBuffer = -1;
            int currentBid  = 0;

            //Find currentBid by using the data from the AMA
            bool foundPrice = false;

            for (int i = 0; i <= 9 & !foundPrice; i++)
            {
                MQCommodityWrapper current = process.agent.commoditiesInfo[i];
                if (current.id == process.commodity)
                {
                    foundPrice = true;
                    currentBid = current.getBid();
                }
            }

            int price = currentBid + priceBuffer;

            //Send request
            bool            success  = false;
            IMarketResponse response = process.comm.SendSellRequest(price, process.commodity, amount);

            if (response.getType() == ResponseType.buySell)
            {
                success = true;
                MBuySell resp = (MBuySell)response;
                process.requestID = resp.getID();
            }
            return(success);
        }
Ejemplo n.º 5
0
        public bool runAction(AlgoProcess process)
        {
            //Calculate the buy price:
            //currentAsk + priceBuffer
            int priceBuffer = 1;
            int currentAsk  = 0;

            //Find currentAsk by using the data from the AMA
            bool foundPrice = false;

            for (int i = 0; i <= 9 & !foundPrice; i++)
            {
                MQCommodityWrapper current = process.agent.commoditiesInfo[i];
                if (current.id == process.commodity)
                {
                    foundPrice = true;
                    currentAsk = current.getAsk();
                }
            }

            //calculate price and amount
            double funds          = process.agent.userData.funds;
            double availableFunds = (int)((funds / 100) * fundsPercentage);
            int    price          = currentAsk + priceBuffer;

            int amount = (int)(availableFunds / price);

            //Send request
            bool            success  = false;
            IMarketResponse response = process.comm.SendBuyRequest(price, process.commodity, amount);

            if (response.getType() == ResponseType.buySell)
            {
                success = true;
                MBuySell resp = (MBuySell)response;
                process.requestID = resp.getID();
            }
            return(success);
        }