home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga MA Magazine 1997 #3
/
amigamamagazinepolishissue03-1
/
polski_aminet
/
tomasz_janeczko
/
amibroker190e
/
rexx
/
telestock
/
telestock.rexx
< prev
Wrap
OS/2 REXX Batch file
|
1996-10-22
|
4KB
|
142 lines
/* ARexx-Program to read Telestock quotings into Amibroker
* (C) 4'96 by M.Baumeister (baumeister@informatik.rwth-aachen.de)
* may be used freely by anyone
* may be distributed with Amibroker
* may not be sold or otherwise comercialized
*
* Several small improvements by Tomasz Janeczko
* October 22nd, 1996
* (By the way: Big thanks for this script, Markus !!! )
*/
/* Synopsis:
*
* rx telestock.rexx <filename>
*
* where <filename> is the name of the file containing the quotings
*
* It needs an additional file named 'names' containg the translation table
* from telestock-symbols to Amibroker names
*/
OPTIONS RESULTS
ARG filename
ADDRESS REXX
/* Open translation file */
OPEN(.Aktiennamen,'names','R')
IF( result>0 ) THEN OPEN(.Aktiennamen,'rexx/telestock/names','R')
/* Open quotes file */
OPEN(.Aktienwerte,filename,'R')
IF( result>0 ) THEN OPEN(.Aktienwerte,'rexx/telestock/'filename,'R')
/* read symbols and build an associative map */
longname.=""
DO UNTIL EOF(.Aktiennamen)
line=READLN(.Aktiennamen)
PARSE VAR line name kuerzel .
longname.kuerzel=name
end
CLOSE(.Aktiennamen)
ADDRESS 'AMIBROKER.1' 'REQUEST BODY "Telestock import script|(C)1996 Markus Baumeister|Enhanced by Tomasz Janeczko"'
/* read quotes */
DO UNTIL EOF(.Aktienwerte)
/* skip any rubbisch */
DO UNTIL EOF(.Aktienwerte)
line=readln(.Aktienwerte)
if(index(line,'---------------------')>0) then BREAK
end
/* After the '-------' line we know we have to ignore 3 lines */
DO 3 UNTIL EOF(.Aktienwerte)
dummy=readln(.Aktienwerte)
end
/* try to identify EOF (doesn't work really) */
DO UNTIL EOF(.Aktienwerte)
line=readln(.Aktienwerte)
if(length(line)>10) then break
END
if EOF(.Aktienwerte) then break
/* parse the line containing the symbol of the stock */
/* "BAY .f" -> kuerzela="BAY", kuerzelb=".f" */
PARSE VAR line . 6 kuerzela 10 kuerzelb .
kuerzela=COMPRESS(kuerzela)
kuerzel=kuerzela || kuerzelb
/* find the Amibroker name */
name=longname.kuerzel
if(name="") then
DO
say 'Werte der Aktie' kuerzel 'können nicht eingefügt werden, da dieses'
say 'Kürzel unbekannt ist'
END
else
/* read the supplied qoutings */
CALL readaktie(name)
END
exit
readaktie:
PROCEDURE
PARSE ARG name
/* again 3 lines must be ignored */
DO 3 UNTIL EOF(.Aktienwerte)
dummy=readln(.Aktienwerte)
end
IF EOF(.Aktienwerte) THEN RETURN
say 'Stock' name 'is inserted'
/* add stock if it doesn't exist in the database */
ADDRESS 'AMIBROKER.1' 'ASK STOCK="'name'"'
IF( result = 0 ) THEN ADDRESS 'AMIBROKER.1' 'ADDSTOCK' '"'name'"' 'CONT'
/* read each quoting line */
DO UNTIL EOF(.Aktienwerte)
line=readln(.Aktienwerte)
if(length(line)<10) then BREAK
/* due to problems with the "Save to Text" routine of netscape
* when saving telestock quotings with 4 pre-comma digits
* we can't depemd on ' ' between the different quote-entries (i.e.
* high, low, ...). So we have to parse it by hand using the
* position.
* THIS IS DANGEROUS!
* Any change in netscape or telestock can provoke the need to
* change these lines
*/
parse var line . 7 date +10 open1 '.' open2 high1 '.' high2 low1 ,
'.' low2 close1 '.' close2 +3 . +9 volume .
date=substr(date,3) /* remove century */
/* translate '-' (i.e. not available) to 0 */
if(~ DATATYPE(volume,NUMERIC)) then volume = 0
volume=trunc(volume+0.5) /* make volume an integer */
/* say open1 high1 low1 close1 close2 volume */
close=close1+close2/1000
open=open1+open2/1000
high=high1+high2/1000
low=low1+low2/1000
say close
if(volume>0) then
ADDRESS 'AMIBROKER.1' 'ADDQUOTATION' '"'name'"' date 'CLOSE=' || close 'volume='|| volume 'OPEN=' || open 'HIGH='|| high 'LOW='|| low
else
ADDRESS 'AMIBROKER.1' 'ADDQUOTATION' '"'name'"' date 'CLOSE=' || close 'OPEN=' || open 'HIGH='|| high 'LOW='|| low
if(RC>0) then
do
say 'Error with AmiBroker:' RC
say 'on quote' date volume close open high low
end
end
return