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

Tip: consider to install python-dev if you are facing python.h no such file or directory.

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

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

qsh's Issues

Error at installation

Hello !
I am installing the lib on Windows python 3.10 and get :

pip install qsh

Collecting qsh
Downloading qsh-0.8.2.tar.gz (98 kB)
---------------------------------------- 98.4/98.4 kB 1.4 MB/s eta 0:00:00
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: python-dateutil in c:\users\dexph\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\site-packages (from qsh) (2.8.2)
Requirement already satisfied: six>=1.5 in c:\users\dexph\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\site-packages (from python-dateutil->qsh) (1.16.0)
Building wheels for collected packages: qsh
Building wheel for qsh (pyproject.toml) ... error
error: subprocess-exited-with-error

× Building wheel for qsh (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [19 lines of output]
running bdist_wheel
running build
running build_py
creating build
creating build\lib.win-amd64-cpython-310
creating build\lib.win-amd64-cpython-310\qsh
copying qsh\six.py -> build\lib.win-amd64-cpython-310\qsh
copying qsh_init_.py -> build\lib.win-amd64-cpython-310\qsh
running build_ext
building 'qsh.init' extension
creating build\temp.win-amd64-cpython-310
creating build\temp.win-amd64-cpython-310\Release
creating build\temp.win-amd64-cpython-310\Release\qsh
"C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.38.33130\bin\HostX86\x64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD "-IC:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\include" "-IC:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\Include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.38.33130\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\VS\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\cppwinrt" /Tcqsh/init.c /Fobuild\temp.win-amd64-cpython-310\Release\qsh/init.obj
init.c
"C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.38.33130\bin\HostX86\x64\link.exe" /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO "/LIBPATH:C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\libs" "/LIBPATH:C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0" "/LIBPATH:C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\PCbuild\amd64" "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.38.33130\lib\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.22621.0\ucrt\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.22621.0\um\x64" /EXPORT:PyInit___init__ build\temp.win-amd64-cpython-310\Release\qsh/init.obj /OUT:build\lib.win-amd64-cpython-310\qsh_init_.cp310-win_amd64.pyd /IMPLIB:build\temp.win-amd64-cpython-310\Release\qsh_init_.cp310-win_amd64.lib
LINK : error LNK2001: unresolved external symbol PyInit___init__
build\temp.win-amd64-cpython-310\Release\qsh_init_.cp310-win_amd64.lib : fatal error LNK1120: 1 unresolved externals
error: command 'C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.38.33130\bin\HostX86\x64\link.exe' failed with exit code 1120
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for qsh
Failed to build qsh
ERROR: Could not build wheels for qsh, which is required to install pyproject.toml-based projects

Cheers!

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.