Git Product home page Git Product logo

vnpy_webtrader's Introduction

vn.py框架的Web服务模块

说明

针对B-S架构需求设计的Web服务应用模块,实现了提供主动函数调用(REST)和被动数据推送(Websocket)的Web服务器。

目前仅提供了基础的交易和管理接口,用户根据自己的需求扩展支持其他vn.py应用模块的Web接口(如CTA策略自动交易等)。

安装

安装需要基于2.4.0版本以上的VN Studio

下载解压后在cmd运行:

python setup.py install

架构

  • 基于Fastapi-Restful实现的主动函数调用功能,数据流程:

    1. 用户点击浏览器中的某个按钮,发起Restful功能调用;
    2. Web服务器收到Restful请求,将其转化为RPC功能调用发送给交易服务器;
    3. 交易服务器收到RPC请求,执行具体的功能逻辑,并返回结果;
    4. Web服务器返回Restful请求的结果给浏览器。
  • 基于Fastapi-Websocket实现的被动数据推送功能,数据流程:

    1. 交易服务器的事件引擎转发某个事件推送,并推送给RPC客户端(Web服务器);
    2. Web服务器收到事件推送后,将其转化为json格式,并通过Websocket发出;
    3. 浏览器通过Websocket收到推送的数据,并渲染在Web前端界面上。
  • 将程序分为两个进程的主要原因包括:

    1. 交易服务器中的策略运行和数据计算的运算压力较大,需要保证尽可能保证低延时效率;
    2. Web服务器需要面对互联网访问,将交易相关的逻辑剥离能更好保证安全性。

vnpy_webtrader's People

Contributors

edanflame avatar vnpy avatar xuxin3101 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.