وبلاگ بلیان

Python Programming for Economics and Finance

معرفی کتاب «Python Programming for Economics and Finance» نوشتهٔ Thomas J. Sargent & John Stachurski، منتشرشده توسط نشر QuantEcon در سال 2023. این کتاب در فرمت pdf، زبان انگلیسی ارائه شده است. «Python Programming for Economics and Finance» در دستهٔ بدون دسته‌بندی قرار دارد.

This book presents a set of lectures on Python programming for economics and finance. This is the first text in the series, which focuses on programming in Python. Python is a general-purpose language used in almost all application domains such as: • communications • web development • CGI and graphical user interfaces • game development • resource planning • multimedia, data science, security, etc., etc., etc. For reasons we will discuss, Python is particularly popular within the scientific community and behind many scientific achievements in: • Space Science • Particle Physics • Genetics and practically all branches of academia. Meanwhile, Python is also very beginner-friendly and is found to be suitable for students learning programming and recommended to introduce computational methods to students in fields other than Computer Science. Python is also replacing familiar tools like Excel as an essential skill in the fields of finance and banking. One nice feature of Python is its elegant syntax — we’ll see many examples later on. Elegant code might sound superfluous but in fact it’s highly beneficial because it makes the syntax easy to read and easy to remember. Remembering how to read from files, sort dictionaries and other such routine tasks means that you don’t need to break your flow in order to hunt down correct syntax. Closely related to elegant syntax is an elegant design. Features like iterators, generators, decorators and list comprehensions make Python highly expressive, allowing you to get more done with less code. Namespaces improve productivity by cutting down on bugs and syntax errors. I Introduction to Python About Python Overview What’s Python? Common Uses Relative Popularity Features Syntax and Design Scientific Programming Numerical Programming Graphics Symbolic Algebra Statistics Pandas Other Useful Statistics and Data Science Libraries Networks and Graphs Cloud Computing Parallel Processing Other Developments Learn More Getting Started Overview Python in the Cloud Local Install The Anaconda Distribution Installing Anaconda Updating Anaconda Jupyter Notebooks Starting the Jupyter Notebook Notebook Basics Running Cells Modal Editing Inserting Unicode (e.g., Greek Letters) A Test Program Working with the Notebook Tab Completion On-Line Help Other Content Debugging Code Sharing Notebooks QuantEcon Notes Installing Libraries Working with Python Files Editing and Execution Option 1: JupyterLab Option 2: Using a Text Editor Exercises An Introductory Example Overview The Task: Plotting a White Noise Process Version 1 Imports Why So Many Imports? Packages Subpackages Importing Names Directly Random Draws Alternative Implementations A Version with a For Loop Lists The For Loop A Comment on Indentation While Loops Another Application Exercises Functions Overview Function Basics Built-In Functions Third Party Functions Defining Functions Basic Syntax Keyword Arguments The Flexibility of Python Functions One-Line Functions: lambda Why Write Functions? Applications Random Draws Adding Conditions Recursive Function Calls (Advanced) Exercises Advanced Exercises Python Essentials Overview Data Types Primitive Data Types Boolean Values Numeric Types Containers Slice Notation Sets and Dictionaries Input and Output Paths Iterating Looping over Different Objects Looping without Indices List Comprehensions Comparisons and Logical Operators Comparisons Combining Expressions Coding Style and Documentation Python Style Guidelines: PEP8 Docstrings Exercises OOP I: Objects and Names Overview Python and OOP Objects Type Identity Object Content: Data and Attributes Methods Names and Name Resolution Variable Names in Python Namespaces Viewing Namespaces Interactive Sessions The Global Namespace Local Namespaces The __builtins__ Namespace Name Resolution Mutable Versus Immutable Parameters Summary Exercises OOP II: Building Classes Overview OOP Review Key Concepts Why is OOP Useful? Defining Your Own Classes Example: A Consumer Class Usage Self Details Example: The Solow Growth Model Example: A Market Example: Chaos Special Methods Exercises Writing Longer Programs Overview Working with Python files Development environments A step forward from Jupyter Notebooks: JupyterLab Using magic commands Using the terminal A walk through Visual Studio Code Using the run button Using the terminal Git your hands dirty II The Scientific Libraries Python for Scientific Computing Overview Scientific Libraries The Role of Scientific Libraries Python’s Scientific Ecosystem The Need for Speed Where are the Bottlenecks? Dynamic Typing Static Types Data Access Summing with Compiled Code Summing in Pure Python Vectorization Operations on Arrays Universal Functions Beyond Vectorization NumPy Overview References NumPy Arrays Shape and Dimension Creating Arrays Array Indexing Array Methods Arithmetic Operations Matrix Multiplication Broadcasting Mutability and Copying Arrays Making Copies Additional Functionality Vectorized Functions Comparisons Sub-packages Exercises Matplotlib Overview Matplotlib’s Split Personality The APIs The MATLAB-style API The Object-Oriented API Tweaks More Features Multiple Plots on One Axis Multiple Subplots 3D Plots A Customizing Function Style Sheets Further Reading Exercises SciPy Overview SciPy versus NumPy Statistics Random Variables and Distributions Alternative Syntax Other Goodies in scipy.stats Roots and Fixed Points Bisection The Newton-Raphson Method Hybrid Methods Multivariate Root-Finding Fixed Points Optimization Multivariate Optimization Integration Linear Algebra Exercises Pandas Overview Series DataFrames Select Data by Position Select Data by Conditions Apply Method Make Changes in DataFrames Standardization and Visualization On-Line Data Sources Accessing Data with requests Using pandas_datareader and yfinance to Access Data Exercises SymPy Overview Getting Started Symbolic algebra Symbols Expressions Equations Example: fixed point computation Inequalities and logic Series Example: bank deposits Example: discrete random variable Symbolic Calculus Limits Derivatives Integrals Plotting Application: Two-person Exchange Economy Exercises III High Performance Computing Numba Overview Compiling Functions An Example How and When it Works Decorator Notation Type Inference Compiling Classes Alternatives to Numba Cython Interfacing with Fortran via F2Py Summary and Comments Limitations A Gotcha: Global Variables Exercises Parallelization Overview Types of Parallelization Multiprocessing Multithreading Advantages and Disadvantages Implicit Multithreading in NumPy A Matrix Operation A Multithreaded Ufunc A Comparison with Numba Multithreading a Numba Ufunc Multithreaded Loops in Numba A Warning Exercises JAX IV Advanced Python Programming Writing Good Code Overview An Example of Poor Code Good Coding Practice Don’t Use Magic Numbers Don’t Repeat Yourself Minimize Global Variables JIT Compilation Use Functions or Classes Which One, Functions or Classes? Revisiting the Example Exercises More Language Features Overview Iterables and Iterators Iterators Iterators in For Loops Iterables Iterators and built-ins * and ** Operators Unpacking Arguments Arbitrary Arguments Decorators and Descriptors Decorators An Example Enter Decorators Descriptors A Solution How it Works Decorators and Properties Generators Generator Expressions Generator Functions Example 1 Example 2 Advantages of Iterators Exercises Debugging and Handling Errors Overview Debugging The debug Magic Setting a Break Point Other Useful Magics Handling Errors Errors in Python Assertions Handling Errors During Runtime Catching Exceptions Exercises V Other Troubleshooting Fixing Your Local Environment Reporting an Issue Execution Statistics Index
دانلود کتاب Python Programming for Economics and Finance