# The Function of Computer Science in Finance and Economics
## Introduction
In recent decades, **Computer Science** has seen a growing presence in **finance and economics**. Leading financial institutions are **utilizing technology** to enhance the speed and accuracy of their investment choices. Firms such as **JP Morgan, Chase, and Barclays** employ **supercomputers** to oversee risk management, assess alterations in stock portfolios, and forecast asset values.
But **what is their approach?**
In this piece, we will delve into the methods by which computers assess **financial sentiment** and utilize **machine learning** to optimize investment gains.
—
## Sentiment Analysis in Finance
The **stock market** has predominantly transitioned from being influenced by intuition-based trading to **data-driven strategies**. The traditional brokers who operated on the **trading floor** are increasingly being supplanted by **quantitative analysts** (commonly referred to as **quants**). These quants create **computer algorithms** that employ complex mathematical models to **execute trades** and **forecast stock fluctuations**.
### How Computers Evaluate Sentiment
A widely-used **advanced method** in financial computing is **sentiment analysis**, which involves training a **computer program to assess a stock’s market sentiment** through financial news, social media, and corporate announcements.
To enhance the efficiency of sentiment analysis, **Dow Jones** (a prominent financial information entity) developed a **financial lexicon** that enables machines to **interpret economic news**. This lexicon consists of specialized vocabularies that categorize financial terms as **positive, negative, or neutral**.
Financial organizations may also **create customized lexicons** suited to **individual stocks** or **market segments**.
### Instance of Sentiment Analysis in Practice
A **computer program** armed with a **financial lexicon** can review a **news headline** and **determine a sentiment score** for a particular stock. Terms such as **”dropped,”**, **”lost,”**, or **”fell”** signify **negative sentiment** (bearish), while expressions like **”gained,”**, **”rose,”**, or **”climbed”** signify **positive sentiment** (bullish).
The **position** of these terms bears significance:
– Words in **headlines** or the **opening sentences** of an article **carry additional significance** in sentiment scoring.
– A stock that accumulates **predominantly negative sentiment scores** could indicate a **declining price**, compelling traders to respond appropriately.
**Example:**
Let’s examine a real-world **CNBC article** dated **November 26, 2021**, soon after the identification of a **new COVID-19 variant**.
> *“Stock futures dropped as new COVID variant worries investors.”*
In this example:
– The term **”dropped”** denotes **negative sentiment**.
– The term **”worries”** additionally conveys uncertainty, reinforcing **bearish sentiment**.
Evaluating **various news outlets** in real-time aids firms in **predicting stock transitions** and enhancing their trading actions.
—
## Machine Learning for Stock Market Forecasting
A further significant trend in **financial computing** is **Machine Learning (ML)**, a division of **Artificial Intelligence (AI)**. Machine learning empowers **computer algorithms** to **detect patterns** within market data and **generate predictions** regarding stock values.
### How Machine Learning Functions in Trading
For a **computer model** to effectively **forecast stock behaviors**, it requires **historical stock data** for its training. The model learns according to **four essential factors**:
1. **Open price** (Stock price at the day’s start).
2. **High price** (The stock’s peak value throughout the day).
3. **Low price** (The stock’s lowest value during the day).
4. **Trading volume** (The number of shares bought or sold).
By analyzing **previous data**, the **machine learning algorithm** recognizes **trends** and applies them to **future price estimates**.
### Preparing Data for Machine Learning
To enhance precision and **accelerate processing**, stock data is **normalized**, meaning it’s adjusted to a **scale between 0 and 1**. This prevents large values from **skewing predictions**.
#### Data Example (Microsoft Stock)
| Date | Open | High | Low | Volume |
|————|——–|———|——–|————|
| 1990-01-02 | 0.0001 | 0.0001 | 0.0001 | 0.0648 |
| 1990-01-03 | 0.0002 | 0.0002 | 0.0002 | 0.1447 |
This data is subsequently processed by a specialized **Machine Learning model** known as **LSTM (Long Short-Term Memory Network)**.
—
## Implementing Machine Learning for Stock Forecasts
### Step 1: Specifying Variables
To apply machine learning,