#useDynLib(IBrokers)
importFrom(utils,
           flush.console,
           str,
           timestamp,
           write.table)
import(zoo, xts)

export(twsConnect,
       twsConnect2,             # experimental connection object
       ibgConnect,
       twsDisconnect,

       is.twsConnection,
       isConnected,

       twsConnectionTime,
       serverVersion,
       setServerLogLevel,
       reqCurrentTime,

      .reqIds,                  # send only
       reqIds,

       reqContractDetails,

      .reqAccountUpdates,       # send only
       reqAccountUpdates,
       cancelAccountUpdates,

       twsPortfolioValue,

       # Both Family and individual tested, implemented the EWrapper to make it work
       reqManagedAccts,

       # FA accounts only - untested as there is a missing EWrapper method here
       requestFA,
       replaceFA,
      
       reqMatchingSymbols,

       twsExecutionFilter,
       reqExecutions,

       reqScannerParameters,
       twsScannerSubscription,
       reqScannerSubscription,

       twsContract,
       is.twsContract,
       as.twsContract,

       twsBAG,
       twsComboLeg,

       twsCurrency,
       twsCASH,
       twsEquity,
       twsSTK,
       twsIndex,
       twsIND,
       twsCFD,
       twsFuture,
       twsFUT,
       twsFutureOpt,
       twsFOP,
       twsOption,
       twsOPT,

       reqHistoricalData,
       cancelHistoricalData,
       reqHistory,              # convenience wrapper

       reqMktData,
       reqMktDataType,
       cancelMktData,
      .calculateImpliedVolatility,
       calculateImpliedVolatility,
      .calculateOptionPrice,
       calculateOptionPrice,


       reqMktDepth,
       cancelMktDepth,

       reqRealTimeBars,
       cancelRealTimeBars,

       twsOrder,
      .placeOrder,              # send only
       placeOrder,
       cancelOrder,

      .reqOpenOrders,
       reqOpenOrders,
      .reqAllOpenOrders,
      .reqAutoOpenOrders,
       exerciseOptions,

       reqNewsBulletins,
       cancelNewsBulletins,

       twsCALLBACK,
       twsDEBUG,
       processMsg,

       eWrapper,

       eWrapper.data,
       eWrapper.RealTimeBars,

       eWrapper.RealTimeBars.CSV,
       eWrapper.MktData.CSV,
       eWrapper.MktDepth.CSV
      )

export(.twsIncomingMSG,
       .twsOutgoingMSG,
       .twsERR,
       .twsTickType,
       .twsOrderID
      )

export(IBrokersRef)

S3method(print,twsConnection)
S3method(print,twsconn)
S3method("[[", twsconn)
S3method(close,twsConnection)
S3method(close,twsconn)

S3method(print,twsContract)
S3method(as.twsContract, list)
S3method(as.twsContract, twsContract)
S3method(as.twsContract, twsContractDetails)
S3method(print,twsContractDetails)

S3method(print,twsScannerSubscription)
S3method(print,eventPortfolioValue)
S3method(print,eventAccountValue)

S3method(twsPortfolioValue, eWrapper)
S3method(twsPortfolioValue, AccountUpdate)

S3method(summary, AccountUpdate)

