I'm working on an app for evaluating the products sold on a market in a videogame. The products can be bought for cheap and sold for expensive. I want to evaluate the best product to buy and sell, but this requires analyzing a few parameters.

The parameters I can get for each product are:

  • buy_summary
  • sell_summary
  • quick_status

buy_summary and sell_summary are the current top 30 orders for each transaction type.

quick_status is a computed summary of the live state of the product:

  • sellVolume and buyVolume are the sum of item amounts in all orders.
    • sellPrice and buyPrice are the weighted average of the top 2% of orders by volume.
    • buyMovingWeek and sellMovingWeek is the historic transacted volume from last 7d + live state.
    • sellOrders and buyOrders are the count of active orders.

More info bout the parameters: https://api.hypixel.net/#tag/SkyBlock/paths/\~1v2\~1skyblock\~1bazaar/get

So far what I've done is:

  1. divide sellMovingWeek and buyMovingWeek by 7, and then divide the result by sellVolume and buyVolume respectively to get if all the orders will be cleared in a day. Example: if I sellMovingWeek has a value of 70, and sellVolume has a value of 10 i would get (70/7)/10=1 this means that in 1 day approximately all orders for this item are cleared. A value of 2 would mean that in half of a day, all orders are cleared... This is done for all products. The name i gave this values are sellAvailability and buyAvailability.

  2. Get the money that the user has available to spend, and divide the cost of each item by the money to get how many he can afford.

  3. Multiply the amount of each product by the cost of each of them (might sound redundant but if my wallet contains 10 coins and a product costs 3, i would actually spend 9 coins, not all 10).

  4. Multiply the amount of each product by the price it is sold.

  5. Subtract the total cost price from the selling price to get the profit

  6. Normalize all the values so sellAvailability, buyAvailability and Profit have the same magnitud.

  7. I get the difference between sellAvailability and buyAvailability for each product

  8. Normalize the difference, average and profit to get them on the same order of magnitude.

  9. I calculate a product score based on a weighted average using the difference between availabilities, the average of availabilities and the profit.

This does not work because even tweaking the weights, i get products with high scores that would make someone go bankrupt. My major is not on economics and I guess that in that field there might be some formula that would solve my problem but after searching on internet i came emptyhanded and chatGPT didn't help at all. I wonder if any could come up with an algorithm get what product will give me the most profit taking in account the buying and selling volume.

My code looks like:

private void calculateButtonActionPerformed(java.awt.event.ActionEvent evt) {                                                
        float money;
        int ammount;
        //Obtain the values for money and ammount. If incorrect, set them to 0
        try{
            money = Float.parseFloat(moneyField.getText());
        } catch(NumberFormatException e){
            moneyField.setText(0+"");
            money = 0;
        }
        try{
            ammount = Integer.parseInt(ammountCombo.getSelectedItem().toString());
        } catch(NumberFormatException e){
            ammountCombo.setSelectedItem(0+"");
            ammount = 0;
        }
        
        //Calcular:
        //1) Cantidad que se puede comprar y clamp al valor de ammount
        //2) Multiplicar el clamped ammount por valor de compra
        //3) Multiplicar el clamped ammount por valor de venta
        //4) Obtener el revenue
        //5) Obtener el maximo de revenue
        //5.2) Obtener el maximo de diferencia y media
        //6) Obtener la diferencia de Availabilities y flipear el valor
        //7) Obtener la media de Availabilities
        //8) Normalizar los valores
        //9) Calcular score
        double maxRevenue = 0;
        double maxDifference = 0;
        double maxAverage = 0;
        double[] revenue = new double[tabla.length];
        //for para calcular revenue y obtener el max
        for(int i = 0; i<tabla.length; i++){
            //1) Cantidad que se puede comprar y clamp al valor de ammount
            int buyingAmmount = calculateAmmountAndClamp(ammount, money, Float.parseFloat(tabla[i][2].toString()));
            //2) Multiplicar el clamped ammount por valor de compra
            double buyingCost = buyingAmmount*(Double.parseDouble(tabla[i][2].toString()));
            //3) Multiplicar el clamped ammount por valor de venta
            double sellingCost = buyingAmmount*(Double.parseDouble(tabla[i][4].toString()));
            //4) Obtener el revenue
            revenue[i] = sellingCost-buyingCost;
            //5) Obtener el maximo de revenue
            maxRevenue = Math.max(maxRevenue, revenue[i]);
            //5.2) Obtener el maximo de diferencia y media
            maxDifference = Math.max(maxDifference, Math.abs(Double.parseDouble(tabla[i][1].toString())-Double.parseDouble(tabla[i][3].toString())));
            maxAverage = Math.max(maxAverage, (Double.parseDouble(tabla[i][1].toString())+Double.parseDouble(tabla[i][3].toString())/2));
        }
        //for para calcular las diferencias, medias de availabilies, normalizar y calcular el score
        for (int i = 0; i < tabla.length; i++) {
            //6) Obtener la diferencia de Availabilities
            double difference = Math.abs(Double.parseDouble(tabla[i][1].toString())-Double.parseDouble(tabla[i][3].toString()));
            difference = maxDifference-difference;
            //7) Obtener la media de Availabilities
            double average = (Double.parseDouble(tabla[i][1].toString())+Double.parseDouble(tabla[i][3].toString()))/2.;
            //8) Normalizar los valores
            System.out.println("\nDifference: "+difference+" Average: "+average+" Profit: "+revenue[i]);
            difference = scaleValue(difference, maxDifference, maxRevenue);
            average = scaleValue(average, maxAverage, maxRevenue);
            
            //9) Calcular score
            tabla[i][5]=difference*availabilityDiffereneWeight+average*availabilityAverageWeight+revenue[i]*profitWeight;
            System.out.println("Difference: "+difference+" Average: "+average+" Profit: "+revenue[i]+"Score: "+tabla[i][5]+"\n");
        }

And a pic of the table:
enter image description here

0

There are 0 best solutions below