Giter Club home page Giter Club logo

time-series_analysis's Introduction

Time Series & Linear Regression Modeling - A Yen for the Future

Analyzing the future direction and risk of Japanese Yen Currencies

Yen Photo

Background

The financial departments of large companies often deal with foreign currency transactions while doing international business. As a result, they are always looking for anything that can help them better understand the future direction and risk of various currencies. Hedge funds, too, are keenly interested in anything that will give them a consistent edge in predicting currency movements.

Here we will test the many time-series tools to predict future movements in the value of the Japanese yen versus the U.S. dollar.

Hereby gain proficiency in the following tasks:

  • Time Series Forecasting
    1. ARMA Model - Forecasting Returns
    2. ARIMA Model - Forecasting the Settle Price
    3. GARCH - Forecasting Volatatility
  • Linear Regression Modeling

Files

Time-Series Starter Notebook

Linear Regression Starter Notebook

Yen Data CSV File


Time-Series Forecasting

In this notebook, load historical Dollar-Yen exchange rate futures data and apply time series analysis and modeling to determine whether there is any predictable behavior.

The steps outlined in the time-series Analysis:

  1. Decomposition using a Hodrick-Prescott Filter (Decompose the Settle price into trend and noise).
Trend Noise
alt-text-1 alt-text-2
  1. Forecasting Returns using an ARMA Model.
Summary Report Forecast Returns
  1. Forecasting the Settle Price using an ARIMA Model.
Summary Report Forecast Settle Price
  1. Forecasting Volatility with GARCH.
Summary Report Forecast Volatality

Use the results of the time series analysis and modeling to answer the following questions:

  1. Based on your time series analysis, would you buy the yen now?

Based on the above models, its more likely to uptrend next 5 Business days

  1. Is the risk of the yen expected to increase or decrease?

Based on GARCH Modeling analysis, the risk is expected to increase for the Yen

  1. Based on the model evaluation, would you feel confident in using these models for trading?

For ARMA & ARIMA models, p < 0.05 and also, AIC & BIC values are way high. These are not the best models for trading the Yen

Linear Regression Forecasting

In this notebook, Build a Scikit-Learn linear regression model to predict Yen futures ("settle") returns with lagged Yen futures returns and categorical calendar seasonal effects (e.g., day-of-week or week-of-year seasonal effects).

The steps outlined in the regression_analysis:

  1. Data Preparation (Creating Returns and Lagged Returns and splitting the data into training and testing data)

  2. Fitting a Linear Regression Model.

       # Create a Linear Regression model and fit it to the training data
       from sklearn.linear_model import LinearRegression
       model = LinearRegression()
       # Fit a SKLearn linear regression using just the training set (X_train, Y_train):
       model.fit(X_train, y_train)
  3. Making predictions using the testing data.

        predictions = model.predict(X_test)
  4. Out-of-sample performance.

    Out-of-sample Root Mean Squared Error (RMSE): 0.41521640820129047

  5. In-sample performance.

    In-sample Root Mean Squared Error (RMSE): 0.5663352320297497

  • Does this model perform better or worse on out-of-sample data compared to in-sample data?

    RMSE for Out-of-sample is lower (0.415) as compared to in-sample (0.566). Model performs better on out-of-sample data


Hints and Considerations

  • Out-of-sample data is data that the model hasn't seen before (Testing data).
  • In-sample data is data that the model was trained on (Training data).

time-series_analysis's People

Watchers

James Cloos avatar Kowsalya Jeyabalan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.