: | : | :期货程序化 | :期货程序化研究 | :期货量化学习 | :期货量化 |
返回列表 发帖

TWS API v9.72 在线文档 —— 软件架构【翻译】

TWS API v9.72 在线文档 —— 软件架构【翻译】

【译者注】 IB API 在线文档包含有 C#/Java/CPP/Python 等版本,程序的调用方法基本一致。但因为时间有限,不能翻译全部的版本,而且考虑到适用性和性能,因此在这个版本里,主要围绕着 Java API 进行翻译。您可以从 IB API 在线文档中找到自己熟悉的语言部分,差异不会很大。

http://interactivebrokers.github.io/tws-api/introduction.html
API Software Architecture
【译】 API 软件架构

EClientSocket and EWrapper Classes
Once the TWS is up and running and actively listening for incoming connections we are ready to write our code. This brings us to the TWS API's two major classes: the IBApi.EWrapper interface and the IBApi.EClientSocket

【译】 当TWS运行后,并开始监听来自我们程序的消息请求。这里,将介绍两个重要的类,IBApi.EWrapper 接口和 IBApi.EClientSocket。

Implementing the EWrapper Interface
【译】 对EWrapper接口的实现

The IBApi.EWrapper interface is the mechanism through which the TWS delivers information to the API client application. By implementing this interface the client application will be able to receive and handle the information coming from the TWS. For further information on how to implement interfaces, refer to your programming language's documentation.

【译】 IBApi.EWrapper 接口是客户端接收来自TWS消息的机制。通过对它的实现,客户端能够获取以及处理来自TWS的消息。更多关于如何实现IBApi.EWrapper的方法,请参考您自己的编程语言的相关说明。

public class EWrapperImpl implements EWrapper
The EClientSocket Class
The class used to send messages to TWS is IBApi.EClientSocket. Unlike EWrapper, this class is not overriden as the provided functions in EClientSocket are invoked to send messages to TWS. To use EClientSocket, first it may be necessary to implement the IBApi.EWrapper interface as part of its constructor parameters so that the application can handle all returned messages. Messages sent from TWS as a response to function calls in IBApi.EClientSocket require a EWrapper implementation so they can processed to meet the needs of the API client.

【译】 EClientSocket 类用于向TWS发送消息,与 EWrapper 不同,它不需要被重写,因为它提供的函数将被用于向TWS发送消息。为了使用EclientSocket,首先需要实现 IBApi.EWrapper 的接口,并作为参数传递至构造函数中,从而使得程序能够处理全部的返回消息。此外对于程序来说,从TWS发送的消息,需要依靠实现 EWrapper 的接口,并作为 IBApi.EClientSocket 的回掉函数进行处理。

Another crucial element is the IBApi.EReaderSignal object passed to theEClientSocket's constructor. With the exception of Python, this object is used in APIs to signal a message is ready for processing in the queue. (In Python the Queue class handles this task directly). We will discuss this object in more detail in the The EReader Thread section.

【译】 另一个关键元素是传递给 EClientSocket 构造函数的 IBApi.EReaderSignal。除了Python之外,这个对象在 API 中被用于表示消息队列的状态。(在Python中,队列直接处理这些任务)。我们将在 EReader Thread 章节中详细的讨论这个对象。

  1. private EReaderSignal readerSignal;
  2. private EClientSocket clientSocket;
  3. protected int currentOrderId = -1;
复制代码


  1. public EWrapperImpl()
  2. {
  3.     Signal = new EReaderMonitorSignal();
  4.     clientSocket = new EClientSocket(this, readerSignal);
  5. }
复制代码

论坛官方微信、群(期货热点、量化探讨、开户与绑定实盘)
 
期货论坛 - 版权/免责声明   1.本站发布源码(包括函数、指标、策略等)均属开放源码,用意在于让使用者学习程序化语法撰写,使用者可以任意修改语法內容并调整参数。仅限用于个人学习使用,请勿转载、滥用,严禁私自连接实盘账户交易
  2.本站发布资讯(包括文章、视频、历史记录、教材、评论、资讯、交易方案等)均系转载自网络主流媒体,内容仅为作者当日个人观点,本网转载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。本网不对该类信息或数据做任何保证。不对您构成任何投资建议,不能依靠信息而取代自身独立判断,不对因使用本篇文章所诉信息或观点等导致的损失承担任何责任。
  3.本站发布资源(包括书籍、杂志、文档、软件等)均从互联网搜索而来,仅供个人免费交流学习,不可用作商业用途,本站不对显示的内容承担任何责任。请在下载后24小时内删除。如果喜欢,请购买正版,谢谢合作!
  4.龙听期货论坛原创文章属本网版权作品,转载须注明来源“龙听期货论坛”,违者本网将保留追究其相关法律责任的权力。本论坛除发布原创文章外,亦致力于优秀财经文章的交流分享,部分文章推送时若未能及时与原作者取得联系并涉及版权问题时,请及时联系删除。联系方式:http://www.qhlt.cn/thread-262-1-1.html
如何访问权限为100/255贴子:/thread-37840-1-1.html;注册后仍无法回复:/thread-23-1-1.html;微信/QQ群:/thread-262-1-1.html;网盘链接失效解决办法:/thread-93307-1-1.html

返回列表