Closed pat42w closed 3 years ago
When would we want to do the conversion back to EUR? My guess would be the date that our Expected Returns prediction is for. Not something we could do for our future predictions.
Perhaps a similar algo is needed to predict FX rates? lol
First step would be to have a historic price per euro of any currency we are using covering our date range , for testing. then I'd probably use the FB prophet model for time series to predict future exchange rates we can test it out and see ?
The more i think on this would we want to be using closing price * exchange rate on a daily level here when running the Efficient frontiers this way we capture the aditional risk& variance due to operating in a different currency all in one ?
Would be interesting to see how that affects results alright
To do: Calculate covariance of volatility of EUR / USD pair
Steps:
Only real unknown is getting data
We don't treat the currency as an asset in itself. Instead we are standardising our prices to euros. Prior to running our portfolio s
Inputs:
Outputs:
Two functions in DatabaseMainFnc.py
:
gen_curr_csv:
param: currency pair (default [USD->EUR,JPY->EUR,GBP->EUR])
Generates dataframe for currency pair(s) between 2006 and yesterday, and saves to csv
and
load_curr_csv:
params: stocks_df
input_curr
output_curr
Loads currency csv
converts date col to index
Checks if input currency is in currency_df column names
Prompt user to run gen_curr_csv if not (or run automatically?)
If output currency is not EUR,
rates = conversion from output to EUR to input
If output is EUR,
rates = column values where column = output
**return** rates \* stocks_df row-wise (index-wise?)
vectorised anyway
Committed changes to currency_dev branch. gen_curr_csv
and load_curr_csv
are now in. Multiplication using numpy looks to work as we want. Can check with the proper stocks dataframe.
A couple of changes from previous comment:
I hard-coded the 3 currency pairs in gen_curr_csv
to simplify things.
I also fixed the output currency to EUR in load_curr_csv
. If an input currency that isn't JPY, GBP or USD is passed in, it should return with a Currency not Supported message
Apart from that should be all g
I didn't properly look at your latest notebook on the main branch yet, can look at integrating after we merge these branches
Will make a merge request now
Tried the currency conversion in Historic_portfolio_nb.ipynb & I get the following error:
#Test the currency conversion
dmf.load_curr_csv(df_Nasdaq['AACG'],'USD')
ValueError Traceback (most recent call last)
Ah yes, it should be rates_df[input_curr] on that line. I think it should work then
-------- Original Message -------- On 11 Apr 2021, 20:59, pat42w wrote:
Tried the currency conversion in Historic_portfolio_nb.ipynb & I get the following error:
Test the currency conversion
dmf.load_curr_csv(df_Nasdaq['AACG'],'USD')
ValueError Traceback (most recent call last) in 1 #Test the currency conversion 2 ----> 3 dmf.load_curr_csv(df_Nasdaq['AACG'],'USD') c:\Users\patri\OneDrive\Documents\GitHub\EF_Portfolio_Optimization\DatabaseMainFnc.py in load_curr_csv(stocks_df, input_curr) 304 305 # Multiply each row of stocks dataframe by its' corresponding exchange rate --> 306 result = pd.DataFrame(np.array(rates_df) * np.array(stocks_df),columns=stocks_df.columns,index=stocks_df.index) 307 308 return result
ValueError: operands could not be broadcast together with shapes (5579,4) (3848,)
Looks like a shape issue and its trying to use maybe the index needs to be the dates of prices database, and its trying to use all the currencies instead of just the input_curr?
— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub, or unsubscribe.
Ah okay, does that sort the length issue too?
Ah I see now. Length issue will probably still be there. Do you know why the stocks_df is 3k long? Is it a new stock(i.e. joined the market after Jan 2006)? I hadn't considered that possibility.
Will need to do a join of some sort, keeping the intersection of the two indexes
-------- Original Message -------- On 11 Apr 2021, 21:25, pat42w wrote:
Ah okay, does that sort the length issue too?
— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub, or unsubscribe.
Well thered be currency rates for every day but stock data only on trading days . I'd say that's why it's shorter. But I think the datetime indexes can be used to take the dates needed ,
Ah yes that too. Ok I'll add in that step before the multiply -------- Original Message -------- On 11 Apr 2021, 21:34, pat42w wrote:
Well there's be currency rates for every day but stock data only on trading days . I'd say that's why it's shorter. But I think the datetime indexes can be used to take the dates needed ,
— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub, or unsubscribe.
Ok if I make this patch directly onto main branch?
Currently all portfolios are in the index's currency rather than euro.
Perhaps a database of daily Euro to other currency prices is the way to go here