#] #] ********************* #] "$d_mkts"'[interest, exchange] rates/0_exchange rate model notes.txt' - ??? # www.BillHowell.ca 21Sep2022 initial # view in text editor, using constant-width font (eg courier), tabWidth = 3 CADUSD https://www.tradingview.com/chart/bBOx2dOW/?symbol=FX_IDC%3ACADUSD CNYUSD https://www.tradingview.com/chart/zxwnYiAA/ EURUSD https://www.tradingview.com/chart/9eRoPBHx/ GBPUSD https://www.tradingview.com/chart/lJ7pSprS/ INRUSD JPYUSD #48************************************************48 #24************************24 # Table of Contents, generate with : # $ grep "^#]" "$d_mkts"'[interest, exchange] rates/0_exchange rate model notes.txt' | sed "s/^#\]/ /" # #24************************24 # Setup, ToDos, #08********08 #] ??Sep2022 #08********08 #] ??Sep2022 #08********08 #] ??Sep2022 #08********08 #] ??Sep2022 #08********08 #] 26Sep2022 download Canada [debt, deficit, Central Bank leveraging, covid stimulus] data https://ourworldindata.org - doesn't have economic series? government data - I have already source some macro-economic data - check that out I might not be able to get TradingView equivalents - confined to put in exogenous data? US Bureau of Economic Analysis World Bank all countries, annual data 1960-2019 in USD (can update) Metadata - 2 files for use with annua data... but TradingView provides GDP series, . 08******08 #] 25Sep2022 download FX-related data must save [10Y, USD] separately - USD exchange rates are often shorter time series quick URL for ECONOMICS: https://www.tradingview.com/symbols/ECONOMICS-INEXP/ TradingView market symbol glossary : where xx = [CA, CN, EU, GB, IN, JP] 'xx10Y Feb1998-Sep2022 TradingView' Economics: central bank 10Y bond rate 'xxEXP Jan1957-Aug2022 TradingView' Economics: exports 'xxGDP Dec1960-Dec2021 TradingView' Economics: one data point per year! not good 'xxGDPD Dec2005-Dec2021 TradingView' Economics: GDP deflator 'xxGDPQQ Sep1996-Jun2022 TradingView' Economics: GDP growth rate quarterly 'xxIMP Jan1957-Aug2022 TradingView' Economics: imports 'xxIRMM Feb2011-Aug2022 TradingView' Economics: inflation rate month-to-month 'xxIRYY Jan1989-Aug2022 TradingView' Economics: inflation rate year-over-year 'xxyUSD Jun2007-Sep2022 TradingView' Economics: currency exchange versus USD ** ** inverted plot unlike DXY, but same trend directions +-----+ finished this 28Sep2022 ''CA10Y Jan1986-Sep2022 TradingView' ''CADUSD Jun1987-Sep2022 TradingView' ''CAEXP Jan1971-Jul2022 TradingView' ''CAGDP Dec1960-Sep2022 TradingView' ''CAGDPD Mar1961-Jun2022 TradingView' ''CAGDPQQ Jun1961-Sep2022 TradingView' ''CAIMP Jan1971-Jul2022 TradingView' ''CAIRMM Jan1950-Aug2022 TradingView' ''CAIRYY Feb1915-Aug2022 TradingView' ''CAOE Jan1988-Jul2022 TradingView' ''CN10Y Jun2002-Sep2022 TradingView' ''CNEXP Jan1981-Aug2022 TradingView' ''CNGDP Dec1960-Dec2021 TradingView' ''CNGDPD Dec1978-Dec2020 TradingView' ''CNGDPQQ Dec2010-Jun2022 TradingView' ''CNIMP Jan1981-Aug2022 TradingView' ''CNIRMM Jan1996-Aug2022 TradingView' ''CNIRYY Jan1986-Aug2022 TradingView' ''CNYUSD Jun2007-Sep2022 TradingView' ''EU10Y Dec1998-Sep2022 TradingView' ''EUEXP Jan1999-Jul2022 TradingView' ''EUGDP Dec1960-Dec2021 TradingView' ''EUGDPD Mar1995-Dec2021 TradingView' ''EUGDPQQ Jun1995-Jun2022 TradingView' ''EUIMP Jan1999-Jul2022 TradingView' ''EUIRMM Feb1990-Aug2022 TradingView' ''EUIRYY Jan1991-Aug2022 TradingView' ''EURUSD Jan1971-Sep2022 TradingView' ''GB10Y Dec1979-Sep2022 TradingView' ''GBEXP Mar1955-Jul2022 TradingView' ''GBGDP Dec1960-Dec2021 TradingView' ''GBGDPD Mar1955-Jun2022 TradingView' ''GBGDPQQ Jun1955-Jun2022 TradingView' ''GBIMP Mar1955-Jul2022 TradingView' ''GBIRMM Feb1988-Aug2022 TradingView' ''GBIRYY Jan1989-Aug2022 TradingView' ''GBPUSD Jan1971-Sep2022 TradingView' ''IN10Y Feb1998-Sep2022 TradingView' ''INEXP Jan1957-Aug2022 TradingView' ''INGDP Dec1960-Dec2021 TradingView' ''INGDPD Dec2005-Dec2021 TradingView' ''INGDPQQ Sep1996-Jun2022 TradingView' ''INIMP Jan1957-Aug2022 TradingView' ''INIRMM Feb2011-Aug2022 TradingView' ''INIRYY Jan2012-Aug2022 TradingView' ''INRUSD Jun2007-Sep2022 TradingView' ''JP10Y Feb2006-Sep2022 TradingView' ''JPEXP Jan1963-Aug2022 TradingView' ''JPGDP Dec1960-Dec2021 TradingView' ''JPGDPD Mar1980-Jun2022 TradingView' ''JPGDPQQ Jun1980-Jun2022 TradingView' ''JPIMP Jan1963-Aug2022 TradingView' ''JPIRMM Feb1970-Aug2022 TradingView' ''JPIRYY Jan1958-Aug2022 TradingView' ''JPYUSD Feb1986-Sep2022 TradingView' nothing for oil [exports, imports] -> need another data source : 'CNOE Jan1988-Jul2022 TradingView' 'EUOE Jan1988-Jul2022 TradingView' 'GBOE Jan1988-Jul2022 TradingView' 'INOE Jan1988-Jul2022 TradingView' done : CA[GDP, GDPQQ, EXP, IMP, OE (oil exports)] #08********08 #] 21Sep2022 PineScript - intl exchange rates versus [TNX-10Y, USOIL Temporary save coefficients : a_CADUSD = -25. a_CNYUSD = -30. a_EURUSD = -30. a_JPYUSD = -0.2 b_CADUSD = 0.01 b_CNYUSD = 50. b_EURUSD = 0.5 b_JPYUSD = 0.05 +-----+ olde code // doesn't need this - except 5Y time.period, but leave it at that //if (timeframe.period == "60") // 3 months // avg_INRUSD := 0.006976 // delMin_IN10Y := -0.168934 // delMax_IN10Y := 1.045793 // constCoeff := 0.002 //else if (timeframe.period == "120") // 6 months // avg_INRUSD := 0.006976 // delMin_IN10Y := -0.528119 // delMax_IN10Y := 1.037960 // constCoeff := 0.002 //else if (timeframe.period == "D") // 1 year // avg_INRUSD := 0.006976 // delMin_IN10Y := -1.581633 // delMax_IN10Y := 1.00300 // constCoeff := 0.0025 //else if (timeframe.period == "W") // 5 years // avg_INRUSD := 0.008731 // 0.006976?? // delMin_IN10Y := -2.530463 // delMax_IN10Y := 1.00300 // constCoeff := 0.0012 +-----+ https://towardsdatascience.com/exchange-rate-prediction-machine-learning-with-5-regression-models-d7a3192531d Andrew Nguyen May 29, 2020 Exchange Rate Prediction: Machine Learning with 5 Regression Models Following data cleaning and visualisation, this part deploys Machine Learning to find the best line that fits all data points, as the preparation for the prediction in the final part. >> Nguyen uses [interest rate differential, unemployment rate] +-----+ https://towardsdatascience.com/exchange-rate-prediction-machine-learning-with-5-regression-models-d7a3192531d Andrew Nguyen Github: https://github.com/andrewnguyen07 May 29, 2020 Exchange Rate Prediction: Machine Learning with 5 Regression Models Following data cleaning and visualisation, this part deploys Machine Learning to find the best line that fits all data points, as the preparation for the prediction in the final part. According to Investopedia, there are 3 common ways to forecast exchange rates: Purchasing Power Parity (PPP), Relative Economic Strength, and Econometric Model. Among the three, I decided to go with the third as it involves a multitude of factors that affect currency movements. This method greatly aligns with the direction that employs “any independent variable” that is influential on the dependent variable — linear regression. Therefore, the factors I wanted to test out are interest rate differential, GDP growth rates, and income growth rate, sequentially yet accumulatively. For this project, I used the exchange rate of AUD/USD for the analysis. >> Howell - I already did interest rate differentials I like GDP growth rate. Nguyen doesn't consider [net import, debt, deficit]/GDP he used : variable R-squared (after cumulative use of variables listed) interest rate diff 72% GDP growth rate 87.2 Consumer Price Idx (CPI) 87.3 no good, no longer used Unemployment Rate (UER) 88.9 not enough, Nguyen therefore tried different regressions polynomial regression with [interest rate, GDP growth rate] diff 99.9% degree 4 (randomly selected) Overfitting - tried [ridge, lasso] regression : Ridge Regression and Lasso Regression were developed from this concept of Regularisation. The only difference between the two is: Ridge Regression uses L2 Regularisation technique, which shrinks the coefficients to zero, but NOT absolute zero Lasso Regression uses L1 Regularisation technique, which shrinks the coefficients to absolute zero This is because Ridge keeps all variables/features while Lasso only keeps the important ones that matter, hence voted as the variable/feature selection technique when our dataset has TOO MANY variables/features. ridge 88% r-squared lasso 88.9% +-----+ https://en.wikipedia.org/wiki/Mundell%E2%80%93Fleming_model Mundell–Fleming model Variables This model uses the following variables: Y is real GDP C is real consumption I is real physical investment, including intended inventory investment G is real government spending (an exogenous variable) M is the exogenous nominal money supply P is the exogenous price level i is the nominal interest rate L is liquidity preference (real money demand) T is real taxes levied NX is real net exports >> Howell - Hah, I already did interest rates, was thinking of [net export, debt, deficit]/GDP >> I like the other variables too Equations The Mundell–Fleming model is based on the following equations: The IS curve: Y = C + I + G + N X {\displaystyle Y=C+I+G+NX\,} Y=C+I+G+NX\, where NX is net exports. The LM curve: M P = L ( i , Y ) {\displaystyle {\frac {M}{P}}=L(i,Y)} {\frac {M}{P}}=L(i,Y) A higher interest rate or a lower income (GDP) level leads to lower money demand. The BoP (Balance of Payments) Curve: B o P = C A + K A {\displaystyle BoP=CA+KA\,} BoP=CA+KA\, where BoP is the balance of payments surplus, CA is the current account surplus, and KA is the capital account surplus. IS components C = C ( Y − T ( Y ) , i − E ( π ) ) {\displaystyle C=C(Y-T(Y),i-E(\pi ))\,} C=C(Y-T(Y),i-E(\pi ))\, where E(π) is the expected rate of inflation. Higher disposable income or a lower real interest rate (nominal interest rate minus expected inflation) leads to higher consumption spending. I = I ( i − E ( π ) , Y t − 1 ) {\displaystyle I=I(i-E(\pi ),Y_{t-1})\,} {\displaystyle I=I(i-E(\pi ),Y_{t-1})\,} where Yt-1 is GDP in the previous period. Higher lagged income or a lower real interest rate leads to higher investment spending. N X = N X ( e , Y , Y ∗ ) {\displaystyle NX=NX(e,Y,Y^{*})} {\displaystyle NX=NX(e,Y,Y^{*})} where NX is net exports, e is the nominal exchange rate (the price of foreign currency in terms of units of the domestic currency), Y is GDP, and Y* is the combined GDP of countries that are foreign trading partners. Higher domestic income (GDP) leads to more spending on imports and hence lower net exports; higher foreign income leads to higher spending by foreigners on the country's exports and thus higher net exports. A higher e leads to higher net exports. Balance of payments (BoP) components C A = N X {\displaystyle CA=NX} CA=NX where CA is the current account and NX is net exports. That is, the current account is viewed as consisting solely of imports and exports. K A = z ( i − i ∗ ) + k {\displaystyle KA=z(i-i^{*})+k} {\displaystyle KA=z(i-i^{*})+k} where i ∗ {\displaystyle i^{*}} i^* is the foreign interest rate, k is the exogenous component of financial capital flows, z is the interest-sensitive component of capital flows, and the derivative of the function z is the degree of capital mobility (the effect of differences between domestic and foreign interest rates upon capital flows KA). Variables determined by the model After the subsequent equations are substituted into the first three equations above, one has a system of three equations in three unknowns, two of which are GDP and the domestic interest rate. Under flexible exchange rates, the exchange rate is the third endogenous variable while BoP is set equal to zero. In contrast, under fixed exchange rates e is exogenous and the balance of payments surplus is determined by the model. Under both types of exchange rate regime, the nominal domestic money supply M is exogenous, but for different reasons. Under flexible exchange rates, the nominal money supply is completely under the control of the central bank. But under fixed exchange rates, the money supply in the short run (at a given point in time) is fixed based on past international money flows, while as the economy evolves over time these international flows cause future points in time to inherit higher or lower (but pre-determined) values of the money supply. +-----+ https://towardsdatascience.com/exchange-rate-prediction-time-series-forecasting-with-arima-27260faafcdc Andrew Nguyen A data analyst, without a higher degree, aspires to master data science skillsets by on-the-side projects. May 31, 2020 Exchange Rate Prediction: Time Series Forecasting with ARIMA Utilizing the previous work with Regression, this final part aims to forecast future exchange rates using ARIMA, a machine learning algorithm that “predicts the future from the past”. # enddoc