Python Archives - blitz https://tufan.blitzarchive.com/category/python/ tufan Sun, 02 Mar 2025 12:26:25 +0000 en-US hourly 1 https://wordpress.org/?v=6.7.2 241003612 Database Connectivity and Financial Data Analysis Using Python https://tufan.blitzarchive.com/2025/03/02/database-connectivity-and-financial-data-analysis-using-python/ https://tufan.blitzarchive.com/2025/03/02/database-connectivity-and-financial-data-analysis-using-python/#respond Sun, 02 Mar 2025 12:26:25 +0000 https://tufan.blitzarchive.com/?p=4127 Total 20 Points.(You can submit/upload the complete ipynb file in the canvas) Task A. Data Visualization: 4 pointsGet the data “30_Industry_Portfolios.csv” data and “F-F_Research_Data_Factors.CSV” from class google drive. For both data select date from January 01, 2000 to December 31, 2018 Draw a 2*2 scatterplot that reflect the relationship between (1) mkt-rf and food, (2) […]

The post Database Connectivity and Financial Data Analysis Using Python appeared first on blitz.

]]>
Total 20 Points.(You can submit/upload the complete ipynb file in the canvas)
Task A. Data Visualization: 4 pointsGet the data “30_Industry_Portfolios.csv” data and “F-F_Research_Data_Factors.CSV” from class google drive.
For both data select date from January 01, 2000 to December 31, 2018
Draw a 2*2 scatterplot that reflect the relationship between (1) mkt-rf and food, (2) SMB and food, (3) mkt-rf and games and (4) SMB and games.
From the scatterplot what kind of relationshiop you see. [explain in words]
Task B. Regression Specification- Use the OLS function to estimate the follwoing: 10 PointsRun two univariate regression on Food and Games using excess market return (mkt-rf) as the dependent variable. Include a constant in the regressions.
Report the coefficient and t-stat of the market in this both industry, are they significant?
Report the R-squares of the models.
Run a multivarite regression for this two industry return (Food and Games) using all three Fama French Factors ( Market, SMB and HML).
Report the coefficient and t-stat of all three factors in both models, are they significant?
Report the R-squares of the models.
Is their any difference in the R-squares on 3 and 6. What doese this mean?
Task C. White’s covariance estimator: 6 pointsRe-estimate the two multivarite regression (Task B.4) with White’s covariance estimator.
Report the coefficient and t-stat of all three factors in both models, are they significant?
Are the parameter standard errors similar using the two covariance estimators (homoskedastic errors in Task B.4 and White’s covariance estimator). If not, what does this mean?

 

📝 Struggling with where to start this assignment? Follow this guide to tackle your assignment easily!


Step-by-Step Guide to Completing the Assignment

Task A: Data Visualization (4 points)

  1. Load the data

    • Import the datasets “30_Industry_Portfolios.csv” and “F-F_Research_Data_Factors.CSV” into Python using pandas.
    • Filter the data to include only dates between January 1, 2000, and December 31, 2018.
  2. Create Scatterplots

    • Use Matplotlib or Seaborn to plot four 2×2 scatterplots:
      • (1) MKT-RF vs. Food
      • (2) SMB vs. Food
      • (3) MKT-RF vs. Games
      • (4) SMB vs. Games
    • Label axes and titles properly.
  3. Interpret the Scatterplots

    • Observe the relationship between variables:
      • Are they positively or negatively correlated?
      • Do they have a strong or weak relationship?

Task B: Regression Specification (10 points)

Step 1: Univariate Regression (2 models)

  1. Use the OLS (Ordinary Least Squares) function from statsmodels to estimate two regressions:

    • Dependent Variable: Excess Market Return (MKT-RF)
    • Independent Variables:
      • Model 1: Food
      • Model 2: Games
    • Include a constant in the regression.
  2. Report Findings

    • Extract and report:
      • Coefficient & t-statistic for MKT-RF in both regressions.
      • Significance (p-value < 0.05 means it is statistically significant).
      • R-squared values to evaluate model fit.

Step 2: Multivariate Regression

  1. Estimate two multiple regressions:

    • Dependent Variables:
      • Model 3: Food
      • Model 4: Games
    • Independent Variables:
      • Market (MKT-RF)
      • SMB
      • HML
  2. Report Findings

    • Extract and analyze:
      • Coefficients & t-statistics for MKT-RF, SMB, and HML.
      • Significance levels (p-values).
      • R-squared values for both models.
  3. Compare R-Squared Values

    • Is the R-squared higher in the multivariate model than in the univariate?
    • What does this tell you about the importance of SMB and HML factors?

Task C: White’s Covariance Estimator (6 points)

  1. Re-run the multivariate regressions (Task B, Step 2)

    • This time, use White’s covariance estimator to adjust for heteroskedasticity.
  2. Compare Standard Errors

    • Extract coefficients and t-statistics.
    • Compare standard errors from homoskedastic (Task B) vs. heteroskedastic (White’s estimator) models.
  3. Interpret Findings

    • If standard errors change significantly, heteroskedasticity is present.
    • What does this mean for reliability?

Technical Requirements

  • Submit a Jupyter Notebook (.ipynb) file.
  • Use Python with pandas, numpy, matplotlib/seaborn, and statsmodels.
  • Label all charts and tables properly.
  • Ensure code is clean, commented, and well-structured.

Let me know if you need further clarifications! 🚀

The post Database Connectivity and Financial Data Analysis Using Python appeared first on blitz.

]]>
https://tufan.blitzarchive.com/2025/03/02/database-connectivity-and-financial-data-analysis-using-python/feed/ 0 4127
Project Deliverables and Demonstration Guide for Your Program Submission https://tufan.blitzarchive.com/2025/02/28/project-deliverables-and-demonstration-guide-for-your-program-submission/ https://tufan.blitzarchive.com/2025/02/28/project-deliverables-and-demonstration-guide-for-your-program-submission/#respond Fri, 28 Feb 2025 20:28:01 +0000 https://tufan.blitzarchive.com/?p=3515 Project Deliverables If your program is working, submit the source code of your program. You must demonstrate your program is working during the demonstration. Submit the source code, input file(s), output file(s), and visualizations/results. Please be sure to include thorough comments throughout your program where necessary. The comments should explain the code step-by-step during the […]

The post Project Deliverables and Demonstration Guide for Your Program Submission appeared first on blitz.

]]>
Project Deliverables If your program is working, submit the source code of your program. You must demonstrate your program is working during the demonstration. Submit the source code, input file(s), output file(s), and visualizations/results. Please be sure to include thorough comments throughout your program where necessary. The comments should explain the code step-by-step during the demonstration. Provide a detailed description of your algorithm and program flow. Be sure to include a step-by-step description of the tools that you used (compiler, libraries, etc). Zip all files or submit all files at once. This should be in report format. Prepare a demonstration of your project. This should be done in PowerPoint format, 15-20 slides are required.

 

Struggling with where to start this assignment? Follow this guide to tackle your assignment easily!

Step 1: Understand the Assignment

This assignment is focused on submitting the deliverables for a working program you’ve created. You’ll need to provide several components that demonstrate how your program works. You will also prepare a PowerPoint presentation to showcase the project.

Step 2: Program Deliverables

You are required to submit the following:

  • Source Code: Provide the complete code of your program. Ensure that it is well-commented. Comments should explain the purpose and function of each section of the code to make it easier for others to understand.
  • Input File(s): If your program requires any input files, submit them as well. These are files that the program uses to run, such as data files or configuration files.
  • Output File(s): Include the output that your program generates. This might be files or data logs that show the results of the program.
  • Visualizations/Results: If your program produces any visual output (like graphs or charts), be sure to include them. This could be visualizations of data or results.

Step 3: Comments in Your Code

In your source code, you must add thorough comments. This is essential so that anyone who looks at your code can easily follow the steps and logic behind your program. Here’s what to include in your comments:

  • Header comments: Start your code with comments that explain what the program does, its purpose, and any important details about how it works.
  • Step-by-step comments: For each major section of your code, describe what is happening. For example:
    • “This section reads the input file.”
    • “Here we process the data to calculate the average.”
    • “This block handles errors in case of invalid input.”

By explaining the code step-by-step, you help others (including your future self) understand how the program works.

Step 4: Program Algorithm and Flow Description

Write a detailed description of your algorithm. This should explain how your program works logically from start to finish. You should:

  • Describe the input: What data is needed for your program to run, and how is it collected or provided?
  • Explain the processing: What steps does the program take to transform the input into the output? Describe the logic, calculations, or transformations that occur.
  • Describe the output: What does the program produce once it has processed the input data? What format is the output in?
  • Ensure that the description flows logically from one step to the next so that anyone reading it can follow along with the program’s steps.

Step 5: Tools Used (Compiler, Libraries, etc.)

Provide a step-by-step description of the tools you used to build and run the program. For example:

  • Compiler/IDE: Mention the programming environment you used (e.g., Visual Studio, Eclipse, IntelliJ, or a command-line compiler like GCC).
  • Libraries and frameworks: If you used any external libraries or frameworks, mention them (e.g., NumPy for Python, OpenCV for computer vision, pandas for data processing).
  • Version control: If you used version control tools like Git, mention this and explain briefly how it helped manage your project.

Step 6: Prepare Your PowerPoint Presentation

The final step is to prepare a PowerPoint presentation to demonstrate your project. The presentation should be 15-20 slides long and should include the following:

  1. Introduction (1-2 slides): Briefly introduce the project, its purpose, and goals.
  2. Algorithm Overview (3-4 slides): Explain the algorithm in simple terms. Include a flowchart if possible to visually represent the logic.
  3. Program Features (4-5 slides): Showcase the main features of your program. What does it do, and how does it work?
  4. Demo of Your Program (5-6 slides): Show the program in action. Include screenshots or screen recordings of the program running. Show how it processes the input files and produces the output.
  5. Challenges and Solutions (2-3 slides): Discuss any challenges you encountered during the project and how you overcame them.
  6. Conclusion (1 slide): Summarize the project’s success and potential future improvements.

Make sure each slide has clear and concise content, and use bullet points for easy readability.

Step 7: Zip Your Files

Once everything is prepared, zip all your files together. Include:

  • Source code files
  • Input and output files
  • Visualizations or results
  • PowerPoint presentation

Ensure that the files are organized and easy to access. This will make it easier for anyone reviewing your work.


Final Tips:

  • Be thorough: The comments in your code and the descriptions of your algorithm are essential for understanding your work. Make sure everything is clear and easy to follow.
  • Keep the PowerPoint clear and concise: Avoid overcrowding slides with too much text. Use visuals like graphs, flowcharts, or screenshots where applicable to support your explanation.
  • Follow APA format: If you refer to any external resources, make sure to cite them correctly in APA format.

Let me know if you need further clarification or assistance!

The post Project Deliverables and Demonstration Guide for Your Program Submission appeared first on blitz.

]]>
https://tufan.blitzarchive.com/2025/02/28/project-deliverables-and-demonstration-guide-for-your-program-submission/feed/ 0 3515