httpget handshake_failure

new BookmarkLockedFalling
metro
Full Member
***

metro Avatar

Posts: 207

Post by metro on Sept 20, 2017 5:42:34 GMT -5

this code works with LB4.5.0
but fails with RB1.01 Build 2.44 I'm sure it was working for me
and wonder if the problem is with yahoo.
any chance someone can run it on their system
thanks in advance

on error goto [httpGetError]
print "Please Wait fetching data..."
doc1$ = httpget$("http://finance.yahoo.com/d/quotes.csv?s=STO.AX&f=sp")
print "Retrieved "; len(doc1$); " characters."
print doc1$
wait
[httpGetError]
print "Error fetching HTTP document."
print "Error description: "; Err$

Last Edit: Sept 20, 2017 5:58:46 GMT -5 by metro
Intel Core2 QUAD CPU @2.54 x 4 Mint Linux 19.3 Mate
meerkat
Senior Member
****

meerkat Avatar

Posts: 250

neal
Full Member
***

neal Avatar

Posts: 104

metro
Full Member
***

metro Avatar

Posts: 207

Intel Core2 QUAD CPU @2.54 x 4 Mint Linux 19.3 Mate
metro
Full Member
***

metro Avatar

Posts: 207

Post by metro on Sept 22, 2017 7:15:00 GMT -5

back for more advice, to get over the problem with httpget$
I've created a small *.exe using LB4.5 . that's now created another
issue for me , is there a way of "SHELL"ing to the exe and stopping
a window from popping up.
I have used nomainwin in the *.exe but no luck

thanks in advance

update: lastyahooprice.bat
this works but adds another layer is there a better way
cmd /c START /min lastyahooprice.exe
WGET seems like an option

Last Edit: Sept 22, 2017 7:51:54 GMT -5 by metro
Intel Core2 QUAD CPU @2.54 x 4 Mint Linux 19.3 Mate
meerkat
Senior Member
****

meerkat Avatar

Posts: 250

Post by meerkat on Sept 22, 2017 9:49:46 GMT -5

I tried this for 3 stocks.
html "<A HREF='http://finance.yahoo.com/d/quotes.csv?s=AAPL+GOOG+MSFT&f=nab'>Quote</A>"

Then I open "quotes.csv" for input.

For the fun of it I'm going to select a stock, place it in a DB and try some forecast models.
I already showed how to do least squares against a DB on the LB site..

Hope this helps.
Dan

Last Edit: Sept 22, 2017 9:50:17 GMT -5 by meerkat
metro
Full Member
***

metro Avatar

Posts: 207

Post by metro on Sept 23, 2017 7:10:20 GMT -5

Thanks Dan,
as I update 70 stocks each day I've decided to stick with WGET on my Linux machine
and the LB4.5.exe on windows.


For the fun of it I'm going to select a stock, place it in a DB and try some forecast models.
I already showed how to do least squares against a DB on the LB site..


I'm keen to what you do with this, now that Yahoo have abandoned historical data through their finance API
its a bit more time consuming to get historical data.

Which is fine for what I do, as I'm trading options on our Australian Index (ASX200)
I now only need to add to the DB at the end of each trading day historical data is already stored!

I'll re-read your post on the Liberty forum and try and understand it!

Last Edit: Sept 23, 2017 7:12:10 GMT -5 by metro
Intel Core2 QUAD CPU @2.54 x 4 Mint Linux 19.3 Mate
meerkat
Senior Member
****

meerkat Avatar

Posts: 250

Post by meerkat on Sept 23, 2017 9:09:42 GMT -5

All least squares fit does is try to make a straight line out of a bunch of data points (x,y).
Least Squares Fit

For example suppose you had a DB with the following info.
create table stocks (
ticker varchar(5),
ticDate date,
price decimal(8,2)
)
The x,y would be ticDate,price. to get the equation of the line for any date and price you could use strftime('%s',ticDate)/86400 as x and price as y. Now given any date (converted to days since 1970) you can predict a price.
You could also try to see if there is a relation to day of week using strftime('%w',ticDate), month, week, or any 2 x,y you decide.
SQLite Date Conversion

The only problem with least squares fit is that it gives you a straight line and it may not fit a particular stock. There are other methods, but this is probably the best. And you can always use combinations of days since 1970 and week if the stock wonders up and down by week.

Give it a try..
Dan
meerkat
Senior Member
****

meerkat Avatar

Posts: 250

Post by meerkat on Oct 13, 2017 5:20:26 GMT -5

Made some changes, corrected some bugs, added some stuff.
When adding a DB I shell out to the OS to select your DB from a directory. In windows it's DIR c:\*.* for root.

Not having a UNIX system, can someone show me what the directory looks like. I was using LS/LA to start. Is that correct.
Or make the changes to the code and post them so I can add it to the program.

Thanks for the help

Download the program at ionSQL Go to the RunBasic directory and download the ionSQL.zip file.
Last Edit: Oct 13, 2017 5:22:47 GMT -5 by meerkat
meerkat
Senior Member
****

meerkat Avatar

Posts: 250

Post by meerkat on Jan 15, 2018 7:42:29 GMT -5

Have you tried to get your stock quotes from Google. Seems to be a little easier.
I'm going to try some analysis on some of this stuff and see what I get..
Give it a try.. You may make millions.


a$ = httpGet$("http://finance.google.com/finance/historical?output=csv&q=AAPL")
sqliteconnect #mem, ":memory:"
mem$ = "CREATE TABLE market (mrkDate date,opn decimal(8,2),high decimal(8.2), low decimal(8,2), mktClose decimal(8.2), vol int(10))"
#mem execute(mem$)
mth$ = "JanFebMarAprMayJunJulAugSepOctNovDec"
T$ = chr$(9)
j = 1

for i = 1 to len(a$)
k = instr(a,ドルchr$(10),j)
if k < 1 then exit for
x$ = mid$(a,ドルj,k-j)
if x$ = "" then exit for
if i > 1 then ' skip first line header
m = instr(x,ドル",") ' convert date to yyyy-mm-dd
d$ = left$(x,ドルm-1)
dd$ = right$("0";word$(d,1,ドル"-"),2)
mmm$ = word$(d,2,ドル"-")
mm = instr(mth,ドルmmm$)
mm = (mm + 2) / 3
mm$ = right$("0";mm,2)
yyyy$ = "20";word$(d,3,ドル"-")
d1$ = yyyy$;"-";mm$;"-";dd$
x$ = "'";d1$;"'";mid$(x,ドルm)
mem$ = "INSERT INTO market VALUES(";x$;")"
#mem execute(mem$)
end if
j = k + 1
next i

print " ------------------- day of week average ------------------------------"

mem$ = "SELECT strftime('%w',mrkDate) as dow,
*,
avg(opn) as opn,
avg(high) as high,
avg(low) as low,
avg(mktClose) as mktClose,
avg(vol) as vol
FROM market
GROUP BY strftime('%w',mrkDate)"
#mem execute(mem$)
rows = #mem rowcount()

for i = 1 to rows
#row = #mem #nextrow()
dow$ = #row dow$()
gosub [getMarketData]

print i;T$;dow$;T$;opn;T$;high;T$;low;T$;mktClose;T$;vol
next i

print "------------------ for days from today ------------------------------"
mem$ = "SELECT round(julianday('now') - julianday(mrkDate),0) as julDay,* FROM market"
#mem execute(mem$)
rows = #mem rowcount()

for i = 1 to rows
#row = #mem #nextrow()
julDay$ = #row julDay$()
gosub [getMarketData]

print i;T$;julDay$;T$;mrkDate$;T$;opn;T$;high;T$;low;T$;mktClose;T$;vol
next i

print "------------------- for day of week -----------------------------"
mem$ = "SELECT *,strftime('%w',mrkDate) as dow FROM market"
#mem execute(mem$)
rows = #mem rowcount()

for i = 1 to rows
#row = #mem #nextrow()
dow$ = #row dow$()
gosub [getMarketData]

print i;T$;dow$;T$;mrkDate$;T$;opn;T$;high;T$;low;T$;mktClose;T$;vol
next i
end

[getMarketData]
mrkDate$ = #row mrkDate$()
opn = #row opn()
high = #row high()
low = #row low()
mktClose = #row mktClose()
vol = #row vol()
RETURN
Last Edit: Jan 15, 2018 11:11:12 GMT -5 by meerkat
metro
Full Member
***

metro Avatar

Posts: 207

Post by metro on Jan 15, 2018 18:14:13 GMT -5

G'day Dan.
thanks for the code.
I've found the best way to make a small fortune on the stock market is to start with a big one. :)

It would seem Google are not giving the same historical data to us Aussies
"q=ASX:BHP" does not work and I cant find any API that helps

however using the ASX: exchange in the address bar will display other info on Australian stocks

thanks for taking the time

Laurie

Last Edit: Jan 15, 2018 18:14:58 GMT -5 by metro
Intel Core2 QUAD CPU @2.54 x 4 Mint Linux 19.3 Mate
metro
Full Member
***

metro Avatar

Posts: 207

Intel Core2 QUAD CPU @2.54 x 4 Mint Linux 19.3 Mate
metro
Full Member
***

metro Avatar

Posts: 207

Intel Core2 QUAD CPU @2.54 x 4 Mint Linux 19.3 Mate
metro
Full Member
***

metro Avatar

Posts: 207

Post by metro on May 3, 2019 21:35:50 GMT -5

Good to see Carl dropping by again from time to time!

I'm guessing that you are either too busy with lb5 or having trouble locating
your code for the current release of runbasic Carl to look at solving this..

I'll try getting around this problem with httpget$() using libertybasic4.5.1

good luck with the workload
Intel Core2 QUAD CPU @2.54 x 4 Mint Linux 19.3 Mate