Zipline and PyFolio

Zipline and PyFolio abstract away the complexities of the backtesting and performance/risk analysis aspects of algorithmic trading strategies. Backtesting should include all relevant factors, such as slippage and trading costs. Zipline is one of the most advanced open source Python libraries for algorithmic trading backtesting engines. PyFolio is an open-source Python performance and risk analysis…

Financial Market Data Access in Python

Exploring the yahoofinancials Python library The yahoofinancials Python library provides free access to the market data available from Yahoo Finance, whose provider is ICE Data Services. It provides access to historical and, for most assets, also real-time pricing data for the following: Single-ticker retrieval Convert the nested JSON to a pandas’ DataFrame Real-time data retrieval…

Statistical Estimation, Inference, and Prediction

Four key statistical libraries in Python statsmodels is a Python library to explore data, perform statistical tests, and estimate statistical models Normal distribution test with Q-Q plots While there are many robust statistical tests for normal distributions, an intuitive visual method is known as a quantile-quantile plot (Q-Q plot). If a sample is normally distributed,…

Data Manipulation and Analysis with pandas

The name pandas is derived from panel data, an econometrics term for a multidimensional structured dataset. Introducing pandas Series, pandas DataFrames, and pandas Indexes pandas.Series The pandas.Series data structure represents a one-dimensional series of homogeneous values (integer values, string values, double values, and so on). Series are a type of list and can contain only…

High-Speed Scientific Computing Using NumPy

Creating NumPy ndarrays Creating 1D ndarrays Inspect the type of the array Creating 2D ndarrays Creating any-dimension ndarrays Creating an ndarray with np.zeros(…) Creates an ndarray populated with all 0s Creating an ndarray with np.ones(…) Each value is assigned a value of 1 Creating an ndarray with np.identity(…) Creating an ndarray with np.arange(…) Creating an…

A Basic Python main()

In some python scripts, you may see a function definition and a conditional statement that looks like the example below: In this code, there is a function called main() that prints the phrase “Hello World!” when the Python interpreter executes it. There is also a conditional (or if) statement that checks the value of __name__…