Ejemplo n.º 1
0
 // Gets the Kth most traded commodity in the last N trades made in the market
 public static int GetKthTradedComm(int numOfTrades, int k)
 {
     try
     {
         int[,] marketShare = DatabaseSocket.getMarketShare(numOfTrades);
         return(GetKthTradedComm(marketShare, k));
     }
     catch
     {
         return(-1);
     }
 }
        //The main trade function which goes over the Market Share and trades each commodity
        private void trade()
        {
            int n = DatabaseSocket.GetHistoryOfLastHour(false).Rows.Count;

            int[,] marketShare = DatabaseSocket.getMarketShare(n);
            Console.WriteLine("Market share of the last " + n + " trades : ");
            printMatrix(marketShare);
            for (int i = marketShare.GetLength(0) - 1; i >= 0; i--)
            {
                TradeComm(this._commodities[marketShare[i, 0]], marketShare[i, 1]);
            }
        }
Ejemplo n.º 3
0
        public void marketShare()
        {
            /*Transaction[] t = DatabaseSocket.getOurLastHistory();
             * foreach (Transaction item in t)
             * {
             *  Console.WriteLine(item.ToString());
             * }*/
            int[,] marketShare = DatabaseSocket.getMarketShare(1000);
            printMatrix(marketShare);

            //Console.WriteLine("Least Traded: " + Statistics.GetLeastTradedStock(marketShare));
            //Console.WriteLine("Most Traded: " + Statistics.GetMostTradedStock(marketShare));
        }
Ejemplo n.º 4
0
 // Calculates the average price of the given commodity based on its last N trades in the market
 public static double CalcAvgCommPriceByLastNTrades(int commID, int n)
 {
     Transaction[] lastNTransactions = DatabaseSocket.getPriceOfCommByLastNTrades(commID, n);
     return(CalcAvgCommPrice(lastNTransactions));
 }
Ejemplo n.º 5
0
 // Gets the least traded commodity based on the last N trades made in the market
 public static int GetLeastTradedComm(int numOfTrades)
 {
     int[,] marketShare = DatabaseSocket.getMarketShare(numOfTrades);
     return(GetLeastTradedComm(marketShare));
 }