Sign in to follow this  
Followers 0
Medic873

Pull Stock Data

4 posts in this topic

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

#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);

Share this post


Link to post
Share on other sites



#3 ·  Posted (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 by boththose

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

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);

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0