[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Re: python, COM and AB



PureBytes Links

Trading Reference Links

Hi,

I can see now that the parameter types are different. The Markets item method takes an integer and the Stocks method takes a variant.

According to the win32com docs, http://oreilly.com/catalog/pythonwin32/chapter/ch12.html#24074, PythonWin will map python types to a variant automagically, so it should just work. Perhaps this is an issue with late binding, and that I should force it to use early binding?

Any ideas anyone?

Thanks
Peter.

--- In amibroker@xxxxxxxxxxxxxxx, "pwa72x" <peter.aberline@xxx> wrote:
>
> Hi,
> 
> I'm using Python and the PyWin32 extensions to allow COM iterop with AB.
> 
> I'm trying to call the Item method on a Stocks object, but I'm getting the error below.
> Confusingly, doing the same thing on the Markets object works fine. Can anyone suggest what is happening here?
> 
> Thanks
> Peter
> 
> ################################################
> import win32com.client
> 
> def doWork():
> 	ab = win32com.client.Dispatch("Broker.Application")
> 
> 	bLoadLSE = ab.LoadDatabase("E:\data\AmiBroker\Amibroker_databases\LSE");
> 	if bLoadLSE == False:
> 		print "Could not load the LSE database"
> 		return
> 
> 	nNumMarkets = ab.Markets.Count
> 	print "\nNumMarkets is %d " % nNumMarkets
> 	for nMarketIdx in range(nNumMarkets):
> 		currMarket = ab.Markets.Item(nMarketIdx)
> 		print currMarket.Name
> 		
> 	nNumStocks = ab.Stocks.Count;
> 	print "\nNumStocks is %d " % nNumStocks
> 	for nStockIdx in range(nNumStocks):
> 		print "StockIdx is %d" % nStockIdx
> 		currStock = ab.Stocks.Item(nStockIdx) # <---- fails here
> 		print currStock.Ticker
> 
> if __name__ == "__main__":
> 	doWork()
> 
> ################################################
> 
> Output:
> E:\data\python>python posting.py
> 
> NumStocks is 714
> StockIdx is 0
> Traceback (most recent call last):
>   File "posting.py", line 25, in <module>
>     doWork()
>   File "posting.py", line 21, in doWork
>     currStock = ab.Stocks.Item(nStockIdx) # <---- fails here
> TypeError: 'NoneType' object is not callable
>




------------------------------------

**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to 
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/