
RE: Kostenlose Historische EOD Daten
| 08.02.2019, 15:02 (Dieser Beitrag wurde zuletzt bearbeitet: 08.02.2019, 15:04 von Noni-Binder. Bearbeitungsgrund: update )
TWS und IBPy:
ref: stackoverflow
ich nehme ein py-modul und ruf die tickerdaten EUR/USD auf
#! /usr/bin/env python
# -*- coding: utf-8 -*-
from ib.ext.Contract import Contract
from ib.opt import ibConnection, message
from time import sleep
# print all messages from TWS
def watcher(msg):
print (msg)
# show Bid and Ask quotes
def my_BidAsk(msg):
if msg.field == 1:
print ('%s:%s: bid: %s' % (contractTuple[0],
contractTuple[6], msg.price))
elif msg.field == 2:
print ('%s:%s: ask: %s' % (contractTuple[0], contractTuple[6], msg.price))
def makeStkContract(contractTuple):
newContract = Contract()
newContract.m_symbol = contractTuple[0]
newContract.m_secType = contractTuple[1]
newContract.m_exchange = contractTuple[2]
newContract.m_currency = contractTuple[3]
newContract.m_expiry = contractTuple[4]
newContract.m_strike = contractTuple[5]
newContract.m_right = contractTuple[6]
print ('Contract Values:%s,%s,%s,%s,%s,%s,%s:' % contractTuple)
return newContract
if __name__ == '__main__':
con = ibConnection()
con.registerAll(watcher)
showBidAskOnly = True # set False to see the raw messages
if showBidAskOnly:
con.unregister(watcher, message.tickSize, message.tickPrice,
message.tickString, message.tickOptionComputation)
con.register(my_BidAsk, message.tickPrice)
con.connect()
sleep(1)
tickId = 1
# Note: Option quotes will give an error if they aren't shown in TWS
#contractTuple = ('QQQQ', 'STK', 'SMART', 'USD', '', 0.0, '')
#contractTuple = ('QQQQ', 'OPT', 'SMART', 'USD', '20070921', 47.0, 'CALL')
#contractTuple = ('ES', 'FUT', 'GLOBEX', 'USD', '200709', 0.0, '')
#contractTuple = ('ES', 'FOP', 'GLOBEX', 'USD', '20070920', 1460.0, 'CALL')
contractTuple = ('EUR', 'CASH', 'IDEALPRO', 'USD', '', 0.0, '')
stkContract = makeStkContract(contractTuple)
print ('* * * * REQUESTING MARKET DATA * * * *')
con.reqMktData(tickId, stkContract, '', False)
sleep(15)
print ('* * * * CANCELING MARKET DATA * * * *')
con.cancelMktData(tickId)
sleep(1)
con.disconnect()
sleep(1)
------------------------------------------------------------------------
# Note: Option quotes will give an error if they aren't shown in TWS
#contractTuple = ('QQQQ', 'STK', 'SMART', 'USD', '', 0.0, '')
#contractTuple = ('QQQQ', 'OPT', 'SMART', 'USD', '20070921', 47.0, 'CALL')
#contractTuple = ('ES', 'FUT', 'GLOBEX', 'USD', '200709', 0.0, '')
#contractTuple = ('ES', 'FOP', 'GLOBEX', 'USD', '20070920', 1460.0, 'CALL')
---------------------------------------------------------------------
contractTuple = ('EUR', 'CASH', 'IDEALPRO', 'USD', '', 0.0, '')
also nur diese 'EUR' Abfrage zu den nachfolgenden Antworten der TWS führt
* * * * REQUESTING MARKET DATA * * * *
<marketDataType reqId=1, marketDataType=1>
EUR:: bid: 1.1337
EUR:: ask: 1.13375
<tickGeneric tickerId=1, tickType=49, value=0.0>
<tickGeneric tickerId=1, tickType=49, value=0.0>
* * * * CANCELING MARKET DATA * * * *
-----------------------------------------------------------------
ergo - irgendwie stimmen die parameter und die Folge der Parameter Eingaben nicht
Fehler noch nicht gefunden ??
-----------------------------------------------------------------
Test gemacht mit IDLE 3.6 (32 bit ) 3.7 geht nicht
das ist mein Startbeitrag - wobei mein Ziel ist - Stockdaten und Optionsdaten in ein excelsheet zu bringen und da die Auswertungen zu machen.
excel sheet benötigt Daten für Optionen closing und strike (clsPr2 und cls str2) - die nicht manuell sondern auto via TWS streaming daten und py eingefügt werden sollen
was ist euer Bedarf mit py ??
oder excel od. java oder IB API's ?
ref: stackoverflow
ich nehme ein py-modul und ruf die tickerdaten EUR/USD auf
#! /usr/bin/env python
# -*- coding: utf-8 -*-
from ib.ext.Contract import Contract
from ib.opt import ibConnection, message
from time import sleep
# print all messages from TWS
def watcher(msg):
print (msg)
# show Bid and Ask quotes
def my_BidAsk(msg):
if msg.field == 1:
print ('%s:%s: bid: %s' % (contractTuple[0],
contractTuple[6], msg.price))
elif msg.field == 2:
print ('%s:%s: ask: %s' % (contractTuple[0], contractTuple[6], msg.price))
def makeStkContract(contractTuple):
newContract = Contract()
newContract.m_symbol = contractTuple[0]
newContract.m_secType = contractTuple[1]
newContract.m_exchange = contractTuple[2]
newContract.m_currency = contractTuple[3]
newContract.m_expiry = contractTuple[4]
newContract.m_strike = contractTuple[5]
newContract.m_right = contractTuple[6]
print ('Contract Values:%s,%s,%s,%s,%s,%s,%s:' % contractTuple)
return newContract
if __name__ == '__main__':
con = ibConnection()
con.registerAll(watcher)
showBidAskOnly = True # set False to see the raw messages
if showBidAskOnly:
con.unregister(watcher, message.tickSize, message.tickPrice,
message.tickString, message.tickOptionComputation)
con.register(my_BidAsk, message.tickPrice)
con.connect()
sleep(1)
tickId = 1
# Note: Option quotes will give an error if they aren't shown in TWS
#contractTuple = ('QQQQ', 'STK', 'SMART', 'USD', '', 0.0, '')
#contractTuple = ('QQQQ', 'OPT', 'SMART', 'USD', '20070921', 47.0, 'CALL')
#contractTuple = ('ES', 'FUT', 'GLOBEX', 'USD', '200709', 0.0, '')
#contractTuple = ('ES', 'FOP', 'GLOBEX', 'USD', '20070920', 1460.0, 'CALL')
contractTuple = ('EUR', 'CASH', 'IDEALPRO', 'USD', '', 0.0, '')
stkContract = makeStkContract(contractTuple)
print ('* * * * REQUESTING MARKET DATA * * * *')
con.reqMktData(tickId, stkContract, '', False)
sleep(15)
print ('* * * * CANCELING MARKET DATA * * * *')
con.cancelMktData(tickId)
sleep(1)
con.disconnect()
sleep(1)
------------------------------------------------------------------------
# Note: Option quotes will give an error if they aren't shown in TWS
#contractTuple = ('QQQQ', 'STK', 'SMART', 'USD', '', 0.0, '')
#contractTuple = ('QQQQ', 'OPT', 'SMART', 'USD', '20070921', 47.0, 'CALL')
#contractTuple = ('ES', 'FUT', 'GLOBEX', 'USD', '200709', 0.0, '')
#contractTuple = ('ES', 'FOP', 'GLOBEX', 'USD', '20070920', 1460.0, 'CALL')
---------------------------------------------------------------------
contractTuple = ('EUR', 'CASH', 'IDEALPRO', 'USD', '', 0.0, '')
also nur diese 'EUR' Abfrage zu den nachfolgenden Antworten der TWS führt
* * * * REQUESTING MARKET DATA * * * *
<marketDataType reqId=1, marketDataType=1>
EUR:: bid: 1.1337
EUR:: ask: 1.13375
<tickGeneric tickerId=1, tickType=49, value=0.0>
<tickGeneric tickerId=1, tickType=49, value=0.0>
* * * * CANCELING MARKET DATA * * * *
-----------------------------------------------------------------
ergo - irgendwie stimmen die parameter und die Folge der Parameter Eingaben nicht
Fehler noch nicht gefunden ??
-----------------------------------------------------------------
Test gemacht mit IDLE 3.6 (32 bit ) 3.7 geht nicht
das ist mein Startbeitrag - wobei mein Ziel ist - Stockdaten und Optionsdaten in ein excelsheet zu bringen und da die Auswertungen zu machen.
excel sheet benötigt Daten für Optionen closing und strike (clsPr2 und cls str2) - die nicht manuell sondern auto via TWS streaming daten und py eingefügt werden sollen
was ist euer Bedarf mit py ??
oder excel od. java oder IB API's ?