Skip to content

Course material for the "IT For Business and Finance" 2019/20 course at University of Siena

Notifications You must be signed in to change notification settings

gabrielepompa88/IT-For-Business-And-Finance-2019-20

Repository files navigation

IT For Business and Finance 2019/20

This repository (https://github.com/gabrielepompa88/IT-For-Business-And-Finance-2019-20) provides course informations and material supporting the first year master course of IT For Business and Finance held at University of Siena in 2019/20.

WARNING: the course and this repository is under ongoing update.


Symbols conventions: updated sections/material in this README.md file will be highlited with 🔴 (a big red circle) displayed next to it.

  • Objectives: To acquire practice in the use of financial models through Python programming language
  • Contents: IT tools for modeling in Finance; Python
  • Teaching Methods: Lessons in IT lab
  • Verification of learning: written exam
  • Learning Material:

Table of contents


IMPORTANT COMMUNICATIONS

The e-learning for IT for Business and Finance course at http://elearning.unisi.it/moodle/ (more info to come) is now active. You can access with your unisiPass credentials at http://elearning.unisi.it/moodle/ and type "IT pompa" in the "Cerca Corso" search window (top right corner of screen). E-learning material is under ongoing production and addition.

  • Exam dates: these below are the exam dates of the IT for Business and Finance course terms:
    • Summer term – 1st session: Thursday June 4th, 2020 h 10:30 – 12:30
    • Summer term – 2nd session: Monday June 29th, 2020 h 10:30 – 12:30
    • Fall term – 1st session: Tuesday September 1st, 2020 h 10:30 – 12:30
    • Fall term – 2nd session: Friday September 18th, 2020 h 10:30 -12:30
    • Winter term - 2nd session: Friday February 12th, 2021 h 10:00 - 12:00
    • March term - Monday March 15th, 2021 h 10:00 - 12:00

EXAMS

For additional informations see Exams section of Moodle page for IT for Business and Finance class

General Informations

On the exam date, at the beginning of the exam time window (next exam: Monday March 15th, 2021 at 10:00, Rome time, you will find attached an exam sheet to the specific exam activity section (next: March Term; The exam sheet is a Jupyter Notebook with questions/exercises and empty Code cells for your answers. A Jupyter Notebook is a file with .ipynb extension. It is the kind of file on which lecture notes have been delivered so far, so you should be already familiar with this (see Prerequisites);

Operational Instructions

Answer to the questions on the exam sheet offline, on your personal computer, following these operational instructions:

  • download the exam sheet on your personal computer;
  • move the exam sheet downloaded to the Exams sub-folder of your class folder (IT_For_Business_And_Finance_2019_20\Exams); (see Prerequisites)
  • open the exam sheet using the Jupyter Notebook app of the Anaconda Navigator (see Prerequisites);
  • answer to the exam questions directly on the exam sheet;
  • once done, save and download (as Notebook) the exam sheet completed;
  • before the end of the exam time window: upload the exam sheet as an attachement, using the dedicated upload form.

Prerequisites

These are the prerequisites you must fulfill before taking the exam: You should have already the latest updated version of the class folder IT_For_Business_And_Finance_2019_20 on your personal computer. You should have the Anaconda Navigator installed on your personal computer. Using the Jupyter Notebook application of the Anaconda Navigator, you should be able to (these are all step you should have already be well familiar with, if you have followed the class):

  • navigate to the directory containing the notebook you want to open,
  • open the notebook,
  • making changes to it,
  • run it,
  • save it,
  • download it (as Notebook .ipynb file).

As per exam, it will be assumed that all of you satisfy these prerequisites. Should you still be missing some of those, please follow these instructions on how to work this class: https://github.com/gabrielepompa88/IT-For-Business-And-Finance-2019-20/blob/master/How-to-work-this-class.md and please do let me know if you need assistance.

About the exam

  • Exam questions can ask you to write code or answer theoretical questions.
  • Comment extensively your code. A well written and commented code which does not run is more valuable (and will be graded accordingly) than a poorly written and not-commented code that does run.
  • You can use whatever you want to do the exam (textbook, books, internet, etc.)
  • In the exam sheet you will find further instructions to be followed. In particular: even if the exam sheet will be unique for everybody, you will be asked to use your unisi identification number unisi_id (e.g. 589160) in several ways to make it unique (for example: you might be asked to set the lenght of a NumPy array to the second digit (e.g. 8) of your unisi_id, or to input the full unisi_id as a seed for a random number generation, like: np.random.seed(589160) )

Extra

Upon suggestions, you may do some extra work and prepare a financial project . The following rules apply:

  • The project is not compulsory and, in particulary, does not substitute the Exam;
  • The project might be helpful for exam preparation and, in particular, for your future to show off your ability (to recruiters and/or hiring managers);
  • The project shall take the form of the development of a personal GitHub repository, on the footprints of the class one;
  • I will be happy (write me to take an appointment) to discuss with you project topics of mutual interest and to help you with the project;

For any question, I’m here to help you ([email protected], Skype: gabriele.pompa)

🔴 March Term

Exam: https://elearning.unisi.it/mod/assign/view.php?id=146803

Exam Schedule

Exam timing: Monday MArch 15th, 2021 h 10:00 - 12:00 (2 hours), Rome time;

Exam sheet: Exam_March_Term.ipynb (you'll find it attached by the beginning of the exam time-window: 10:00 Rome time);

Complete exam sheets must be submitted using this form before the end of the exam time-window: 12:00 Rome time).

Registrations are now open and will close on Monday March 8th, 2021.

II Exam - Winter Term

Exam: https://elearning.unisi.it/mod/assign/view.php?id=139180

Exam Schedule

Exam timing: Friday February 12th, 2021 h 10:00 - 12:00 (2 hours), Rome time;

Exam sheet: II_Exam_Winter_Term.ipynb (you'll find it attached by the beginning of the exam time-window: 10:00 Rome time);

Complete exam sheets must be submitted using this form before the end of the exam time-window: 12:00 Rome time).

Registrations are now open and will close on Sunday February 7th, 2021.

II Exam - Fall Term

Exam: https://elearning.unisi.it/mod/assign/view.php?id=112760

Exam Schedule

Exam timing: Friday September 18th, 2020 h 10:30 - 12:30 (2 hours), Rome time;

Exam sheet: II_Exam_Fall_Term.ipynb (you'll find it attached by the beginning of the exam time-window: 10:30 Rome time);

Complete exam sheets must be submitted using this form before the end of the exam time-window: 12:30 Rome time).

Registrations are now open and will close on Wednesday September 16th, 2020.

II Exam - Summer Term

Exam: https://elearning.unisi.it/mod/assign/view.php?id=106971

Exam Schedule

Exam timing: Monday June 29th, 2020 h 10:30 - 12:30 (2 hours), Rome time;

Exam sheet: II_Exam_Summer_Term.ipynb (you'll find it attached by the beginning of the exam time-window: 10:30 Rome time);

Complete exam sheets must be submitted using this form before the end of the exam time-window: 12:30 Rome time).

Registrations are closed.

I Exam - Summer Term

Exam: https://elearning.unisi.it/mod/assign/view.php?id=104104

Exam Schedule

Exam timing: Thursday June 4th, 2020 h 10:30 - 12:30 (2 hours), Rome time;

Exam sheet: I_Exam_Summer_Term.ipynb (you'll find it attached by the beginning of the exam time-window: 10:30 Rome time);

Complete exam sheets must be submitted using this form before the end of the exam time-window: 12:30 Rome time).

Registrations are closed.


Class Schedule

Classes start on Monday, February 24 2020 at 14:00 in Aula informatica 1. The timetable is:

Monday: 14:00-16:00
Tuesday: 18:00-19:30 this lesson starts sharply at 18:00
Wednesday: 14:00-16:00

Currently known amendements to this schedule are the following:

Monday 16/3: Aula 1
Wednesday 4/3 and 18/3: Aula 12


Contacts

Gabriele Pompa ([email protected])


Class Diary

This is the diary of the class. Here the topics covered during the lessons are listed, as well as the corresponding reading material.

Conventions for reading material: sections from

A. the TextBook Python for Finance (2nd ed.) are labelled as TB.ChapterNumber.SectionName to refer to a whole Section (e.g. TB.1.The Python Programming Language) or as TB.ChapterNumber.SubSectionName to refer to a particular sub-Section (e.g. TB.1.Data-Driven Finance ).

B. the Python Tutorial are labelled as PyT.SectionNumber.SubSectionNumber.SubSubSectionNumber (SubSubSectionName)_ (e.g.: section 3.1.2 on Strings is labelled PyT.3.1.2 (Strings) ).

C. the Numpy Quickstart Tutorial are labelled as Numpy Quickstart Tutorial - SectionName (list of SubSections).

D. the Pandas - Getting started tutorials are mentioned by section name (e.g.: What kind of data does pandas handle?).

Below the list of lessons with relevant related material:

  • Lesson 1 (24/02): class presentation. introduction to: programming in Python, Anaconda platform, Jupyter Notebooks and interactive programming, Spyder IDE and programmatic programming, Python modules and import expressions.

    • TB.1.The Python Programming Language, TB.1.Technology in Finance.
    • Lecture Notes Introduction I .ipynb | .pdf.
  • Lesson 2 (25/02): motivations for adopting Python in Finance.

    • TB.1.Python for Finance, TB.1.Data-Driven Finance, TB.2.Basic Operations with conda, TB.2.conda as a Virtual Environment Manager.
  • Lesson 3 (26/02): random number generation. Histogram. Empirical distribution (normalized histogram). Template for .py files (scripts) in Spyder.

    • Spyder Template file template_example.py: use this file as a template example. Any script (.py file) that you write in Spyder IDE has to follow the structure of this template.
    • Lecture Notes Introduction II .ipynb | .pdf: Sec. 1, 2, 3.
  • Lesson 4 (2/03): int data type, .bit_length() method for int, binary representation of integers (examples). float data type, issues of finite precision of internal binary representation of decimal numbers, arbitrary precision in Python (Decimal module). Normal random variables in Python (Scipy norm class),.pdf() method of norm class, Normal fit to empirical distribution, .fit() method of norm class.

    • TB.3.Integers, TB.3.Floats.
    • Lecture Notes Introduction II .ipynb | .pdf:: Sec. 4.
    • Lecture Notes Basics_I___Data_Types .ipynb | .pdf: Sec. 1 and 2.
  • μετα-Lesson 5 (3/03): gentle introduction to github. Teacher-Student(s) workflow (push-pull flow). Edit - Stage (git add) - Commit (git commit) pattern. Setup of a local development clone of a repository already established (hands-on example: git clone of the class repository into computers of Aula Informatica 1). Syncing local clone with updated class repository (the hard way) with git fetch and git reset.

  • Lesson 6 (4/03): how to work this class, class/home study work-flow, how to take notes in class and at home (the Personal_Notes personal folder). Random number generation: Normal fit of a distribution, higher moments of a distribution (Skewness and Kurtosis), sample skewness and kurtosis, Jarque-Bera test of Normality, null-hypothesis and use of p-value of a test for decision-making.

  • Lesson 7 (9/03): introduction to the e-learning platform moodle. bool data type, while loop, if statement. str data type (definition, indexing, slicing).

  • Lesson 8 (10/03): introduction to data-structures in Python, tuple data structure, list data structure, for loop, dict data structure, set data structure.

  • Lesson 9 (11/03): NumPy ndarray data-structure: arrays creation, indexing, slicing, iterating over arrays, basic operations, built-in methods, universal functions, shape manipulation, stacking of arrays

  • Lesson 10 (16/03): Pandas Series data-structure: creation from 1-dim NumPy array using pd.Series() constructor, indexing and slicing using [] access operator, basic plotting, basic analytics, built-in methods, interface with NumPy's universal functions. Returns time-series: log-normal i.i.d. time-series (using NumPy's random.lognormal function), step-by-step computation, direct computation using .shift(), linear and log-returns.

  • Lesson 11 (18/03): Pandas DataFrame data-structure: creation from multi-dim NumPy array using pd.DataFrame() constructor, columns selection using [] access operator, indexing and slicing of rows and columns using .loc[] and .iloc[] access operators, basic plotting, creation and deletion of columns, basic analytics on row- and column-wise base and .groupby() method, built-in methods, interface with NumPy's universal functions. Concatenation, Joining and Merging of two DataFrames using .join() method and pd.merge() function.

  • Lesson 12 (30/03): Python serializations protocols: JSON (json module) and Pickle (pickle module). IO operations in Pandas with output formats (.to_*() DataFrame methods and pd.read_*() function): SQL (SQLite engine and sqlite3 module), CSV and Excel.

  • Lesson 13 (01/04): yfinance API: installation, Yahoo! Finance tickers lookup page. Basic usage: get market and meta data for one (yf.Ticker()) and multiple (yf.Tickers()) security/s, mass download of market data (yf.download()).

    • yfinance library:
    • Lecture Notes Data Analysis - Financial Time Series .ipynb | [.pdf]: Section 1.Introduction to yfinance library
    • Exercises: practice with yfinance API:
      • download ticker data for "General Electric Company" stock from Jan 1st, 1985;
      • save its "Close" price Pandas Series as a 'GE_Close_Price.csv' file in /Data folder;
      • open both the 'Securities_Close_Price_Dataset.csv' and the, just saved 'GE_Close_Price.csv';
      • integrate GE Close price data with other data as an additional column 'GE' of the closePrice DataFrame in 'Securities_Close_Price_Dataset.csv' file;
      • save the extended closePrice DataFrame as 'Extended_Securities_Close_Price_Dataset.csv' file.
    • Videos:
  • Lesson 14 (06/04): Data Analysis: first look at DataFrame (.head(), .tail() and .plot() methods), buy-and-hold portfolio, summary statistics, returns: simple (.pct_change() method) and log-returns (.shift() method), resampling (.resample() method), graphical test of normality (Normal fit, Q-Q plot), rolling statistics (.rolling() method), rolling correlation matrix (not for exam), SPX/VIX inverse relationship analysis: OLS regression (np.polyfit() function), correlation analysis.

    • TB.8.Financial Data, TB.8Rolling Statistics, TB.8.Correlation Analysis, TB.13.Real-World Data.
    • Lecture Notes Data Analysis - Financial Time Series .ipynb | [.pdf]: Section 2.Data Analysis
    • Exercises:
      • practice on the Data Analysis (summary statistics, returns, resampling, rolling statistics etc.) topics covered using the 'Extended_Securities_Close_Price_Dataset.csv' file, which includes closing prices for the 'GE' Stock;
      • In particular: do the graphical tests of normality (histogram, normal fit and Q-Q plot) on the 'GE' stock. Do this in a script file named 'GE_Returns_Graphical_Normality_Tests.py' and save it in the 'Scripts' folder (Hint: you can modify SPX_Returns_Graphical_Normality_Tests.py which you can find in the 'Scripts' folder already)
    • Videos:
  • Lesson 15 (08/04): introduction to Object-Oriented Programming (OOP) paradygm. Non-financial example (Person class). Call-option Black-Scholes pricer (CallOption class). Encapsulation: name hiding, getters and setters methods. General PlainVanillaOption class to price put options too.

  • Lesson 16 (15/04): digital Cash-Or-Nothing options. Inheritance. Polymorphism: in functions, in classes methods. Polymorphism in overridden methods. Abstract classes.

  • Lesson 17 (17/04): default parameters in functions; optional parameters: *args, **kwargs, input flexibility and agnostic flow in functions and classes. Objects Composition and Aggregation. P&L computation (.PnL() method). Portfolio of options (Portfolio). Plotting functionalities (Plotter class and sub-classes for single options and portfolios of options). Option Strategies: short positions, Bull Spread (synthtetic cash-or-nothing digital replication), Straddle, Calendar Spread

  • 🔴 BONUS Lesson 18 - NOT FOR THE EXAM: Option greeks: Black-Scholes analytic greeks for plain-vanilla and digital optinos. Numeric derivatives (finite-differences methods, NumericDerivatives class). Root-finding: Newton-Rhapsod method, implied volatility estimation. Introduction to pyBlackScholesAnalytics Python package.

Resources

Reading

Programming

  • Anaconda platform is a free and open-source distribution of the Python and R programming languages for scientific computing (data science, machine learning applications, large-scale data processing, predictive analytics, etc.), that aims to simplify package management and deployment. Package versions are managed by the package management system conda The Anaconda distribution includes data-science packages suitable for Windows, Linux, and MacOS (quoting wikipedia page)

    Tips:

  • Jupyter Notebooks (included in Anaconda distribution) is a web-based interactive computational environment for creating Jupyter notebook documents (quoting wikipedia page)

    Tips:

  • Spyder IDE (also shipped with Anaconda distribution) is an open source integrated development environment (IDE) for scientific programming in the Python language (quoting wikipedia page)


Setup

This section describes practical informations on how to work this class. Daily activities and once-for-all setup(s) are separately described both for in-class lessons and study from-home.

Feel free to contact me at [email protected] in case something is not clear or if you spot errors or if you have suggestions for improvement. Thanks.

About

Course material for the "IT For Business and Finance" 2019/20 course at University of Siena

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published