testmeout Posted June 7, 2007 Share Posted June 7, 2007 I am sure it is probably just user error, but I can't get my script to work, I am trying to call functions from opentick.com's dll.I don't know much of anything about C++, they talk about classes, modules, etc, so I am not sure if my code is correct but it doesn't error out except on the return array.;addHost("feed1.opentick.com", 10010); ;void addHost ( char * hostName, int portNum ) ;void login ( char * username, char * password ) ;int getStatus ( ) ;Status Values ;Constant name Description Value ;OT_STATUS_INACTIVE The client is inactive. 1 ;OT_STATUS_CONNECTING The client is trying to connect. 2 ;OT_STATUS_CONNECTED The client is connected, but not logged in. 3 ;OT_STATUS_LOGGED_IN The client is connected and logged in. 4 Dim $status sleep(1000) $dll = DllOpen("otfeed_net.dll") If $dll = -1 Then MsgBox(0,"","Error - dll failed to open.") Exit EndIf $addhost = DllCall($dll,"none","addHost","str","feed1.opentick.com","int",10010) sleep(200) msgbox(0, "Error", @error) $login = DllCall($dll,"none", "login", "str", "fakeusername", "str", "fakepassword") sleep(200) msgbox(0, "Error", @error) $status = DllCall($dll,"int", "getStatus") sleep(200) msgbox(0, "Error", @error) sleep(200) msgbox(0, "Status", $status[0])Here is part of the dll, don't know if it helps or nottypedef struct { int reqId; OTDataEntity *data; } RequestsVectorElement_t; using namespace std; /** This is the main OTFeed class. */ class DLL_EXP OTClient { public: /** Default constructor. */ OTClient (); /** * Returns an integer value which indicates the current status of the OTClient object. * * @return Integer value which indicates the current status of the OTClient object. */ int getStatus();None of the @errors return an error everything is good untilmsgbox(0, "Status", $status^ ERROR==> Subscript used with non-Array variableIf anyone could shed some light on this I would greatly appreciate it.If you are interested in openticks class reference it can be found herehttp://www.opentick.com/docs/OTFeed_Cpp/index.html Link to comment Share on other sites More sharing options...
testmeout Posted June 7, 2007 Author Share Posted June 7, 2007 Opentick makes different dll versions, or I am able to compile it myself, so maybe I have not done somthing related to the dll. I have tried several different ones. They also have some install guides for the different precompiled dlls. But I have some questions ******************* *** C++ Builder *** ******************* (BCB) __WIN32 must be defined. Also define either DLL_IMPORT to use OTFeed_bcb.lib + OTFeed_bcb.dll or DLL_NONE to use static link with OTFeed_bcb_static.lib. ************** *** C#.NET *** ************** (C#.NET/Usefeed - native .NET dll) Just add OTFeed_NET to references. ****************** *** COM object *** ****************** (Delphi, C#.NET/Sample, VB.NET) COTFeed.dll To use COM object in your applications you must register it. ********************* *** Visual Studio *** ********************* (VC/Sample) __WIN32 must be defined. Also define either DLL_IMPORT to use OTFeed_vc.lib + OTFeed_vc.dll or DLL_NONE to use static link with OTFeed_vc_static.lib. OTFeed_vc-files were built with option /MD specified (multithreaded dll). Does anyone have any recommendations on which dll to use? Does it matter that the _WIN32 must be defined? on VC? Link to comment Share on other sites More sharing options...
Zedna Posted June 7, 2007 Share Posted June 7, 2007 (edited) After your DllCall() run _GetLastErrorMessage()Look here Edited June 7, 2007 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
testmeout Posted June 7, 2007 Author Share Posted June 7, 2007 After your DllCall() run _GetLastErrorMessage()Look hereThanks Zedna for the reply and I like your function but unfortunetly it didn't uncover my problem.Your function returns:The operation completed successfully.On all of the dll callsAny other ideas? Link to comment Share on other sites More sharing options...
testmeout Posted June 7, 2007 Author Share Posted June 7, 2007 Here is a sample program they have. Would the best way to access these function be dllcalls or should I look into COM ObjCreate? expandcollapse popupImports otfeed_net Imports System Module OTFeed_Sample Dim WithEvents client As OTClient = New OTClient() Dim user As String = "" Dim pwd As String = "" <MTAThread()> _ Sub Main() Console.WriteLine("Client started") Console.WriteLine("Add hosts") client.addHost("feed1.opentick.com", 10015) ' Delayed data client.addHost("feed1.opentick.com", 10010) ' Real-time data client.addHost("feed2.opentick.com", 10010) ' Real-time data While user = "" System.Console.Write("Please, enter your login: ") user = System.Console.ReadLine() End While System.Console.Write("Please, enter your password: ") pwd = System.Console.ReadLine() client.login(user, pwd) Console.ReadKey() client.logout() Console.WriteLine("Press any button to quit") Console.ReadKey() End Sub Private Sub client_onLogin() Handles client.onLogin Console.WriteLine("You were logged in at " + DateTime.Now.TimeOfDay.ToString) client.Status() client.requestTickStream(New OTDataEntity("@", "QQQQ")) 'client.requestTickStream(New OTDataEntity("Q", "VRSN"), OTTickType.Trade) 'client.requestTickStream(New OTDataEntity("EM", "/ESU6"), OTTickType.Quote) 'client.requestTodaysOHL(New OTDataEntity("Q", "GOOG")) 'client.requestOptionChain(New OTDataEntity("AO", "MSFT"), 2007, 1) 'client.requestEquityInit(New OTDataEntity("Q", "AAPL")) 'client.requestDividends(New OTDataEntity("Q", "MSFT"), New DateTime(2006, 5, 1), New DateTime(2006, 7, 10)) 'client.requestDividends(New OTDataEntity("N", "MKH"), New DateTime(2000, 5, 1), New DateTime(2006, 7, 10)) 'client.requestSplits(New OTDataEntity("V", "RCCCO"), New DateTime(2000, 1, 1), New DateTime(2006, 1, 1)) 'client.requestHistData(New OTDataEntity("Q", "INTC"), New DateTime(2006, 5, 1), New DateTime(2006, 5, 14), OTHistoricalType.OhlcDaily, 1) 'client.requestHistTicks(New OTDataEntity("Q", "YHOO"), New DateTime(2006, 5, 5, 15, 0, 0), New DateTime(2006, 5, 5, 15, 5, 0), OTTickType.All) 'client.requestListExchanges() 'client.requestListSymbols("P") 'client.requestBookStream(New OTDataEntity("is", "YHOO")) End Sub Private Sub client_onerror(ByVal [error] As OTFeed_NET.OTError) Handles client.onerror Console.WriteLine("Error: reqId=" + [error].RequestId.ToString _ + " type=" + [error].Type.ToString _ + " code=" + [error].Code.ToString _ + " description=" + [error].Description _ + " now is " + DateTime.Now.TimeOfDay.ToString) End Sub Private Sub client_onMessage(ByVal message As OTFeed_NET.OTMessage) Handles client.onMessage Console.WriteLine("Message: reqId=" + message.RequestId.ToString _ + " code=" + message.Code.ToString _ + " description=" + message.Description _ + " now is " + DateTime.Now.TimeOfDay.ToString) End Sub Private Sub client_onRealtimeBBO(ByVal bbo As OTFeed_NET.OTBBO) Handles client.onRealtimeBBO, client.onHistoricalBBO Console.WriteLine("Trade: reqId=" + bbo.RequestId.ToString _ + " exchTime=" + bbo.ExchangeTime.TimeOfDay.ToString _ + " price=" + bbo.Price.ToString _ + " size=" + bbo.Size.ToString _ + " side=" + bbo.Side _ + " exchange=" + bbo.Exchange.ToString _ + " now is " + DateTime.Now.TimeOfDay.ToString) End Sub Private Sub client_onRealtimeMMQuote(ByVal mmQuote As OTFeed_NET.OTMMQuote) Handles client.onRealtimeMMQuote, client.onHistoricalMMQuote Console.Write("mmQuote: reqId=" + mmQuote.RequestId.ToString _ + " exchTime=" + mmQuote.ExchangeTime.TimeOfDay.ToString _ + " askPrice=" + mmQuote.AskPrice.ToString _ + " askSize=" + mmQuote.AskSize.ToString _ + " bidPrice=" + mmQuote.BidPrice.ToString _ + " bidSize=" + mmQuote.BidSize.ToString _ + " MMID=" + mmQuote.MMID _ + " Ind=" + mmQuote.Indicator _ + " exchange=" + mmQuote.Exchange.ToString _ + " now is " + DateTime.Now.TimeOfDay.ToString) If (mmQuote.SymbolCode <> Nothing) Then Console.WriteLine(" symcode=" + mmQuote.SymbolCode) Else Console.WriteLine() End If End Sub Private Sub client_onRealtimeQuote(ByVal quote As OTFeed_NET.OTQuote) Handles client.onRealtimeQuote, client.onHistoricalQuote Console.WriteLine("Quote: reqId=" + quote.RequestId.ToString _ + " exchTime=" + quote.ExchangeTime.TimeOfDay.ToString _ + " askPrice=" + quote.AskPrice.ToString _ + " askSize=" + quote.AskSize.ToString _ + " askExchange=" + quote.AskExchange.ToString _ + " bidPrice=" + quote.BidPrice.ToString _ + " bidSize=" + quote.BidSize.ToString _ + " bidExchange=" + quote.BidExchange.ToString _ + " Ind=" + quote.Indicator _ + " TInd=" + quote.TickIndicator _ + " exchange=" + quote.Exchange.ToString _ + " now is " + DateTime.Now.TimeOfDay.ToString) End Sub Private Sub client_onRealtimeTrade(ByVal trade As OTFeed_NET.OTTrade) Handles client.onRealtimeTrade, client.onHistoricalTrade Dim flags As String = "" If trade.isUpdateLast Then flags += "U" Else flags += "." If trade.isOpen Then flags += "O" Else flags += "." If trade.isHigh Then flags += "H" Else flags += "." If trade.isLow Then flags += "L" Else flags += "." If trade.isClose Then flags += "C" Else flags += "." Console.WriteLine("Trade: reqId=" + trade.RequestId.ToString _ + " exchTime=" + trade.ExchangeTime.TimeOfDay.ToString _ + " size=" + trade.Size.ToString _ + " price=" + trade.Price.ToString _ + " volume=" + trade.Volume.ToString _ + " flags=" + flags _ + " exchange=" + trade.Exchange.ToString _ + " now is " + DateTime.Now.TimeOfDay.ToString) End Sub Private Sub client_onRestoreConnection() Handles client.onRestoreConnection Console.WriteLine("Connection was restored") End Sub Private Sub client_onStatusChanged(ByVal status As Integer) Handles client.onStatusChanged Console.WriteLine("New status is " + status.ToString) End Sub Private Sub client_onSplit(ByVal split As OTFeed_NET.OTSplit) Handles client.onSplit Console.WriteLine("Split: reqId=" + split.RequestId.ToString _ + " declarationDate=" + split.DeclarationDate.ToString _ + " executionDate=" + split.ExecutionDate _ + " paymentDate=" + split.PaymentDate _ + " recordDate=" + split.RecordDate _ + " forFactor=" + split.ForFactor.ToString _ + " toFactor=" + split.ToFactor.ToString _ ) End Sub Private Sub client_onDividend(ByVal dividend As OTFeed_NET.OTDividend) Handles client.onDividend Console.WriteLine("Dividend: reqId=" + dividend.RequestId.ToString _ + " declarationDate=" + dividend.DeclarationDate.ToString _ + " executionDate=" + dividend.ExecutionDate.ToString _ + " flag1=" + dividend.Flags1.ToString _ + " flag2=" + dividend.Flags2.ToString _ + " paymentDate=" + dividend.PaymentDate.ToString _ + " recordDate=" + dividend.RecordDate.ToString _ + " price=" + dividend.Price.ToString _ + " isAnnual=" + dividend.isAnnual.ToString _ + " isApproximate=" + dividend.isApproximate.ToString _ + " isCanadian=" + dividend.isCanadian.ToString _ + " isExtra=" + dividend.isExtra.ToString _ + " isFinal=" + dividend.isFinal.ToString _ + " isIncrease=" + dividend.isIncrease.ToString _ + " isSemiannual=" + dividend.isSemiannual.ToString _ + " isSpecial=" + dividend.isSpecial.ToString _ + " isStock=" + dividend.isStock.ToString _ ) End Sub Private Sub client_onEquityInit(ByVal equityInit As OTFeed_NET.OTEquityInit) Handles client.onEquityInit Console.WriteLine("EquityInit: reqId=" + equityInit.RequestId.ToString _ + " cname=" + equityInit.CompanyName.ToString _ + " prevDate=" + equityInit.PrevCloseDate _ + " prevPrice=" + equityInit.PrevClosePrice.ToString _ + " annualHD=" + equityInit.AnnualHighDate _ + " annualHP=" + equityInit.AnnualHighPrice.ToString _ + " annualLD=" + equityInit.AnnualLowDate _ + " annualLP=" + equityInit.AnnualLowPrice.ToString _ + " EarningsDate=" + equityInit.EarningsDate _ + " EarningsPrice=" + equityInit.EarningsPrice.ToString _ + " AverageVolume=" + equityInit.AverageVolume.ToString _ + " TotalShares=" + equityInit.TotalShares.ToString _ + " InstrumentType=" + equityInit.InstrumentType.ToString _ + " ISIN=" + equityInit.ISIN.ToString _ + " CUSIP=" + equityInit.CUSIP.ToString _ + " IsSmallCap=" + equityInit.IsSmallCap.ToString _ + " IsUPC11830=" + equityInit.IsUPC11830.ToString _ + " IsTestlssue=" + equityInit.IsTestlssue.ToString) End Sub Private Sub client_onTodaysOHL(ByVal requestId As Integer, ByVal openPrice As Double, ByVal highPrice As Double, ByVal lowPrice As Double) Handles client.onTodaysOHL Console.WriteLine("TodaysOHL: reqId=" + requestId.ToString _ + " open=" + openPrice.ToString _ + " high=" + highPrice.ToString _ + " low =" + lowPrice.ToString) End Sub Private Sub client_onHistoricalOHLC(ByVal ohlc As OTFeed_NET.OTOHLC) Handles client.onHistoricalOHLC Console.WriteLine("OHLC: reqId=" + ohlc.RequestId.ToString _ + " time=" + ohlc.Timestamp.ToString _ + " open=" + ohlc.OpenPrice.ToString _ + " high=" + ohlc.HighPrice.ToString _ + " low=" + ohlc.LowPrice.ToString _ + " close=" + ohlc.ClosePrice.ToString _ + " volume=" + ohlc.Volume.ToString _ ) End Sub Private Sub client_onListExchanges(ByVal exchanges() As OTFeed_NET.OTExchange) Handles client.onListExchanges Dim i As Integer = 0 For i = 0 To exchanges.Length - 1 Dim exchange As OTExchange = exchanges(i) Console.WriteLine("listExchanges: reqId=" + exchange.RequestId.ToString _ + " isAvailable=" + exchange.Available.ToString _ + " title=" + exchange.Title _ + " code=" + exchange.Code.ToString _ + " description=" + exchange.Description _ + " url=" + exchange.SubscriptionURL _ ) Next End Sub Private Sub client_onListSymbols(ByVal symbols() As OTFeed_NET.OTSymbol) Handles client.onListSymbols Dim i As Integer = 0 For i = 0 To symbols.Length - 1 Dim symbol As OTSymbol = symbols(i) Console.WriteLine("listSymbols: reqId=" + symbol.RequestId.ToString _ + " code=" + symbol.Code.ToString _ + " company=" + symbol.Company _ + " currency=" + symbol.Currency _ + " type=" + symbol.Type.ToString _ ) Next End Sub Private Sub client_onBookCancel(ByVal bookCancel As OTFeed_NET.OTBookCancel) Handles client.onBookCancel Console.WriteLine("bookCancel: reqId=" + bookCancel.RequestId.ToString _ + " orderRef=" + bookCancel.OrderRef _ + " size=" + bookCancel.Size.ToString _ + " time=" + bookCancel.Timestamp.ToString _ ) End Sub Private Sub client_onBookChange(ByVal bookChange As OTFeed_NET.OTBookChange) Handles client.onBookChange Console.WriteLine("bookChange: reqId=" + bookChange.RequestId.ToString _ + " orderRef" + bookChange.OrderRef _ + " price=" + bookChange.Price.ToString _ + " size=" + bookChange.Size.ToString _ + " time=" + bookChange.Timestamp.ToString _ ) End Sub Private Sub client_onBookExecute(ByVal bookExecute As OTFeed_NET.OTBookExecute) Handles client.onBookExecute Console.WriteLine("bookExecute: reqId=" + bookExecute.RequestId.ToString _ + " matchNumber=" + bookExecute.MatchNumber.ToString _ + " orderRef=" + bookExecute.OrderRef _ + " size=" + bookExecute.Size.ToString _ + " time=" + bookExecute.Timestamp.ToString _ ) End Sub Private Sub client_onBookPriceLevel(ByVal bookPriceLevel As OTFeed_NET.OTBookPriceLevel) Handles client.onBookPriceLevel Console.WriteLine("bookPriceLevel: reqId=" + bookPriceLevel.RequestId.ToString _ + " levelId=" + bookPriceLevel.LevelId.ToString _ + " price=" + bookPriceLevel.Price.ToString _ + " side=" + bookPriceLevel.Side.ToString _ + " size=" + bookPriceLevel.Size.ToString _ + " time=" + bookPriceLevel.Timestamp.ToString _ ) End Sub Private Sub client_onBookOrder(ByVal bookOrder As OTFeed_NET.OTBookOrder) Handles client.onBookOrder Console.WriteLine("bookOrder: reqId=" + bookOrder.RequestId.ToString _ + " display=" + bookOrder.Display.ToString _ + " orderRef=" + bookOrder.OrderRef _ + " price=" + bookOrder.Price.ToString _ + " side=" + bookOrder.Side.ToString _ + " size=" + bookOrder.Size.ToString _ + " time=" + bookOrder.Timestamp.ToString _ ) End Sub Private Sub client_onBookPurge(ByVal bookPurge As OTFeed_NET.OTBookPurge) Handles client.onBookPurge Console.WriteLine("bookPurge: reqId=" + bookPurge.RequestId.ToString _ + " exchangeNameRoot=" + bookPurge.ExchangeNameRoot _ + " time=" + bookPurge.Timestamp.ToString _ ) End Sub Private Sub client_onBookReplace(ByVal bookReplace As OTFeed_NET.OTBookReplace) Handles client.onBookReplace Console.WriteLine("bookReplace: reqId=" + bookReplace.RequestId.ToString _ + " orderRef=" + bookReplace.OrderRef _ + " price=" + bookReplace.Price.ToString _ + " side=" + bookReplace.Side.ToString _ + " size=" + bookReplace.Size.ToString _ + " timestamp=" + bookReplace.Timestamp.ToString _ ) End Sub Private Sub client_onBookDelete(ByVal bookDelete As OTFeed_NET.OTBookDelete) Handles client.onBookDelete Console.WriteLine("bookDelete: reqId=" + bookDelete.RequestId.ToString _ + " deleteType=" + bookDelete.DeleteType.ToString _ + " orderRef=" + bookDelete.OrderRef _ + " side=" + bookDelete.Side.ToString _ + " time=" + bookDelete.Timestamp.ToString _ ) End Sub End Module Link to comment Share on other sites More sharing options...
Zedna Posted June 7, 2007 Share Posted June 7, 2007 Here is a sample program they have.Would the best way to access these function be dllcalls or should I look into COM ObjCreate?It looks like COM code. Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
testmeout Posted June 7, 2007 Author Share Posted June 7, 2007 It looks like COM code. This is their VB sample, they have lots of other samples. I have moved on from using dllcall to trying to use COM, I installed the dll using regsvr32 COTFeed.dll. This is what I have so far but this doesn't work either. $obj = ObjCreate("COTFeedLib.COTClient");create the object $ret = $obj.addHost("feed1.opentick.com", 10010) msgbox (0,"From Call",$ret) I get the error message: Variable must be of type "Object".: Any ideas? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now