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

Re: [amibroker] Re: IB Shortable Stocks



PureBytes Links

Trading Reference Links

Title: Re: [amibroker] Re: IB Shortable Stocks

Thank you for the feedback,


Yes... I looked at it and it is not that easy. If we could download the page in txt format it would be easier. But even then there as complications. I saved the page as text and imported it in Excel to experiment with parsing. The pages are really not setup for easy parsing. 


I have decided to explore another way...I simply place the Short order and look for the appropriate error message from IB, if the short is rejected I substitute my next ticker and go down the list until my Short order is accepted, and I have the required number of shorts to give me L/S balanced portfolios. However modifying my automated trading code will have to wait until I have my procedure (OLE) working more robust. 


Nothing is ever simple :-)


herman



Wednesday, October 8, 2008, 3:50:06 PM, you wrote:


> Hi Herman,


> I have a solution using Python not the AFL.


> There are a couple of problems you will have to deal with.


> 1. The IB webpage uses _javascript_ so just grabbing the page won't

> work, you need to use something that knows _javascript_.


> 2. There are some embedded html characters to translate.


> I used links, a text based browser that knows _javascript_ to get the

> file and BeautifulSoup to parse it.


> www.python.org

> www.crummy.com/software/BeautifulSoup/

> links.twibright.com/


> The Python script is below, no guarantees it doesn't have errors.


> #!/usr/bin/env python


> """

> getIBshortable.py

> """


> import os

> from BeautifulSoup import BeautifulSoup


> cmd = 'links -source

> "http://www.interactivebrokers.com/en/trading/ViewShortableStocks.php?cntry=usa&tag=United%20States&ib_entity=llc"

> '

> shortableStocks = os.popen(cmd)


> soup=BeautifulSoup(shortableStocks)

> tdList=[t.string for t in soup('td') if t.string != None]


> i=iter(tdList)

> symbol=i.next()

> output="symbol,currency,name\n"

> while not symbol.startswith('3IN'): symbol=i.next()

> stockList={}

> while True:

>     output+=symbol[:-1]+','

>     currency=i.next()

>     output+=currency+','

>     name=i.next()

>     output+=name+'\n'

>     if name.startswith('Sealy Corp'):break

>     symbol=i.next()


> s=output.replace(r' ','

> ').replace(r'&','&').replace(r'/','/')

> file('IBshortable.csv','w').write(s)




> ------------------------------------


> **** IMPORTANT ****

> This group is for the discussion between users only.

> This is *NOT* technical support channel.


> *********************

> TO GET TECHNICAL SUPPORT from AmiBroker please send an e-mail directly to

> SUPPORT {at} amibroker.com

> *********************


> For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:

> http://www.amibroker.com/devlog/


> For other support material please check also:

> http://www.amibroker.com/support.html


> *********************************

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



__._,_.___

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

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

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

For other support material please check also:
http://www.amibroker.com/support.html

*********************************




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

__,_._,___