https://blog.polygon.io/open-source-ticker-tape-29fce03d3f66?gi=64bac086efb3 polygon.io Sign in polygon.io Open Source Ticker Tape Quinton Pike Quinton Pike Follow Nov 15 * 6 min read [1] About a year ago we had the crazy idea: let's put a Wall St.-like ticker tape on top of our office building. At Polygon.io we provide market data for developers, so it seemed a perfect fit. After getting quotes from several companies who provide such services north of $140k, plus licensing the software to run it, we were dead in the water. But we did create a rendering of what it would look like for city approval: Rendering of our office building with the ticker display installed. Rendering of our office building with the ticker display installed. Rendering of our office building with the ticker tape installed. After much discussion, we asked ourselves if we could make one using commodity hardware and open-source software. Use cheap computers (raspberry pis?), normal computer screens and we have all the stock data we could possibly need. We decided to pilot the idea on the inside of the office since outdoor hardware would take additional research. Project Goals: * Use commodity hardware Specialty hardware for these types of setups costs a ton of money. We should be able to use any computer to run this. No dot matrix displays, and no crazy graphics cards. * Cross-platform We mainly use Macs at Polygon.io and we would probably run these on some Linux distro. Making it cross-platform would make dev life easier, as well as broaden the use cases. Linux, Mac, x86, ARM, it shouldn't matter. * Horizontally Scalable This is a big one. Most ticker tapes are run by a single beefy machine with specialty gfx card(s). We wanted the ability to keep adding screens as we needed, so this would be a distributed system running on many machines. * Open Source Not only did we plan to use open-source tools and software, we also wanted to open-source the project. Most of the things we write at Polygon.io use Go, so naturally, we decided to use that. Challenges: We knew starting out that a big challenge of the project was going to be the synchronization of elements between displays. This was going to be a distributed system, and each display is an independent machine. But, the tickers must scroll across all the displays as if it were one. And since the entire project is around the visual display of information, it would be immediately noticeable and jarring if it's not working properly. We thought of a couple of solutions, the first being that the leader would render frames for all followers and the followers would just receive that data and display it. This solution obviously wouldn't scale very well since the entire cluster would be dependent on the rendering power of 1 machine. It would require some kind of marshaling or streaming codec to get any kind of decent compression and performance over the network. Pass. The solution we settled on was to not do it.. kind of. Synchronization is hard, as we know from our experience with stock exchanges and precision time-stamping. What if we let the OS do it for us. Almost all machines already have an NTP set up to make sure their clocks are in sync. What if we just used the system clock as the basis for our rendering, so that as long as the machines' clocks are in sync, then the displays would be in sync. We achieved this by using the system's timestamp as the global offset of the ticker tape. This was a quite simple, yet elegant way to solve the problem. Tech stack: For rendering, we chose to use NanoVG, which is a 2d rendering library that interacts with OpenGL. This would allow us the portability we wanted, and a somewhat simple API for drawing. It is modeled after the HTML5 canvas API, so learning it wouldn't be too difficult and there are Go bindings for it. We tried several other projects, but this one was the winner. We would use gRPC between the machines to communicate, and there would be a leader/follower setup. We initially wanted to use UDP multicast for communication since that is heavily used in our industry and seemed like a good fit. However, after some deliberation, we decided not to. If this was to be open-sourced it would make it much more difficult for some users. Some networks wouldn't support it, and it can also be very dangerous if not configured properly. It should be as "plug and play" as possible. Hardware We wanted to avoid any specialty hardware for the project. So dot matrix displays were out. That left us with LCD panels, which are affordable and easy to source. For the office install, we chose LG signage monitors, which we got on eBay for a heavy discount. These have a small bezel so that there is a minimal gap between them. We wanted to use raspberry pis for the nodes. Although it worked fine running on a raspberry pi, making the wiring look nice and clean wasn't possible. Instead, we purchased some old used Dell OptiPlex 7040 machines for ~$100/ea. [1] [1] Computers running the ticker tape in office. All totaled, the hardware for the setup costs around $6,800 USD. Not exactly cheap, but much more affordable than the alternatives. We could have used more standard LCD displays, but it would have required more mounting, which was not fun. Software The ticker wall is compiled as a single binary cli. You can start a server/leader, or GUI(s) using the cli tool, as well as interact with a running cluster. You can change most settings in real-time like the color pallets, tickers, animation speed. ./tickerwall update --scroll-speed=10 --animation-duration=600 You can also make announcements, which we use to broadcast messages to the office when cool things happen. ./tickerwall announce "Big News!" --type=success --animation=bounce [1] [1] It runs on most machines we have tested it on. Mac on both Intel and M1 chips, Linux on x86 and ARM chips. It should work on Windows, but we do not have a machine to test it on. We have also tested it running on 6x Macbook Pros, and it worked without issue. So it should scale to that and beyond. [1] [1] For the office setup, we do not use any desktop environments. It's an ubuntu server minimal install with x11 installed. We have systemd units for x11 and the application. So when the systems are powered on, it comes up without any human interaction. Results This week was hack week at Polygon.io, where we spend 1 week working on a passion project, so it was the perfect time to finish this up and open source it. Below is a picture of the ticker tape in our office. It has been running without any issues so far, and turned out great. You can find more about the technical parts of the project on Github. [1] [1] polygon.io Built by Developers for Developers Follow 34 * Stocks * Open Source * Ticker Tape * Trading * Golang 34 claps 34 Quinton Pike Written by Quinton Pike Follow Founder and CEO at Polygon.io Follow polygon.io polygon.io Follow Our financial data platform provides developers with frictionless access to the most accurate historical and real-time data available. Follow Quinton Pike Written by Quinton Pike Follow Founder and CEO at Polygon.io polygon.io polygon.io Follow Our financial data platform provides developers with frictionless access to the most accurate historical and real-time data available. More From Medium How To: Connect to AMB-NET Ambrosus in Ambrosus Ecosystem [0] [0] Profiling In Unity Ben Pielstick [1] [1] Optical Character Recognition (OCR) with less than 12 Lines of Code using Python Hucker Marius in Towards Data Science [1] [1] Coding Chronicles-5 Shelby Gottschall [1] [1] So...who gets the cake, and what do we eat? Two stories of time, order, and consensus Aashray Anand [0] [0] Microservices and how to analyse them Andras Gerlits in ITNEXT [1] [1] How to write beautiful python code. prakshaal jain in Analytics Vidhya [0] [0] Just Fluent 4.0: Manage Database Connections and Decode SQL Queries in Swift Maulik Shah [1] [1]