VTF – Signs And Quote Data

I said I’d fix all the quoteboard signs, and I did – took a bit of work since I had to do all the contract names and the months (for futures), but it was worth it. Here’s the final result:

Note the visual “weight” is all consistent now. I love the results! Not displaying months yet, but they’re done and look good too.

I also figured out how to implement a “style” layer for colors on the different columns, which allows me to do different things per display element.

Multi-color! Looking pretty good – and necessary for some elements I’ll be displaying, like volume.

A quoteboard is useless without data. I’ve been displaying the same test string over and over just to get the sprite drawing done right, but now its time to get the real deal. I’m doing something a bit unorthodox, since Teardown doesn’t allow you to do direct file read/writes. (For security purposes, which I understand.)

Funny thing, while I was working on this I realized that some of the quote data I wanted to display would take one more column to do so. I’m glad I caught that early, because it would’ve been painful to rework all the boards later on when they had surrounding structures and things. Its always the details that bite you if you’re not careful.

This will probably take more than one post, but I wanted to outline my meandering path towards figuring out how to get some data to display on the boards. As I mentioned, my method for importing data into Teardown is unorthodox, since I’m doing an “out-of-band” method to encode data into vox models.

So, where to get data?

My first thought was using some publicly available services that have some limited free data, using an API (Application Programming Interface) key. I futzed around with a few, but that approach rubbed me the wrong way because it seemed really easy to run up against their query frequency limits.

I wasn’t trying to do anything TOO crazy, but even a moderate polling interval would make it so I’d run up on their limit, and encroach into territory that required paid services. I’m sure that design decision was intentional on their part – not that I blame them, really.

While doing quote source research I realized the big “SPOOOOS” contract had been delisted at the CME. They started trading on April 21st, 1982 and were delisted in September 17th, 2021 – a total of 39 years! I was present on the floor for some of those years, so that hit me pretty hard. I guess the E-Mini was more popular, since its still active. Rest In Peace, spoooos! (We called them that on the floor, probably because when it was september the contract month code is “U”, so SPU sounds like Spoooos.)

Finding ticker data sources is easy, the problem is whether you want to pay $1 – 2,000 USD (per year, about $100/mo) for a full range of data or scrape it from somewhere that has it already. Since this is a hobby project, I’m going to scrape some free sources instead. I need a combination of historical data – so I can get 24/hr and all-time highs and lows as well as current open/high/low/close stuff, and a method to get direct live quotes (semi-delayed is fine) for when I’m updating the boards in real-time mode.

One source I considered was Tradingview.

You know when you have what you think is a clear goal and you just need to achieve one more step? Well, I went down a total rabbit hole when it came to Tradingview and its streaming quotes. I found some Python code “in the wild” that allowed negotiating with their websocket to grab quotes – it was not-so-helpfully formatted like this:

~m~147~m~{"m":"qsd","p":["qs_ofmdqrghftjd",{"n":
"CME_MINI:ESM2022","s":"ok","v":{"volume":442387,
"lp_time":1648220119,"lp":4533.25,"chp":0.46,
"ch":20.75}}]}

All I cared about is getting the “lp” which was “last price” and the volume. Though the timestamp was helpful and the “chp” (Change percentage) and “ch” (Net change) was a nice added bonus. However, I needed more than just one instrument at a time, which required some more Python-ing.

More to come…

VTF – Quoteboard Fun

Initial plan was to make signs using Krita, a free graphics program, and import them into my favorite voxel editor to make them into voxel signs. Problem is, I really needed the resolution, so the voxel characters were too blocky and it really detracted from the legibility.

I ended up making a dynamic sign that reads from a tag on itself, then grabs the right image and displays it in-game, crisp and neat.

An early view of the initial prototype in the Teardown editor.
In-game view. Yes, the prices have nothing to do with the sign right now. Dynamic sign code works!

As I was working with the signs, I made a mistake in one area – see if you can spot it:

Yep, I didn’t pay proper attention to the font sizes when fitting them to the width of the sign. That will have to be changed! So, I reworked things. At least the dynamic part is working.
--- Contract Signs

local imagePath = "MOD/images/contract/"
local contractName = "Nil"
local screenHandle = 0

function tick()
    if contractName == "Nil" then -- Only firing once to not waste cycles
        screenHandle = UiGetScreen()
        contractName = GetTagValue(screenHandle, "name") -- picks up name=<contract name> in "tags" for the screen entity
    end
end

function draw() -- UI Stack
    UiTranslate(UiCenter(), UiMiddle())
    UiAlign("center middle")
    UiImage(imagePath .. contractName .. ".png")
end

The above is a snippet in lua of how I got that to work – trust me, I wouldn’t have used tick() if I had any other way — but it seems to work fine without performance hits.

Before balancing out the visual weight of the signs, it was time for more destruction testing. The signs I used were different than sprites, so I had to make another type of damage-detection to deal with them.

Fire tornado! That wasn’t made by me, its “BattleBob72” – If you have steam, here’s a link. Note how the signs deactivate and get removed. Exactly what I wanted.
Here’s a test I did with a pistol. Its fun destroying your own creation, so I don’t mind making things destructible/flammable.

That is it for now, more to come…