Skip to content

Instantly share code, notes, and snippets.

@jjttjj
Created March 27, 2019 19:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jjttjj/95ff42fedd49893d51a4333da3abe436 to your computer and use it in GitHub Desktop.
Save jjttjj/95ff42fedd49893d51a4333da3abe436 to your computer and use it in GitHub Desktop.
(defn wrapper
[cb]
(reify
com.ib.client.EWrapper
(^void tickOptionComputation [this ^int tickerId ^int field ^double
impliedVol ^double delta ^double optPrice
^double pvDividend ^double gamma ^double
vega ^double theta ^double undPrice]
(cb {:field field,
:type :tickOptionComputation,
:theta theta,
:delta delta,
:tickerId tickerId,
:gamma gamma,
:vega vega,
:impliedVol impliedVol,
:pvDividend pvDividend,
:optPrice optPrice,
:undPrice undPrice}))
(^void tickGeneric [this ^int tickerId ^int tickType ^double value]
(cb {:tickType tickType,
:value value,
:type :tickGeneric,
:tickerId tickerId}))
(^void tickString [this ^int tickerId ^int tickType ^java.lang.String
value]
(cb {:tickType tickType,
:value value,
:type :tickString,
:tickerId tickerId}))
(^void tickEFP [this ^int tickerId ^int tickType ^double basisPoints
^java.lang.String formattedBasisPoints ^double
impliedFuture ^int holdDays ^java.lang.String
futureLastTradeDate ^double dividendImpact ^double
dividendsToLastTradeDate]
(cb {:tickType tickType,
:holdDays holdDays,
:type :tickEFP,
:impliedFuture impliedFuture,
:futureLastTradeDate futureLastTradeDate,
:formattedBasisPoints formattedBasisPoints,
:dividendImpact dividendImpact,
:tickerId tickerId,
:basisPoints basisPoints,
:dividendsToLastTradeDate dividendsToLastTradeDate}))
(^void orderStatus [this ^int orderId ^java.lang.String status ^double
filled ^double remaining ^double avgFillPrice ^int
permId ^int parentId ^double lastFillPrice ^int
clientId ^java.lang.String whyHeld ^double
mktCapPrice]
(cb {:avgFillPrice avgFillPrice,
:clientId clientId,
:mktCapPrice mktCapPrice,
:remaining remaining,
:type :orderStatus,
:whyHeld whyHeld,
:status status,
:lastFillPrice lastFillPrice,
:parentId parentId,
:filled filled,
:permId permId,
:orderId orderId}))
(^void tickPrice [this ^int tickerId ^int field ^double price
^com.ib.client.TickAttrib attrib]
(cb {:attrib attrib,
:field field,
:type :tickPrice,
:tickerId tickerId,
:price price}))
(^void tickSize [this ^int tickerId ^int field ^int size]
(cb {:field field, :type :tickSize, :size size, :tickerId tickerId}))
(^void openOrder [this ^int orderId ^com.ib.client.Contract contract
^com.ib.client.Order order ^com.ib.client.OrderState
orderState]
(cb {:contract contract,
:type :openOrder,
:order order,
:orderState orderState,
:orderId orderId}))
(^void openOrderEnd [this] (cb {:type :openOrderEnd}))
(^void updateAccountValue [this ^java.lang.String key ^java.lang.String
value ^java.lang.String currency
^java.lang.String accountName]
(cb {:key key,
:value value,
:accountName accountName,
:type :updateAccountValue,
:currency currency}))
(^void updatePortfolio [this ^com.ib.client.Contract contract ^double
position ^double marketPrice ^double marketValue
^double averageCost ^double unrealizedPNL ^double
realizedPNL ^java.lang.String accountName]
(cb {:unrealizedPNL unrealizedPNL,
:averageCost averageCost,
:contract contract,
:marketPrice marketPrice,
:accountName accountName,
:type :updatePortfolio,
:marketValue marketValue,
:position position,
:realizedPNL realizedPNL}))
(^void updateAccountTime [this ^java.lang.String timeStamp]
(cb {:type :updateAccountTime, :timeStamp timeStamp}))
(^void accountDownloadEnd [this ^java.lang.String accountName]
(cb {:accountName accountName, :type :accountDownloadEnd}))
(^void nextValidId [this ^int orderId]
(cb {:type :nextValidId, :orderId orderId}))
(^void contractDetails [this ^int reqId ^com.ib.client.ContractDetails
contractDetails]
(cb {:type :contractDetails,
:contractDetails contractDetails,
:reqId reqId}))
(^void bondContractDetails [this ^int reqId ^com.ib.client.ContractDetails
contractDetails]
(cb {:type :bondContractDetails,
:contractDetails contractDetails,
:reqId reqId}))
(^void contractDetailsEnd [this ^int reqId]
(cb {:type :contractDetailsEnd, :reqId reqId}))
(^void execDetails [this ^int reqId ^com.ib.client.Contract contract
^com.ib.client.Execution execution]
(cb {:execution execution,
:contract contract,
:type :execDetails,
:reqId reqId}))
(^void execDetailsEnd [this ^int reqId]
(cb {:type :execDetailsEnd, :reqId reqId}))
(^void updateMktDepth [this ^int tickerId ^int position ^int operation
^int side ^double price ^int size]
(cb {:operation operation,
:type :updateMktDepth,
:size size,
:tickerId tickerId,
:side side,
:position position,
:price price}))
(^void updateMktDepthL2 [this ^int tickerId ^int position
^java.lang.String marketMaker ^int operation ^int
side ^double price ^int size ^boolean
isSmartDepth]
(cb {:marketMaker marketMaker,
:isSmartDepth isSmartDepth,
:operation operation,
:type :updateMktDepthL2,
:size size,
:tickerId tickerId,
:side side,
:position position,
:price price}))
(^void updateNewsBulletin [this ^int msgId ^int msgType ^java.lang.String
message ^java.lang.String origExchange]
(cb {:origExchange origExchange,
:msgType msgType,
:type :updateNewsBulletin,
:msgId msgId,
:message message}))
(^void managedAccounts [this ^java.lang.String accountsList]
(cb {:accountsList accountsList, :type :managedAccounts}))
(^void receiveFA [this ^int faDataType ^java.lang.String xml]
(cb {:faDataType faDataType, :type :receiveFA, :xml xml}))
(^void historicalData [this ^int reqId ^com.ib.client.Bar bar]
(cb {:bar bar, :type :historicalData, :reqId reqId}))
(^void scannerParameters [this ^java.lang.String xml]
(cb {:type :scannerParameters, :xml xml}))
(^void scannerData [this ^int reqId ^int rank
^com.ib.client.ContractDetails contractDetails
^java.lang.String distance ^java.lang.String benchmark
^java.lang.String projection ^java.lang.String
legsStr]
(cb {:rank rank,
:type :scannerData,
:benchmark benchmark,
:legsStr legsStr,
:distance distance,
:contractDetails contractDetails,
:projection projection,
:reqId reqId}))
(^void scannerDataEnd [this ^int reqId]
(cb {:type :scannerDataEnd, :reqId reqId}))
(^void realtimeBar [this ^int reqId ^long time ^double open ^double high
^double low ^double close ^long volume ^double wap
^int count]
(cb {:open open,
:time time,
:type :realtimeBar,
:close close,
:volume volume,
:high high,
:wap wap,
:count count,
:low low,
:reqId reqId}))
(^void currentTime [this ^long time]
(cb {:time time, :type :currentTime}))
(^void fundamentalData [this ^int reqId ^java.lang.String data]
(cb {:type :fundamentalData, :reqId reqId, :data data}))
(^void deltaNeutralValidation [this ^int reqId
^com.ib.client.DeltaNeutralContract
deltaNeutralContract]
(cb {:type :deltaNeutralValidation,
:deltaNeutralContract deltaNeutralContract,
:reqId reqId}))
(^void tickSnapshotEnd [this ^int reqId]
(cb {:type :tickSnapshotEnd, :reqId reqId}))
(^void commissionReport [this ^com.ib.client.CommissionReport
commissionReport]
(cb {:commissionReport commissionReport, :type :commissionReport}))
(^void positionEnd [this] (cb {:type :positionEnd}))
(^void accountSummary [this ^int reqId ^java.lang.String account
^java.lang.String tag ^java.lang.String value
^java.lang.String currency]
(cb {:value value,
:type :accountSummary,
:account account,
:currency currency,
:tag tag,
:reqId reqId}))
(^void accountSummaryEnd [this ^int reqId]
(cb {:type :accountSummaryEnd, :reqId reqId}))
(^void verifyMessageAPI [this ^java.lang.String apiData]
(cb {:apiData apiData, :type :verifyMessageAPI}))
(^void verifyCompleted [this ^boolean isSuccessful ^java.lang.String
errorText]
(cb {:type :verifyCompleted,
:isSuccessful isSuccessful,
:errorText errorText}))
(^void marketDataType [this ^int reqId ^int marketDataType]
(cb {:marketDataType marketDataType,
:type :marketDataType,
:reqId reqId}))
(^void verifyAndAuthMessageAPI [this ^java.lang.String apiData
^java.lang.String xyzChallenge]
(cb {:apiData apiData,
:type :verifyAndAuthMessageAPI,
:xyzChallenge xyzChallenge}))
(^void verifyAndAuthCompleted [this ^boolean isSuccessful
^java.lang.String errorText]
(cb {:type :verifyAndAuthCompleted,
:isSuccessful isSuccessful,
:errorText errorText}))
(^void displayGroupList [this ^int reqId ^java.lang.String groups]
(cb {:type :displayGroupList, :groups groups, :reqId reqId}))
(^void displayGroupUpdated [this ^int reqId ^java.lang.String
contractInfo]
(cb {:type :displayGroupUpdated,
:reqId reqId,
:contractInfo contractInfo}))
(^void connectAck [this] (cb {:type :connectAck}))
(^void positionMulti [this ^int reqId ^java.lang.String account
^java.lang.String modelCode ^com.ib.client.Contract
contract ^double pos ^double avgCost]
(cb {:contract contract,
:pos pos,
:type :positionMulti,
:account account,
:modelCode modelCode,
:avgCost avgCost,
:reqId reqId}))
(^void positionMultiEnd [this ^int reqId]
(cb {:type :positionMultiEnd, :reqId reqId}))
(^void accountUpdateMulti [this ^int reqId ^java.lang.String account
^java.lang.String modelCode ^java.lang.String
key ^java.lang.String value ^java.lang.String
currency]
(cb {:key key,
:value value,
:type :accountUpdateMulti,
:account account,
:modelCode modelCode,
:currency currency,
:reqId reqId}))
(^void accountUpdateMultiEnd [this ^int reqId]
(cb {:type :accountUpdateMultiEnd, :reqId reqId}))
(^void securityDefinitionOptionalParameter
[this ^int reqId ^java.lang.String exchange ^int underlyingConId
^java.lang.String tradingClass ^java.lang.String multiplier
^java.util.Set expirations ^java.util.Set strikes]
(cb {:underlyingConId underlyingConId,
:expirations expirations,
:multiplier multiplier,
:tradingClass tradingClass,
:type :securityDefinitionOptionalParameter,
:exchange exchange,
:strikes strikes,
:reqId reqId}))
(^void securityDefinitionOptionalParameterEnd [this ^int reqId]
(cb {:type :securityDefinitionOptionalParameterEnd, :reqId reqId}))
(^void softDollarTiers [this ^int reqId ^"[Lcom.ib.client.SoftDollarTier;"
tiers]
(cb {:type :softDollarTiers, :tiers tiers, :reqId reqId}))
(^void familyCodes [this ^"[Lcom.ib.client.FamilyCode;" familyCodes]
(cb {:type :familyCodes, :familyCodes familyCodes}))
(^void symbolSamples [this ^int reqId
^"[Lcom.ib.client.ContractDescription;"
contractDescriptions]
(cb {:type :symbolSamples,
:contractDescriptions contractDescriptions,
:reqId reqId}))
(^void historicalDataEnd [this ^int reqId ^java.lang.String startDateStr
^java.lang.String endDateStr]
(cb {:type :historicalDataEnd,
:startDateStr startDateStr,
:endDateStr endDateStr,
:reqId reqId}))
(^void mktDepthExchanges [this ^"[Lcom.ib.client.DepthMktDataDescription;"
depthMktDataDescriptions]
(cb {:depthMktDataDescriptions depthMktDataDescriptions,
:type :mktDepthExchanges}))
(^void tickNews [this ^int tickerId ^long timeStamp ^java.lang.String
providerCode ^java.lang.String articleId
^java.lang.String headline ^java.lang.String extraData]
(cb {:headline headline,
:providerCode providerCode,
:articleId articleId,
:type :tickNews,
:timeStamp timeStamp,
:tickerId tickerId,
:extraData extraData}))
(^void smartComponents [this ^int reqId ^java.util.Map theMap]
(cb {:theMap theMap, :type :smartComponents, :reqId reqId}))
(^void tickReqParams [this ^int tickerId ^double minTick ^java.lang.String
bboExchange ^int snapshotPermissions]
(cb {:bboExchange bboExchange,
:type :tickReqParams,
:tickerId tickerId,
:snapshotPermissions snapshotPermissions,
:minTick minTick}))
(^void newsProviders [this ^"[Lcom.ib.client.NewsProvider;" newsProviders]
(cb {:type :newsProviders, :newsProviders newsProviders}))
(^void newsArticle [this ^int requestId ^int articleType ^java.lang.String
articleText]
(cb {:type :newsArticle,
:requestId requestId,
:articleText articleText,
:articleType articleType}))
(^void historicalNews [this ^int requestId ^java.lang.String time
^java.lang.String providerCode ^java.lang.String
articleId ^java.lang.String headline]
(cb {:headline headline,
:providerCode providerCode,
:articleId articleId,
:time time,
:type :historicalNews,
:requestId requestId}))
(^void historicalNewsEnd [this ^int requestId ^boolean hasMore]
(cb {:hasMore hasMore, :type :historicalNewsEnd, :requestId requestId}))
(^void headTimestamp [this ^int reqId ^java.lang.String headTimestamp]
(cb {:type :headTimestamp, :headTimestamp headTimestamp, :reqId reqId}))
(^void histogramData [this ^int reqId ^java.util.List items]
(cb {:type :histogramData, :items items, :reqId reqId}))
(^void historicalDataUpdate [this ^int reqId ^com.ib.client.Bar bar]
(cb {:bar bar, :type :historicalDataUpdate, :reqId reqId}))
(^void rerouteMktDataReq [this ^int reqId ^int conId ^java.lang.String
exchange]
(cb {:conId conId,
:type :rerouteMktDataReq,
:exchange exchange,
:reqId reqId}))
(^void rerouteMktDepthReq [this ^int reqId ^int conId ^java.lang.String
exchange]
(cb {:conId conId,
:type :rerouteMktDepthReq,
:exchange exchange,
:reqId reqId}))
(^void marketRule [this ^int marketRuleId
^"[Lcom.ib.client.PriceIncrement;" priceIncrements]
(cb {:priceIncrements priceIncrements,
:marketRuleId marketRuleId,
:type :marketRule}))
(^void pnl [this ^int reqId ^double dailyPnL ^double unrealizedPnL ^double
realizedPnL]
(cb {:dailyPnL dailyPnL,
:type :pnl,
:unrealizedPnL unrealizedPnL,
:realizedPnL realizedPnL,
:reqId reqId}))
(^void pnlSingle [this ^int reqId ^int pos ^double dailyPnL ^double
unrealizedPnL ^double realizedPnL ^double value]
(cb {:value value,
:dailyPnL dailyPnL,
:pos pos,
:type :pnlSingle,
:unrealizedPnL unrealizedPnL,
:realizedPnL realizedPnL,
:reqId reqId}))
(^void historicalTicks [this ^int reqId ^java.util.List ticks ^boolean
done]
(cb {:done done, :type :historicalTicks, :ticks ticks, :reqId reqId}))
(^void historicalTicksBidAsk [this ^int reqId ^java.util.List ticks
^boolean done]
(cb {:done done,
:type :historicalTicksBidAsk,
:ticks ticks,
:reqId reqId}))
(^void historicalTicksLast [this ^int reqId ^java.util.List ticks ^boolean
done]
(cb
{:done done, :type :historicalTicksLast, :ticks ticks, :reqId reqId}))
(^void tickByTickAllLast [this ^int reqId ^int tickType ^long time ^double
price ^int size ^com.ib.client.TickAttribLast
tickAttribLast ^java.lang.String exchange
^java.lang.String specialConditions]
(cb {:tickType tickType,
:specialConditions specialConditions,
:time time,
:type :tickByTickAllLast,
:size size,
:tickAttribLast tickAttribLast,
:exchange exchange,
:price price,
:reqId reqId}))
(^void tickByTickBidAsk [this ^int reqId ^long time ^double bidPrice
^double askPrice ^int bidSize ^int askSize
^com.ib.client.TickAttribBidAsk tickAttribBidAsk]
(cb {:bidSize bidSize,
:tickAttribBidAsk tickAttribBidAsk,
:time time,
:askSize askSize,
:type :tickByTickBidAsk,
:askPrice askPrice,
:bidPrice bidPrice,
:reqId reqId}))
(^void tickByTickMidPoint [this ^int reqId ^long time ^double midPoint]
(cb {:time time,
:type :tickByTickMidPoint,
:midPoint midPoint,
:reqId reqId}))
(^void orderBound [this ^long orderId ^int apiClientId ^int apiOrderId]
(cb {:apiOrderId apiOrderId,
:apiClientId apiClientId,
:type :orderBound,
:orderId orderId}))
(^void connectionClosed [this] (cb {:type :connectionClosed}))
(^void position [this ^java.lang.String account ^com.ib.client.Contract
contract ^double pos ^double avgCost]
(cb {:contract contract,
:pos pos,
:type :position,
:account account,
:avgCost avgCost}))
(^void error [this ^int id ^int errorCode ^java.lang.String errorMsg]
(cb {:errorCode errorCode, :type :error, :errorMsg errorMsg, :id id}))
(^void error [this ^java.lang.Exception e] (cb {:type :error, :e e}))
(^void error [this ^java.lang.String str] (cb {:type :error, :str str}))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment