1620576808

# Build your own Markowitz Portfolio Solver from Scratch | Derivations | Stock Market Analysis

Stock Market Analysis is of interest to many investors, economists, and financial engineers. This lecture is twofold. First, we derive the closed form weight vector solution of the Markowitz Portfolio Optimization problem using Convex Optimization tools, which enables us to highlight potential assets or stocks within our selected portfolio. Second, we use this essential equation to build our Markowitz Portfolio solver on Python. For the sake of demonstration, we compare the outcome of our solver versus the one given by SciPy’s minimize solver (which uses Sequential Least Squares for Quadratic Programs) and discuss the advantages/disadvantages of both solvers (i.e. our solver vs SciPy). This lecture is outlined as follows:

⏲Outline⏲
00:00​ Introduction
00:47​ Markowitz Portfolio Optimization Problem (a recap)
03:08​ Lagrangian Function
05:38​ Optimal Weights
11:11​ Lagrangian Multiplier Solutions
21:35​ Our Portfolio Solver Equation
22:17​ Python Implementation: SciPy approach (method 1)
33:36​ Python Implementation: Our Solver (method 2)
37:28​ Comparisons: SciPy Solver vs Our Solver
41:00​ Summary
41:40​ Outro

#python

1590469702

## Stock Market Betting Software Development | Stock Market Betting Solutions

Mobiweb Technologies is considered as an expert stock market betting software development company that offers an extensive and wide coverage betting software to empower the bettors. Our Team of top level management and expert sports betting software developers design unbeatable software development strategies that compete with other betting software in the market. People who believe in investment consider gambling as a source of profit generation and for this, Mobiweb’s betting software offers one touch betting facility to place the wager. Most importantly, it offers best-in-class user experience and provides a user engaging atmosphere. If you are looking for developing stock market betting software then you don’t need to hesitate, give this opportunity to Mobiweb and get on time delivery of your project under minimum possible cost.

#stock market betting software development #stock market betting software #stock market betting app development #stock market betting app developers #stock market betting software providers

1624384800

## The Stock Market Crash of 2021 (How to Profit BIG)

Is the stock market crashing in 2021? In this video, we are going over why and when the stock market will crash, what you can do to prepare for it and profit, and what stocks I’m buying right now that are great long term holds.

Make sure to watch until the end, as I will go over what’s happening with the markets right now, what’s causing it, and my sentiment about why a crash will occur.

📺 The video in this post was made by Charlie Chang
The origin of the article: https://www.youtube.com/watch?v=vOIxDL5XCjY
🔺 DISCLAIMER: The article is for information sharing. The content of this video is solely the opinions of the speaker who is not a licensed financial advisor or registered investment advisor. Not investment advice or legal advice.
Cryptocurrency trading is VERY risky. Make sure you understand these risks and that you are responsible for what you do with your money
🔥 If you’re a beginner. I believe the article below will be useful to you ☞ What You Should Know Before Investing in Cryptocurrency - For Beginner
⭐ ⭐ ⭐The project is of interest to the community. Join to Get free ‘GEEK coin’ (GEEKCASH coin)!
Thanks for visiting and watching! Please don’t forget to leave a like, comment and share!

#bitcoin #blockchain #stock #the stock market crash #the stock market crash of 2021 #the stock market crash of 2021 (how to profit big)

1596376860

## Stock Fundamental Analysis: EDA of SEC’s quarterly data summary

Many investors consider fundamental analysis as their secret weapon to beat the stock market. You can perform it using many methods, but one thing they have in common. They all need data about companies’ financial statements.

Luckily all stocks traded on US stock markets must quarterly report to the Securities and Exchange Commission (SEC). Every quarter SEC prepares a comfortable CSV package to help all the investors in their quest for the investment opportunity. Let’s explore how to get valuable insights from these .csv files.

In this tutorial, we will use python’s pandas library which ideal for parsing CSV files, and we will learn how to:

We will process the data and:

• explore files in the SEC dump
• review each column of these files and talk about the most relevant
• remove **duplicated **data grouped by a key column or multiple columns
• visualize the data to support our exploration using interactive Plotly charts
• and much more

As usual, you can follow the code in the notebook shared on GitHub.

## vaclavdekanovsky/data-analysis-in-examples

Permalink Dismiss GitHub is home to over 50 million developers working together to host and review code, manage…

github.com

# SEC Quarterly data

There doesn’t seem to be any problem. You simply download the quarterly package from the SEC dataset page, you sort the values from the financial statements in descending order and pick the stocks on the top. The reality isn’t that straightforward. Let’s have a look and explore 45.55MB big zip file with all SEC filings for the first quarter of 2020.

The package for every quarter contains 5 files. Here’s an example of 2020 Q1:

• readme.htm — describes the structure of the files
• **sub.txt **— master information about the submissions including company identifiers and type of the filing
• **num.txt **— numeric data for each financial statement and other documents
• tag.txt — standard taxonomy tags
• pre.txt — information about how the data from num.txt is displayed in the online presentation

Unzipped files in the SEC quarterly data dump

This article will only deal with the submission master because it contains more than enough information for one article. Follow-up story will examine the data in more detail. Let’s begin.

## 2020Q1 Submission files

In the first quarter of 2020, the companies have submitted `13560` files and the sub.txt gathers 36 columns about them.

``````# load the .csv file into pandas

# explore number of rows and columns
sub.shape
[Out]: (13560, 36)
``````

I always start with a simple function that reviews each column of the data frame, checks the percentage of empty values, and how many unique values appear in the columns.

Explore the sub.txt file to see what data each column contain

Let me highlight a few important columns in the SEC submission master.

Example of the quick file overview in pandas

• adsh — EDGAR accession number uniquely identifies each report. This value is **never duplicated **in the sub.txt. Example 0001353283–20–000008 is the code for 10-K (yearly filing) of Splunk.
• cik — Central Index Key, unique key identifying each SEC registrant. E.g. 0001353283 for Splunk. As you can see the first part of the adsh is the cik.
• name — the name of the company submitting the quarterly financial data
• form — the type of the report being submitted

# Form s— submissions types delivered to SEC

Based on the analysis, we see that the 2020Q1 submission contains 23 unique types of financial reports. Investors’ primary interest lies in the 10-K report, which covers the annual performance of the publically traded company. Because this report is expectedly delivered only once a year, important is also 10-Q report showing quarterly changes in the company’s financials.

• `10-K` Annual report of US-based company
• `10-Q` Quarterly report and maybe
• `20-F` Annual Reports of a foreign company
• `40-F` Annual Reports of a foreign company (Canadian)

Let’s see which forms are the most common in the dataset. Plotting of the form types in the 2020Q1 will show this picture:

Using Plotly’s low level API to produce bar and pie subplots

Different submission types reported by the companies in 2020Q1 using visualization in Plotly

The dataset contains over 7000 8-K reports notifying about important events like agreements, layoffs, usage of material, modification of shareholder rights, change in the senior positions, and more (see SEC’s guideline). Since they are the most common we should spend some time exploring them.

#stocks #exploratory-data-analysis #python #data-analysis #stock-market #data analysis

1594436580

# Background

Have you ever got tired to select a stock by looking at more than hundreds of financial ratios ? Or have you felt bored on polishing your technical analysis skills or improving your time series model to make better price prediction ? If the answer is YES, you have come to the right place.

In this article, we will go though an experiment to see whether financial ratios in different dimensions really add value to stock selection. During the process, we would also see how cluster analysis helps us to get rid of the sea of financial metrics.

Before that, I am also going to show you the procedures to (1) download historical financial ratios of stocks, and (2) daily price data of stocks, which could be very useful for many of you playing around stock data in different projects.

For the originals of all the codes below, you may refer to my Github link here.

First, we would use a library called FundamentalAnalysis. For the details of this library, please refer to the website here.

To be able to use this package, we need an API Key from FinancialModellingPrep, and follow the instructions there to obtain a free API Key. Please note that these keys are limited to 250 requests per account though there is no time limit. So I strongly recommend all of you to output the downloaded data as excel file for further use. Otherwise, the limitation is easy to exceed.

And due to this limitation, I set the scope for stock selection in the experiment as 97 stocks listed below, which are all components of Nasdaq 100 Index.

The above codes would generate two excel files, (a) key_metrics.xlsx, and (b) financial_ratios.xlsx, with each stock in a separate sheet. Both files store various financial indicators for the past 10–20 years, depending on when the companies are listed. We will combine them together with the returns and price volatility data in later step.

A captured image of key metrics data of MSFT

N

ext, let’s download the price data. Since the above package has limitation on requests quota, we would switch to another free library yfinance.

The above code would download the daily price data for all the stocks in the ticker list. And close price is selected to represent the price and is outputted as an excel file, price.xlsx.

A captured image of price data

# (3) Combine all the data for use

At

last, we would like to combine the three excel files prepared into a single file, each for one year in the selected period (2017–2019). I am not planning to go through the details here, since all are just some basic skills using pandas and numpy. For the original code of this section, please refer to **_cluster_stocks_data.py _**in the Github link here.

Nonetheless, I would like to mention some key tricks that are quite useful and applicable even when you are working on other projects.

(a) dataframe.at[index, column name]_ — instead of getting confused about iloc or loc or any other similar functions, you may try the function **“.at”**,_which directly refers to a single cell within the dataframe. And you can easily set its value with an equal sign.

(b) dataframe.T_ —transpose the dataframe if you want to swap the row and column. By applying this function **“.T”**, column name will then become index, and vice versa._

_© pd.concat() _— combine two dataframes in parallel (horizontally).

(d) dataframe.fillna(value=N)_ — fill the cells with NaN with a specific value._

After going through tedious procedures, the end products would be three excel files (2017, 2018 and 2019). Each stores the data of returns, price volatility and other financial indicators for every stock in the ticker list in a specific year.

#cluster-analysis #portfolio #data-science #stock-market #finance #data analysis

1596443760

## How to Measure Stock Portfolio Performance using R

Stock market is a place where people arrange a transaction for buying or selling shares of publicly listed company

Indonesia has been named as the Largest Economy in Southeast Asia by the World Bank. As one of the four most populous countries in the world with more than 200 million people living in this country, Indonesia has a bargaining power to emerge as one of the biggest economies in the world. Those promising prospect of Indonesia economic condition makes this country as one of the best choices to put your investment on.

Indonesia stock markets with more than 600 listed enterprises still on the uptrends before the coronavirus outbreak. Some of the listed enterprises are state-owned enterprises and for this case study, I will only analyze 17 state-owned enterprises which been a member of the latest IDX-BUMN20 Index.

Stock used for analysis:

ANTM.JK, BBNI.JK, BBRI.JK, BBTN.JK, BJBR.JK, BMRI.JK, ELSA.JK, JSMR.JK, KAEF.JK, PGAS.JK, PTBA.JK, PTPP.JK, SMGR.JK, TINS.JK, TLKM.JK, WIKA.JK, WSKT.JK

The assumption for this case study:

1. Stocks weight in the portfolio is the same for every enterprise.
2. Analysis based on the historical adjusted closing price data from 1st January 2013 to 26th July 2020.
3. Risk-Free Rate: 4.5%
4. Portfolio rebalancing quarterly

## Import and Prepare Stocks Data

We will import stock price data using getSymbols() function from the quantmod package. getSymbols() function is a particular function to load and manage financial data from various sources, but for this example, we will use Yahoo Finance as our data source.

``````#Import Library
library(PerformanceAnalytics)
library(quantmod)
library(ggplot2)
library(xts)
library(zoo)
library(tidyverse)
library(dplyr)
library(PortfolioAnalytics)

#Set Default Time Period
setDefaults(getSymbols.yahoo, from = as.Date('2013/01/01'), to= as.Date('2020/07/26')) #Set GetSymbols default parameter such as Data Source and Time Periods

#IDX- BUMN20 Symbol List
IDXBUMN20 = c('ANTM.JK','BBNI.JK','BBRI.JK','BBTN.JK','BJBR.JK','BMRI.JK','ELSA.JK','JSMR.JK','KAEF.JK',
'PGAS.JK','PTBA.JK','PTPP.JK','SMGR.JK','TINS.JK','TLKM.JK','WIKA.JK','WSKT.JK')

weight = rep(1/length(IDXBUMN20), length(IDXBUMN20)) #Define Weight for every stock in Portfolio
#Import Stock Price from yahoo Finance
getSymbols(IDXBUMN20)
``````

Import Stock Price Data from Yahoo Finance

In default, we will have every stock price data assigned to their stock code as xts object (ex: ANTM.JK prices will be stored in ANTM.JK variable as xts object). To make it easier for analysis, we should gather all these separate data into a single xts object.

``````#IDX-BUMN20 Create Dataframe
Index <- list(ANTM.JK,BBNI.JK,BBRI.JK,BBTN.JK,BJBR.JK,BMRI.JK,ELSA.JK,JSMR.JK,KAEF.JK,
PGAS.JK,PTBA.JK,PTPP.JK,SMGR.JK,TINS.JK,TLKM.JK,WIKA.JK,WSKT.JK)
names(Index) <- IDXBUMN20
Index <- lapply(Index, '[', i =,j = 6) #Select only Adjusted Close Price
Index <- do.call(cbind.data.frame, Index) #List To Dataframe
names(Index) <- IDXBUMN20 #Change Colnames

Index <- as.xts(Index)
view raw
Closing Adj. Price and Gather Object.R hosted with ❤ by GitHub
``````

Gather separate data into a single xts object

Fig-1. Index xts object preview

## Portfolio Analytics

We already made a portfolio, and it stored as single xts object in a variable named Index. The data that we store in this variable is still in closing price format for every market day, since most of the portfolio analytics method need to feed by return data, we have to calculate its Return first before taking a step into portfolio analysis.

#finance #towards-data-science #stock-market #portfolio #data-analysis #data analysis