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…

VTF – Furnishings And Destruction

After getting all the sprites working for different orientations on the quoteboards, it was time to turn to filling in the floor with authentic props, at least partially.

See! No rain, but some of my temporary measuring tools like that striped stick. The floor is supposed to resemble the raised-dot pattern used on high-wear surfaces at the exchange.
Frontal view, the contrast of the sprites on the quoteboard is pretty obvious here, but the lighting won’t be anywhere near full noon when the environment is fully built out.
Getting the vertical offsets right. The purple was lifted directly from images of the CME floor from the time period I’m modeling. The floor booths indeed looked like this, with carpet inserts, grey metal and plastic framing.

I ended up reworking these pieces so they were more modular – then I could import them into the editor and piece together what I needed. Making large format models sometimes makes sense, but not in this case. Also its easier to make changes when you only have a few components to edit.

Floating quoteboards, booth stands and a inset octagonal trading pit, which took longer to build than I care to admit. The sub-flooring also has a full metal support structure just like the real trading floor did.

As I was building (and destroying, as this game fully allows) I realized I needed a system to detect that damage so the sprites weren’t just floating in the air if they got destroyed by any projectiles or fire. One thing about this game, the fire simulation and smoke physics are top-notch.

Just a touch ‘o fire, to test the sprites winking out of existence. Pretty cool.

As you can see from the video, I got some of the lights defined and glowing, but no specific sources set yet. Things tend to lag when a lot of point sources are added, so I’ll just add the minimum to give it some presence. I may add some slight highlights for the sprites as well so they’re captured in reflections from the ground plane.

Next up, dynamic signs so I can label the columns with the proper instrument name.

More to come…

Virtual Trading Floor – (Cont.)

More pictures and design elements that went into this project:

An electronic flipdot display shows current prices for Cattle Futures at the CME on November 18, 2004. (Photo by Frank J Polich/Bloomberg via Getty Images) – Note it is only five columns wide, which means the leading numbers for some prices – the “handle” – get dropped.
Each display unit is 7 pixels high by 5 wide, which is easier to see in this cropped photo.

One thing they don’t tell you about older displays like flipdots is the sound they make. When a whole series of them are moving, its like something between the murmur of a crowd and the shuffling of cards. A bit “zen”, I think. Sitting on the trading floor after close with nothing but the large clock whuff-whooshing each digit into place, it was a peaceful contrast to the usual activity on the floor.

First attempt at animating the flipdots virtually using my model. Needs finesse, especially some variation when the dots start and a bit of “shimmer” when they settle against their range of motion.

Some views of the trading floor and its displays were difficult to find. Most pictures focus on the open outcry pits, where all the action is, but not many are taken of the quoteboards which were my primary focus. I was beyond happy to find this one, I couldn’t recall the exact wording of some of the legend that was displayed at the edges of the boards, so this photo helped immensely.

The Open, Range, High, Low bit at the right of the quoteboard is what I needed.

To get data into the game, I decided to make a physical model that resembled a server cabinet, with ventilation slots and a mounting rail for the memory modules (vox models) that I would be spawning and reading from. This version doesn’t have any indicator lights — which I plan to add to show new modules updating and being read. Everyone loves blinkenlights, right? I do.

In game data server cabinet, with a few modules spawned to see how it all fit. Glass door, which is breakable in the game, but the modules and cabinet aren’t so easy to destroy.

One of the hard parts was figuring out the X, Y, Z coordinate offsets so I could spawn those properly in the cabinet. I solved this by making a system based on static location markers. I ended up using the same system to draw sprites on the quoteboards themselves, although not everything would go to plan — some early shots/debug:

Too far back, and squished together.
Aww look, the numbers are hiding! No no no…
Better, right? Nope – the numbers are in reverse order vertically.
First test to get rotations right, that nearly melted my brain. Especially when you consider I’m making a grid of sprites offset horizontally/vertically for the whole board. If you wonder about the rainy environment, I just like the sound when I’m working.
Quoteboards working in all four cardinal directions, which was no small feat. Remember, there’s a whole grid of coordinates being calculated for each slot on the board, including the offsets which change if the board itself is oriented differently. Don’t you dare ask about doing 45-degree angles, lol.

Its a learning process. Working through this got me deep into Three-Dimensional arrays, which honestly aren’t tough to visualize, but a bit harder to debug since you’re dealing with three indexes at the same time.

More to come, documenting continues…

Teardown – Virtual Trading Floor

I’ve been messing with this game “Teardown” that uses little 3D cubes called “voxels” to build objects and terrain.

When I started, there were only two editors that would build things for it, and I wanted to understand it better – so I dove into some tools to see what makes the .vox file format tick.

I finally found some code that I could adapt – in python – so I’ve been working on making that work. If I had the ability to create .vox files programmatically, then I could do nearly anything and automate it – instead of doing things by hand. (Although I still do from time to time.)

I’m at the point where I can create my own .vox models and import them into the game, purely with code. This is awesome. But so what? you may ask.

I’ve been wanting to recreate a small part of the open-outcry trading floor environment that I used to work in long ago. I started with the idea of having the quoteboards first.

That’s nice, but they were circa 2008, so they didn’t use LEDs. They were flipdots. These are small discs that are switched or ‘flipped’ on a side with an electromagnet.

So they have particular characteristics and I’ve been working on making that happen. I made a model in a 3D editing program that I can drive with code to flip the correct dots for a given number or letter.

Some script and the flipdot model – lots commented since I’m experimenting

The only other problem is that the game doesn’t allow you to read local files or write them. This is mostly a security thing, because they allow mods to be made for their game and if they allowed a mod to have file access — some bad actors could do nasty things like wipe your drive or overwrite something important.

This means that the data needed to drive my quoteboards – which would be contract, price, etc couldn’t just be read in using a text file.

So the next step is to make a web-scraper in python, (I’ve done it before, so it isn’t too hard.), then have my voxel writer encode the numeric/character data into color values.

In the ASCII table – there’s a decimal number for each character and number. This works for me, because colors can range from 0 – 255 and the table itself only goes from 0 – 127.

That’s including a bunch of special characters I may not need, but why not.

So, if I were to encode something like a contract symbol ‘SPH2’S&P500 Futures March 2022 futures contract — It would look like this in ASCII — 83, 80, 72, 50

In a color it would be Vec(83, 80, 72) one color and then Vec(50, 0, 0) for the next

Obviously I’d pack these together with delimiters so I could strip out the data again, so ideally it would be like — :SPH2: — using colons to separate things.

Point being, I’ll be able to scrape a website/datafeed, get the quotes, and encode it into R,G,B colors and write a voxel model that I can import into the game and ‘read’ the data from it.

Flipdot numbers, modeled after the character set in use on the trading floor, circa 2008. The zero is intentionally offset to prevent visual confusion with the character “O”

More to come, just getting started…