Skip to content

Framework for generating order book data from raw updates, modelling, and signal generation for mid-price prediction.

Notifications You must be signed in to change notification settings

franqsbepop/FrameworkForShortTermMidPricePrediction

Repository files navigation

Mid Price Prediction

The mid_price_prediction package provides tools for analyzing and predicting mid prices in financial trading using order book data. It includes classes and methods for processing trading data, constructing order books, and predicting price movements.

Installation

To install the mid_price_prediction package, run the following command:

bashCopy code
pip install mid_price_prediction

Modules

OrderBook Class

The OrderBook class in OrderBookClass.py represents and manipulates an order book for trading data. It provides functionalities to update the order book based on transaction data, retrieve top price levels, and process trading data for a given day.

Features

  • Update the order book with new transaction data.
  • Retrieve top k price levels from the order book.
  • Process and output data for trading days.

Usage

pythonCopy code
from mid_price_prediction.OrderBookClass import OrderBook # Create an instance of OrderBook order_book = OrderBook() # Example: Processing a day's trading data day_files = ['res_20190610.csv', 'res_20190611.csv', 'res_20190612.csv'] for day_file in day_files: order_book.create_output_for_dayfile(day_file, 5)

PricePredictionModel Class

The PricePredictionModel class in PredictionModel.py is used for predicting future price movements based on historical order book data.

Features

  • Reads and transforms trading data.
  • Normalizes features for model training.
  • Performs feature engineering.
  • Trains a logistic regression model for price prediction.
  • Evaluates the model and plots the coefficients.
  • Performs feature selection and quantile analysis.

Usage

pythonCopy code
from mid_price_prediction.PredictionModel import PricePredictionModel # Initialize the model with data files data_files = ['day1.csv', 'day2.csv', 'day3.csv', 'day4.csv', 'day5.csv'] model = PricePredictionModel(data_files) # Prepare data and train the model model.prepare_data() model.train_model() # Evaluate the model model.evaluate_model() # Pass test data as needed model.plot_coefficients() # Perform feature selection model.perform_feature_selection(3) # Quantile analysis on timestamp differences quantile_list = [0.1, 0.2, 0.3, 0.4, 0.5] model.plot_timestamp_difference_distribution(quantile_list)

Requirements

The mid_price_prediction package requires the following libraries:

  • numpy
  • pandas
  • scikit-learn
  • matplotlib
  • mlxtend

About

Framework for generating order book data from raw updates, modelling, and signal generation for mid-price prediction.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages