use python to answer: c. Create a dataframe that holds the daily returns of the 2 funds as well as the ETF. Note that since the three time series have different lengths, when combining them in a dataframe using concat, the time series that has no record on a given date will have NaN value. Removing those rows will give you a database that contains dates that are common across the three series. Rename the columns appropriately and display the final dataframe.
Question
use python to answer: c. Create a dataframe that holds the daily returns of the 2 funds as well as the ETF. Note that since the three time series have different lengths, when combining them in a dataframe using concat, the time series that has no record on a given date will have NaN value. Removing those rows will give you a database that contains dates that are common across the three series. Rename the columns appropriately and display the final dataframe.
Solution
To answer your question, I'll assume that you have three pandas Series or DataFrames: fund1, fund2, and etf, each representing the daily prices of two funds and one ETF. Here's how you can create a DataFrame of daily returns for these three time series:
import pandas as pd
# Assuming fund1, fund2, and etf are your time series data
# Calculate daily returns
fund1_returns = fund1.pct_change()
fund2_returns = fund2.pct_change()
etf_returns = etf.pct_change()
# Combine the three series into one DataFrame
combined = pd.concat([fund1_returns, fund2_returns, etf_returns], axis=1)
# Drop rows with missing values
combined = combined.dropna()
# Rename columns
combined.columns = ['Fund1 Returns', 'Fund2 Returns', 'ETF Returns']
# Display the final DataFrame
print(combined)
This code first calculates the daily returns for each time series using the pct_change() function. It then combines these three series into one DataFrame using pd.concat(). The dropna() function is used to remove any rows with missing values. Finally, the columns are renamed appropriately using the columns attribute, and the final DataFrame is displayed.
Similar Questions
Available for download from the final assessment folder are two csv files which contain daily unit prices for two Australia-based funds (labelled Fund A and Fund B) since inception. According to their fund profiles, they claim to be investing in high quality global companies including US big tech. a. For each of the data files, import the net asset value (NAV) as a Pandas dataframe. Fix any bugs in the data including ensuring there are no duplication in the dates. Once the data has been cleaned and sorted appropriately, compute the daily returns for each of the funds.(5 marks) b. Download the last 10 years of daily prices of NDQ.AX, an Exchange Traded Fund (ETF) on the Australian Stock Exchange that tracks the NASDAQ 100 index. Compute its daily returns.(5 marks)
use python to do:Download daily data for Amazon (AMZN), Netflix (NFLX) and Bank of America (BA) from 2/1/2011 to the present day and retain Adj Close only. Name the dataframe xdata.
use python to answer: Calculate the total return that investors would earn if they invested in CBA 5 years ago (according to the latest date in your dataframe). Round up to 2 decimal places and display the output.
use python to answer: File "fund_return.csv' contains the historical returns generated by an active fund manager over 2001-2021. File FF_Research_Factor_Data.csv contains historical returns on Fama-French's 3 factors. The files are available for download from the assessment's folder. a. Write a code to perform factor analysis on this manager using Fama-French's 3 factor model. Display the regression results. (10 marks) b. Based on your results in a), describe the investment style of this manager in terms of value versus growth and small stocks versus big stocks. What is their factor benchmark portfolio? Did the manager generate any positive alpha? (10 marks)
2 .ASSUME YOU HAVE BEEN GIVEN 1000$ VIRTUAL FUNDS BY A CLIENT TO INVEST IN THE STOCK MARKET ON THEIR BEHALF. USING A STOCK MARKET OF YOUR CHOICE, IDENTIFY ANY TWO STOCKS THAT YOU WOULD ADD TO YOUR INVESTMENT PORTFOLIO. APPORTION THE 1000$ DOLLARS AMONG THE SELECTED STOCKS IN FOUR MONTHS PER WEEK.
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.