TAQ Average Spread¶
Computes the average spread of a stock in a year.
To run this part of the code is necessary to have the results from the module TAQ Responses Physical.
Modules¶
- The code is divided in four parts:
Tools¶
TAQ data tools module.
The functions in the module do small repetitive tasks, that are used along the whole implementation. These tools improve the way the tasks are standardized in the modules that use them.
- This script requires the following modules:
- matplotlib
- os
- pandas
- pickle
- The module contains the following functions:
- taq_function_header_print_data - prints info about the function running.
- taq_initial_message - prints the initial message with basic information.
- taq_business_days - creates a list of week days for a year.
- taq_get_tickers_data - gets the available ticker names.
- main - the main function of the script.
-
taq_data_tools_avg_spread.main()[source]¶ The main function of the script.
The main function is used to test the functions in the script.
Returns: None.
-
taq_data_tools_avg_spread.taq_bussiness_days(year)[source]¶ Generates a list with the dates of the bussiness days in a year
Parameters: year – string of the year to be analyzed (i.e ‘2008’). Returns: list.
-
taq_data_tools_avg_spread.taq_function_header_print_data(function_name, ticker_i, ticker_j, year, month, day)[source]¶ Prints a header of a function that generates data when it is running.
Parameters: - function_name – name of the function that generates the data.
- ticker_i – string of the abbreviation of the stock to be analyzed (i.e. ‘AAPL’).
- ticker_j – string of the abbreviation of the stock to be analyzed (i.e. ‘AAPL’).
- year – string of the year to be analyzed (i.e ‘2016’).
- month – string of the month to be analyzed (i.e ‘07’).
- day – string of the day to be analyzed (i.e ‘07’).
Returns: None – The function prints a message and does not return a value.
Analysis¶
TAQ data analysis module.
The functions in the module analyze the statistics from the NASDAQ stock market and compute the average spread of the stocks.
- This script requires the following modules:
- itertools
- multiprocessing
- numpy
- pandas
- taq_data_tools_avg_spread
- The module contains the following functions:
- taq_quotes_trades_day_avg_spread_data - statistics of quotes and trades for a day.
- taq_quotes_trades_year_avg_spread_data - statistics of quotes and trades for a year.
- main - the main function of the script.
-
taq_data_analysis_avg_spread.main()[source]¶ The main function of the script.
The main function is used to test the functions in the script.
Returns: None.
-
taq_data_analysis_avg_spread.taq_quotes_trades_day_avg_spread_data(ticker, date)[source]¶ Obtain the quotes and trades statistics for a day.
Using the quotes files, obtain the statistics of the average spread, number of quotes and number of trades for a day.
Parameters: - ticker – string of the abbreviation of the stock to be analyzed (i.e. ‘AAPL’).
- date – string with the date of the data to be extracted (i.e. ‘2008-01-02’).
Returns: tuple – The function returns a tuple with float values.
-
taq_data_analysis_avg_spread.taq_quotes_trades_year_avg_spread_data(tickers, year)[source]¶ Obtain the quotes and trades statistics for a year.
Using the taq_quotes_trades_day_avg_spread_data function computes the statistics of the average spread, number of quotes and number of trades for a year.
Parameters: - tickers – list of the string abbreviation of the stocks to be analyzed (i.e. [‘AAPL’, ‘MSFT’]).
- year – string of the year to be analyzed (i.e ‘2016’).
Returns: None – The function saves the data in a file and does not return a value.
Main¶
TAQ data main module.
The functions in the module run the complete analysis of the TAQ data.
- This script requires the following modules:
- itertools
- multiprocessing
- pandas
- taq_data_analysis_avg_spread
- taq_data_tools_avg_spread
- The module contains the following functions:
- taq_data_generator - generates all the analysis of the TAQ data.
- main - the main function of the script.
-
taq_data_main_avg_spread.main()[source]¶ The main function of the script.
The main function extract, analyze and plot the data.
Returns: None.
-
taq_data_main_avg_spread.taq_data_generator(tickers, year)[source]¶ Generates all the analysis of the TAQ data.
Parameters: - tickers – list of the string abbreviation of the stocks to be analyzed (i.e. [‘AAPL’, ‘MSFT’]).
- year – string of the year to be analyzed (i.e ‘2016’).
Returns: None – The function saves the data in a file and does not return a value.