You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
AQuery/tests/best_profit.a

46 lines
1.3 KiB

-- please run datagen.get_stock_data() to generate data/stock.csv first
create table ticks(ID varchar(10), timestamp int, tradeDate date, price int);
LOAD DATA INFILE "data/stock.csv"
INTO TABLE ticks
FIELDS TERMINATED BY ","
SELECT max(price-mins(price))
FROM ticks ASSUMING ASC timestamp
WHERE ID="S"
AND tradeDate='2003-01-10'
create table base(ID varchar(10), name varchar(10));
LOAD DATA INFILE "data/base.csv"
INTO TABLE base
FIELDS TERMINATED BY ","
SELECT last(price)
FROM ticks t, base b
ASSUMING ASC name, ASC timestamp
WHERE t.ID=b.ID
AND name="x"
create table TradedStocks(ID varchar(15), SeqNo int, TradeDate date, TimeStamp time, Type varchar(5));
create table HistoricQuotes(ID varchar(15), TradeDate date, HighPrice real, LowPrice real, ClosePrice real, OpenPrice real, volume bigint);
LOAD DATA INFILE "data/tick-price-file.csv"
INTO TABLE TradedStocks
FIELDS TERMINATED BY "|"
LOAD DATA INFILE "data/hist-price-file.csv"
INTO TABLE HistoricQuotes
FIELDS TERMINATED BY "|"
select distinct ID, TradeDate
into td
from TradedStocks
-- -- Monetdb wont recognize right table when
-- -- doing a natural join
SELECT ID, avgs(10, ClosePrice)
FROM td NATURAL JOIN
HistoricQuotes hq
ASSUMING ASC TradeDate
GROUP BY hq.ID