IBAPI:期货和重新建立“ 321错误验证请求”。-' bs' :原因 - 请输入本地符号或有效期。
问题:
> "321 Error validating request.-'bS' : cause - Please enter a local
> symbol or an expiry"
我对ReqhistoricalData没有运气,我找不到任何符号作为最低可行的工作产品,我只需要一个基线,我希望看到的是期货合约的OHLCV数据。
我尝试了什么: 在将GetMarketData用于同一未来合同对象时,我没有同样的问题。
各种符号并注释了合同对象旁边的错误。
#needs to be set to live data
from ibapi.client import EClient
from ibapi.wrapper import EWrapper
from ibapi.common import *
from ibapi.contract import *
import time
class TestApp(EWrapper, EClient):
def __init__(self):
EClient.__init__(self, self)
def error(self, reqId, errorCode, errorString):
print("Error: ", reqId, " ", errorCode, " ", errorString)
def historicalData(self, reqId, bar):
print("HistoricalData. ", reqId, " Date:", bar.date, "Open:", bar.open, "High:", bar.high, "Low:", bar.low, "Close:", bar.close, "Volume:", bar.volume, "Count:", bar.barCount, "WAP:", bar.average)
def main():
app = TestApp()
app.connect("127.0.0.1", 7497, 0)
#"200 No security definition has been found for the request"
BTC_futures__contract = Contract()
BTC_futures__contract.symbol = 'BRR'
BTC_futures__contract.secType = 'FUT'
BTC_futures__contract.exchange = 'CMECRYPTO'
BTC_futures__contract.lastTradeDateOrContractMonth = '202003'
"321 Error validating request.-'bS' : cause - Please enter a local symbol or an expiry"
ES_contract = Contract()
#ES_contract.symbol = "ES"
ES_contract.symbol = "ESM2"
#added
ES_contract.LocalSymbol = 'ES IND'
ES_contract.TradingClass = 'ES'
ES_contract.secType = "FUT"
ES_contract.exchange = "GLOBEX"
ES_contract.currency = "USD"
ES_contract.lasttradedateorcontractmonth = "202206"
RTY_contract = Contract()
#RTY_contract.symbol = "ES"
RTY_contract.symbol = "RTY"
#added
#RTY_contract.LocalSymbol = 'ES IND'
#RTY_contract.TradingClass = 'ES'
RTY_contract.secType = "FUT"
RTY_contract.exchange = "GLOBEX"
RTY_contract.currency = "USD"
RTY_contract.lasttradedateorcontractmonth = "202206"
#app.reqHistoricalData(1, ES_contract, "", "1 D", "1 min", "MIDPOINT", 1, 1, False, [])
#snapshot
app.reqHistoricalData(1, RTY_contract, "", "1 D", "1 min", "MIDPOINT", 1, 1, False, [])
app.run()
time.sleep(2)
app.disconnect()
if __name__ == "__main__":
main()
Problem:
> "321 Error validating request.-'bS' : cause - Please enter a local
> symbol or an expiry"
I have no luck with reqHistoricalData, I can't find any symbol as a minimum viable working product, I just need a baseline and what I hope to see is OHLCV data for futures contracts.
What I've tried:
I don't have the same issue when using getMarketData for the same future contract object.
Various symbols and annotated their errors next to the contract object.
#needs to be set to live data
from ibapi.client import EClient
from ibapi.wrapper import EWrapper
from ibapi.common import *
from ibapi.contract import *
import time
class TestApp(EWrapper, EClient):
def __init__(self):
EClient.__init__(self, self)
def error(self, reqId, errorCode, errorString):
print("Error: ", reqId, " ", errorCode, " ", errorString)
def historicalData(self, reqId, bar):
print("HistoricalData. ", reqId, " Date:", bar.date, "Open:", bar.open, "High:", bar.high, "Low:", bar.low, "Close:", bar.close, "Volume:", bar.volume, "Count:", bar.barCount, "WAP:", bar.average)
def main():
app = TestApp()
app.connect("127.0.0.1", 7497, 0)
#"200 No security definition has been found for the request"
BTC_futures__contract = Contract()
BTC_futures__contract.symbol = 'BRR'
BTC_futures__contract.secType = 'FUT'
BTC_futures__contract.exchange = 'CMECRYPTO'
BTC_futures__contract.lastTradeDateOrContractMonth = '202003'
"321 Error validating request.-'bS' : cause - Please enter a local symbol or an expiry"
ES_contract = Contract()
#ES_contract.symbol = "ES"
ES_contract.symbol = "ESM2"
#added
ES_contract.LocalSymbol = 'ES IND'
ES_contract.TradingClass = 'ES'
ES_contract.secType = "FUT"
ES_contract.exchange = "GLOBEX"
ES_contract.currency = "USD"
ES_contract.lasttradedateorcontractmonth = "202206"
RTY_contract = Contract()
#RTY_contract.symbol = "ES"
RTY_contract.symbol = "RTY"
#added
#RTY_contract.LocalSymbol = 'ES IND'
#RTY_contract.TradingClass = 'ES'
RTY_contract.secType = "FUT"
RTY_contract.exchange = "GLOBEX"
RTY_contract.currency = "USD"
RTY_contract.lasttradedateorcontractmonth = "202206"
#app.reqHistoricalData(1, ES_contract, "", "1 D", "1 min", "MIDPOINT", 1, 1, False, [])
#snapshot
app.reqHistoricalData(1, RTY_contract, "", "1 D", "1 min", "MIDPOINT", 1, 1, False, [])
app.run()
time.sleep(2)
app.disconnect()
if __name__ == "__main__":
main()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论