23 Jan 2013

Stocker – Arduino Stock Market Tracking Lamp

*** Click for Build Instruction and Code

23 Jan 2013

*** Click for Build Instruction and Code ***

Pronounced Stalker, Stocker is a USB Arduino lamp which changes colors depending on the state of the stock it’s tracking.

Using the desktop application we enter a stock or indices to monitor and from there the app checks the market every minute and change the lamp color accordingly.

Here is a video of Stocker in action.

Stocker is controlled via Processing and Firmata and uses Google API to obtain stock data.

Here is an example of API URL to check Apple stock.



The device portion of this project consists of a USB powered Arduino UNO and a homemade RGB LED shield.


Lamp cover was made ofย  some spare acrylic heated and shaped into an arc. The texture was achieved by creating bubbles in the surface using a heat gun.


If you have any questions or want instructions on how to build your own Stocker leave me a comment and I’ll post schematic and code.

Leave a comment
More Posts
  1. Sam January 24th, 2013 9:40AM

    I’m interested in taking a look and learning from your Processing code ๐Ÿ˜‰

    • Kohani January 24th, 2013 12:56PM

      Great! I’ll post it.

  2. Alan January 24th, 2013 5:58PM

    As someone who tracks more than one stock, I’d be interested in the code – but I’d need to modify it.
    Software like FCharts can add green (or red) indicators. It can also set up conditions using daily, weekly etc. moving averages – and make a list of stocks matching these conditions.
    If I had a set of 3 (or more) “buy” conditions, I’d want 3 (or more) green LEDS – and a display telling me which stock meets my conditions.

    • Kohani January 25th, 2013 1:30AM

      Sounds interesting. There are six PWM pins on the Arduino UNO so I think you are good to go.

  3. rolls January 24th, 2013 8:41PM

    Can you please give a description of what software you needed on the PC and how you controlled the Arduino UNO with Processing. Also please provide the schematic.

    • Kohani January 25th, 2013 1:55AM

      I’ll post more details as soon as possible but in a nutshell Arduino interprets Serial data from Processing to control pins. This is made possible with the aid of processing.serial, and cc.arduino libraries in Processing and Frimata on Arduino.

  4. Ben January 24th, 2013 11:07PM

    This is a neat project, but the API link you provided above is for iGoogle, which is scheduled to be taken down at the end of this year, so you might need to find an alternate data source.

    • Kohani January 25th, 2013 2:17AM

      Thank you. Many of the stock feeds I came across were paid or did not support xml. To keep things simple for the prototype I decided to use iGoogle. Let me know if you good source for stock data.

  5. brian January 25th, 2013 3:24AM

    Yahoo finance is very easy to use from scripts. Try googling for yahoo finance csv/yql/historical csv and you’ll get hits in practically any programming language your heart desires.
    These are the common ones:
    CSV Intraday quotes ~15 mins delayed
    CSV Historical quotes # end of day quotes, updated ~8pm EST M-F
    YQL quotes (IMO easier-to-use alternative to CSV intraday, returns json or xml)
    With enough digging you can get almost-real-time quotes for free from yahoo (1-2 mins delayed). It’s practically undocumented and I’m sure what their TOS is regarding its use, however. Firebug to the rescue! ๐Ÿ˜‰

  6. brian January 25th, 2013 3:51AM
    import sys
    import urllib
    import urllib2
    properties = [
                # delayed quote properties
                # WARNING: quote properties will return None from very early morning EST until market open
                'BidRealtime',        # delayed ~15 minutes
                'AskRealtime',        # delayed ~15 minutes
                'LastTradeDate',      # delayed ~15 minutes
                'LastTradeTime',      # delayed ~15 minutes
                'Open',               # delayed ~15 minutes
                'DaysHigh',           # delayed ~15 minutes
                'DaysLow',            # delayed ~15 minutes
                'LastTradePriceOnly', # delayed ~15 minutes
                'Volume',             # delayed ~15 minutes
                'PercentChange',      # delayed ~15 minutes
    def get_yql_url(yql):
        base_url = 'http://query.yahooapis.com/v1/public/yql'
        query = urllib.urlencode({
            'q': yql,
            'env': 'store://datatables.org/alltableswithkeys',
            'format': 'xml' })
        return ''.join([base_url, '?', query])
    def download_xml(symbols):
        if not isinstance(symbols, list):
            symbols = [symbols]
        ret = {}
        yql = 'select %s from yahoo.finance.quotes where symbol in (%s)' % (
            ','.join(['"%s"' % symbol.upper() for symbol in symbols]))
        url = get_yql_url(yql)
        data = urllib2.urlopen(url).read()
        return data
    if __name__ == '__main__':
        if len(sys.argv) > 1:
            symbols = [symbol for symbol in sys.argv[1:]]
            print download_xml(symbols)
            print 'Usage example: python yql.py goog, amd, aapl'

    Save to yql.py and use like so:
    python yql.py goog > google.xml
    python yql.py goog, aapl, rimm > goog_aapl_rimm.xml
    Sorry I don’t have parsing code; I much prefer JSON personally.

    • Kohani January 25th, 2013 4:37AM

      Thank you. This is great!

  7. brian January 25th, 2013 4:01AM

    Seems your wordpress code block is broken so indents don’t work :(
    Working code: https://www.dropbox.com/s/auek6pd15jgl87i/yql.py

    • Kohani January 25th, 2013 4:51AM

      Awesome! Thank you sharing the code.

      Swapped out “code” for “pre” and it looks like it’s working. I think “pre” is required for multi line code.

      • brian January 25th, 2013 4:25PM

        Nice! The code on dropbox had some bugs anyway. Oops. Tip: you can use “select * from …” to download all the properties Yahoo offers.

      • brian January 25th, 2013 4:39PM

        Actually, would you mind testing out the property “AfterHoursChangeRealtime” around the appropriate times of day next week and post back if it works?

        • Kohani January 27th, 2013 2:05PM

          Thanks. Will see what I can find.

  8. Jack Smith January 27th, 2013 11:42AM

    Love the idea- My Apple stock is falling and I need to watch it.
    Please send the “prints”

    • Kohani January 27th, 2013 2:06PM

      Thank you Jack. I will be posting more details soon.

  9. Kohani January 30th, 2013 9:06PM

    Here is a link on how to build your own Arduino Stocker. http://alirezakohani.com/building-stocker/


  1. Stocker monitors the markets
  2. Stocker monitors the markets | Daily IT News on it news..it news..
  3. Stocker, Arduino Stock Market Tracking Lamp to monitor your investments | Gizmo Chunk
  4. Stocker monitors the markets / Cooking Hacks Blog