Andr40 (@35235) • Hey
bella raga
Publications
- what'happeninggggg bears are fucked!!!!
- hey, what's up guys
how do u feel about btc at 60k to the moon
- whatsup
- I can't mirror post. can I?
- when early access?
- 🔥
- montecarlo simulation
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from scipy.optimize import minimize
# Load the dataset
file_path = '/Users//Downloads/F-F_Research_Data_Factors-2.xlsx'
df = pd.read_excel(file_path)
# Convert 'Date' to datetime type and filter for the last 30 years
df['Date'] = pd.to_datetime(df['Date'], format='%m/%Y')
df_filtered = df[df['Date'] >= (df['Date'].max() - pd.DateOffset(years=30))]
# Extracting the factors for analysis
factors = ['Mkt-RF', 'SMB', 'HML', 'Mom', 'LT_Rev']
returns = df_filtered[factors]
# Normalizing the returns (assuming they are in percentage format)
returns_normalized = returns / 100
# Monte Carlo Simulation for Portfolio Optimization
num_portfolios = 30000
all_weights = np.zeros((num_portfolios, len(factors)))
ret_arr = np.zeros(num_portfolios)
vol_arr = np.zeros(num_portfolios)
np.random.seed(42) # For reproducibility
for i in range(num_portfolios):
weights = np.random.random(len(factors))
weights /= np.sum(weights)
all_weights[i, :] = weights
ret_arr[i] = np.sum((returns_normalized.mean() * weights * 12)) # Annualizing returns
vol_arr[i] = np.sqrt(np.dot(weights.T, np.dot(returns_normalized.cov() * 12, weights))) # Annualizing standard deviation
# Identifying the portfolio with minimum variance
min_vol_idx = np.argmin(vol_arr)
min_vol_weights = all_weights[min_vol_idx]
min_vol_portfolio_return = ret_arr[min_vol_idx]
min_vol_portfolio_volatility = vol_arr[min_vol_idx]
# Plotting the portfolios
plt.figure(figsize=(12, 8))
plt.scatter(vol_arr, ret_arr, c=ret_arr/vol_arr, marker='o')
plt.colorbar(label='Sharpe Ratio')
plt.xlabel('Expected Volatility')
plt.ylabel('Expected Return')
plt.scatter(min_vol_portfolio_volatility, min_vol_portfolio_return, c='red', s=50, marker='*', label='Minimum Variance Portfolio')
plt.legend()
plt.title('Monte Carlo Simulation of Portfolios')
plt.show()
# Outputting the minimum variance portfolio details
min_vol_portfolio_details = {
'Return': min_vol_portfolio_return,
'Volatility': min_vol_portfolio_volatility,
'Weights': dict(zip(factors, min_vol_weights))
}
print(min_vol_portfolio_details)
# Continuing from the previous analysis, we will now find portfolios that satisfy the additional criteria:
# 2. Maximum Sharpe Ratio
# 3. Maximum Return
# 4. Minimum Value-at-Risk (VaR) at 1%
# Calculating the Sharpe Ratio for each portfolio
risk_free_rate = 0 # Assuming a risk-free rate of 0 for simplicity
sharpe_ratios = ret_arr / vol_arr # Sharpe Ratio = Return / Volatility
# Finding the portfolio with the maximum Sharpe Ratio
max_sharpe_idx = np.argmax(sharpe_ratios)
max_sharpe_portfolio = {
'Return': ret_arr[max_sharpe_idx],
'Volatility': vol_arr[max_sharpe_idx],
'Sharpe Ratio': sharpe_ratios[max_sharpe_idx],
'Weights': all_weights[max_sharpe_idx]
}
# Finding the portfolio with the maximum Return
max_ret_idx = np.argmax(ret_arr)
max_ret_portfolio = {
'Return': ret_arr[max_ret_idx],
'Volatility': vol_arr[max_ret_idx],
'Weights': all_weights[max_ret_idx]
}
# Value-at-Risk (VaR) Calculation
# Assuming normal distribution of returns, we can calculate VaR using the Z-score for the 1% confidence interval
from scipy.stats import norm
# Z-score for 1% confidence interval
z_score_1pc = norm.ppf(1 - 0.01)
# Calculating VaR for each portfolio
var_1pc = -z_score_1pc * vol_arr # Negative sign because VaR is typically expressed as a positive number
# Finding the portfolio with the minimum VaR
min_var_idx = np.argmin(var_1pc)
min_var_portfolio = {
'Return': ret_arr[min_var_idx],
'Volatility': vol_arr[min_var_idx],
'VaR 1%': var_1pc[min_var_idx],
'Weights': all_weights[min_var_idx]
}
- Lenny is heading to Devconnect and @lens/ethglobal İstanbul
- btc to the moon
- follow meeee I just minted https://lenster.xyz/u/35235.lens #lens
- edo sei bello
- When will we learn?
- Thanks for nothing
- lelelelellelelelellelellele
- whaaaaa
- Loving my new MacBook! Holds my coffee nice and steady on the couch
10/10 product would recommend
- gm
- binance fud
- what have I missed?
- papapapapappappadelllll
@libai59.lens
- retweet and follow me
- On my 35. birthday I wish all of you a very heartfelt GM!
Enjoy the sun, go for a walk, get some time off the screen!
- retweet and follow me
- gm good boys
- 1️⃣ after each drop, we ask our holders to complete a survey
2️⃣ the team takes the feedback very seriously in terms of the direction we're building in
⬛️ 95%+ of the participants expressed positivity towards holders only drop, ask and you shall receive
⬛️ only way to mint = HOLD NFT
- we are anotherblock – a music NFT platform that provides real-world value through streaming royalties onchain. by collecting anotherblock NFTs you earn % of the streaming royalties based on the performance of world-renowned songs.
INVESTING IN MUSIC - MADE EASY
⬛️ join us on our @lensprotocol journey ⬛️
- gM
- gm
- gm world
- we are anotherblock – a music NFT platform that provides real-world value through streaming royalties onchain. by collecting anotherblock NFTs you earn % of the streaming royalties based on the performance of world-renowned songs.
INVESTING IN MUSIC - MADE EASY
⬛️ join us on our @lensprotocol journey ⬛️
- Got it! I will check first the binding of issac 🧐
- I think that #hashtags were a way to be relevant and get discovered in 2010s.
A sort of social-media-SEO.
Today the best way to be relevant is to connect with your community.
In a AI powered world the best way to get discovered is to be human.
- buongiorno
- ritracciamentooo short
- eth bullishhh
- Lens Protocol is open, anyone who has a profile can have permissionless access regardless of what application they are using. We believe in supporting content creators and followers who create an engaging environment for everyone.
Some applications use gasless and signless transactions, and we have now introduced eligibility requirements for these features.
While everyone is eligible by default, accounts with low-signal engagement will not be eligible. You can read more about our requirements here. https://docs.lens.xyz/docs/gasless#eligibility-requirements
We are also testing filtering low-signal notifications for a better user experience. https://docs.lens.xyz/docs/users-notifications#api-details
At Lens, we believe that Web3 social should create a better experience than before, by using blockchain technology. We are always experimenting with ways to better our user experience by filtering low-signal profiles and bots. Let’s keep experimenting, our DMs are open for feedback 🧪
- turkey is really cool
- Its Sunday, going to hang in Sonar. Anyone tried Sonar? Whats the vibes 👀
- happy easter mooner
- Built on @memester-xyz.lens
- my padel racket
- I just voted "Yes" on "Make Velodrome the STG Hub on Optimism" https://snapshot.org/#/stgdao.eth/proposal/0xd78c441994d140edde34131051113479651c593ab83badebc537a347ba86b705 #snapshotlabs
- gm
- My husky
She does not like photos, but sometimes I still manage to catch her in the lens
- I can't believe Justin Timberlake actually said this in the movie
- Wow, just realized I crossed over 1000 followers on Lens!! Starting tomorrow, I’m releasing 15-30sec beat snippets every single day of April as a FREE COLLECT 🔥🔥🔥
Wanna pay it forward & reciprocate the love!! 🖤
(Stay tuned)
- lens airdrop when?????????????
- yayayayayya
- ddudududududuud
- forza forza la romaaaaa