PineJam 2025 is starting soon!
185 downloads 752 views Jul 7, 2024
profile

Stock Display by Octo

project thumbnail

Display real world stock values

Using Yahoo Finance API.

How it works:

  • Automatically download the display lib from Github, allowing us to have an improved resolution for display, but comes with some drawbacks.
  • Registers the script to startup, so it will start automatically with the computer (and so also on world load).
  • Checks if you already have a stock selected to display. If not, it will prompt you to select one stock with an interval and range. It will then save it to a config file for later use. If you want to change the selection, you can do it by changing the local stocks array and deleting the config file selected_stock_config.json it it exist.
  • Fetches the current GMT real world time from the internet to later calculate market open and close.
  • Sets the display to an external monitor if possible.
  • Downloads and loads the stock data (in this step, we also remove empty values by discarding them).
  • Displays the graph and stock information based on the collected values.

Customization:

You can set the different stocks options to display as well as the colors at the start of the StockDisplay.lua file.

Stocks settings:

You can look in the URL of quotes selected from https://finance.yahoo.com/lookup and edit the following array.

local stocks = {{"AAPL","US"}, {"GOOGL","US"}}

Color settings:

You can set the colors of display from white, orange, magenta, lightBlue, yellow, lime, pink, gray, lightGray, cyan, purple, blue, brown, green, red, black by changing the following values:

local defaultTextColor = colors.white
local buyColor = colors.lime
local sellColor = colors.red
local backgroundColor = colors.black

Limitations:

  • Currently, the script can only display one stock per computer.
  • No axes are currently displayed on the graph.
  • Each candles represent the current non-null close value versus the previous non-null close value to avoid missing data points. So no 100% real world timeframe handling or accurate display.
  • Pixels may be missing on the graph due to computercraft ASCII character limitations.
wget run https://pinestore.cc/d/103
Git Repository
comments
You can login with Discord to leave comments and reply to others!
There are no comments yet