Um historische Daten aus der API zu erhalten, muss ein Benutzer Level 1 Marktdatenabonnements für diesen Vertrag haben. Historische Daten sind in TWS-Charts für viele Arten von Instrumenten verfügbar, ohne Marktdaten-Abonnements zu haben, werden aber der API nicht zur Verfügung stehen, es sei denn, alle Anforderungen an Live-Marktdaten sind erfüllt. Wenn Sie historische Daten aus der TWS abrufen, beachten Sie die Historical Data Limitations. Anfordern historischer Daten Historische Daten werden aus der TWS über die Funktion IBApi. EClient. reqHistoricalData erhalten. Jede Anfrage benötigt: Eine eindeutige Kennung, die zur Identifizierung der eingehenden Daten dient. Die IBApi. Contract Sie interessiert sind. Die Anfragen Enddatum und Uhrzeit. Die Zeitspanne (oder Valid Duration String Einheiten), um von den Anfragen endet Ende und Uhrzeit zurückzukehren. Die Daten-Granularität oder Gültige Bar-Größen Die Art der abzurufenden Daten. Siehe Historische Datentypen (whatToShow) Ob Daten, die nur innerhalb der regulären Handelszeiten (RTH) generiert wurden, abrufen oder nicht, das Format, in dem das eingehende Balkendatum dargestellt werden soll. Beachten Sie, dass für Tagesleisten nur das Format yyyyMMdd verfügbar ist. Zum Beispiel, eine Anfrage mit einem Enddatum und Zeit von 20160127 23:59:59, eine Dauer von 3 D und eine Bar Größe von 1 Stunde wird drei Tage im Wert von 1 Stunde Bars Daten, in denen die letzte Bar wird Seien Sie der nächstgelegene bis 20160127 23:59:59. String queryTime DateTime. Now. AddMonths (-6).ToString (quotyyyMMdd HH: mm: ssquot) client. reqHistoricalData (4001, ContractSamples. EurGbpFx (), queryTime, quot1 Mquot. Quot1 dayquot. QuotMIDPOINTquot 1, 1, null) Client. reqHistoricalData (4002, ContractSamples. EuropeanStock (), queryTime, quot10 Dquot. "1" 1, 1, null) Kalender cal Calendar. getInstance () SimpleDateFormat form new SimpleDateFormat (quotyyyMMdd HH: mm: ssquot) String formatiertes Formular. Format (cal. getTime ()) client. reqHistoricalData (4001, ContractSamples. EurGbpFx (), formatiert, quot1 Mquot .11. 10-Quartett (1) 1) 1) 1) 1 2 1 2 3 4 5 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 7 9 (), QueryTime, quot1 Mquot. Quot1 dayquot. MIDPOINTquot. 1, 1, Nichts) client. reqHistoricalData (4002, ContractSamples. EuropeanStock (), queryTime, quot10 Dquot. "1, 1, Nichts) char queryTime 80 std :: strftime (queryTime, 80, quotYmd H: M : Quint. dr. dr. dr. dr. dr. dbdddddddddddddddddddddddddddddddddddddddddddddddddddddddddd , 1, 1, TagValueListSPtr ()) 1 160 queryTime (datetime. datetime. today () - 2 160 datetime. timedelta (days180)) strftime (quotYmd H: M: Squot) 3 160 String queryTime DateTime. Now. AddMonths (-6).ToString (quotyyyMMdd HH: mm: ssquot) 4 160 self. reqHistoricalData (4101, ContractSamples. USStockAtSmart (), queryTime, 5 160 quot1 Mquot. Quot1 dayquot. MIDPOINTquot 1, 1 , 6 160 self. reqHistoricalData (4001, ContractSamples. EurGbpFx (), queryTime, 7 160 quot1 Mquot. Quot1 dayquot. QuotMIDPOINTquot 1, 1,) 8 160 self. reqHistoricalData (4002, ContractSamples. EuropeanStock (), queryTime, 9 160 quot10 Dquot. Quot1 minquot QuotTRADESquot. 1, 1,) Abfrage des Anfangs der historischen Daten Um den frühesten verfügbaren Datenpunkt für ein bestimmtes Instrument und einen Datentyp zu finden, befindet sich eine Funktion in der API ab v973.02 und v963 von TWSIBG, IBApi :: EClient :: reqHeadTimestamp client. reqHeadTimestamp (14001, ContractSamples. USStock (), quotTRADESquot 1, 1) client. reqHeadTimestamp (4003, ContractSamples. USStock (), quotTRADESquot 1, 1) client. reqHeadTimestamp (14001, ContractSamples. USStock (), quotTRADESquot 1, 1 ) MpClient-gtreqHeadTimestamp (14001, ContractSamples :: EurGbpFx (), quotMIDPOINTquot 1, 1) 1 160 self. reqHeadTimeStamp (4103, ContractSamples. USStockAtSmart (), quotTRADESquot 0, 1) Der resultierende Kopfzeitstempel wird an die Funktion IBApi zurückgegeben :: client :: headTimestamp public class EWrapperImpl. EWrapper public void headTimestamp (int reqId, string headTimestamp) Console. WriteLine (quotHead Zeitstempel) Anforderungs-ID:, Kopf Zeitstempel: ReqId, headTimestamp) public class EWrapperImpl implementiert EWrapper public void headTimestamp (int reqId, String headTimestamp) System. Out. println (quotAnz Zeitstempel, Req Id: ReqId quot, headTimestamp: headTimestamp) Öffentliche Klasse EWrapperImpl Public Sub headTimestamp (requestId As Integer, timeStamp As String) implementiert IBApi. EWrapper. headTimestamp Console. WriteLine (quotHead Zeitstempel Request Id :, Kopfzeitstempel: AnforderungId, timeStamp) Klasse TestCppClient. Öffentlicher EWrapper void TestCppClient :: headTimestamp (int reqId, const std :: stringamp headTimestamp) printf (quotHead Zeitstempel ReqId: d - Kopf Zeitstempel: s, nquot. ReqId, headTimestamp. cstr ()) 1 160 Klasse TestWrapper (Wrapper. EWrapper): 1 160 def headTimestamp (self, reqId: int, headTimestamp: str): 2 160 print (quotHeadTimestamp: quot reqId, quot. HeadTimestamp) Erhalt historischer Daten Die historischen Daten werden über den IBApi :: EWrapper ausgeliefert :: historicData-Methode in Form von Leuchtern. Sobald alle Leuchter empfangen worden sind, wird die IBApi. EWrapper. historicalDataEnd Marker die öffentliche Klasse EWrapperImpl gesendet. EWrapper public virtuelle void historicData (int reqId, string date, double open, double high, double low, double close, int volume, int count, double WAP, bool hasGaps) Console. WriteLine (quotHistoricalData. Quot reqId quot - Datum: Datum Klicken Sie auf "Öffnen", "Öffnen", "Hoch", "Hoch", "Niedrig", "Niedrig", "Niedrig" Virtuelles void historicDataEnd (int reqId, string startDate, string endDate) Console. WriteLine (quotHistoricalDataEnd - quot reqId quot von quot startDate quot to quot endDate) public class EWrapperImpl implementiert EWrapper public void historicData (int reqId, String date, double open, double high , Double low, double close, int volume, int count, doppelte WAP, boolean hasGaps) System. out. println (quotHistoricalData. Quot quot quot - Datum: quot date quot, Open: quot offen, High: quot high quot, niedrig : "Niedrig", "Schließen", "Schließen", "Schließen", "Zitat", "WAP": "WAP": "HasGaps": "HasGaps".println (quotHistoricalDataEnd. ReqId Als Integer, Datum Als String, öffnen Sie als Double, high As Double, low As Double, schließen Sie als Double, Volume As Integer, Zähl als Integer, WAP als Double, hasGaps als Boolean) implementiert IBApi. EWrapper. historicalData Console. WriteLine (quotHistoricalData - ReqId am amp reqId amp quot Datumsdatum amp date amp quot offener amp offener amp quot High quot amp high amp quot Niedriger Quell-Verstärker-Verstärker-Verstärker-Verstärker-Verstärker-Verstärker-Verstärker-Verstärker-Verstärker-Verstärker-Verstärker-Verstärker-Verstärker-Verstärkungsfaktoren - ReqId amp quot Start Start amp start amp quot End beendet amp end amp quotquot) class TestCppClient. Public EWrapper void TestCppClient :: historicData (TickerId reqId, const std :: stringamp date, double open, double high, double low, double schließen, int volume, int barCount, double WAP, int hasGaps) printf (quotHistoricalData ReqId: ld - Datum: s, Offen: g, Hoch: g, Niedrig: g, Schließen: g, Volumen: d, Anzahl: d, WAP: g, HasGaps: dnquot, reqId, date. cstr (), offen, hoch, niedrig, Close, volume, barCount, WAP, hasGaps) void TestCppClient :: historicDataEnd (int reqId, std :: string startDateStr, std :: string endDateStr) std :: cout ltlt quotHistoricalDataEnd. ReqId: ltlt reqId ltlt quot - Startdatum: ltlt startDateStr ltlt quot, Enddatum: ltlt endDateStr ltlt std :: endl 1 160 Klasse TestWrapper (wrapper. EWrapper): 1 160 def historicData (self, reqId: TickerId, date : Str, offen: float, high: float, 2 160 low: float, schließen: float, volume: int, barCount: int, 3 160 WAP: float, hasGaps: int): 4 160 super () historische Daten (reqId, Datum, offen, hoch, niedrig, schließen, Volumen, 5 160 barCount, WAP, hasGaps) 6 160 print (quotHistoricalData. Quotal, quot Datum: Datum, quotOpen: offen, 7 160 quotHigh: high , Quatrisch, fehlerhaft, fehlerhaft, fehlerlos, fehlerhaft, fehlerhaft, fehlerhaft, dgl. Start: str, end: str): 2 160 super () historischDatenEnd (reqId, start, end) 3 160 print (quotHistoricalDataEnd quot. ReqId, quotfromquot. Start, quottoquot Ende) Gültige Dauer String Einheiten Gültige Bargrößen Historische Datentypen (WhatToShow) Verfügbare Daten pro Produkt,. ,,, , Offen, Clos, Hoch, Niedrig. . Aufrechtzuerhalten. Aufrechtzuerhalten. -,,,. Aufrechtzuerhalten. Aufrechtzuerhalten. :,,,, . ,,,,, ,,,, . Aufrechtzuerhalten. ,,,,, , DemoNotepad 7.3.1 Forrskd szerkeszt alkalmazs. 339 letlts rtkels 5 5 VirtualBox 5.1.14 Virtulis gp alternatv oprendsz. Teleptshez 417 letlts rtkels 5 5 VirtualBox 5.0.24 Virtulis gp alternatv oprendsz. Teleptshez 940 letlts rtkels 4 5 VirtualBox 5.0.18 Virtulis gp alternatv oprendsz. Teleptshez 502 letlts rtkels 4 5 Wise Care 365 4.15.401 Rendszerkarbantart s optimizl alkalmazs. 2097 letlts rtkels 4.3 5 Evernote 6.0.4.1688 Virtulis jegyzetfzet, sok extra funkcival. 243 letlts rtkels 5 5
Comments
Post a Comment