Coder Social home page Coder Social logo

szse_v5_parser's Introduction

szse_v5_parser

深交所V5报文解析库

[email protected]

目前实现了binary协议的行情数据解析

binary协议的交易数据可参考行情格式添加

当前测试:

在本地环境:[email protected] Win7 16GB内存,immutable_方式可达到1GB/s

(包括 Structure Packet,GetField)

两类报文


cn::szse::binary::immutable_::Packet // 不可变报文,只保存原始字节流的引用
cn::szse::binary::mutable_::Packet // 可变报文,将原始自己流拷贝至报文内部
结构化方法:

bool Structure(const char* mem_addr, size_t* mem_size)
输入:
    mem_addr即输入字节流
    mem_size即输入字节流的长度
输出:
    bool 结构化成功/失败
    mem_size 若成功,该值为消耗的字节长度;若失败,该值为需要的字节长度

数据域获取:


bool GetField(FieldType*)
输入:数据域对象
输入:是否成功

数据域也分为两种类型:可变和不可变,实现方式类似Packet

GetField函数可接收两种类型的数据域

数据域写入:


bool InsertField(FieldType*)
输入:待写入的数据域
输出:是否成功

要求:只能是将可变类型数据域写入到可变类型报文中

使用方法


const char* mem_addr =  szse_binary_packet_stream;  // 接收到的报文字节流
size_t mem_size = szse_binary_packet_stream_size;   // 接收到的字节流尺寸

cn::szse::binary::immutable_::Packet packet;
if (packet.Structure(mem_addr, &mem_size))
{
    const cn::szse::binary::MsgHeader* header = packet.GetHeader();
    switch (header->MsgType.get_value())
    {
        case cn::szse::binary::Logon::TypeID:
        {
            cn::szse::binary::Logon logon_field;
            if (packet.GetField(&logon_field))
            {
                // do something
            }
            {
                assert(false);
            }
            break;
        }
        default:
            break;
    }
}

szse_v5_parser's People

Contributors

caoning1985 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.