IB証券(インタラクティブ・ブローカーズ証券)のAPIに接続してシストレをするために利用するライブラリib_insyncのモジュールのうち、IBモジュールのイベント処理についてクラスや関数などをPythonのサンプルプログラムを用いて紹介しています。
取り急ぎ、利用頻度が高い、または重要そうなイベントを紹介しています。
エラーのイベントを取得|errorEvent
ib.errorEvent
何らかのエラーが発生すると、その情報を出力します。
出力する情報は以下の4種類です。
- reqId:リクエストID?
- error_code:エラーコード
- error_string:エラーメッセージ(エラーの内容など)
- contract:商品情報
いろいろなシステムの作り方があると思いますが、以下のサンプルプログラムは関数で取得するようにしました。
テストはシステムを稼働させているネットワークを強制的に遮断してみました。
その出力結果をコメントに記載しています。
def ib_onErrorEvent(reqId, error_code, error_string, contract): print('reqId',reqId) print('error_code',error_code) print('error_string',error_string) print('contract',contract) ib.errorEvent += ib_onErrorEvent while True: ib.sleep(1) # reqId -1 # error_code 2105 # error_string HMDSデータファームのコネクションが破損されています:cashhmds # contract None # reqId -1 # error_code 2157 # error_string Sec-defデータファームの接続に問題があります:secdefhk # contract None # reqId -1 # error_code 2106 # error_string HMDSデータファーム・コネクションはOKです:cashhmds # contract None # reqId -1 # error_code 2103 # error_string マーケットデータファームのコネクションが破損されています:usfarm.nj # contract None # reqId -1 # error_code 2158 # error_string Sec-defデータファームの接続に問題ありません:secdefhk # contract None # reqId -1 # error_code 2104 # error_string マーケットデータファームのコネクションは問題ありません:usfarm.nj # contract None
注文の処理を取得|onCommissionReports
ib.commissionReportEvent
注文が発生すると、その情報を出力します。
出力する情報は以下の3種類です。
- trade
- contract
- orderStatus
- fills*リスト型
- log
- fill
- contract
- execution
- commissionReport
- time
- report
- execId
- commission
- currency
注文が完了していなくても、情報を出力しますので、以下のようなコードで完了した情報のみを取得すると良いでしょう。
if trade.orderStatus.status == "Filled":
いろいろなシステムの作り方があると思いますが、以下のサンプルプログラムはクラスの関数で取得するようにしました。
1回で全て約定した場合
trade, fill, reportのそれぞれを1回取得することができます。
class trading: def onCommissionReports(self, trade, fill, report): print(trade) trading_ins = trading() ib.commissionReportEvent += trading_ins.onCommissionReports contract = Forex('EURUSD', exchange='IDEALPRO') ib.qualifyContracts(contract) order = MarketOrder('SELL', 5) log = ib.placeOrder(contract, order) # Trade(contract=Forex('EURUSD', conId=12087792, exchange='IDEALPRO', localSymbol='EUR.USD', tradingClass='EUR.USD'), order=MarketOrder(orderId=27, clientId=2000, permId=1116985991, action='SELL', totalQuantity=10.0, lmtPrice=0.0, auxPrice=0.0, tif='DAY', ocaType=3, trailStopPrice=0.19104999999999994, openClose='', eTradeOnly=False, firmQuoteOnly=False, volatilityType=0, deltaNeutralOrderType='None', referencePriceType=0, account='XX1234567', clearingIntent='IB', orderComboLegs=[], adjustedOrderType='None', conditions=[], softDollarTier=SoftDollarTier(), cashQty=0.0, dontUseAutoPriceForHedge=True), orderStatus=OrderStatus(status='Filled', filled=10.0, avgFillPrice=1.191, permId=1116985991, lastFillPrice=1.191, clientId=2000), fills=[Fill(contract=Forex('EURUSD', conId=12087792, exchange='IDEALPRO', localSymbol='EUR.USD', tradingClass='EUR.USD'), execution=Execution(execId='0000e215.5f4c1a4c.01.01', time=datetime.datetime(2020, 8, 30, 9, 54, 11, tzinfo=datetime.timezone.utc), acctNumber='XX1234567', exchange='IDEALPRO', side='SLD', shares=10.0, price=1.191, permId=1116985991, clientId=2000, orderId=27, cumQty=10.0, avgPrice=1.191, lastLiquidity=2), commissionReport=CommissionReport(execId='0000e215.5f4c1a4c.01.01', commission=2.5, currency='USD'), time=datetime.datetime(2020, 8, 30, 22, 54, 11, 494494, tzinfo=datetime.timezone.utc))], log=[TradeLogEntry(time=datetime.datetime(2020, 8, 30, 22, 54, 11, 166344, tzinfo=datetime.timezone.utc), status='PendingSubmit', message=''), TradeLogEntry(time=datetime.datetime(2020, 8, 30, 22, 54, 11, 262599, tzinfo=datetime.timezone.utc), status='PreSubmitted', message=''), TradeLogEntry(time=datetime.datetime(2020, 8, 30, 22, 54, 11, 494494, tzinfo=datetime.timezone.utc), status='PreSubmitted', message='Fill 10.0@1.191'), TradeLogEntry(time=datetime.datetime(2020, 8, 30, 22, 54, 11, 495513, tzinfo=datetime.timezone.utc), status='Filled', message='')]) # Fill(contract=Forex('EURUSD', conId=12087792, exchange='IDEALPRO', localSymbol='EUR.USD', tradingClass='EUR.USD'), execution=Execution(execId='0000e215.5f4c1a4c.01.01', time=datetime.datetime(2020, 8, 30, 9, 54, 11, tzinfo=datetime.timezone.utc), acctNumber='XX1234567', exchange='IDEALPRO', side='SLD', shares=10.0, price=1.191, permId=1116985991, clientId=2000, orderId=27, cumQty=10.0, avgPrice=1.191, lastLiquidity=2), commissionReport=CommissionReport(execId='0000e215.5f4c1a4c.01.01', commission=2.5, currency='USD'), time=datetime.datetime(2020, 8, 30, 22, 54, 11, 494494, tzinfo=datetime.timezone.utc)) # CommissionReport(execId='0000e215.5f4c1a4c.01.01', commission=2.5, currency='USD')
1回で全て約定しなかった場合
trade, fill, reportのそれぞれを部分約定の度に出力されます。
コンボ注文(複数の注文を一括で発注する注文)も同様になります。
class trading: def onCommissionReports(self, trade, fill, report): print(trade) print("***") print(fill) print("***") print(report) print("===========================") trading_ins = trading() ib.commissionReportEvent += trading_ins.onCommissionReports contract = Contract( secType = 'FUT', symbol = 'NQ', exchange = 'GLOBEX', lastTradeDateOrContractMonth = '20200918', tradingClass = 'NQ', ) ib.qualifyContracts(contract) order = MarketOrder('SELL', 5) log = ib.placeOrder(contract, order) # Trade(contract=Contract(secType='FUT', conId=371749745, symbol='NQ', lastTradeDateOrContractMonth='20200918', multiplier='20', exchange='GLOBEX', currency='USD', localSymbol='NQU0', tradingClass='NQ'), order=MarketOrder(orderId=37, clientId=2000, permId=1116985996, action='SELL', totalQuantity=5.0, lmtPrice=0.0, auxPrice=0.0, tif='DAY', ocaType=3, trailStopPrice=12026.25, openClose='', eTradeOnly=False, firmQuoteOnly=False, volatilityType=0, deltaNeutralOrderType='None', referencePriceType=0, account='XX1234567', clearingIntent='IB', orderComboLegs=[], adjustedOrderType='None', conditions=[], softDollarTier=SoftDollarTier(), cashQty=0.0, dontUseAutoPriceForHedge=True), orderStatus=OrderStatus(status='Submitted', filled=3.0, remaining=2.0, avgFillPrice=12027.25, permId=1116985996, lastFillPrice=12027.25, clientId=2000), fills=[Fill(contract=Contract(secType='FUT', conId=371749745, symbol='NQ', lastTradeDateOrContractMonth='20200918', multiplier='20', exchange='GLOBEX', currency='USD', localSymbol='NQU0', tradingClass='NQ'), execution=Execution(execId='0000e1a7.5f4c24fd.01.01', time=datetime.datetime(2020, 8, 30, 10, 5, 7, tzinfo=datetime.timezone.utc), acctNumber='XX1234567', exchange='GLOBEX', side='SLD', shares=3.0, price=12027.25, permId=1116985996, clientId=2000, orderId=37, cumQty=3.0, avgPrice=12027.25, lastLiquidity=1), commissionReport=CommissionReport(execId='0000e1a7.5f4c24fd.01.01', commission=5.1, currency='USD'), time=datetime.datetime(2020, 8, 30, 23, 5, 7, 961471, tzinfo=datetime.timezone.utc))], log=[TradeLogEntry(time=datetime.datetime(2020, 8, 30, 23, 5, 7, 644056, tzinfo=datetime.timezone.utc), status='PendingSubmit', message=''), TradeLogEntry(time=datetime.datetime(2020, 8, 30, 23, 5, 7, 955647, tzinfo=datetime.timezone.utc), status='PreSubmitted', message=''), TradeLogEntry(time=datetime.datetime(2020, 8, 30, 23, 5, 7, 961471, tzinfo=datetime.timezone.utc), status='PreSubmitted', message='Fill 3.0@12027.25'), TradeLogEntry(time=datetime.datetime(2020, 8, 30, 23, 5, 7, 961930, tzinfo=datetime.timezone.utc), status='PreSubmitted', message=''), TradeLogEntry(time=datetime.datetime(2020, 8, 30, 23, 5, 7, 964130, tzinfo=datetime.timezone.utc), status='Submitted', message='')]) # *** # Fill(contract=Contract(secType='FUT', conId=371749745, symbol='NQ', lastTradeDateOrContractMonth='20200918', multiplier='20', exchange='GLOBEX', currency='USD', localSymbol='NQU0', tradingClass='NQ'), execution=Execution(execId='0000e1a7.5f4c24fd.01.01', time=datetime.datetime(2020, 8, 30, 10, 5, 7, tzinfo=datetime.timezone.utc), acctNumber='XX1234567', exchange='GLOBEX', side='SLD', shares=3.0, price=12027.25, permId=1116985996, clientId=2000, orderId=37, cumQty=3.0, avgPrice=12027.25, lastLiquidity=1), commissionReport=CommissionReport(execId='0000e1a7.5f4c24fd.01.01', commission=5.1, currency='USD'), time=datetime.datetime(2020, 8, 30, 23, 5, 7, 961471, tzinfo=datetime.timezone.utc)) # *** # CommissionReport(execId='0000e1a7.5f4c24fd.01.01', commission=5.1, currency='USD') # =========================== # Trade(contract=Contract(secType='FUT', conId=371749745, symbol='NQ', lastTradeDateOrContractMonth='20200918', multiplier='20', exchange='GLOBEX', currency='USD', localSymbol='NQU0', tradingClass='NQ'), order=MarketOrder(orderId=37, clientId=2000, permId=1116985996, action='SELL', totalQuantity=5.0, lmtPrice=0.0, auxPrice=0.0, tif='DAY', ocaType=3, trailStopPrice=12026.25, openClose='', eTradeOnly=False, firmQuoteOnly=False, volatilityType=0, deltaNeutralOrderType='None', referencePriceType=0, account='XX1234567', clearingIntent='IB', orderComboLegs=[], adjustedOrderType='None', conditions=[], softDollarTier=SoftDollarTier(), cashQty=0.0, dontUseAutoPriceForHedge=True), orderStatus=OrderStatus(status='Filled', filled=5.0, avgFillPrice=12027.25, permId=1116985996, lastFillPrice=12027.25, clientId=2000), fills=[Fill(contract=Contract(secType='FUT', conId=371749745, symbol='NQ', lastTradeDateOrContractMonth='20200918', multiplier='20', exchange='GLOBEX', currency='USD', localSymbol='NQU0', tradingClass='NQ'), execution=Execution(execId='0000e1a7.5f4c24fd.01.01', time=datetime.datetime(2020, 8, 30, 10, 5, 7, tzinfo=datetime.timezone.utc), acctNumber='XX1234567', exchange='GLOBEX', side='SLD', shares=3.0, price=12027.25, permId=1116985996, clientId=2000, orderId=37, cumQty=3.0, avgPrice=12027.25, lastLiquidity=1), commissionReport=CommissionReport(execId='0000e1a7.5f4c24fd.01.01', commission=5.1, currency='USD'), time=datetime.datetime(2020, 8, 30, 23, 5, 7, 961471, tzinfo=datetime.timezone.utc)), Fill(contract=Contract(secType='FUT', conId=371749745, symbol='NQ', lastTradeDateOrContractMonth='20200918', multiplier='20', exchange='GLOBEX', currency='USD', localSymbol='NQU0', tradingClass='NQ'), execution=Execution(execId='0000e1a7.5f4c24fe.01.01', time=datetime.datetime(2020, 8, 30, 10, 5, 8, tzinfo=datetime.timezone.utc), acctNumber='XX1234567', exchange='GLOBEX', side='SLD', shares=2.0, price=12027.25, permId=1116985996, clientId=2000, orderId=37, cumQty=5.0, avgPrice=12027.25, lastLiquidity=1), commissionReport=CommissionReport(execId='0000e1a7.5f4c24fe.01.01', commission=3.4, currency='USD'), time=datetime.datetime(2020, 8, 30, 23, 5, 8, 805827, tzinfo=datetime.timezone.utc))], log=[TradeLogEntry(time=datetime.datetime(2020, 8, 30, 23, 5, 7, 644056, tzinfo=datetime.timezone.utc), status='PendingSubmit', message=''), TradeLogEntry(time=datetime.datetime(2020, 8, 30, 23, 5, 7, 955647, tzinfo=datetime.timezone.utc), status='PreSubmitted', message=''), TradeLogEntry(time=datetime.datetime(2020, 8, 30, 23, 5, 7, 961471, tzinfo=datetime.timezone.utc), status='PreSubmitted', message='Fill 3.0@12027.25'), TradeLogEntry(time=datetime.datetime(2020, 8, 30, 23, 5, 7, 961930, tzinfo=datetime.timezone.utc), status='PreSubmitted', message=''), TradeLogEntry(time=datetime.datetime(2020, 8, 30, 23, 5, 7, 964130, tzinfo=datetime.timezone.utc), status='Submitted', message=''), TradeLogEntry(time=datetime.datetime(2020, 8, 30, 23, 5, 8, 805827, tzinfo=datetime.timezone.utc), status='Submitted', message='Fill 2.0@12027.25'), TradeLogEntry(time=datetime.datetime(2020, 8, 30, 23, 5, 8, 807419, tzinfo=datetime.timezone.utc), status='Filled', message='')]) # *** # Fill(contract=Contract(secType='FUT', conId=371749745, symbol='NQ', lastTradeDateOrContractMonth='20200918', multiplier='20', exchange='GLOBEX', currency='USD', localSymbol='NQU0', tradingClass='NQ'), execution=Execution(execId='0000e1a7.5f4c24fe.01.01', time=datetime.datetime(2020, 8, 30, 10, 5, 8, tzinfo=datetime.timezone.utc), acctNumber='XX1234567', exchange='GLOBEX', side='SLD', shares=2.0, price=12027.25, permId=1116985996, clientId=2000, orderId=37, cumQty=5.0, avgPrice=12027.25, lastLiquidity=1), commissionReport=CommissionReport(execId='0000e1a7.5f4c24fe.01.01', commission=3.4, currency='USD'), time=datetime.datetime(2020, 8, 30, 23, 5, 8, 805827, tzinfo=datetime.timezone.utc)) # *** # CommissionReport(execId='0000e1a7.5f4c24fe.01.01', commission=3.4, currency='USD') # ===========================
リアルタイムデータ(ティックデータ)を取得|pendingTickersEvent
ib.pendingTickersEvent
詳しくは本サイトの以下のページを参照してください。
アカウントの資産情報を取得|accountValueEvent
ib.accountValueEvent
アカウントの資産に変化が発生すると、その情報を出力します。
情報は資産の値ごとに出力され、value.tag
で情報を識別してvalue.value
で値を取得することができます。
class trading: def __init__(self): self.positions = {} def accountValueEvent(self, value): print(value) if value.tag == "TotalCashValue": Portfolio["TotalCashValue"] = value.value if value.tag == "NetLiquidation": Portfolio["NetLiquidation"] = value.value if value.tag == "MaintMarginReq": Portfolio["MaintMarginReq"] = value.value if value.tag == "ExcessLiquidity": Portfolio["ExcessLiquidity"] = value.value if value.tag == "TotalCashValue": Portfolio["BuyingPower"] = value.value trading_ins = trading() ib.accountValueEvent += trading_ins.accountValueEvent Portfolio = { "TotalCashValue" : 0, "NetLiquidation" : 0, "MaintMarginReq" : 0, "ExcessLiquidity" : 0, "BuyingPower" : 0, } symbol = 'NQ' exchange = 'GLOBEX' tradingClass = 'NQ' expiration = '20200918' strike = ['12040', '12130'] contracts = [ Contract( secType = 'FOP', symbol = symbol, exchange = exchange, lastTradeDateOrContractMonth = expiration, right = "P", strike = strike[0], tradingClass = tradingClass ), Contract( secType = 'FOP', symbol = symbol, exchange = exchange, lastTradeDateOrContractMonth = expiration, right = "C", strike = strike[1], tradingClass = tradingClass ), ] conid = [] for contract in contracts: ib.qualifyContracts(contract) conid.append(contract.conId) contract = Contract( symbol=symbol, secType='BAG', exchange=exchange, currency='USD', comboLegs=[ ComboLeg(conId=conid[0],ratio=1, action='SELL', exchange=exchange), ComboLeg(conId=conid[1],ratio=1, action='SELL', exchange=exchange) ] ) ib.sleep(3) order = MarketOrder('BUY', 1) trade = ib.placeOrder(contract, order) # AccountValue(account='XX1234567', tag='EquityWithLoanValue-S', value='91221.38', currency='USD', modelCode='') # AccountValue(account='XX1234567', tag='EquityWithLoanValue-S', value='91221.38', currency='USD', modelCode='') # AccountValue(account='XX1234567', tag='NetLiquidation-S', value='91221.38', currency='USD', modelCode='') # AccountValue(account='XX1234567', tag='NetLiquidation-S', value='91221.38', currency='USD', modelCode='') # AccountValue(account='XX1234567', tag='TotalCashValue-S', value='91221.38', currency='USD', modelCode='') # AccountValue(account='XX1234567', tag='TotalCashValue-S', value='91221.38', currency='USD', modelCode='') # AccountValue(account='XX1234567', tag='EquityWithLoanValue-C', value='580136.63', currency='USD', modelCode='') # AccountValue(account='XX1234567', tag='EquityWithLoanValue-C', value='580136.63', currency='USD', modelCode='') # AccountValue(account='XX1234567', tag='NetLiquidation-C', value='593930.07', currency='USD', modelCode='') # AccountValue(account='XX1234567', tag='NetLiquidation-C', value='593930.07', currency='USD', modelCode='') ・・・
コメントのように、多くの資産の値がありますので、上記のように売買が発生すれば、一気にたくさんの情報が吐き出されます。
上記の場合、必要な情報をPortfolioに代入するようにしました。
その結果は以下です。
pprint.pprint(Portfolio) # {'BuyingPower': '697579.28', # 'ExcessLiquidity': '656034.62', # 'MaintMarginReq': '28923.97', # 'NetLiquidation': '684958.59', # 'TotalCashValue': '697579.28'}
このようにシステムを組んでおけば、常に最新の資産状況をメモリーに保持させることができます。
アカウントのサマリーを取得?|accountSummaryEvent
ib.accountSummaryEvent
本イベントの仕様と挙動は不明でした。
以下のようにib_insyncのサイトにib.accountValueEventと同じようなニュアンスで説明が書いてありましたが、新規購入や決済注文ではイベントを取得することができませんでした。
* “accountValueEvent“ (value: :class:`.AccountValue`): An account value has changed. * “accountSummaryEvent“ (value: :class:`.AccountValue`): An account value has changed.
ポジション(建玉)の変化を取得|positionEvent
ib.positionEvent
ポジション(建玉)が変化すると、その情報を出力します。
出力する情報は以下の4種類です。
- account:アカウント名
- contract:商品情報
- position:ポジション数
- avgCost:平均価格
class trading: def __init__(self): self.positions = {} def positionEvent(self, position): print("---positionEvent") print(position) trading_ins = trading() ib.positionEvent += trading_ins.positionEvent symbol = 'NQ' exchange = 'GLOBEX' tradingClass = 'NQ' expiration = '20200918' strike = ['12040', '12130'] contracts = [ Contract( secType = 'FOP', symbol = symbol, exchange = exchange, lastTradeDateOrContractMonth = expiration, right = "P", strike = strike[0], tradingClass = tradingClass ), Contract( secType = 'FOP', symbol = symbol, exchange = exchange, lastTradeDateOrContractMonth = expiration, right = "C", strike = strike[1], tradingClass = tradingClass ), ] conid = [] for contract in contracts: ib.qualifyContracts(contract) conid.append(contract.conId) contract = Contract( symbol=symbol, secType='BAG', exchange=exchange, currency='USD', comboLegs=[ ComboLeg(conId=conid[0],ratio=1, action='SELL', exchange=exchange), ComboLeg(conId=conid[1],ratio=1, action='SELL', exchange=exchange) ] ) ib.sleep(3) order = MarketOrder('BUY', 1) trade = ib.placeOrder(contract, order) # ---positionEvent # Position(account='XX1234567', contract=FuturesOption(conId=438225673, symbol='NQ', lastTradeDateOrContractMonth='20200918', strike=12040.0, right='P', multiplier='20', currency='USD', localSymbol='NQU0 P1204', tradingClass='NQ'), position=-2.0, avgCost=4429.29) # ---positionEvent # Position(account='XX1234567', contract=FuturesOption(conId=438225644, symbol='NQ', lastTradeDateOrContractMonth='20200918', strike=12130.0, right='C', multiplier='20', currency='USD', localSymbol='NQU0 C1213', tradingClass='NQ'), position=-2.0, avgCost=6804.29)
ポートフォリオアイテムの変化後を取得?|updatePortfolioEvent
ib.updatePortfolioEvent
このイベントに関しては、理解ができていません。挙動が不明確ですが、恐らく、ポジションの変化などによりイベントが発生するようで、そのときに取得できる情報は、TWSのポートフォリオに表示されている全てのポジションの情報のようです。
ですので、取得した情報をよく見ると、ポジション数が0でもTWSのポートフォリオに表示されている商品はポジション数が0で主力されています。
それぞれのポジションの出力する情報は以下のようです。*若干自身がありません。
- contract:商品情報
- position:ポジション数
- marketPrice:現在の価格
- marketValue:現在の時価評価額(marketPrice × multiplier)
- averageCost:取得時の時価評価額
- unrealizedPNL:未実現損益
- realizedPNL:評価損益
- account:アカウント名
本イベントをなにかに使えないか調べてみましたが、私には使い道がわかりませんでした。
class trading: def __init__(self): self.positions = {} def updatePortfolioEvent(self, item): print("---updatePortfolioEvent") print(item) trading_ins = trading() ib.updatePortfolioEvent += trading_ins.updatePortfolioEvent symbol = 'NQ' exchange = 'GLOBEX' tradingClass = 'NQ' expiration = '20200918' strike = ['12040', '12130'] contracts = [ Contract( secType = 'FOP', symbol = symbol, exchange = exchange, lastTradeDateOrContractMonth = expiration, right = "P", strike = strike[0], tradingClass = tradingClass ), Contract( secType = 'FOP', symbol = symbol, exchange = exchange, lastTradeDateOrContractMonth = expiration, right = "C", strike = strike[1], tradingClass = tradingClass ), ] conid = [] for contract in contracts: ib.qualifyContracts(contract) conid.append(contract.conId) contract = Contract( symbol=symbol, secType='BAG', exchange=exchange, currency='USD', comboLegs=[ ComboLeg(conId=conid[0],ratio=1, action='SELL', exchange=exchange), ComboLeg(conId=conid[1],ratio=1, action='SELL', exchange=exchange) ] ) ib.sleep(3) order = MarketOrder('BUY', 1) # trade = ib.placeOrder(contract, order) # ---updatePortfolioEvent # PortfolioItem(contract=FuturesOption(conId=403301148, symbol='ES', lastTradeDateOrContractMonth='20200918', strike=3325.0, right='P', multiplier='50', primaryExchange='GLOBEX', currency='USD', localSymbol='ESU0 P3325', tradingClass='ES'), position=0.0, marketPrice=16.74040415, marketValue=0.0, averageCost=0.0, unrealizedPNL=0.0, realizedPNL=-719.86, account='XX1234567') # ---updatePortfolioEvent # PortfolioItem(contract=FuturesOption(conId=413134723, symbol='ES', lastTradeDateOrContractMonth='20200918', strike=3675.0, right='C', multiplier='50', primaryExchange='GLOBEX', currency='USD', localSymbol='ESU0 C3675', tradingClass='ES'), position=0.0, marketPrice=5.74838065, marketValue=0.0, averageCost=0.0, unrealizedPNL=0.0, realizedPNL=-53.12, account='XX1234567') # ---updatePortfolioEvent # PortfolioItem(contract=FuturesOption(conId=416995692, symbol='ES', lastTradeDateOrContractMonth='20200918', strike=2920.0, right='P', multiplier='50', primaryExchange='GLOBEX', currency='USD', localSymbol='ESU0 P2920', tradingClass='ES'), position=0.0, marketPrice=3.42003535, marketValue=0.0, averageCost=0.0, unrealizedPNL=0.0, realizedPNL=-10.34, account='XX1234567') # ---updatePortfolioEvent # PortfolioItem(contract=FuturesOption(conId=419601319, symbol='ZN', lastTradeDateOrContractMonth='20200925', strike=146.5, right='C', multiplier='1000', primaryExchange='ECBOT', currency='USD', localSymbol='C OZN OCT 20 14650', tradingClass='OZN'), position=1.0, marketPrice=0.00624855, marketValue=6.25, averageCost=17.12, unrealizedPNL=-10.87, realizedPNL=0.0, account='XX1234567') # ---updatePortfolioEvent # PortfolioItem(contract=FuturesOption(conId=419602099, symbol='ZN', lastTradeDateOrContractMonth='20200925', strike=132.0, right='P', multiplier='1000', primaryExchange='ECBOT', currency='USD', localSymbol='P OZN OCT 20 13200', tradingClass='OZN'), position=1.0, marketPrice=0.0010283, marketValue=1.03, averageCost=17.12, unrealizedPNL=-16.09, realizedPNL=0.0, account='XX1234567') # ---updatePortfolioEvent # PortfolioItem(contract=FuturesOption(conId=419608326, symbol='ZB', lastTradeDateOrContractMonth='20200925', strike=184.0, right='C', multiplier='1000', primaryExchange='ECBOT', currency='USD', localSymbol='C OZB OCT 20 18400', tradingClass='OZB'), position=-1.0, marketPrice=0.0625, marketValue=-62.5, averageCost=45.185, unrealizedPNL=-17.31, realizedPNL=-198.92, account='XX1234567') # ---updatePortfolioEvent # PortfolioItem(contract=FuturesOption(conId=419608659, symbol='ZB', lastTradeDateOrContractMonth='20200925', strike=166.0, right='P', multiplier='1000', primaryExchange='ECBOT', currency='USD', localSymbol='P OZB OCT 20 16600', tradingClass='OZB'), position=-1.0, marketPrice=0.05939585, marketValue=-59.4, averageCost=29.56, unrealizedPNL=-29.84, realizedPNL=-198.91, account='XX1234567') # ---updatePortfolioEvent # PortfolioItem(contract=FuturesOption(conId=424630606, symbol='ES', lastTradeDateOrContractMonth='20200918', strike=3320.0, right='P', multiplier='50', primaryExchange='GLOBEX', currency='USD', localSymbol='ESU0 P3320', tradingClass='ES'), position=0.0, marketPrice=16.3442383, marketValue=0.0, averageCost=0.0, unrealizedPNL=0.0, realizedPNL=41.88, account='XX1234567') # ---updatePortfolioEvent # PortfolioItem(contract=FuturesOption(conId=424630618, symbol='ES', lastTradeDateOrContractMonth='20200918', strike=3330.0, right='P', multiplier='50', primaryExchange='GLOBEX', currency='USD', localSymbol='ESU0 P3330', tradingClass='ES'), position=-1.0, marketPrice=17.1953392, marketValue=-859.77, averageCost=911.08, unrealizedPNL=51.31, realizedPNL=-55.68, account='XX1234567') # ---updatePortfolioEvent # PortfolioItem(contract=FuturesOption(conId=438225644, symbol='NQ', lastTradeDateOrContractMonth='20200918', strike=12130.0, right='C', multiplier='20', primaryExchange='GLOBEX', currency='USD', localSymbol='NQU0 C1213', tradingClass='NQ'), position=-3.0, marketPrice=351.2839966, marketValue=-21077.04, averageCost=6843.58, unrealizedPNL=-546.3, realizedPNL=-3152.72, account='XX1234567') # ---updatePortfolioEvent # PortfolioItem(contract=FuturesOption(conId=438225673, symbol='NQ', lastTradeDateOrContractMonth='20200918', strike=12040.0, right='P', multiplier='20', primaryExchange='GLOBEX', currency='USD', localSymbol='NQU0 P1204', tradingClass='NQ'), position=-3.0, marketPrice=220.4954834, marketValue=-13229.73, averageCost=4400.24666665, unrealizedPNL=-28.99, realizedPNL=457.28, account='XX1234567') # ---updatePortfolioEvent # PortfolioItem(contract=FuturesOption(conId=439266509, symbol='ES', lastTradeDateOrContractMonth='20200918', strike=3680.0, right='C', multiplier='50', primaryExchange='GLOBEX', currency='USD', localSymbol='ESU0 C3680', tradingClass='ES'), position=0.0, marketPrice=5.3255081, marketValue=0.0, averageCost=0.0, unrealizedPNL=0.0, realizedPNL=-437.36, account='XX1234567') # ---updatePortfolioEvent # PortfolioItem(contract=FuturesOption(conId=439752315, symbol='ES', lastTradeDateOrContractMonth='20200918', strike=3690.0, right='C', multiplier='50', primaryExchange='GLOBEX', currency='USD', localSymbol='ESU0 C3690', tradingClass='ES'), position=-1.0, marketPrice=4.5999999, marketValue=-230.0, averageCost=206.08, unrealizedPNL=-23.92, realizedPNL=-38.52, account='XX1234567') # ---updatePortfolioEvent # PortfolioItem(contract=FuturesOption(conId=441829763, symbol='ZB', lastTradeDateOrContractMonth='20200925', strike=166.5, right='P', multiplier='1000', primaryExchange='ECBOT', currency='USD', localSymbol='P OZB OCT 20 16650', tradingClass='OZB'), position=0.0, marketPrice=0.06334625, marketValue=0.0, averageCost=0.0, unrealizedPNL=0.0, realizedPNL=-34.63, account='XX1234567') # ---updatePortfolioEvent # PortfolioItem(contract=FuturesOption(conId=441829766, symbol='ZB', lastTradeDateOrContractMonth='20200925', strike=184.5, right='C', multiplier='1000', primaryExchange='ECBOT', currency='USD', localSymbol='C OZB OCT 20 18450', tradingClass='OZB'), position=0.0, marketPrice=0.0448628, marketValue=0.0, averageCost=0.0, unrealizedPNL=0.0, realizedPNL=-34.63, account='XX1234567')
コメント