Browse Source

fix: change files

pull/42/head
Badr Ghazlane 3 years ago
parent
commit
c8e1d7cec9
  1. 16
      one_exercise_per_file/day05/ex02/readme.md
  2. 31
      one_exercise_per_file/day05/ex03/readme.md
  3. 2
      one_exercise_per_file/raid01/readme.md

16
one_exercise_per_file/day05/ex02/readme.md

@ -0,0 +1,16 @@
# Exercise 2
The goal of this exercise is to learn to use Pandas on Time Series an on Financial data.
The data we will use is Apple stock.
1. Using `Plotly` plot a Candlestick
2. Aggregate the data to **last business day of each month**. The aggregation should consider the meaning of the variables. How many months are in the considered period ?
3. When comparing many stocks between them the metric which is frequently used is the return of the price. The price is not a convenient metric as the prices evolve in different ranges. The return at time t is defined as
- (Price(t) - Price(t-1))/ Price(t-1)
Using the open price compute the **daily return**. Propose two different ways **without for loop**.

31
one_exercise_per_file/day05/ex03/readme.md

@ -0,0 +1,31 @@
# Exercise 3 Multi asset returns
The goal of this exercise is to learn to compute daily returns on a DataFrame that contains many assets (multi-assets).
```python
business_dates = pd.bdate_range('2021-01-01', '2021-12-31')
#generate tickers
tickers = ['AAPL', 'FB', 'GE', 'AMZN', 'DAI']
#create indexs
index = pd.MultiIndex.from_product([business_dates, tickers], names=['Date', 'Ticker'])
# create DFs
market_data = pd.DataFrame(index=index,
data=np.random.randn(len(index), 1),
columns=['Price'])
```
1. **Without using a for loop**, compute the daily returns (return(d) = (price(d)-price(d-1))/price(d-1)) for all the companies and returns a DataFrame as:
| Date | ('Price', 'AAPL') | ('Price', 'AMZN') | ('Price', 'DAI') | ('Price', 'FB') | ('Price', 'GE') |
|:--------------------|--------------------:|--------------------:|-------------------:|------------------:|------------------:|
| 2021-01-01 00:00:00 | nan | nan | nan | nan | nan |
| 2021-01-04 00:00:00 | 1.01793 | 0.0512955 | 3.84709 | -0.503488 | 0.33529 |
| 2021-01-05 00:00:00 | -0.222884 | -1.64623 | -0.71817 | -5.5036 | -4.15882 |
Note: The data is generated randomly, the values you may have a different results. But, this shows the expected DataFrame structure.
`Hint use groupby`

2
one_exercise_per_file/raid01/readme.md

@ -137,7 +137,7 @@ A data point (x-axis: date, y-axis: cumulated_return) is: the **cumulated return
![alt text][performance]
[performance]: images/weekend/w1_weekend_plot_pnl.png "Cumulative Performance"
[performance]: images/w1_weekend_plot_pnl.png "Cumulative Performance"
## 5. Main

Loading…
Cancel
Save