 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
nerdyguy Guest
|
Posted: Fri Sep 22, 2006 4:16 pm Post subject: Day Trader Stock Program |
|
|
Hi...If you like to keep track of stocks all day long, you might want to try out this Stock Market Program. I have divided the stocks into 8 categories (Pharma, Digital, Soda-Tobacco, Finance, Telco, Dept Stores-Food, Oil-Energy-Autos-Shipping-Metal, Entertainment-Other). You can easily change the categories to suit yourself. And you can add/subtract other stocks. Fortunately, there is a Yahoo website that supplies the data. If you want to see all of the data available, go to
http://www.gummy-stuff.org/Yahoo-data.htm
The data is added to the program by using the command urldownloadtofile. The output to the screen is a list of the stocks sorted by a parameter ans (my own quality factor).
ans = (52wk High - Price)/(52wk High - 52wk Low)
If you have a better quality factor, let me know! The list displays the stock name (shortened version) followed by ans(quality factor), Price, 52week low, 52week high, Market Capitalization and Dividend.
If you are looking for my stock market advice, here it is: BUY LOW, SELL HIGH. This program tells you which stocks are unusually low. Your job, should you choose to accept, is to study the stocks at the top of the list. I usually limit myself to stocks with an ans factor above 0.900. After that, I look at the dividend. If it's above 3.5%, then the stock has reached a bottom and it probably won't go lower. Traders will buy it for the dividend. I also tend to limit myself to BIG companies (BIG Market Capitalization). They are probably going to be around when I am ready to SELL. Then look up the stock on Yahoo. Find out what the problem is. Is it a fixable problem or is it a permanent problem? My favorite example is IBM at the end of 1999. Remember the Y2K problem that caused the IBM stock price to drop? That was a fixable problem. Eventually, it went away and the stock price recovered. I made a nice profit at that time. In fact, that's when I first began to really investigate stocks. Note that there is lots of work to be done. You do have to watch the stock frequently (more than once aday) to see how things are going. Don't be greedy. When you have a satisfactory profit, sell and look for another stock to buy. Note that there will be times when no stock has a sufficiently high quality rating to make it a BUY. Find something else to do. Take a rest. Watch TV, etc.
I hope you find this program to be fun and entertaining and profitable. Goo Luck. Nerdyguy
-------------------------------------------------------------------------------
| Code: | #s::
newl=`n
Loop
{
InputBox,nstk,NUMBER,12345678,,100,110,500,20
If nstk = 1 ;PHARMA
urldownloadtofile,http://finance.yahoo.com/d/quotes.csv?s=bmy+mdt+jnj+bsx+lly+dna+sgp+gsk+abt+nvs+mhs+hum+teva+sny+azn+cah+hsp+thc+amgn+frx+wye+cl+hca+syk+bax+cmx+gild+wlp+ci+unh+bmet+imcl+bay+medi+mlnm&f=sl1jkj1d,nome.txt
If nstk = 2 ;DIGITAL
urldownloadtofile,http://finance.yahoo.com/d/quotes.csv?s=intc+msft+amd+csco+dell+fsl+txn+amat+mot+hpq+ge+si+emr+tek+bf+adi+yhoo+ip+fdc+sunw+caj+col+emc+hon+stx+ibm+dov+brcm&f=sl1jkj1d,nome.txt
If nstk = 3 ;SODA-TOBACCO
urldownloadtofile,http://finance.yahoo.com/d/quotes.csv?s=hsy+pep+ko+mo+rai+wy+adm+gis+sle+cpb+syy+wfmi+rmk&f=sl1jkj1d,nome.txt
If nstk = 4 ;FINANCE
urldownloadtofile,http://finance.yahoo.com/d/quotes.csv?s=c+jpm+mer+gs+wfc+cbh+ncc+bk+wb+wm+ms+fnm+cfc+bac+axp+schw+lm+cof+aet+leh+aig+bsc+trow+all+fre+laz+met+stt+hig+cit+afl+mel+age+sta+fitb+stt+payx+usb+acf+mmc+pru+csr&f=sl1jkj1d,nome.txt
If nstk = 5 ;TELCO
urldownloadtofile,http://finance.yahoo.com/d/quotes.csv?s=vz+s+t+lu+lmt+gd+rtn+qcom+twx+bls+cvc+jnpr+jdsu+orcl+at+hrs+nt+aapl+mmm&f=sl1jkj1d,nome.txt
If nstk = 6 ;DEPT STORES-FOOD
urldownloadtofile,http://finance.yahoo.com/d/quotes.csv?s=wmt+hd+fd+tgt+kss+wag+dg+jcp+cost+cc+bby+rsh+gps+wen+mcd+tsn+pg+cvs+nke+hrb+anf+csg+bbby&f=sl1jkj1d,nome.txt
If nstk = 7 ;OIL-ENERGY-AUTOS-SHIPPING-METAL
urldownloadtofile,http://finance.yahoo.com/d/quotes.csv?s=xom+slb+hal+peg+cop+oxy+sun+imo+oke+f+gm+dcx+bwa+ups+fdx+duk+vlo+ba+cat+x+mt+dd+dow+aa+pd+nue+itw+bpt+ir+sjt+al+tyc+svm&f=sl1jkj1d,nome.txt
If nstk = 8 ;ENTERTAINMENT-OTHER
urldownloadtofile,http://finance.yahoo.com/d/quotes.csv?s=ccl+wynn+lvs+mar+het+mgm+dis+dish+dtv+stn+eds+adp+jci+coh+lltc+shld+spls+fds+mhp+dbd+ca+cmcsa+q&f=sl1jkj1d,nome.txt
stock=name....fact....price....low.....high.....cap........divd...%nstk%%newl%
stox=
Loop,Read,nome.txt
{
LineNumber=%A_Index%
Loop,parse,A_LoopReadLine,CSV
{
If A_Index = 1
{
nam = %A_LoopField%
Gosub,xred
}
If A_Index = 2
pri = %A_LoopField%
If A_Index = 3
low = %A_LoopField%
If A_Index = 4
hig = %A_LoopField%
If A_Index = 5
cap = %A_LoopField%
If A_Index = 6
div = %A_LoopField%
}
xxx = %hig%
xxx -= %pri% ;52wkhigh - price
zzz = %xxx%
yyy = %hig%
yyy -= %low% ;52wkhigh - 52wklow
SetFormat,float,0.3
xxx /= %yyy% ;(high-price)/(high-low)
ans = %xxx%
SetFormat,float,0.2
ddd = 100.
ddd *= %div%
ddd /= %pri%
Gosub,xten
}
stock=%stock%%stox%
ToolTip %stock%,50,50
;FileAppend,%stock%,nome.txt
}
Return
xred:
StringLen,len,nam
If len = 1
; nam = %nam%%a_space%%a_space%%a_space%
nam = %nam%___
If len = 2
; nam = %nam%%a_space%%a_space%
nam = %nam%__
If len = 3
; nam = %nam%%a_space%
nam = %nam%_
Return
xten:
stox=%stox%%nam% \%ans% %pri% %low% %hig% %cap% %ddd% %newl%
Sort,stox,N R \
Return |
|
|
| Back to top |
|
 |
SoggyDog
Joined: 02 May 2006 Posts: 261 Location: Greeley, CO
|
Posted: Fri Sep 22, 2006 5:58 pm Post subject: |
|
|
I think this was a GREAT idea and I like your script a lot.
I made a few minor mods that make it look and feel a little nicer for me.
1. Descriptive Input Screen (for new users)
2. Use MsgBox instead of ToolTip (can be moved, closed, etc)
3. Cleaned up output (tabbed columns; Category appears in Title Bar)
4. Added error handling for incorrect input (<1, >8, NULL, or Alpha)
5. Allowed Input Box to be canceled (script still runs until next Win+s)
6. Kill app with CTRL-Alt-q
Edit : Sept 25
- Error Handling for Divide by Zero
- Removed "\" from output to Fact field (It just bugged me)
- Removed "_" from output to Name field (Same reason)
| Code: | ;By NerdyGuy - http://www.autohotkey.com/forum/viewtopic.php?t=12813
; Slight modifications by SoggyDog - Sept 22, 2006
; Descriptive Input Screen (for new users)
; Use MsgBox instead of ToolTip (can be moved, closed, etc)
; Cleaned up output (tabbed columns; Category in Title Bar)
; Added error handling for incorrect input ( <0, >8, or NULL )
; Allowed Input Box to be canceled (leaves script running until next Win+s)
; Kill app with CTRL-Alt-q
;
; Sept 25
; - Error Handling for Divide by Zero
; - Removed "\" from output to Fact field (It just bugged me)
; - Removed "_" from output to Name field (Same reason)
;
Title1 = Pharma
Title2 = Digital
Title3 = Soda/Tobacco
Title4 = Finance
Title5 = TelCo
Title6 = Dept Stores/Food
Title7 = Oil/Energy/Autos/Shipping/Metal
Title8 = Entertainment/Other
Wait_for_Key:
#s::
newl=`n
Start:
Loop
{
InputBox,nstk,Enter Category,1 = %Title1%`n2 = %Title2%`n3 = %Title3%`n4 = %Title4%`n5 = %Title5%`n6 = %Title6%`n7 = Oil/Energy/Autos`n Shipping/Metal`n8 = %Title8%,,170,250,20,20
if ErrorLevel
{
Break
Goto Wait_for_Key
}
If nstk = ; NULL
{
Goto Start
}
If nstk not between 1 and 8
{
Goto Start
}
If nstk = 1 ;PHARMA
urldownloadtofile,http://finance.yahoo.com/d/quotes.csv?s=bmy+mdt+jnj+bsx+lly+dna+sgp+gsk+abt+nvs+mhs+hum+teva+sny+azn+cah+hsp+thc+amgn+frx+wye+cl+hca+syk+bax+cmx+gild+wlp+ci+unh+bmet+imcl+bay+medi+mlnm&f=sl1jkj1d,nome.txt
If nstk = 2 ;DIGITAL
urldownloadtofile,http://finance.yahoo.com/d/quotes.csv?s=intc+msft+amd+csco+dell+fsl+txn+amat+mot+hpq+ge+si+emr+tek+bf+adi+yhoo+ip+fdc+sunw+caj+col+emc+hon+stx+ibm+dov+brcm&f=sl1jkj1d,nome.txt
If nstk = 3 ;SODA-TOBACCO
urldownloadtofile,http://finance.yahoo.com/d/quotes.csv?s=hsy+pep+ko+mo+rai+wy+adm+gis+sle+cpb+syy+wfmi+rmk&f=sl1jkj1d,nome.txt
If nstk = 4 ;FINANCE
urldownloadtofile,http://finance.yahoo.com/d/quotes.csv?s=c+jpm+mer+gs+wfc+cbh+ncc+bk+wb+wm+ms+fnm+cfc+bac+axp+schw+lm+cof+aet+leh+aig+bsc+trow+all+fre+laz+met+stt+hig+cit+afl+mel+age+sta+fitb+stt+payx+usb+acf+mmc+pru+csr&f=sl1jkj1d,nome.txt
If nstk = 5 ;TELCO
urldownloadtofile,http://finance.yahoo.com/d/quotes.csv?s=vz+s+t+lu+lmt+gd+rtn+qcom+twx+bls+cvc+jnpr+jdsu+orcl+at+hrs+nt+aapl+mmm&f=sl1jkj1d,nome.txt
If nstk = 6 ;DEPT STORES-FOOD
urldownloadtofile,http://finance.yahoo.com/d/quotes.csv?s=wmt+hd+fd+tgt+kss+wag+dg+jcp+cost+cc+bby+rsh+gps+wen+mcd+tsn+pg+cvs+nke+hrb+anf+csg+bbby&f=sl1jkj1d,nome.txt
If nstk = 7 ;OIL-ENERGY-AUTOS-SHIPPING-METAL
urldownloadtofile,http://finance.yahoo.com/d/quotes.csv?s=xom+slb+hal+peg+cop+oxy+sun+imo+oke+f+gm+dcx+bwa+ups+fdx+duk+vlo+ba+cat+x+mt+dd+dow+aa+pd+nue+itw+bpt+ir+sjt+al+tyc+svm&f=sl1jkj1d,nome.txt
If nstk = 8 ;ENTERTAINMENT-OTHER
urldownloadtofile,http://finance.yahoo.com/d/quotes.csv?s=ccl+wynn+lvs+mar+het+mgm+dis+dish+dtv+stn+eds+adp+jci+coh+lltc+shld+spls+fds+mhp+dbd+ca+cmcsa+q&f=sl1jkj1d,nome.txt
stock=Name`tFact`tPrice`tLow`tHigh`tCap`t Divd%newl%`n
stox=
Loop,Read,nome.txt
{
LineNumber=%A_Index%
Loop,parse,A_LoopReadLine,CSV
{
If A_Index = 1
{
nam = %A_LoopField%
}
If A_Index = 2
pri = %A_LoopField%
If A_Index = 3
low = %A_LoopField%
If A_Index = 4
hig = %A_LoopField%
If A_Index = 5
cap = %A_LoopField%
If A_Index = 6
div = %A_LoopField%
}
xxx = %hig%
xxx -= %pri% ;52wkhigh - price
zzz = %xxx%
yyy = %hig%
yyy -= %low% ;52wkhigh - 52wklow
SetFormat,float,0.3
if yyy != 0
{
xxx /= %yyy% ;(high-price)/(high-low)
}
else
{
xxx = N/A
}
ans = %xxx%
SetFormat,float,0.2
ddd = 100.
ddd *= %div%
if pri != 0
{
ddd /= %pri%
}
else
{
ddd = N/A
}
Gosub,xten
}
Title_Bar := Title%nstk%
StringReplace, stox, stox, \,,All
stock=%stock%%stox%
MsgBox, ,%Title_Bar%, %stock%
}
Return
xten:
stox=%stox%%nam%`t\%ans%`t%pri%`t%low%`t%hig%`t%cap%`t %ddd%`t%newl%
Sort,stox,N R \
Return
^!q::
ExitApp |
Thanks to you (and everyone that helped you) for all
the hard work that went in to getting this script written. _________________
SoggyDog
Download AutoHotKey Wallpaper
Does 'Fuzzy Logic' tickle?
Last edited by SoggyDog on Mon Sep 25, 2006 10:36 pm; edited 7 times in total |
|
| Back to top |
|
 |
Nerd611 Guest
|
Posted: Fri Sep 22, 2006 6:31 pm Post subject: |
|
|
Excellent... Maybe you should be Geekyguy. Thats a promotion from mere nerd to geek! |
|
| Back to top |
|
 |
nerdyguy Guest
|
Posted: Fri Sep 22, 2006 8:51 pm Post subject: Day Trader Stock Program |
|
|
Hi SoggyDog and Nerd611...Thanks for the compliments. I will test out the proposed changes and see what they do. I hope I have inspired some bright guys out there to look over my program and add some new stock market ideas to the program. My formula for ans is quite simple. But someone out there might find some way to improve upon it.
As far as real investing is concerned, I suggest that a trader remember to employ the STOP-LOSS feature of his personal trading website (Ameritrade, E-Trade, Schwab, etc) to minimize his LOSS in case things go wrong and the stock price falls unexpectedly. The STOP-LOSS feature will automatically SELL the stock at a price you select (below the price you bought it at and below the present price). Caution is always a good idea when it comes to playing the market. Good Luck! Nerdyguy (aka geekyguy) |
|
| Back to top |
|
 |
SoggyDog
Joined: 02 May 2006 Posts: 261 Location: Greeley, CO
|
Posted: Mon Sep 25, 2006 3:24 pm Post subject: |
|
|
Error handling needs to be added for instances of Divide by Zero error in this line;
| Code: | | xxx /= %yyy% ;(high-price)/(high-low) |
_________________
SoggyDog
Download AutoHotKey Wallpaper
Does 'Fuzzy Logic' tickle? |
|
| Back to top |
|
 |
nerdyguy Guest
|
Posted: Mon Sep 25, 2006 7:45 pm Post subject: Day Trader Stock Program |
|
|
| Hi SoggyDog...You are correct. I think CSR was bought by another company and it was removed from the stock market. I also noticed the divide-by-zero today. I put in a statement that said if pri was zero, set pri to 1.0. I suppose you could also ask the program to ignore the stock entirely or tell the user that the stock is gone. Thanks. Nerdyguy |
|
| Back to top |
|
 |
nerdyguy Guest
|
Posted: Mon Sep 25, 2006 8:00 pm Post subject: Day Trader Stock Program |
|
|
Hi Everyone...You can also look at the output of another stock program on the web and compare the results with the results from my program. The results of other program can found at:
<http://invest.kleinnet.com/bmw1/stats20/index.html>
This program examines the long term (20 years) variation of a stock price and tries to fit the price rise to an exponential function (I think). The variation from that "middle" or "curve fit" line tells you if the price above the "middle" or below the middle. Check it out. This site also contains a list of the stocks with a 20 year history. Have fun. Nerdyguy |
|
| Back to top |
|
 |
SoggyDog
Joined: 02 May 2006 Posts: 261 Location: Greeley, CO
|
Posted: Mon Sep 25, 2006 8:34 pm Post subject: |
|
|
I fixed the Divide by Zero error. If the value is zero, then "N/A" is displayed.
Of course, stocks that are no longer trading can simply be removed, but this fix
allows the script to continue running without error and gives the user a clear
picture of which stock(s) caused the problem.
I also used StringReplace to get rid of the "\" in the output to Fact field.
No real reason really... It was just buggin' me.
Further, I removed the "_" from the output to Name field. It bugged me, too.
Updated Code posted Here. _________________
SoggyDog
Download AutoHotKey Wallpaper
Does 'Fuzzy Logic' tickle? |
|
| Back to top |
|
 |
nerdyguy Guest
|
Posted: Thu Sep 28, 2006 2:29 pm Post subject: Day Trader Stock Program |
|
|
| Hi Everyone...It looks like the NY Times uses the same idea that my Day Trader Stock Program uses. In the NY Times Business Section, the Times lists the S&P 100 Stocks. Next to each stock is the Price, the 52week Low and the 52week High. In between these last two numbers is a dot which tells you where the Price is relative to the High and the Low. If the Price is close to the Low, the dot is at the left. If the Price is close to the High, the dot is at the right. This essentially duplicates what my program does (in numbers). Have fun. Nerdyguy |
|
| Back to top |
|
 |
Zed Gecko
Joined: 23 Sep 2006 Posts: 100
|
Posted: Sun Oct 08, 2006 12:10 am Post subject: a slightly better version (I hope so) |
|
|
Hi, i liked your program much, but we are not interested in the same stocks.
so when i was modifying your script, i started adding some extra features.
This lead to the following script.
It is custumizable, so you can change the Hotkeys and the stocklists to download with a configuration dialog.
It stores the configuration in an .ini-file.
It uses listviews (no presorting cause of this) and
i have made your Indicator more graphic (more like the NY Times
it will look now "!.........." for 1, ".!........." for 0.9 and so on
till "..........!" for 0.
So no need to mess around with the code
to custumize this script anymore
ah, and there is a list of "default stocks" implemented to start with
| Code: | ;Getstock script by Zed Gecko
;based on a script from NerdyGuy - http://www.autohotkey.com/forum/viewtopic.php?t=12813 ,slight modifications by SoggyDog
;a fully costumizable stockdownloader
;set your own hotkey for start and quit
;select your own stocks
;uses listviews
;made the "NerdyGuy-Indicator" graphic (not really, but)
;stores configuration in an ini-file
;and provides 2 Languages (Englisch,German)
;---------------------------------------------------------------------------
; here are the defaultsettings set in case there is no stockget.ini file present
; it sets the default for stocks, button-names, hotkeys, language and info-Tooltip display-time
defstocklist1 = @`%5ENYL
defstocklist2 = @`%5EGSPTSE
defstocklist3 = @`%5EGDAXI
defstocklist4 = @`%5EFTSE
defstocklist5 = @`%5ESSMI
defstocklist6 = @`%5EDJA
defstocklist7 = @`%5ENYA
defstocklist8 = @`%5ENDX
defstocklist9 = @`%5EOEX
defstocklist10 = @`%5EAORD
defbuttonname1 = NYSE World Leaders (World)
defbuttonname2 = S&&P/TSX Composite Index (World)
defbuttonname3 = DAX (Germany)
defbuttonname4 = FTSE 100 (U.K.)
defbuttonname5 = SMI (Swiss)
defbuttonname6 = DOW JONES COMPOSITE INDEX (U.S.)
defbuttonname7 = NYSE COMPOSITE INDEX (U.S.)
defbuttonname8 = NASDAQ-100 (U.S.)
defbuttonname9 = S&&P 100 INDEX,RTH (U.S.)
defbuttonname10 = ALL ORDINARIES IDX (Australia)
defkeyvar = !s
defendvar = !q
deflangvar = e
definfotimevar = 10
;------------------------------------------------------------------------------------------------------------------
;these are the infotextes the program shows depending on selected languague
usage_e = Stockquotes at Keypress. `nUse the following Hotkeys: `n
usage_g = Auf Knopfdruck Aktienkurse abrufen.`nBenutzen Sie folgende Hotkeys:`n
startsg_e = to start stockquote download
startsg_g = zum Starten der Kursabfrage
endsg_e = to quit the program
endsg_g = zum Beenden des Programms
description_e = Press the Number-Keys`n or click on a button to `n to display the stockquotes.
description_g = Drücken Sie auf eine der Nummerntasten`n oder klicken Sie auf einen Button, `n um die entsprechenden Aktienkurse anzuzeigen.
ConfigStocksforButtone = Stocklist for Button
ConfigStocksforButtong = Aktienliste für Button
configinfotxt1e =
(
You can set the language, the time(in seconds) the StartUp-Screen is shown and
the Hotkeys to start and quit the program.
You can define Hotkeys with one or more modifier-keys (like Shift, Alt, Control und Win)
and one standard-key (a-z). Use the following symbols for the modifier-keys:
"#" for the Windowslogo-Key, "!" for the Alt-Key, "^" for the Control-Key and "+" for the Shift-Key.
Alt+s would be "!s", Ctrl+Alt+x "^!x" and Win+Shift+a "#+a".
)
configinfotxt1g =
(
Hier können Sie die Sprache, die Anzeigedauer des Startbildschirms (in Sekunden) und
die Hotkeys für das Starten und Beenden des Programms ändern.
Sie können beliebige Hotkeys aus einer oder mehreren Modifikator-Tasten (wie Shift, Alt, Control und Win)
und einer Standard-Taste (a-z) definieren. Benutzen Sie für die Modikator-Tasten folgende Zeichen:
"#" für die Windowslogo-Taste, "!" für die Alt-Taste, "^" für die Control-Taste und "+" für die Shift-Taste.
Alt+s würde z.B. geschrieben "!s", Ctrl+Alt+x wäre "^!x" und Win+Shift+a "#+a".
)
configinfotxt2e = Select a predefined stock list, or define an own stock list from Yahoo stock-symbols
configinfotxt2g = Wählen Sie eine vordefinierte Aktienliste aus, oder gestalten Sie unter "own stock list" eine eigene Liste von Yahoo-Aktiensymbolen.
configinfotxt3e = OneYahoo stock-symbol or more tha one seperated through "+" ("BA" for Boeing, "BA+DD+DIS" for Boeing, Du Pont and Disney)
configinfotxt3g = Ein Yahoo-Aktiensymbol oder Mehrere durch ein "+" getrennt. (z.B. "SAP.F" für SAP, "BAS.F+BAY.F+BA" für BASF,Bayer und Boeing)
configinfotxt4e = lookup Stocksymbols at finance.yahoo.com
configinfotxt4g = Aktiensymbole bei Yahoo nachschlagen
;---------------------------------------------------------------------------
; here the usersettings are read from the stockget.ini file
; if not possible, the settings are set to default values from above
IniRead, keyvar, stockget.ini, Config, Hotkey, %defkeyvar%
IniRead, endvar, stockget.ini, Config, Endkey, %defendvar%
IniRead, langvar, stockget.ini, Config, Lang, %deflangvar%
IniRead, infotimevar, stockget.ini, Config, Infotime, %definfotimevar%
Loop, 10
{
defsl := defstocklist%A_Index%
defbn := defbuttonname%A_Index%
IniRead, stocklist%A_Index%, stockget.ini, Stocks, %A_Index%, %defsl%
IniRead, buttonname%A_Index%, stockget.ini, Button, %A_Index%, %defbn%
}
;---------------------------------------------------------------------------
;this will define the hotkey for showing the stockget GUI and for ending the script
Hotkey, %keyvar%, stockget
Hotkey, %endvar%, endprog
;---------------------------------------------------------------------------
;Next the Info ToolTip is displayed for %infotimevar% seconds
;it will show the current HotKeys for the program
stcktxt := RetHK2Txt(keyvar)
endtxt := RetHK2Txt(endvar)
Usage := usage_%langvar%
StartSG :=startsg_%langvar%
EndSG :=endsg_%langvar%
ToolTip, StockGet`n%Usage%`n%StartSG%: %stcktxt%`n%EndSG%: %endtxt%, 200, 200
sleep, infotimevar*1000
ToolTip
;---------------------------------------------------------------------------
return ; End of autoexecute section
;---------------------------------------------------------------------------
stockget:
Gui, Destroy
Tooltip
Gui +Toolwindow
Gui, Add, Text,, % description_%langvar%
Gui, Add, Button, xm gbutton1, &1 %buttonname1%
Gui, Add, Button, xm gbutton2, &2 %buttonname2%
Gui, Add, Button, xm gbutton3, &3 %buttonname3%
Gui, Add, Button, xm gbutton4, &4 %buttonname4%
Gui, Add, Button, xm gbutton5, &5 %buttonname5%
Gui, Add, Button, xm gbutton6, &6 %buttonname6%
Gui, Add, Button, xm gbutton7, &7 %buttonname7%
Gui, Add, Button, xm gbutton8, &8 %buttonname8%
Gui, Add, Button, xm gbutton9, &9 %buttonname9%
Gui, Add, Button, xm gbutton10, &0 %buttonname10%
Gui, Add, Button, xm y+30 gconfig, Config
Gui, Show, yCenter x10, GetStock: choose stocklist
return
;---------------------------------------------------------------------------
button1:
Gui, Destroy
Tooltip, downloading %buttonname1%
getstocks(stocklist1,buttonname1,"1")
return
button2:
Gui, Destroy
Tooltip, downloading %buttonname2%
getstocks(stocklist2,buttonname2,"2")
return
button3:
Gui, Destroy
Tooltip, downloading %buttonname3%
getstocks(stocklist3,buttonname3,"3")
return
button4:
Gui, Destroy
Tooltip, downloading %buttonname4%
getstocks(stocklist4,buttonname4,"4")
return
button5:
Gui, Destroy
Tooltip, downloading %buttonname5%
getstocks(stocklist5,buttonname5,"5")
return
button6:
Gui, Destroy
Tooltip, downloading %buttonname6%
getstocks(stocklist6,buttonname6,"6")
return
button7:
Gui, Destroy
Tooltip, downloading %buttonname7%
getstocks(stocklist7,buttonname7,"7")
return
button8:
Gui, Destroy
Tooltip, downloading %buttonname8%
getstocks(stocklist8,buttonname8,"8")
return
button9:
Gui, Destroy
Tooltip, downloading %buttonname9%
getstocks(stocklist9,buttonname9,"9")
return
button10:
Gui, Destroy
Tooltip, downloading %buttonname10%
getstocks(stocklist10,buttonname10,"10")
return
;---------------------------------------------------------------------------
;download the stockdata to a .csv file
getstocks(argument,guiname,listnr)
{
global MyListView
urldownloadtofile,http://finance.yahoo.com/d/quotes.csv?s=%argument%&f=snl1mjkm3m4j1dc1,quotes%listnr%.csv
;the data is stored in the following order:
;symbol,name,price,day´s range,52week low,52week high,50day moving average,200day moving average,market capitalization,dividende/share,change
Tooltip ; close the Tooltip started by one of the buttonx labels
Gui, +Resize
;add a listview "excel-style" with grid
Gui, Add, ListView, X10 Y10 R40 W825 Grid vMyListView, Symbol|Name|Price| +/- |Day´s Range|52 Low|L/H Pos|52 High|50d MovAv|200d MovAv|Market Cap|Div/Share|Div in `%
;and parse the data from the .csv file into the Listview
Loop,Read,quotes%listnr%.csv
{
LineNumber=%A_Index%
Loop,parse,A_LoopReadLine,CSV
{
stockinfo%A_Index% = %A_LoopField%
}
stockhighprice := (stockinfo6 - stockinfo3)
stockhighlow := (stockinfo6 - stockinfo5)
SetFormat,float,0.1
highlowindex = ...........
if stockhighlow = 0
stockhlpos = undefined
else
stockhlpos := (stockhighprice / stockhighlow)
if stockhlpos = 1.0 ; indicates the stock is at the lower end of the price range
highlowindex = !..........
if stockhlpos = 0.9
highlowindex = .!.........
if stockhlpos = 0.8
highlowindex = ..!........
if stockhlpos = 0.7
highlowindex = ...!.......
if stockhlpos = 0.6
highlowindex = ....!......
if stockhlpos = 0.5
highlowindex = .....!.....
if stockhlpos = 0.4
highlowindex = ......!....
if stockhlpos = 0.3
highlowindex = .......!...
if stockhlpos = 0.2
highlowindex = ........!..
if stockhlpos = 0.1
highlowindex = .........!.
if stockhlpos = 0.0 ; indicates the stock is at the higher end of the price range
highlowindex = ..........!
;truncate some chars behind the point
SetFormat,float,0.2
stockinfo7 *= 1
stockinfo8 *= 1
stockinfo10 *= 1
;get the dividende in Percent
if stockinfo3 = 0
stockdivperc = 0
else
stockdivperc := (stockinfo10 * 100 / stockinfo3)
LV_Add("", stockinfo1, stockinfo2, stockinfo3, stockinfo11, stockinfo4, stockinfo5, highlowindex, stockinfo6, stockinfo7, stockinfo8, stockinfo9, stockinfo10, stockdivperc)
; adjust the colons
LV_ModifyCol(2, "Auto")
LV_ModifyCol(3, "Float")
LV_ModifyCol(3, "Auto")
LV_ModifyCol(5, "Auto")
LV_ModifyCol(6, "Float")
LV_ModifyCol(7, "Center")
LV_ModifyCol(8, "Float")
LV_ModifyCol(9, "Float")
LV_ModifyCol(10, "Float")
LV_ModifyCol(11, "Float")
LV_ModifyCol(12, "Float")
LV_ModifyCol(13, "50")
;LV_ModifyCol()
}
GuiControl, Move, MyListView, % "W" . (A_GuiWidth - 10) . " H" . (A_GuiHeight - 10) ; resizes the Listview according to the size of the gui
StringReplace, guiname, guiname, &&, &, All
Gui, Show,, %guiname%
return
}
;---------------------------------------------------------------------------
GuiSize: ; Expand or shrink the ListView in response to the user's resizing of the window.
if A_EventInfo = 1 ; The window has been minimized. No action needed.
return
; Otherwise, the window has been resized or maximized. Resize the ListView to match.
GuiControl, Move, MyListView, % "W" . (A_GuiWidth - 20) . " H" . (A_GuiHeight - 20)
return
;---------------------------------------------------------------------------
Config:
Gui, Destroy
Gui, Add, Text, w500, % configinfotxt1%langvar%
Gui, Add, Text, xm, Stock-Select-HotKey :
Gui, Add, Edit, x+16 w60 vOwnkeyvar, %keyvar%
Gui, Add, Text, x+5, % " = " . RetHK2Txt(keyvar)
Gui, Add, Text, xm, Quit-Program-HotKey :
Gui, Add, Edit, x+15 w60 vOwnendvar, %endvar%
Gui, Add, Text, x+5, % " = " . RetHK2Txt(endvar)
Gui, Add, Text, xm, Time the startup Screen is shown (in sec.) :
Gui, Add, Edit, x+22 w40 vOwninfotimevar, %infotimevar%
Gui, Add, Text, xm, Language
Gui, Add, Radio, vRadioLanguage , English.
Gui, Add, Radio, Checked, German
if langvar = e
GuiControl,, RadioLanguage, 1
Gui, Add, Tab, -Wrap xm h385 w500 ,Button1|Button2|Button3|Button4|Button5|Button6|Button7|Button8|Button9|Button10|
Loop, 10
{
Gui, Tab, %A_Index%
Gui, Add, Text,, % ConfigStocksforButton%langvar% A_Index
Gui, Add, Text, w450, % configinfotxt2%langvar%
Gui, Add, Radio,, % defbuttonname1
Gui, Add, Radio,, % defbuttonname2
Gui, Add, Radio,, % defbuttonname3
Gui, Add, Radio,, % defbuttonname4
Gui, Add, Radio,, % defbuttonname5
Gui, Add, Radio,, % defbuttonname6
Gui, Add, Radio,, % defbuttonname7
Gui, Add, Radio,, % defbuttonname8
Gui, Add, Radio,, % defbuttonname9
Gui, Add, Radio,, % defbuttonname10
Gui, Add, Radio, Checked vRadioButton%A_Index%, own stock list
Gui, Add, Edit, x+5 w250 vOwnButtonname%A_Index%, % buttonname%A_Index%
Gui, Add, Text, w350, % configinfotxt3%langvar%
Gui, Add, Edit, w350 vOwnStocklist%A_Index%, % stocklist%A_Index%
Gui, Font, underline
Gui, Add, Text, cBlue gLaunchYahoo, % configinfotxt4%langvar%
Gui, Font, norm
}
Gui, Tab
Gui, Add, Button,xm gStoreconfig, Save Changes
Gui, Add, Button, x+15 w70 +Default gCancelconfig, &Cancel
Gui, Show,, StockGet Configuration
return
;---------------------------------------------------------------------------
Storeconfig:
Gui, Submit
Tooltip, Wait
Hotkey, %keyvar%, Off
Hotkey, %endvar%, Off
keyvar := Ownkeyvar
endvar := Ownendvar
infotimevar := Owninfotimevar
if RadioLanguage = 1
langvar = e
if RadioLanguage = 2
langvar = g
Loop, 10
{
if RadioButton%A_Index% = 11
{
buttonname%A_Index% := OwnButtonname%A_Index%
stocklist%A_Index% := OwnStocklist%A_Index%
}
else
{
tempbuttonstate := RadioButton%A_Index%
buttonname%A_Index% := defbuttonname%tempbuttonstate%
stocklist%A_Index% := defstocklist%tempbuttonstate%
}
}
IniWrite, %keyvar%, stockget.ini, Config, Hotkey
IniWrite, %endvar%, stockget.ini, Config, Endkey
IniWrite, %langvar%, stockget.ini, Config, Lang
IniWrite, %infotimevar%, stockget.ini, Config, Infotime
Loop, 10
{
IniWrite, % stocklist%A_Index%, stockget.ini, Stocks, %A_Index%
IniWrite, % buttonname%A_Index%, stockget.ini, Button, %A_Index%
}
;Hotkey, %keyvar%, stockget
;Hotkey, %endvar%, endprog
stcktxt := RetHK2Txt(keyvar)
endtxt := RetHK2Txt(endvar)
ToolTip, StockGet Reloading, 200, 200
reload
return
;------------------------------------------------------------------------------------------------------------------
LaunchYahoo:
Run http://finance.yahoo.com/lookup
return
;------------------------------------------------------------------------------------------------------------------
Cancelconfig:
Gui, Destroy
return
;------------------------------------------------------------------------------------------------------------------
; the RetHK2Txt() function will return the Hotkey in real words from a string
; that is assumed to be a Hotkey-label.
; for example: "!a" would resolve "Alt+a" , "^!U" would resolve "Control+Alt+U" and
; "<^>!a" would resolve "AltGr+a"
; it does not return correct translation for long name hotkeys like LButton or WheelDown
RetHK2Txt(hkstring)
{
hktxt =
Loop, parse, hkstring,,
{
if A_LoopField = #
hktxt := hktxt . "Win+"
if A_LoopField = !
hktxt := hktxt . "Alt+"
if A_LoopField = ^
hktxt := hktxt . "Control+"
if A_LoopField = +
hktxt := hktxt . "Shift+"
if A_LoopField = <
hktxt := hktxt . "left "
if A_LoopField = >
hktxt := hktxt . "right "
if A_LoopField = &
{
StringTrimRight, hktxt, hktxt, 1
hktxt := hktxt . "&"
}
if A_LoopField not in #,!,^,+,<,>,*,~,$,&,:
hktxt := hktxt . A_LoopField . "+"
}
StringReplace, hktxt, hktxt, left Control+right Alt, AltGr, All
StringTrimRight, hktxt, hktxt, 1
return hktxt
}
;------------------------------------------------------------------------------------------------------------------
guiclose:
gui, destroy
return
;---------------------------------------------------------------------------
endprog:
Gui, Destroy
ToolTip, StockGet quits, 200, 200
sleep, 800
ExitApp
return |
474 |
|
| Back to top |
|
 |
userabuser
Joined: 15 Jul 2006 Posts: 29
|
Posted: Thu Jan 03, 2008 3:03 am Post subject: |
|
|
I have begun to modify what soggy dog did here. However, as you see, I'd like to ad a column to google(finance) the %nam%
I'd appreciate some thoughts now how to make it clickable.
| Code: |
;By NerdyGuy - http://www.autohotkey.com/forum/viewtopic.php?t=12813
; Slight modifications by SoggyDog - Sept 22, 2006
; Descriptive Input Screen (for new users)
; Use MsgBox instead of ToolTip (can be moved, closed, etc)
; Cleaned up output (tabbed columns; Category in Title Bar)
; Added error handling for incorrect input ( <0, >8, or NULL )
; Allowed Input Box to be canceled (leaves script running until next Win+s)
; Kill app with CTRL-Alt-q
;
; Sept 25
; - Error Handling for Divide by Zero
; - Removed "\" from output to Fact field (It just bugged me)
; - Removed "_" from output to Name field (Same reason)
;
Title1 = Pharma
Title2 = Digital
Title3 = Soda/Tobacco
Title4 = Finance
Title5 = TelCo
Title6 = Dept Stores/Food
Title7 = Oil/Energy/Autos/Shipping/Metal
Title8 = Entertainment/Other
Wait_for_Key:
;#s::
newl=`n
Start:
Loop
{
InputBox,nstk,Enter Category,1 = %Title1%`n2 = %Title2%`n3 = %Title3%`n4 = %Title4%`n5 = %Title5%`n6 = %Title6%`n7 = Oil/Energy/Autos`n Shipping/Metal`n8 = %Title8%,,170,250,20,20
if ErrorLevel
{
Break
Goto Wait_for_Key
}
If nstk = ; NULL
{
Goto Start
}
If nstk not between 1 and 8
{
Goto Start
}
If nstk = 1 ;PHARMA
urldownloadtofile,http://finance.yahoo.com/d/quotes.csv?s=bmy+mdt+jnj+bsx+lly+dna+sgp+gsk+abt+nvs+mhs+hum+teva+sny+azn+cah+hsp+thc+amgn+frx+wye+cl+hca+syk+bax+cmx+gild+wlp+ci+unh+bmet+imcl+bay+medi+mlnm&f=sl1jkj1d,nome.txt
If nstk = 2 ;DIGITAL
urldownloadtofile,http://finance.yahoo.com/d/quotes.csv?s=intc+msft+amd+csco+dell+fsl+txn+amat+mot+hpq+ge+si+emr+tek+bf+adi+yhoo+ip+fdc+sunw+caj+col+emc+hon+stx+ibm+dov+brcm&f=sl1jkj1d,nome.txt
If nstk = 3 ;SODA-TOBACCO
urldownloadtofile,http://finance.yahoo.com/d/quotes.csv?s=hsy+pep+ko+mo+rai+wy+adm+gis+sle+cpb+syy+wfmi+rmk&f=sl1jkj1d,nome.txt
If nstk = 4 ;FINANCE
urldownloadtofile,http://finance.yahoo.com/d/quotes.csv?s=c+jpm+mer+gs+wfc+cbh+ncc+bk+wb+wm+ms+fnm+cfc+bac+axp+schw+lm+cof+aet+leh+aig+bsc+trow+all+fre+laz+met+stt+hig+cit+afl+mel+age+sta+fitb+stt+payx+usb+acf+mmc+pru+csr&f=sl1jkj1d,nome.txt
If nstk = 5 ;TELCO
urldownloadtofile,http://finance.yahoo.com/d/quotes.csv?s=vz+s+t+lu+lmt+gd+rtn+qcom+twx+bls+cvc+jnpr+jdsu+orcl+at+hrs+nt+aapl+mmm&f=sl1jkj1d,nome.txt
If nstk = 6 ;DEPT STORES-FOOD
urldownloadtofile,http://finance.yahoo.com/d/quotes.csv?s=wmt+hd+fd+tgt+kss+wag+dg+jcp+cost+cc+bby+rsh+gps+wen+mcd+tsn+pg+cvs+nke+hrb+anf+csg+bbby&f=sl1jkj1d,nome.txt
If nstk = 7 ;OIL-ENERGY-AUTOS-SHIPPING-METAL
urldownloadtofile,http://finance.yahoo.com/d/quotes.csv?s=xom+slb+hal+peg+cop+oxy+sun+imo+oke+f+gm+dcx+bwa+ups+fdx+duk+vlo+ba+cat+x+mt+dd+dow+aa+pd+nue+itw+bpt+ir+sjt+al+tyc+svm&f=sl1jkj1d,nome.txt
If nstk = 8 ;ENTERTAINMENT-OTHER
urldownloadtofile,http://finance.yahoo.com/d/quotes.csv?s=ccl+wynn+lvs+mar+het+mgm+dis+dish+dtv+stn+eds+adp+jci+coh+lltc+shld+spls+fds+mhp+dbd+ca+cmcsa+q&f=sl1jkj1d,nome.txt
stock=Name`tFact`tPrice`tLow`tHigh`tCap`t Divd `tGoogle %newl%`n
stox=
Loop,Read,nome.txt
{
LineNumber=%A_Index%
Loop,parse,A_LoopReadLine,CSV
{
If A_Index = 1
{
nam = %A_LoopField%
}
If A_Index = 2
pri = %A_LoopField%
If A_Index = 3
low = %A_LoopField%
If A_Index = 4
hig = %A_LoopField%
If A_Index = 5
cap = %A_LoopField%
If A_Index = 6
div = %A_LoopField%
}
xxx = %hig%
xxx -= %pri% ;52wkhigh - price
zzz = %xxx%
yyy = %hig%
yyy -= %low% ;52wkhigh - 52wklow
google = "http://finance.google.com/finance?q=%nam%"
SetFormat,float,0.3
if yyy != 0
{
xxx /= %yyy% ;(high-price)/(high-low)
}
else
{
xxx = N/A
}
ans = %xxx%
SetFormat,float,0.2
ddd = 100.
ddd *= %div%
if pri != 0
{
ddd /= %pri%
}
else
{
ddd = N/A
}
Gosub,xten
}
Title_Bar := Title%nstk%
StringReplace, stox, stox, \,,All
stock=%stock%%stox%
MsgBox, ,%Title_Bar%, %stock%
}
Return
xten:
stox=%stox%%nam%`t\%ans%`t%pri%`t%low%`t%hig%`t%cap%`t %ddd%`t%google%`t%newl%
Sort,stox,N R \
Return
^!q::
ExitApp
|
|
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|