Giter Club home page Giter Club logo

ohlc-data-manager's Introduction

OHLC-Data-Manager

OHLCManager is a Python class that facilitates the management and analysis of Open, High, Low, Close, (OHLC) data in a DataFrame.

Features

  • DataFrame Management: OHLCManager allows you to easily handle OHLC data stored in a Pandas DataFrame.
  • Data Validation: The class validates the DataFrame structure, ensuring that it contains the necessary columns: "date", "open", "close", "high", and "low".
  • Concatenation: If multiple input DataFrames are provided, OHLCManager can concatenate the OHLC tables, removing duplicates.
  • Visualization: OHLCManager offering convenient plotting and visualization functions for the OHLC data.
  • Indicators: The class also inherits from the Indicators class, providing access to various technical indicators for further analysis.
  • Missing Data Detection: OHLCManager includes functionality to identify missing points in the data, allowing you to easily find gaps or missing entries in the OHLC series.
  • Wrong Data Detection: The class provides the ability to detect wrong data, such as inconsistent OHLC prices, helping with the cleaning process.

Usage

To use OHLCManager, simply instantiate the class with your OCHL DataFrame. The class provides methods for data manipulation, visualization, and applying technical indicators. The class was originally designed to handle 1-hour candlestick charts for cryptocurrencies but can be easily adapted to handle different timeframes and stock market data. Furthermore, the class is capable of generating daily and weekly timeframes based on hourly data.

Example usage on BTC/USDT pair OHLC data obtained from https://www.CryptoDataDownload.com.

import pandas as pd
from ohlc_manager import OHLCManager

BTC_ohlc = 'sample_data/Binance_BTCUSDT_1h.csv'
ohlc_data = pd.read_csv(BTC_ohlc)

# Instantiate OHLCManager
ohlc_manager = OHLCManager(ohlc_data)

# Convert columns to datetime
ohlc_manager.convert_column_to_datetime()

# Remove additional columns
ohlc_manager.clean_columns()

# Order the data
ohlc_manager.order_by_date()

The number of gaps and anomalies in the data can checked with the report method:

# Print the number of gaps and anomalies
report_dict = ohlc_manager.report()

Missing or wrong data can be easily handled:

# Transfrom anomalies point into NaN
self.invalidate_anomalies()

# Remove large gaps between consecutives close and open price
ohlc_manager.fix_inconsistency_open()

# Fill missing data points
ohlc_manager.fill_missing_dates()

All this operations can be performed in once with:

# Clean and prepare the data
ohlc_manager.prepare_data()

Then, technical indicators can be implemented on the table:

ohlc_manager.add_SMA(timeperiod=20)
ohlc_manager.add_RSI()
ohlc_manager.add_STOCHRSI()
ohlc_manager.add_MACD()
ohlc_manager.add_BBANDS()

By utilizing hourly data, it is possible to generate consistent daily and weekly OHLC data across various timeframes:

daily_ohlc = ohlc_manager.generate_daily()
weekly_ohlc = ohlc_manager.generate_weekly()

ohlc-data-manager's People

Contributors

fiver01 avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.