A viral tweet has the trading community buzzing: A trader connected his Zerodha portfolio to his bedroom lights, turning them green when in profit and red during losses

It started with a tweet that got 3,87,000 views in 48 hours.
“My Zerodha stock portfolio now controls my bedroom lights. It turns red when I lose money,” posted Pankaj (@the2ndfloorguy) on November 3, 2025.
The images showed a pink-lit bedroom wall and a Raspberry Pi on his desk. Simple hardware. Simple idea. Massive impact.
Even Nithin Kamath, Zerodha’s CEO, couldn’t help but respond: “This has to be the most unique use case for Kite APIs.”
The concept is dead simple: your portfolio’s profit and loss controls LED lights in your room. Green when you’re winning. Red when you’re losing. A physical reminder of how the market treats you.
Here’s how you can build one yourself this weekend using openalgo with your own broker.
What You Need
There are two ways to do this, depending on your budget and technical comfort.

Budget Option: Rs 500 (if you have a Raspberry Pi)
- Raspberry Pi (any model, even Pi Zero W works)
- 2 LEDs (one red, one green) – Rs 100
- 2x 220 Ohm resistors – Rs 20
- Jumper wires – Rs 50
- OpenAlgo installed with API key
Premium Option: Rs 6,000 to Rs 8,000
- Philips Hue Bridge – Rs 4,000 to Rs 5,000
- Philips Hue Color Bulb – Rs 2,000 to Rs 3,000
- Any computer (Windows/Mac/Linux)
- OpenAlgo installed with API key

The Raspberry Pi route is cheaper and gives you that hacker aesthetic with exposed wires and blinking LEDs. The Philips Hue route is cleaner and wireless, but costs more.
Why OpenAlgo Instead of Direct Broker APIs
Pankaj’s original setup works only with Zerodha’s Kite Connect API. But what if you trade with Dhan, Fyers, Angel One, Upstox, or any other broker?
This is where OpenAlgo becomes useful. It’s an open-source platform that connects to 24+ Indian brokers through a single unified API. Write your code once, and it works regardless of which broker you use.
Same code. Different brokers. No rewrites needed.
OpenAlgo runs locally on your device. Your data never leaves your computer. No cloud dependencies. No subscription fees beyond what your broker charges for API access.
The Setup: Raspberry Pi Version
Step 1: Wire Your LEDs
Connect your LEDs to the Raspberry Pi’s GPIO pins:
- GPIO 17 (Physical Pin 11) connects to Green LED through a 220 Ohm resistor
- GPIO 27 (Physical Pin 13) connects to Red LED through a 220 Ohm resistor
- Both LED negative legs connect to Ground (GND)
The long leg of each LED is positive. The short leg is negative. The resistor prevents the LED from burning out.
Step 2: Install Software
Open terminal on your Raspberry Pi:
sudo apt update
pip3 install openalgo RPi.GPIO --break-system-packages
Step 3: The Python Script
Create a file called portfolio_light.py:
from openalgo import api
import RPi.GPIO as GPIO
import time
RED_PIN = 27
GREEN_PIN = 17
GPIO.setmode(GPIO.BCM)
GPIO.setup(RED_PIN, GPIO.OUT)
GPIO.setup(GREEN_PIN, GPIO.OUT)
client = api(
api_key="your_openalgo_api_key_here",
host="http://127.0.0.1:5000"
)
def update_light():
try:
response = client.funds()
# Get realized and unrealized P&L
realized = float(response["data"]["m2mrealized"])
unrealized = float(response["data"]["m2munrealized"])
total_pnl = realized + unrealized
if total_pnl > 0:
GPIO.output(GREEN_PIN, GPIO.HIGH)
GPIO.output(RED_PIN, GPIO.LOW)
print(f"Profit: Rs {total_pnl:.2f} | GREEN")
elif total_pnl < 0:
GPIO.output(GREEN_PIN, GPIO.LOW)
GPIO.output(RED_PIN, GPIO.HIGH)
print(f"Loss: Rs {total_pnl:.2f} | RED")
else:
GPIO.output(GREEN_PIN, GPIO.LOW)
GPIO.output(RED_PIN, GPIO.LOW)
print("Breakeven | OFF")
except Exception as e:
print(f"Error: {e}")
print("Portfolio Light Controller is running")
try:
while True:
update_light()
time.sleep(10)
except KeyboardInterrupt:
GPIO.cleanup()
print("Stopped")
Step 4: Run It
python3 portfolio_light.py
That’s it. Your LEDs now reflect your portfolio status every 10 seconds.
The Setup: Philips Hue Version
If you prefer smart bulbs over DIY electronics, here’s the Philips Hue approach.
Step 1: Setup Hue Hardware
Connect your Philips Hue Bridge to your Wi-Fi router. Install the bulb. Open the Hue app and complete the setup. Note your bridge’s IP address from the app settings.
Step 2: Install Software
On your laptop or desktop:
pip install openalgo phue
Step 3: The Python Script
Create portfolio_hue.py:
from openalgo import api
from phue import Bridge
import time
b = Bridge("192.168.1.2") # Replace with your bridge IP
b.connect()
lights = b.get_light_objects('name')
light = list(lights.values())[0]
client = api(
api_key="your_openalgo_api_key_here",
host="http://127.0.0.1:5000"
)
def update_light():
try:
response = client.funds()
# Get realized and unrealized P&L
realized = float(response["data"]["m2mrealized"])
unrealized = float(response["data"]["m2munrealized"])
total_pnl = realized + unrealized
if total_pnl > 0:
light.xy = [0.17, 0.7] # Green
light.brightness = 254
light.on = True
print(f"Profit: Rs {total_pnl:.2f} | GREEN")
elif total_pnl < 0:
light.xy = [0.7, 0.29] # Red
light.brightness = 254
light.on = True
print(f"Loss: Rs {total_pnl:.2f} | RED")
else:
light.on = False
print("Breakeven | OFF")
except Exception as e:
print(f"Error: {e}")
print("Hue Portfolio Light is running")
try:
while True:
update_light()
time.sleep(10)
except KeyboardInterrupt:
print("Stopped")
Step 4: Run It
python3 portfolio_hue.py
The first time you run this, press the button on your Hue Bridge to authorize the connection.
How It Works
Both scripts follow the same logic:
- Connect to OpenAlgo using your API key
- Fetch your portfolio data using
client.funds() - Extract total profit and loss from the response
- If profit is positive, turn the green light on
- If profit is negative, turn the red light on
- Wait 10 seconds and repeat
Alternatively client.holdings() method can returns your complete portfolio summary including total P&L across all holdings. This single number determines your room’s color.
The script checks your portfolio every 10 seconds. You can adjust this by changing the time.sleep(10) value. Faster updates mean more API calls. Slower updates mean less real-time feedback.
Multi-Broker Support
The advantage of using OpenAlgo is flexibility. The same script works with:
- Zerodha
- 5paisa
- Dhan
- Angel One
- Upstox
- Fyers
- Firstock
- 5Paisa
- Finvasia
- Shoonya
- Plus 14 more brokers
You don’t rewrite code when you switch brokers. You just reconfigure OpenAlgo to connect to your new broker. The Python script stays identical.
This is particularly useful for traders who maintain accounts with multiple brokers. You can even aggregate P&L across all accounts by modifying the script to query multiple OpenAlgo instances.
Beyond the Novelty
What started as a weekend hack has genuine psychological implications for trading behavior.
Constant portfolio checking creates stress. Opening your app every five minutes to watch numbers fluctuate often leads to impulsive decisions based on short-term noise.
This ambient lighting system provides passive awareness without active engagement. Your peripheral vision registers the room’s color. You know your portfolio status without obsessively checking it.
But as an experiment in how digital data can manifest in physical space, it’s undeniably interesting.
What You Need to Get Started
Before you can run either script, you need:
1. OpenAlgo Installed
Download and install OpenAlgo on your local machine. Visit openalgo.in for installation instructions.
2. Broker API Access
Your broker must support API access. Zerodha’s Kite Connect costs Rs 2,000 per month plus taxes. Other brokers have different pricing. Some offer free API access.
3. OpenAlgo API Key
After installing OpenAlgo, log in and generate an API key from the dashboard. This key authenticates your Python script.
4. Active Broker Connection
Connect your broker to OpenAlgo through the web interface. You’ll need your broker’s API credentials.
Once these prerequisites are met, the hardware setup takes 30 minutes at most.
The Bigger Picture
This project represents something larger than just a novelty light show. It’s an example of how traders are taking control of their technology stack.
For years, retail traders in India relied entirely on broker-provided platforms. No customization. No automation. Limited flexibility.
The rise of broker APIs changed that. Traders could now build custom tools, automated strategies, and personalized interfaces. But each broker had different APIs with different documentation and different quirks.
Platforms like OpenAlgo solve this fragmentation. A unified layer that works across brokers. Code once, deploy anywhere.
This bedroom light project is a simple demonstration of that principle. The same 30 lines of code work whether you’re with Zerodha, Dhan, or any of 22 other supported brokers.
As more traders discover these tools, expect to see increasingly creative applications. Portfolio lights are just the beginning.
Resources
OpenAlgo
- Website: https://openalgo.in
- Documentation: https://docs.openalgo.in/trading-platform/python
- GitHub: https://github.com/marketcalls/openalgo
- Discord Community: https://openalgo.in/discord
Hardware
- Raspberry Pi: Amazon.in, Robu.in, KitsGuru
- Philips Hue: Amazon.in, Flipkart
Source Code Both scripts are provided in full in this article. Copy, paste, and run.