Medic873 Posted July 6, 2012 Share Posted July 6, 2012 Okay im trying to pull stock data from msn not that hard to do but im running into a issue.. I need just the numbers cause im trying to see if the stock goes up through the day then +1 down then -1 but since there are spaces in front of the close price that it pulls it is always a negitive 1 in its world how can I fix this here is my code expandcollapse popup#include <IE.au3> #include <ScreenCapture.au3> #include <Excel.au3> #include "array.au3" #include <File.au3> #include <string.au3> #include <Math.au3> #include <INet.au3> #include<misc.au3> #include <ScreenCapture.au3> #Include<file.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <INet.au3> #include <String.au3> Local $Stock1[1] $StockSymbol = InputBox("Stock Symbol", "Stock Symbol to correlate to"); $MsnHistoricalData = _INetGetSource('http://investing.money.msn.com/investments/equity-historical-price/?PT=7&D4=1&DD=1&D5=0&DCS=2&MA0=0&MA1=0&CF=0&nocookie=1&SZ=0&symbol=' & $StockSymbol); $DayPuller = _StringBetween($MsnHistoricalData, '<td class="first">', '</tr>'); _ArrayDisplay ($DayPuller); For $i = 0 To 31 Step +1 $Open = _StringBetween($DayPuller[$i], '<span>', '</span>'); $Close = _StringBetween($DayPuller[$i], '<span>', '</span>'); If $Open[3] = $Close[4] Then _ArrayAdd($Stock1, +0);Netrul Day If $Open[3] < $Close[4] Then _ArrayAdd($Stock1, +1);Positive Day If $Open[3] > $Close[4] Then _ArrayAdd($Stock1, -1);Negitive Day msgbox (1, "Open", $Open[3]); Msgbox (1, "Close", $Close[4]); Next; _ArrayDisplay ($Stock1); Link to comment Share on other sites More sharing options...
willichan Posted July 6, 2012 Share Posted July 6, 2012 StringStripWS() My UDFs: Barcode Libraries, Automate creation of any type of project folder, File Locking with Cooperative Semaphores, Inline binary files, Continue script after reboot, WinWaitMulti, Name Aggregator, Enigma, CornedBeef Hash Link to comment Share on other sites More sharing options...
iamtheky Posted July 6, 2012 Share Posted July 6, 2012 (edited) assuming [2] is open and [3] is close #include <INet.au3> #include <String.au3> #include <Array.au3> Local $Stock1[1] $StockSymbol = InputBox("Stock Symbol", "Stock Symbol to correlate to"); $MsnHistoricalData = _INetGetSource('[url="http://investing.money.msn.com/investments/equity-historical-price/?PT=7&D4=1&DD=1&D5=0&DCS=2&MA0=0&MA1=0&CF=0&nocookie=1&SZ=0&symbol="]http://investing.money.msn.com/investments/equity-historical-price/?PT=7&D4=1&DD=1&D5=0&DCS=2&MA0=0&MA1=0&CF=0&nocookie=1&SZ=0&symbol=[/url]' & $StockSymbol); $DayPuller = _StringBetween($MsnHistoricalData, '<td class="first">', '</tr>'); ;~ _ArrayDisplay ($DayPuller); For $i = 0 To ubound($DayPuller) - 1 $DayPuller[$i] = StringStripWS($DayPuller[$i] , 8) $current = stringregexp ($Daypuller[$i] , "<td><span>(d.*?)</span></td>" , 3) ;~ _ArrayDisplay($current) ;~ msgbox (0, '' , $current[2] & " " & $current[3]) If $Current[2] = $Current[3] Then _ArrayAdd($Stock1, "+0");Netrul Day If $Current[2] > $Current[3] Then _ArrayAdd($Stock1, "+1");Positive Day If $Current[2] < $Current[3] Then _ArrayAdd($Stock1, "-1");Negitive Day next _ArrayDisplay ($Stock1); Edited July 6, 2012 by boththose ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
DicatoroftheUSA Posted July 6, 2012 Share Posted July 6, 2012 This is how I might do it. #include <Array.au3> #include <Inet.au3> Local $Stock1[1][2] $StockSymbol = InputBox("Stock Symbol", "Stock Symbol to correlate to"); $MsnHistoricalData = _INetGetSource('http://investing.money.msn.com/investments/equity-historical-price/?PT=7&D4=1&DD=1&D5=0&DCS=2&MA0=0&MA1=0&CF=0&nocookie=1&SZ=0&symbol=' & $StockSymbol); $DayPuller = StringRegExp($MsnHistoricalData, '(?s)(.*?)', 3); $iBound=UBound($DayPuller)-1 MsgBox(0,$iBound,"huh") Local $aValTotal[$iBound][6] ;~ _ArrayDisplay ($DayPuller); For $i = 2 To $iBound-1 $Vals = StringRegExp($DayPuller[$i], '(?s)h*?(.*?)h*?', 3); ;vals ;[0]date ;[1]high ;[2]low ;[3]open ;[4]close ;~ _ArrayDisplay($Vals) If UBound($Vals)>3 Then For $x=0 To 4 $aValTotal[$i][$x]=StringStripWS($Vals[$x],8) Next If Number($Vals[3]) = Number($Vals[4]) Then $aValTotal[$i][5] =+0;Netrul Day If Number($Vals[3]) < Number($Vals[4]) Then $aValTotal[$i][5] = +1;Positive Day If Number($Vals[3]) > Number($Vals[4]) Then $aValTotal[$i][5] = -1;Negitive Day EndIf ;~ msgbox (1, "Open", $Open[3]); ;~ Msgbox (1, "Close", $Close[4]); Next; _ArrayDisplay ($aValTotal); Statism is violence, Taxation is theft. Autoit Wiki 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