Coder Social home page Coder Social logo

qsh's Introduction

QSH

This library makes it easy to read QSH binary file format of version 4 using Python.

Project in a stage of active development. Contribution are welcomed!

Supported file formats:

  • Plain binary file - not tested
  • Compressed with gzip binary file

Supported data streams:

  • Quotes
  • Deals
  • OwnOrders - not tested
  • OwnTrades - not tested
  • Messages - not tested
  • AuxInfo
  • OrdLog

QSH Specification - https://www.qscalp.ru/store/qsh.pdf

Links to QSH archives:

Install

pip install qsh

Usage

For case of one stream in a file

import qsh

with qsh.open("Si-9.18.2018-08-24.OrdLog.qsh") as qsh_file:
    print("=== Header ===")
    print("Signature: "     + str(qsh_file.header.signature))
    print("Version: "       + str(qsh_file.header.version))
    print("Application: "   + str(qsh_file.header.application))
    print("Comment: "       + str(qsh_file.header.comment))
    print("Created at: "    + str(qsh_file.header.created_at))
    print("Streams count: " + str(qsh_file.header.streams_count))

    # If file contains one stream
    stream_type, stream_info = qsh_file.read_stream_header()

    # Read frame header & frame data for one stream case
    try:
        while True:
            frame_timestamp, _ = qsh_file.read_frame_header()
            ord_log_entry, aux_info_entry, updated_quotes, deal_entry = qsh_file.read_ord_log_data()

            # Do something...
    except EOFError:
        pass

For case of more than one stream in a file

import qsh

streams = {}
with qsh.open("Si-9.18.2018-08-24.OrdLog.qsh") as qsh_file:
    # If file contains two or more streams
    for i in range(qsh_file.header.streams_count):
        stream_type, stream_info = qsh_file.read_stream_header()
        streams[i] = {"type": stream_type, "info": stream_info}

    # Read frame header & frame data for more than one stream case
    try:
        while True:
            frame_timestamp, stream_index = qsh_file.read_frame_header()
            
            if streams[stream_index]["type"] == qsh.StreamType.ORD_LOG:
                pass # Do something...
    except EOFError:
        pass

All timestamps were converted to exchange time zone i.e. Europe/Moscow

qsh's People

Contributors

inesusvet avatar nethask 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.