10月24日 的日志 盈透api 数据流 查看ibapi 源文件 链接tws 获取实时数据

本文介绍了在10月24日程序员节期间,如何利用盈透API(IBapi)连接TWS获取实时数据的过程。文章首先探讨了不同Python接口如IBpy、simpleClient和ib_insync,强调了实现功能的重要性。接着,作者总结并展示了关键代码片段,实现了从TWS获取实时tick数据的功能。
摘要由CSDN通过智能技术生成

1、首先着手点 在 盈透的 stream tick 数据流

首先 查看 盈透api
tws api , IBpy , simpleClient , ib_insync , IbGateway
首先不管好坏 只要能实现 功能即可

2、通过查看 资料 总结以下代码

### 代码 借鉴云金杞 文章
### https://blog.csdn.net/qq_26948675/article/details/121733934?ops_request_misc=&request_id=&biz_id=102&utm_term=11tws%E5%92%8Cib&utm_medium=distribute.pc_search_result.none-task-blog-2~all~sobaiduweb~default-0-121733934.142^v59^js_top,201^v3^add_ask&spm=1018.2226.3001.4187

### SimpleClient 类来源于 云金杞

from datetime import datetime
from threading import Thread
import time
import sys 
from ibapi.client import EClient, Contract
from ibapi.order import Order
from ibapi.wrapper import EWrapper
from ibapi.utils import iswrapper

class SimpleClient(EWrapper, EClient):
    ''' Serves as the client and the wrapper '''

    def __init__(self, addr, port, client_id):
        EWrapper.__init__(self)
        EClient.__init__(self, self)
        # 订单号
        self.order_id = 0

        # Connect to TWS
        self.connect(addr, port, client_id)

        # Launch the client thread
        thread = Thread(target=self.run)
        thread.start()

    @iswrapper
    def currentTime(self, cur_time):
        t = datetime.fromtimestamp(cur_time)
        print('Current time: {}'.format(t))


    @iswrapper
    def contractDetails(self, reqId, details):
        print('Long name: {}'.format(details.longName))
        print('Category: {}'.format(details.category))
        print('Subcategory: {}'.format(details.subcategory))        
        print('Contract ID: {}\n&#
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

python@king

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值