Entertainment Stock Performance Analysis of 2 Industry Giants with LightningChart Python Trader

Tutorial

Written by a Human

Develop an entertainment stock performance analysis of Netflix and The Walt Disney Company using LightningChart Python Trader.
Mikael Virtanen

Mikael Virtanen

Data Science Python Developer

LinkedIn icon
Entertainment-Stock-Performance-Cover

Introduction

This article demonstrates how to analyze the entertainment stock performance of 2 giants in the industry. The stocks included are Netflix (NFLX) and The Walt Disney Company (DIS). The stock data has been sourced from a Kaggle dataset and will be imported and pre-processed using the Pandas library.

The stocks will be compared using LightningChart Python Trader’s dashboard feature and analysed using several chart types. Charts used include common ones such as Candlestick and Line, but also less common ones such as Renko, Heiki nashi, and Kagi.

Datasets

The dataset in question is provided by Prathamjyot Singh.

Plotted Variables

    Python trader requires Open, High, Low, Close (O, H, L, C) values to work as well as a date. These values refer to the stock’s Highest and Lowest prices during the trading day, as well as what the price was at market open and close. Volume value is not required for the trader to work, but is needed for certain indicators.

    LightningChart Python Trader can read and process the data automatically if the fields (or in this case columns) are labelled correctly. In this case, the date and volume columns have names that work out of the box, but the OHLC values do not. They are named “Open Price”, “Low Price” etc, This needs to be changed, but luckily it is very easy to do.

    Libraries used

    • LightningChart Python
    • Pandas

    Pandas will be used to import data to the trader. This is done by reading the dataset values and importing them into a data frame, which can easily be worked with before visualization. Pandas might be preinstalled with the Python standard library. If this is not the case, simply run the following command in the terminal. Python Trader also needs to be installed.

    pip install pandas
    pip install lightningchart_trader

    LightningChart Python Trader

    LightningChart’s Python Trader (PT) provides extensive charting solutions with a high degree of customizability through its easy-to-use UI and built-in functionalities. Since the library is built for Python, it’s also possible to use other Python libraries if necessary.

    As with all Lightningchart products, Performance has been a high priority when developing the library, even when working with large amounts of data, thus removing possible bottlenecks in this area.

    Overview of the UI

    Stock-Market-Data-Visualization-with-Python-UI

    Above is the PT user interface with stock data charted using the default candlestick chart. On the top left are controls used to customize the chart and work with datasets. Here is the explanation for all the UI controls:

    Stock-Market-Data-Visualization-Python-UI-Controls-IMG

    Charting features

    These are chart types of Python trader provides out of the box.

    Stock-Market-Data-Visualization-with-Python-Chart-Types

    Chart types can be changed with the the UI or with the set_price_chart_type(chart_type) command. Available ones are ‘CandleStick’, ‘Bar’, ‘Line’, ‘Mountain’, ‘HeikinAshi’, ‘Renko’, ‘Kagi’, and ‘PointAndFigure’. For example, a mountain creating a mountain chart using the following methods:

    trader.set_price_chart_type('Mountain')
    trader.add_data_array(data)
    trader.open()
    Stock-Market-Data-Visualization-with-Python-Mountain-Chart-Example

    Chart visuals can be customized using the Python trader UI. Below are available settings for chart and indicator colours, background colour/image etc.

    Stock-Market-Data-Visualization-with-Python-Color-UI
    Stock-Market-Data-Visualization-with-Python-Background-UI

    Default chart colours.

    Stock-Market-Data-Visualization-with-Python-Default-Colors

    Background and indicator colours changed

    Stock-Market-Data-Visualization-with-Python-Background-Color-Options

    Chart customization

    Customisation can also be done with code, using the built-in methods. The code below changes the background image and the chart colours to the ones seen in the right image. But why use code for customisation, since working with UI is easier? 

    trader.set_color_theme('cyberSpace')
    # Changing the indicator colours for the candlesticks
    trader.set_positive_body_color('#0fdf0c')
    trader.set_positive_wick_color('#33d7a0')
    trader.set_negative_body_color("#f3eb16")
    trader.set_negative_wick_color('#b85900')

    When the customization is applied on code level there’s no need to change any settings or load a template. Meaning you won’t have to make the changes every time when opening a chart. Python trader supports the use of templates for customization, and these files can be loaded in with code.

    However, you still need to manually select the file, and in case you want to share the chart the template file would also need to be shared. When the changes are done in code, only it needs to be shared to get the same results.

    Technical indicators

    Python trader supports over 100 technical indicators. These include ones such as Relative Strength Index (RSI), Bollinger bands, Moving averages (SMA, EMA etc), Oscillators for money flow and price, Fibonacci retracements, as well as statistical ones like Standard deviation. Technical indicators can be added to a chart easily with the trader UI, their properties (period count, standard dev) can also be changed the same way.

    Stock-Market-Data-Visualization-with-Python-Technical-Indicators

    These indicators can also be added and customized via code.

    trader.add_simple_moving_average(period_count=14)
    trader.add_bollinger_band(period_count=14)

    Indicators such as the Fibonacci patterns can be added with the built-in draw tools. Other markers can also be added this way. To see all the indicators, refer to the documentation.

    Setting Up Python Environment

    The data set is downloaded as a .csv file. This is the code used to process data and import it into charts.

    from lightningchart_trader import TAChart
    import pandas as pd
    import os
    license_key_path = "Python-Trader_License_key.txt" 
    # license key for python trader and the stock API
    license_key = open(license_key_path).read()
    chart = TAChart(license_key)
    path_to_csv = 'data/project-14/'
    # All file names in the filepath
    csv_list = os.listdir(path_to_csv)
    print(csv_list)
    # Create a new dashboard with two rows and a single column
    new_dashboard = chart.create_dashboard(rows=2, cols=1)
    # These values will be used to add charts to the dashboard
    row_index = 0

    This part of the code imports the necessary libraries and assigns the Python trader license key to a variable. I recommend providing a full file path to the CSV files, even if the data is saved in the same directory or a subdirectory in relation to your .py files. This since I’ve personally experienced issues with Python when only a partial path is provided. In the following example, note the different types of forward slashes used. Python might give an error if you input the path in the same format as it is in the file directory.

    'C:/Users\name\Desktop\path\to\the\files/'

    Entertainment Stock Performance Visualizations

    We will now start creating the visualizations.

    Netflix & Disney stock price development over time

    A line chart comparing Netflix’s 2002 -2024 Q3 and Disney’s 1999-2024 Q3 stock price development over time.

    Entertainment-Stock-Performance-Netflix-and-Disney
    from lightningchart_trader import TAChart
    import pandas as pd
    import os
    license_key_path = "Python-Trader_License_key.txt" 
    # license key for python trader and the stock API
    license_key = open(license_key_path).read()
    chart = TAChart(license_key)
    path_to_csv = 'data/project-14/'
    # All file names in the filepath
    csv_list = os.listdir(path_to_csv)
    print(csv_list)
    # Create a new dashboard with two rows and a single column
    new_dashboard = chart.create_dashboard(rows=2, cols=1)
    # These values will be used to add charts to the dashboard
    row_index = 0
    for stock in csv_list:
        # Transform the CSV into a dataframe, combine the file path, with the desired files name 
        stock_dataframe = pd.read_csv(path_to_csv + stock)
        # A placeholder chart title, file name without the .csv
        chart_title = stock.removesuffix('.csv')
        stock_dataframe.rename(columns={
              'Open Price': 'open',
              'High Price': 'high',
              'Low Price': 'low',
              'Close Price': 'close'}, inplace=True)
        # Add a chart to the dashboard, then increment the row_index        
        dash_chart = new_dashboard.add_chart(chart_type='Line', row_index=row_index, column_index=0, title=chart_title).set_data(stock_dataframe)
        row_index += 1
        # Optional appearence customization
        dash_chart.set_color_theme('darkGold')
        dash_chart.set_line_color("#65FC01")
        dash_chart.change_time_range(4)
    chart.open()

    Candlestick and Heikin Ashi chart OHLC-value plot in 1 year

    Candlestick charts are used to analyze the OHLC values of a stock. Heikin Ashi charts are similar, but can help reduce noise by averaging price fluctuation. This can be useful for certain situations, but not always, for example real time trading .

    Entertainment-Stock-Performance-Candlestick-Heikin-Ashi
    Entertainment-Stock-Performance-Disney-Stock-Price

    Note: Use HeikinAshi for the “chart_type =” parameter when creating the appropriate chart, or changing the type from the trader UI.

    from lightningchart_trader import TAChart
    import pandas as pd
    import os
    license_key_path = "Python-Trader_License_key.txt" 
    # license key for python trader and the stock API
    license_key = open(license_key_path).read()
    chart = TAChart(license_key)
    path_to_csv = 'data/project-14/'
    # All file names in the filepath
    csv_list = os.listdir(path_to_csv)
    print(csv_list)
    # Create a new dashboard with two rows and a single column
    new_dashboard = chart.create_dashboard(rows=2, cols=1)
    # These values will be used to add charts to the dashboard
    row_index = 0
    for stock in csv_list:
        # Transform the CSV into a dataframe, combine the file path, with the desired files name 
        stock_dataframe = pd.read_csv(path_to_csv + stock)
        # A placeholder chart title, file name without the .csv
        chart_title = stock.removesuffix('.csv')
        stock_dataframe.rename(columns={
              'Open Price': 'open',
              'High Price': 'high',
              'Low Price': 'low',
              'Close Price': 'close'}, inplace=True)
        # Add a chart to the dashboard, then increment the row_index        
        dash_chart = new_dashboard.add_chart(chart_type='CandleStick', row_index=row_index, column_index=0, title=chart_title).set_data(stock_dataframe)
        row_index += 1
        # Optional appearence customization
        dash_chart.set_color_theme('darkGold')
        dash_chart.set_line_color("#65FC01")
        dash_chart.change_time_range(4)
    chart.open()

    Renko chart for trend direction analysis

    Renko charts are used to isolate trend directions and price movements. Additionally, these charts do not represent time linearly as line or candlestick charts do. This is because new bricks/boxes are only added when the price moves a set amount in one direction. This means that the time gap between bricks can be a day, a week, a month, or more, depending on volatility.

    A box size of 4 was used for Disney and 16 for Netflix. The box size determines how much the price has to increase or decrease from the previous value for a new brick to be added. Base type was close. These values can be changed from the chart settings, top left icon.

    Entertainment-Stock-Performance-Renko-Chart
    from lightningchart_trader import TAChart
    import pandas as pd
    import os
    license_key_path = "Python-Trader_License_key.txt" 
    # license key for python trader and the stock API
    license_key = open(license_key_path).read()
    chart = TAChart(license_key)
    path_to_csv = 'data/project-14/'
    # All file names in the filepath
    csv_list = os.listdir(path_to_csv)
    print(csv_list)
    # Create a new dashboard with two rows and a single column
    new_dashboard = chart.create_dashboard(rows=2, cols=1)
    # These values will be used to add charts to the dashboard
    row_index = 0
    for stock in csv_list:
        # Transform the CSV into a dataframe, combine the file path, with the desired files name 
        stock_dataframe = pd.read_csv(path_to_csv + stock)
        # A placeholder chart title, file name without the .csv
        chart_title = stock.removesuffix('.csv')
        stock_dataframe.rename(columns={
              'Open Price': 'open',
              'High Price': 'high',
              'Low Price': 'low',
              'Close Price': 'close'}, inplace=True)
        # Add a chart to the dashboard, then increment the row_index        
        dash_chart = new_dashboard.add_chart(chart_type='Renko', row_index=row_index, column_index=0, title=chart_title).set_data(stock_dataframe)
        row_index += 1
        # Optional appearence customization
        dash_chart.set_color_theme('darkGold')
        dash_chart.set_line_color("#65FC01")
        dash_chart.change_time_range(4)
    chart.open()

    Kagi chart for comparing trend reversals

    Kagi charts work similarly to Renko charts that they change direction when the price moves a set amount. Kagi charts also track how strong the trend reversal is. They do this by highlighting where higher or lower highs and lows appear.

    Entertainment-Stock-Performance-Kagi-Chart
    from lightningchart_trader import TAChart
    import pandas as pd
    import os
    license_key_path = "Python-Trader_License_key.txt" 
    # license key for python trader and the stock API
    license_key = open(license_key_path).read()
    chart = TAChart(license_key)
    path_to_csv = 'data/project-14/'
    # All file names in the filepath
    csv_list = os.listdir(path_to_csv)
    print(csv_list)
    # Create a new dashboard with two rows and a single column
    new_dashboard = chart.create_dashboard(rows=2, cols=1)
    # These values will be used to add charts to the dashboard
    row_index = 0
    for stock in csv_list:
        # Transform the CSV into a dataframe, combine the file path, with the desired files name 
        stock_dataframe = pd.read_csv(path_to_csv + stock)
        # A placeholder chart title, file name without the .csv
        chart_title = stock.removesuffix('.csv')
        stock_dataframe.rename(columns={
              'Open Price': 'open',
              'High Price': 'high',
              'Low Price': 'low',
              'Close Price': 'close'}, inplace=True)
        # Add a chart to the dashboard, then increment the row_index        
        dash_chart = new_dashboard.add_chart(chart_type='Kagi', row_index=row_index, column_index=0, title=chart_title).set_data(stock_dataframe)
        row_index += 1
        # Optional appearence customization
        dash_chart.set_color_theme('darkGold')
        dash_chart.set_line_color("#65FC01")
        dash_chart.change_time_range(4)
    chart.open()

    Point and figure chart

    Point and figure charts are another type of chart for tracking trends. Symbols are added when the stock price drops O or rises X by a predetermined amount. The symbol type changes when the price direction reverses by a certain value.

    Entertainment-Stock-Performance-Point-and-Figure
    from lightningchart_trader import TAChart
    import pandas as pd
    import os
    license_key_path = "Python-Trader_License_key.txt" 
    # license key for python trader and the stock API
    license_key = open(license_key_path).read()
    chart = TAChart(license_key)
    path_to_csv = 'data/project-14/'
    # All file names in the filepath
    csv_list = os.listdir(path_to_csv)
    print(csv_list)
    # Create a new dashboard with two rows and a single column
    new_dashboard = chart.create_dashboard(rows=2, cols=1)
    # These values will be used to add charts to the dashboard
    row_index = 0
    for stock in csv_list:
        # Transform the CSV into a dataframe, combine the file path, with the desired files name 
        stock_dataframe = pd.read_csv(path_to_csv + stock)
        # A placeholder chart title, file name without the .csv
        chart_title = stock.removesuffix('.csv')
        stock_dataframe.rename(columns={
              'Open Price': 'open',
              'High Price': 'high',
              'Low Price': 'low',
              'Close Price': 'close'}, inplace=True)
        # Add a chart to the dashboard, then increment the row_index        
        dash_chart = new_dashboard.add_chart(chart_type='PointAndFigure', row_index=row_index, column_index=0, title=chart_title).set_data(stock_dataframe)
        row_index += 1
        # Optional appearence customization
        dash_chart.set_color_theme('darkGold')
        dash_chart.set_line_color("#65FC01")
        dash_chart.change_time_range(4)
    chart.open()

    Conclusion

    From the charts, it’s possible to observe that Disney’s stock price appears somewhat stagnant, while Netflix shows a strong upward trend. The trend-focused charts confirm this observation. Part of this entertainment stock performance may be attributed to post-COVID pandemic effects, as Disney had to close its theme parks, and movie theaters were not allowed to remain open.

    Since Netflix operates as a streaming service, it wasn’t as heavily impacted on an operational level (although its stock price still took a hit). Disney does have its Disney+ service as a competitor, but other factors influencing entertainment stock performance would require deeper fundamental analysis to confirm.

    Continue learning with LightningChart

    Nbody Simulation Data Visualization

    Nbody Simulation Data Visualization

    Written by a human | Updated on April 9th, 2025N-body Simulation  Nbody simulation is maybe one of the most advanced data visualization types out there. The truth is that we’re not talking anymore about visualizing traditional data with a business focus and it...

    Data Visualization Components for React Applications

    Data Visualization Components for React Applications

    Written by a human | Updated on April 9th, 2025React Data Visualization Components  React is one of the most popular front-end development frameworks on the web in the year 2022. It is a free and open-source front-end JS library that is used to build interactive...

    What Is LiDAR Data Visualization?

    What Is LiDAR Data Visualization?

    LiDAR Data Visualization  The LiDAR method conveys another yet complex level of data visualization as it is widely used in demanding industries that require plotting, e.g., topographic or cartography 3D data. But the use of LiDAR goes further as it is also used...