I am having the same issue. It was working fine for an extended period of time and I have unlocked 10+ markets. However, I am no longer able to purchase a chunk with a market. It also crashes when I filter the trades with the buy/sell option in the menu. I looked into the tradeOverview.refresh function. It appears that itemToGive of some of the trades are not present in the itemValues. I did not feel up to reading through the whole itemValues.lua tonight but at first glance it appear the registerAll function has errors. I have included the log dump of my itemValue table at time of the crash. I edited out most of the function references but left the registerAll in as it has errors in it. The itemValues table only has the raw materials entries in it which I assume is the issue. Hope this helps.
I appreciate your investigation on the issue. That's actually not the reason for the crash. itemValues has a function in it, so it cannot be saved in global. This is why control.lua puts the item value entries into global as global.itemValues, without the function. So, global.itemValues is populated correctly, and each time you load up a save, the original itemValues (which contains the function) is reset and only contains the raw materials, but that's irrelevant because the save uses global.itemValues which was calculated at the start of the game to then be reused forever. Moreover, if you run the command /item-values, it will print all calculated item values, overflowing the chat history. You can also check a specific item's value with /item-value <item>, or see help on the command with /help item-value.
The error more likely comes from other things not being cached correctly with global. I do not know exactly why you can't buy some markets yet, but I did very recently find a bug on my own where loading a save can make the trade overview filtering crash the game, even though it doesn't if you play the save all the way through without closing and reloading. This is something I'm currently fixing, and it will be released in 0.0.7.
Hopefully I can catch the bug for why market purchases still crash the game before too long. If not, I may need your help, perhaps your save specifically, to determine what weird edge case is going on. Thank you for your report! For easier communication, you can join my Gridtorio Discord server at https://discord.gg/huJY7QK6UG.