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

Re: [amibroker] Re: python, COM and AB



PureBytes Links

Trading Reference Links



Hello,
 
You may already seen that either below two ways the code will work:
 
1.  currStock = ab.Stocks.__getitem__( nStockIdx)   (# instead of using Item)
2.   loop without using the index variable
 
for stock in ab.Stocks:
  print stock.Ticker
 
The new question brought why the Item method has the power to render ab.Stocks sometimes null, or seems so:  (<== as revealed by the snake lanaguage's complaint about Nonetype object is not callable) ?
 
Regards,
SW 


From: pwa72x <peter.aberline@xxxxxxxxx>
To: amibroker@xxxxxxxxxxxxxxx
Sent: Friday, May 29, 2009 3:55:16 AM
Subject: [amibroker] Re: python, COM and AB


> You've done a search of the forum archives for Python, right?

Yes, unfortunately there doesn't seem to be anything about this. I've got a couple of other ideas to try:

* Early binding of Python.
* Passing a variant from Python to other non-Amibroker COM object.
* Passing a variant to one of the variable parameter methods in Amibroker.

Thanks,
Peter.

--- In amibroker@xxxxxxxxx ps.com, dingo <waledingo@x ..> wrote:
>
> You've done a search of the forum archives for Python, right?
>
> d
>
> On Wed, May 27, 2009 at 2:26 AM, pwa72x <peter.aberline@ ...> wrote:
>
> > 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@xxxxxxxxx ps.com, "pwa72x" <peter.aberline@ > 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.Applicat ion")
> > >
> > > 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
> >
> >
> >
> >
>




__._,_.___


**** 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/





Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___