谁有这篇论文 <<基于的证券行情分析系统 (LEVEL-2)的研究与实现>>

Discussion in 'FIX Protocol' started by fisher, Dec 2, 2009.

  1. 来源:http://210.40.7.188/NEW/NEW08/08lcd/0000.asp

    计算机研究生开放研究
    《基于的证券行情分析系统 (LEVEL-2)的研究与实现》
    美国GeneChiu基金资助


    基于的证券行情分析系统 (LEVEL-2)的研究与实现

    研 究 生: 刘 成 德

    中国﹒贵州﹒贵阳 2008年4月

    第一章 绪论 10

    1.1:STEP协议的制定背景 10
    1.2:STEP协议的制定思路和原则 11
    1.3:STEP协议的制定过程和意义 11
    1.3.1:制定过程 12
    1.3.2:STEP协议引入的重要意义 12
    1.4:证券行情分析系统的发展和趋势 13
    1.4.1.:人工记录模式 13
    1.4.2:电报、电话通信模式 13
    1.4.3:电子化交易方式 14
    1.5:行情系统的架构 14
    1.5.1:Client/Service模式 14
    1.5.2:Brower/Service模式 14
    1.5.3:Mobile/Service模式 15

    第二章:STEP协议 16

    2.1:STEP协议的简介 16
    2.2 :术语和定义 16
    2.3 STEP协议的会话机制 17
    2.3.1 消息序号 17
    2.3.2 心跳 17
    2.3.3缺口填补 17
    2.3.4消息重复发送 17
    2.3.5消息重新发送 17
    2.3.6 消息确认 18
    2.4:STEP连接 18
    2.4.1 :登录 18
    2.4.2:注销 18
    2.4.3: 消息恢复 19
    2.5: 数据类型 20
    2.5.1: 基本数据类型 20
    2.5.2: 扩展数据类型 21
    2.5.3:重复组 22
    2.6:扩展方式 22
    2.6.1 :扩展分类 22
    2.6.2:扩展规则 22
    2.7:消息定义 23
    2.7.1:消息头 23
    2.7.2:消息尾 24
    2.7.3:常用的消息类型 24
    2.8:组件 26
    2.9: 行情 27
    2.9.1:证券信息求情消息(MsgType =e) 27
    2.9.2: 证券信息广播消息(MsgType=f) 28
    2.9.3:证券行情广播消息 (MsgType =U003) 29
    2.10:市场控制 30
    2.10.1:市场参数求情消息(MsgType=BI) 30
    2.10.2: 市场参数消息(MsgType=BJ) 31
    2.11:安全加密和数据完整性 32
    2.11.1:安全加密 32
    2.11.2:数据完整性 32

    第三章:STEP引擎和LEVEL2DCD转码机 34

    3.1: NGTS概述 34
    3.2:广播概述和订阅列表 34
    3.2.1:私有和公共广播 34
    3.2.2:可恢复广播和非可靠广播 35
    3.3:STEP引擎概述 35
    3.4:STEP引擎所用到的主要配置文件及说明 36
    3.4.1:CommonConfig.xml 36
    3.4.2:MissInfo.xml 37
    3.4.3:SwitchPath.xml 38
    3.5:STEP引擎的日志文件 38
    3.5.1:消息日志 38
    3.5.2:系统日志 38
    3.5.3:接口调用日志 39
    3.6:LEVEL2DCD转码机 39
    3.6.1:WinDCD的整体架构设计 39
    3.6.2:对读写DBF文件类的封装 40
    3.6.3:Level2DCD转码机对STEP引擎的应用 41
    3.6.4:Level2转码机和服务器端的交互策略 43

    第四章:行情分析系统用到的通信协议 45

    4.1:协议的特征 45
    4.1.1:面向消息 45
    4.1.2:向连接和无连接 46
    4.1.3:可靠性和次序性 46
    4.1.4:从容关闭 46
    4.1.5: 服务质量 46
    4.2:TCP/IP协议和工作机制 47
    4.2.1:多路复用数据流 47
    4.2.2:测试数据的完整性 47
    4.2.4:流控 48
    4.2.5:计时机制 48
    4.2.6:应答接收 48
    4.3:UDP/IP协议和工作机制 48
    4.4:套接字 50
    4.4.1:套接字模式 50
    4.4.2:套接字I/O模型 51

    第五章:新一代行情分析系统服务器端的设计和实现 53

    5.1:新行情服务器端的功能模块划分 53
    5.1.1:新行情服务器端功能、架构概述 53
    5.1.2:新行情服务器端的模块的划分 53
    5.2:新一代行情系统的简略架构方案及特点 55
    5.2.1:简略架构和说明 55
    5.2.2:该架构的特点: 55
    5.3:行情分析系统通信数据接口的设计和封装 56
    5.3.1:数据帧的头部格式和子类型格式 57
    5.3.2:数据帧类型和各个帧的设计 57
    5.3.3:用户认证类的数据接口的设计 58
    5.3.4:请求市场基本信息和配置类(MFT_CONFIG) 60
    5.3.5:数据资料类 60
    5.3.6:分时走势(CFT_DATA_TREND) 61
    5.3.7:明细资料(CFT_DATA_TICK) 62
    5.3.8:指数类即时数据申请(CFT_DATA_INDEX) 63
    5.3.9:历史数据请求(CFT_DATA_HISTORY) 63
    5.3.10:公告新闻类数据接口的定义: 64
    5.3.11:通用数据查询资料交换方式(MFT_NORMAL_FILE) 64
    5.4:对常用技术模块的封装 65
    5.4.1:对线程的封装 65
    5.4.2:对Mutex的封装 66
    5.4.3:对通信队列的封装 67
    5.4.4:对通信实体的封装 67
    5.4.5:数据包的接收池的封装 68
    5.4.6:对请求队列的封装 68

    第六章:新一代行情分析系统客户端的设计与实现 70

    6.1:总体概述 70
    6.2:主框架的设计 70
    6.2.1主窗口绘制 71
    6.2.2启动过程 71
    6.2.3结束工作 71
    6.2.4网络消息收发 71
    6.2.5支撑视图管理模块 72
    6.2.6支撑智能管理系统模块 72
    6.2.7与辅助子模块和各种命令源的交互 72
    6.2.8:主框架用到的主要接口和函数列表 72
    6.3:视图模块 72
    6.3.1标题栏、工具栏、边框 73
    6.3.2. 状态栏 74
    6.3.3 视图区域 74
    6.4:登录和初始化模块 74
    6.4.1:登录过程 74
    6.4.2:初始化 75
    6.4.3:登录流程和策略 75
    6.5:客户端对一些模块的封装 77
    6.5.1:对文件操作的封装 77

    参考文献 79
    附 录 81
    作者在学习其间的主要工作 81
    发表论文 81
    参与项目 81


    摘 要

      中国经济高速发展,中国证券市场越来越受到国家的重视,中国证券市场变得壮大和成
    熟,证券市场的技术也得到了很大的发展。然而我国证券市场行情的分析还存在着很大的问
    题。沪深证券交易所和券商和其他机构间都采用各自设计的非标准化的接口,数据信息交换
    模式不统一,编码方式不统一,接口定义不统一,业务数据流程不统一,存在对业务创新的
    适应性较差、适应成本高,不同市场间难于有效交换信息等问题。交易系统的改革也带动了
    行情分析系统的改革和提高,证券市场需要一个高质量、快速、大信息量的行情分析系统。
    这就需要引入国际化的信息交换协议。

      在国外,一些成熟的证券市场和银行系统已经有90%在使用FIX(Financial Information
    Exchange 金融信息交换)协议,纽约交易所、泛欧交易所(EURONEXT)、墨西哥交易所、
    芝加哥期权交易所(CBOE)、新加坡交易所、澳大利亚交易所等均支持FIX协议。可以说FIX
    协议已经相当完善、成熟、安全的。中国证监会从1998年开始就计划和讨论证券行业的电
    子信息交换标准化,历经8年的研究,终于推出了适合我国证券市场的一种基于FIX4.4协
    议的STEP协议。

      STEP协议:(Securities Trading Exchange Protocol)证券交易数据交换协议,该协议是
    在国际上通用的金融信息交换协议FIX4.4的基础上结合我国证券市场的实际情况制定出来
    的标准协议,是国家金融“十五”科技攻关任务。于2004年2月,STEP通过了国家金融
    标准化委员会专家会议审核,正式成为国家标准,并定名为《证券交易数据交换协议》。
    证券行情分析系统的架构目前可以分为下面三种类型:

      A):基于Client/Service模式的架构
      Internet在中国的普及,C/S模式的证券行情分析系统在目前得到了大量的普及。它
    证券行情分析软件中最理想、也是最普及的一种模式,这种模式适合散户股民在家中或
    网吧,只要有电脑、网络的地方都可以查看行情。C/S模式所占用的资源较少,速度快,
    传输质量较高。就其传输来说,从服务端到客户端都是采用Tcp/IP,UDP等Socked通信,
    从上证所或深交所出来的数据都是按照一定的数据结构和不同的通信协议(或约定)来
    完成,数据传输到客户端,然后经过处理后显示出来,采用请求应答的机制。
      B):基于Brower/Service模式的架构
      B/S模式的出现也是一种趋势,B/S模式的证券行情分析系统,是基于HTTP协议的,
    一般提供这样的服务都是WebService和SOAP模式的,目前很多大型的门户网站都提供
    这种模式的服务,比如:新浪网、搜狐网、MSN、和讯等,基于B/S模式的证券行情分
    析其优势就是分布广,简单易用,可供大量的人同时使用。其劣势是对服务器端机器性
    能要求比较高,如果这个网站的访问量过大会造成其速度慢,一般能提供的信息量相对
    较少,证券行情分析系统中的数据每秒钟都在变化,因此网页需要不停的定时刷新,所
    以也造成和服务器数据交换量变大,降低了速度。
      C):基于Mobile/Service模式的架构
    手机模式的行情分析系统,其优势就是容易普及,使用方便,但是其致命的劣势是
    成本太高、速度慢、信息量小。需要服务器端将信息推送给电信方,然后转化成无线信
    号传输给客户端,所以增加了通信成本。由于手机屏幕小,所以显示的信息比较少,且
    显示质量没有办法和C/S和B/S模式的证券行情分析系统相比,由于手机内存或缓存比较
    小,因此过来的行情信息处理起来速度就慢的多,因此需要妥善的利用内存,这就给开
    发客户端软件造成了开发上的困难和成本。

     本文采用C/S架构模式,基于国家标准STEP协议,在通信过程中采用TCP/IP、UDP
    协议,详细地介绍了证券行情分析系统的整体架构、系统软件体系结构、系统内部进程
    间通信设计、服务器端的布局和架设、客户端设计和结构及服务器端和客户端通信、功
    能模块的划分等,成功实现了新一代行情分析系统(LEVEL-2),该系统已经在市场上
    成功的应用。本文所做的主要工作、技术难点与创新点如下:

      1. 对国家标准JR/T0022-2004 STEP(Securities Trading Exchange Protocol)协议进行了分
    析和研究。
      2. 对上证所提供的STEP引擎进行了分析和研究,并且对Fix(Financial Information
    Exchange)协议的开放源代码进行研究,参考FIX协议的源代码开发出了适合自己的基于
    STEP协议的Level2DCD转码机,对上证所传来的行情进行解析、存盘、发布。
      3. 对证券行情分析系统服务器端的架构进行了研究,服务器架设在不同的区域,如何
    协调认证服务器、均衡服务器和数据服务器,达到流量的最大化和通信的最优化是一个很重
    要的问题。
      4. 参与了证券行情分析系统客户端的架构设计、功能模块的划分,并编写了部分代码、
    对代码进行了优化。使系统具有灵活性、可配置性、可扩展性,重用性,从系统设计的角度
    实现设计的模块化和可扩展的开放性。
      5. 高效的进程池模式设计:针对系统的特点,即系统在生产过程中存在大量的数据访
    问请求,系统通过建立进程缓冲池,来减少创建及销毁时的资源消耗,提高系统效率。
      6. 网络通讯接口API的封装:基于系统体系结构设计的考虑,为了实现软件体系结构
    的层次化,通讯层、应用层及业务层分开,系统对基于TCP/IP协议的socket底层通讯的网
    络接口进行了合理封装,封装后作为系统底层库函数提供给应用层程序调用,自己对Socket
    包的打包和拆包的处理。
      7. Win下网络编程:设计基于TCP/IP协议的通讯平台。由于系统设计过程中采用多
    服务模式,所以需要搭建一个专门用于各个服务之间交换信息的通讯平台,通讯方式选用异
    步通讯模式来实现。同时要考虑是使用长连接还是短连接。如果使用长连接,发送前需要考
    虑是否连接问题。根据系统不同业务的需求和性能指标的规定来确定具体采用那种连接方
    式。
      8. 心跳包的设计:证券行情服务器端和客户端要保持长时间的通信,很难判断客户端
    由于某种故障和服务器端断开链接,因此采用了如QQ、MSN通用的通信检测方式,服务
    器端以固定的频率向客户端发送一个简单的心跳包,如果长时间没有回应,就将该客户端从
    服务器端断开,经过长时间的试验,该系统的心跳包的频率为30秒/次。
      9. 消息队列及其消息队列的维护:在客户端有大量的窗口消息事件、键盘消息事件、
    网络消息事件,这些消息我们统一放到一个消息队列里,消息队列是为了保证多个进程之间
    的同步运行和对事件的有效管理。消息维护是为了优化消息队列,使其达到较高的工作效率。
      10. 对服务推和拉模式的研究:在通信的过程中客户端可以向服务器端请求信息,而服
    务器端也可以无请求的条件下推送信息。
      11.系统的接口定义和设计:行情信息都是按照一定的结构体发送到客户端的,因此对
    于不同的行情信息需要不同的结构体,又需要一定的协议来约定这个结构体的作用和所包含
    的信息,我们设计了二级消息模式来达到这样的功能。
    目前,本系统已经在乾隆高科公司使用,系统运行稳定,成为公司新的增值点。

    作者在校期间,在《计算机科学数字与方程》上发表论文一篇。

    关键字:STEP协议、STEP引擎、证券行情、行情分析系统、LEVEL-2、TCP/IP、UDP、
    Level2DCD、DataCenter、视图、网络消息、K线图、Socket
    中图分类号:

    Abstract

      China's rapid economic development, China's securities market has been gaining national
    attention, has become China's securities markets grow and mature, and the technology stock
    market has also been a lot of development. However, the prices of China's securities
    market still big problem. Shanghai and Shenzhen stock exchanges and brokerage firms
    and other institutions have adopted their own design of the non-standardization of interfaces, Data
    exchange model are not unified, coding not unified interface definitions are not unified, business
    data processes are not unified, the existence of the adaptability of poor business innovation, to the
    high cost of different markets difficult issues such as the effective exchange of information. The
    reform of the trading system was driven by the market analysis of the reform of the system, and
    improving the stock market needs a high-quality, rapid, large amount of information of market
    analysis system. This requires the introduction of international information exchange protocals.

      In foreign countries, some mature stock market and the banking system has been 90% in the
    use of FIX (Financial Information Exchange financial information exchange) protocol, the New
    York Stock Exchange, Pan-European Exchange (EURONEXT), Mexico Stock Exchange, the
    Chicago Board Options Exchange (CBOE), Singapore Stock Exchange, the Australian Stock
    Exchange and so support the FIX Protocol. FIX protocal can be said to have been very
    comprehensive and mature, safe. China Securities Regulatory Commission from 1998 to the
    planning and discussion on the securities industry standardization of the exchange of electronic
    information, after eight years of study, has finally launched suits China's securities market based
    on the STEP protocal FIX4.4 protocal.

    STEP protocal: (Securities Trading Exchange Protocol) securities transactions data exchange
    protocal. The protocal is common in the international exchange of financial information FIX4.4
    protocal on the basis of the securities market in light of China's actual situation worked out in the
    standard protocal, is the country's financial "15" scientific and technological tasks. n February
    2004, STEP standardization by the state financial audit expert meeting of the Commission to
    become national standards, and will be called 《securities transactions data exchange protocal》.
    Securities market analysis of the structure of the current system can be divided into the following
    three categories:

    A):Based on Client / Service model structure
       The popularity of the Internet in China, C / S mode analysis of the
    securities market in the current system have a lot of popularity. Its
    securities market analysis software in the best and most popular model,
    this model suitable for retail investors at home or Internet cafes, as
    long as there are computers, the local network can check prices. C / S
    mode occupied by fewer resources, speed, high quality transmission. On
    its transmission, from client services are used in front-Tcp / IP, UDP,
    etc. Socked communications, from the Shanghai Stock Exchange or the
    Shenzhen Stock Exchange by the data are in accordance with certain data
    structures and different communication protocols (or protocal) to
    complete, data transmission to the client, and then processed displayed
    by request response mechanism.

    B):Based on Brower/Service model structure
    B / S model is the emergence of a trend, B / S of the securities market
    system is based on the HTTP protocol, the general provision of such services
    are WebService and SOAP model, many large Internet portals are providing
    such Mode of services, such as: Sina, Sohu Network, MSN, and - and so on,
    based on the B / S securities market analysis of its advantages is widely
    distributed, easy to use, available for use at the same time a large number
    of people. Its disadvantage is server-side comparison of high performance
    machines, if the visit to this site will cause excessive speed slowly,
    the amount of information in general can provide a relatively small amount
    of the securities market in the data analysis system in a second change,
    the website regularly need to constantly refresh, I have caused and server
    data exchange quantitative change, reduce speed.

    C):Based on Mobile/Service model structure
    Phone model of market analysis system, its advantages is easy
    universal, easy-to-use, but its fatal disadvantage is too costly, slow,
    small amount of information. The server will need to push the information
    presented telecommunications side, and then into the wireless signal
    transmission to the client, so increased communication costs. Due to the
    small cell phone screen, so the information shows that relatively few,
    and the display quality and not the C / S and B / S mode compared to the
    securities market analysis system, as mobile phone memory or cache
    relatively small, from the information processing market up on slow speed,
    therefore the need for proper use of memory, which developed client
    software for the development of the cause of the difficulties and costs.
    In this paper, using C / S framework, based on national standards
    STEP protocal, in the communication process used TCP / IP, UDP, details
    on the securities market of the overall system architecture, system
    software architecture, inter-process communication system design, the
    layout and the server set up, design and structure of the client and server
    and client communications, such as the delineation of functional modules,
    a new generation of the successful realization of market analysis system
    (LEVEL - 2), the system has been successful in the market application.
    In this paper, the major work done by the technical difficulties and
    innovation points are as follows:

    1) National standards JR/T0022-2004 STEP (Securities Trading Exchange
    Protocol) protocol were analyzed and studied.
    2) Provided by the Shanghai Stock Exchange STEP engines were analyzed and
    research, and the Fix (Financial Information Exchange) protocol of
    open-source research, reference FIX protocol source code developed a
    suitable protocal based on the Level2DCD to STEP code machines on the
    Shanghai Stock Exchange came to the market analysis, archiving,
    publishing.
    3) On the securities market analysis system server-side structure was
    studied, the server set up in different regions, how to coordinate
    authentication server, balanced server and data server, and to maximize
    the flow of communications optimization is a very important issue.
    4) Involved in the securities market analysis system client architecture
    design, the delineation of functional modules, and the preparation of some
    code, the code has been optimized. The system has the flexibility,
    configurability, scalability, reusability, from the perspective of system
    design to achieve the design of the modular and scalable open.
    5) Efficient model design process Pool: The system features that system
    in the production process there are a lot of data access requests, the
    process system through the establishment of a buffer tank to reduce the
    creation and destruction of the consumption of resources and improve system
    efficiency.
    6) Network communications interface API Packaging: Based on the system
    architecture design considerations, in order to achieve the level of
    software architecture, communications layer, application layer and layer
    operations separate systems based on TCP / IP communications bottom of
    the socket network interface for a reasonable package, the package after
    the bottom of the function as a system to the application layer to provide
    procedures called themselves on the socket packet processing package and
    unpacking.
    7) Win Network Programming: design based on the TCP / IP communications
    platform. Because the process of designing systems using multi-service
    model, so it is necessary to build a specialized service for the exchange
    of information between the various communications platforms, means of
    communication chosen asynchronous communication mode to achieve. We
    should also consider the use of long or short connecting link. If the use
    of connections, sending the former need to consider whether connectivity
    problems. According to the system of different business needs and
    performance requirements used to determine the specific kind of
    connection.
    8) Heartbeat package design: securities market server and client to
    maintain lengthy communication, it is difficult to judge because of a fault
    client and server-side disconnect links, used as QQ, MSN common
    communications testing, server-side with a fixed frequency sent to the
    client a simple heartbeat packets, if no longer respond to the client
    disconnect from the server side, after a long period of testing, the
    system's heartbeat packets frequency 30 seconds / th .
    9) Message queue and message queue maintenance: in a large number of
    client-side window news events, keyboard events news, network news, the
    news we put a unified message queue, the message queue is to ensure that
    the various processes synchronous operation and the effective management
    of the incident. News safeguard is to optimize the Message Queue to achieve
    higher efficiency.
    10) Push and pull on the service mode of study: Communication in the process
    of the client to the server side can request information, and no server-side
    can also request information under the conditions Push.
    11) The interface definition and system design: prices are according to
    certain information structure sent to the client, so different prices for
    different information needs of the structure, the protocal will also need
    to agree that the role and structure of the contained information, we
    designed a secondary source model to achieve this functionality.

    Currently, the system has been in use Qianlong High-Tech Company,
    stable operation, a new value-added companies point.

    Author at school, on 《computer science figures and equations》 a paper
    published.

    Keyword: STEP protocal, STEP engine, the securities market, market
    analysis system, LEVEL - 2, TCP / IP, UDP, Level2DCD, DataCenter, View,
    network news, K-map, Socket
     
  2. 牛啊,把L2的技术都泄露了
     
  3. 书是没有,不过接口有。但一般不太可能直接连交易所的DCD,因为DCD对单一用户而言最多就一主一备,一个客户端占上了就没有空了,所以基本上只能考虑连接存储转发的通道(level2的下线)。
     
  4. 我想想办法,最近单位比较忙,可能要等下周抽空看看了
     
  5. 要找个知网账户或者万方的经纪类的账户,我过去的2个账户都失效了
     
  6. 辛苦了
     
  7. 周末去图书馆看看去,带个U盘
     
  8. Last edited by a moderator: Jul 23, 2010
  9. 谢谢wj2000
     
  10. 原来是钱龙公司的人写的.
     
  11. 谢谢,我也save了
     
  12. 谢谢 fisher 和 wj2000
     
  13. 这论文好像删除了,谁还有下载链接吗。
    本人也在研究学习FIX,谢谢。
     
  14. 已发邮件给你了
     
  15. 我刚看到,下载链接已经不能用了,能发我一份吗?
    谢谢
     
  16. 重新传了,
     
    Last edited by a moderator: Jul 23, 2010
  17. 下载成功,多谢wj2000
     
  18. 收到,谢谢fisher
     
  19. 谢谢 好东东 先储备了 可惜至今我level1都没算明白....... :(
     
  20. 怎么我下不了的?