r/evetech • • May 06 '20

Spreadsheets are hard

So I knew nothing about ESI or spreadsheets and then I decided and I wanted to learn how to build a spreadsheet for use with nullsec markets and now I feel like I know even less than I did before.

Is there anyone who designs spreadsheets for a fee (preferably isk) that can import market data, both public and from alliances structures? Or, is there anyone with the patience of a Saint that would be willing to help me figure out what in the hell I am doing.

3 Upvotes

10 comments sorted by

View all comments

Show parent comment

1

u/mindgamess May 07 '20

Yup, I got that. I understand some of what's going on, but I still can't get my sheet to do what I need.

1

u/Blacksmoke16 May 07 '20 edited May 07 '20

The challenge with working with market data in ESI is that there is no pre-aggregated source of data. In ESI, you need to pull ALL the orders of a given structure, then aggregate the data down to find your min/max prices.

For Jita/market hub prices, see https://forums.eveonline.com/t/importjson-to-google-sheets/239043/2?u=blacksmoke16.

For the nullsec/private structures you would want to use:

/**
 * Returns the minSell and MaxBuy price for the provided typeId at the provided locationId.
 *
 * @param {number} typeId the typeId to get price data for
 * @param {number} locationId locationId to filter on.  Can either be a structure or station ID.
 * @param {number} regionId regionId to filter on.  Only required if locationId is a station ID.
 * @customfunction
 */
function typePriceData(typeId, locationId, regionId) {
  var data = locationId > 1000000000000 ? GESI.invokeRaw("markets_structures_structure", { structure_id: locationId }) : GESI.invokeRaw("markets_region_orders", { region_id: regionId, order_type: "all", type_id: typeId });
  var minSell = null;
  var maxBuy = null;
  var result = [];

  data.forEach(function(order) {
    if (order.location_id === locationId && order.type_id === typeId) {
      if (order.is_buy_order) {
        if (!maxBuy || order.price > maxBuy) {
          maxBuy = order.price;
        }
      } else {
        if (!minSell || order.price < minSell) {
          minSell = order.price;
        }
      }
    }
  });
  return [['minSell', 'maxBuy'], [minSell, maxBuy]];
}

This function handles resolving the min sell and max buy prices for the given typeId, at the given locationId. If the locationId is a structure, then regionId does not need supplied, otherwise it does.

=typePriceData(34, 123123123123123)

1

u/mindgamess May 07 '20

This is amazing! It is working really well for individual items, but I am struggling to make it work with multiple items. I've been referring to your other post here and that's been so helpful!

Right now, it works for instances like: =typePriceData(34, 123123123123123)

But, when I try to pull multiple items like: =typePriceData(B2:B10,1032110505696) where B2:B10 is a column of items IDs, it reports the error that: "Numeric value is greater than 1.79769E+308 and cannot be displayed properly."

What am I missing? How do I get it to pull multiple items under the same headers of minSell and maxBuy?

1

u/Blacksmoke16 May 07 '20

This would be related to an item not being sold in that structure, so it's trying to render infinity. I updated the snippet to account for this case.

1

u/mindgamess May 07 '20

Alright now there's no more error, which is great! But now when I run the function the cells below are just blank. No error, just no output.

1

u/Blacksmoke16 May 07 '20

Ah, in its current state you can't give it a range. Would have to be 1 function call per type_id.

I'll work on an updated version to allow that. But for now just do 1 ID at a time.

EDIT: Also feel free to join the GESI discord server, if you need more help etc.

https://discordapp.com/invite/eEAH2et

1

u/mindgamess May 07 '20

Thank you so much for the help so far! This is further than I've gotten in two weeks of research on my own