PYTHON4FINANCE Telegram 1126
رسم نمودارهای جذاب با Pygal- بخش دوم

#code by @python4finance
import yfinance as yf
import pandas as pd
import numpy as np
import pygal
from IPython.display import SVG

tickers = ['AAPL', 'MSFT', 'GOOGL', 'TSLA', 'AMZN']
factors = ['Value (P/E)', 'Momentum (6M)', 'Quality (ROE)']

data = []
for ticker in tickers:
stock = yf.Ticker(ticker)
info = stock.info
hist = stock.history(period='6mo')

try:
pe = info['trailingPE']
roe = info['returnOnEquity']
momentum = (hist['Close'].iloc[-1] - hist['Close'].iloc[0]) / hist['Close'].iloc[0]
data.append({'Ticker': ticker, 'P/E': pe, 'Momentum': momentum, 'ROE': roe})
except:
print(f"Error on reading data")

df = pd.DataFrame(data)

# Normalizing
for col in ['P/E', 'Momentum', 'ROE']:
col_norm = col + '_norm'
values = df[col].values
values = np.nan_to_num(values, nan=np.nanmean(values))
df[col_norm] = (values - np.min(values)) / (np.max(values) - np.min(values))

radar_chart = pygal.Radar(fill=True)
radar_chart.title = 'Factor Investing مقایسه سهام مختلف بر اساس'
radar_chart.x_labels = factors

for i, row in df.iterrows():
radar_chart.add(row['Ticker'], [1 - row['P/E_norm'], row['Momentum_norm'], row['ROE_norm']])

radar_chart.render_to_file('multi_factor_radar.svg')
SVG(filename='multi_factor_radar.svg')


#نمودار
#pygal

پایتون برای مالی

🆔 www.tgoop.com/python4finance
🆔 ble.ir/python4finance
15



tgoop.com/python4finance/1126
Create:
Last Update:

رسم نمودارهای جذاب با Pygal- بخش دوم

#code by @python4finance
import yfinance as yf
import pandas as pd
import numpy as np
import pygal
from IPython.display import SVG

tickers = ['AAPL', 'MSFT', 'GOOGL', 'TSLA', 'AMZN']
factors = ['Value (P/E)', 'Momentum (6M)', 'Quality (ROE)']

data = []
for ticker in tickers:
stock = yf.Ticker(ticker)
info = stock.info
hist = stock.history(period='6mo')

try:
pe = info['trailingPE']
roe = info['returnOnEquity']
momentum = (hist['Close'].iloc[-1] - hist['Close'].iloc[0]) / hist['Close'].iloc[0]
data.append({'Ticker': ticker, 'P/E': pe, 'Momentum': momentum, 'ROE': roe})
except:
print(f"Error on reading data")

df = pd.DataFrame(data)

# Normalizing
for col in ['P/E', 'Momentum', 'ROE']:
col_norm = col + '_norm'
values = df[col].values
values = np.nan_to_num(values, nan=np.nanmean(values))
df[col_norm] = (values - np.min(values)) / (np.max(values) - np.min(values))

radar_chart = pygal.Radar(fill=True)
radar_chart.title = 'Factor Investing مقایسه سهام مختلف بر اساس'
radar_chart.x_labels = factors

for i, row in df.iterrows():
radar_chart.add(row['Ticker'], [1 - row['P/E_norm'], row['Momentum_norm'], row['ROE_norm']])

radar_chart.render_to_file('multi_factor_radar.svg')
SVG(filename='multi_factor_radar.svg')


#نمودار
#pygal

پایتون برای مالی

🆔 www.tgoop.com/python4finance
🆔 ble.ir/python4finance

BY Python4Finance


Share with your friend now:
tgoop.com/python4finance/1126

View MORE
Open in Telegram


Telegram News

Date: |

As of Thursday, the SUCK Channel had 34,146 subscribers, with only one message dated August 28, 2020. It was an announcement stating that police had removed all posts on the channel because its content “contravenes the laws of Hong Kong.” It’s easy to create a Telegram channel via desktop app or mobile app (for Android and iOS): Healing through screaming therapy According to media reports, the privacy watchdog was considering “blacklisting” some online platforms that have repeatedly posted doxxing information, with sources saying most messages were shared on Telegram. Done! Now you’re the proud owner of a Telegram channel. The next step is to set up and customize your channel.
from us


Telegram Python4Finance
FROM American