CREATE DATABASE millistream;
\c millistream

CREATE TABLE corporateactions
(
  "insref" numeric(20) NOT NULL,
  "type" smallint NOT NULL,
  "subtype" smallint,
  "dividend" double precision,
  "netdividend" double precision,
  "adjustmentfactor" double precision,
  "numberofshares" numeric(20),
  "numberofprefshares" numeric(20),
  "numberofsharesdelta" numeric(20),
  "newshares" double precision,
  "oldshares" double precision,
  "subscriptionprice" double precision,
  "redemptionprice" double precision,
  "period" character varying(19),
  "fiscalperiod" character varying(19),
  "nominalvalue" double precision,
  "recorddate" date,
  "paymentdate" date,
  "announcementdate" date,
  "tid" double precision,
  "closeprice" double precision,
  "issuecurrency" character varying(4),
  "tradecurrency" character varying(4),
  "freetextcomment1" character varying(255),
  "freetextcomment2" character varying(255),
  "freetextcomment3" character varying(255),
  "freetextcomment4" character varying(255),
  "freetextcomment5" character varying(255),
  "underlyingid" character varying(255),
  "symbol" character varying(255),
  "name" character varying(255),
  "isin" character(12),
  "boardlot" integer,
  "marketplace" numeric(20),
  "list" character varying(255),
  "votingpowerprc" double precision,
  "capitalprc" double precision,
  "mcap" double precision,
  "eventlink" character(36),
  "eventlinklanguages" character varying(255),
  "eventstatus" smallint,
  "shareclass" character varying(4),
  "lastmodified" timestamp without time zone,
  "date" date NOT NULL, 
  "time" time without time zone NOT NULL,
  CONSTRAINT corporateactions_pkey PRIMARY KEY ("insref","date","time")
);

CREATE INDEX idx_corporateactionsindex1 ON corporateactions ("insref","type","date");
CREATE INDEX idx_corporateactionsindex2 ON corporateactions ("insref","type","subtype","date");

CREATE TABLE instruments
(
  "insref" numeric(20) NOT NULL,
  "symbol" character varying(50),
  "isin" character(12),
  "name" character varying(255),
  "sourcename" character varying(255),
  "boardlot" integer,
  "instrumenttype" smallint,
  "instrumentsubtype" smallint,
  "instrumentclass" smallint,
  "instrumentsubclass" character varying(30),
  "instrumentsubsubclass" character varying(120),
  "derivativeindicator" smallint,
  "exercisetype" smallint,
  "issuecurrency" character varying(4),
  "tradecurrency" character varying(4),
  "basecurrency" character varying(4),
  "quotecurrency" character varying(4),
  "issuedate" date,
  "strikedate" date,
  "strikeprice" double precision,
  "marketplace" numeric(20),
  "primarymarketplace" numeric(20),
  "primaryshare" numeric(20),
  "submarket" numeric(20),
  "company" numeric(20),
  "fundppmcode" integer,
  "fundpmicode" character varying(11),
  "fundcompany" numeric(20),
  "country" character(2),
  "freetextcomment" character varying(255),
  "numberofshares" numeric(20),
  "numberofprefshares" numeric(20),
  "nominalvalue" double precision,
  "mic" character(5),
  "operatingmic" character(5),
  "sector" numeric(20),
  "tradestate" smallint,
  "tradestateactions" smallint,
  "chairman" character varying(60),
  "ceo" character varying(255),
  "website" character varying(255),
  "orgnum" character varying(11),
  "orgnum_no" numeric(9),
  "cvr" integer,
  "y_tunnus" character varying(9),
  "kennitala" numeric(10),
  "cik" numeric(10),
  "shortdescription" text,
  "description" text,
  "genderceo" character(1),
  "genderchairman" character(1),
  "birthyearceo" smallint,
  "birthyearchairman" smallint,
  "address" character varying(255),
  "postalcode" character varying(255),
  "city" character varying(50),
  "telephone" character varying(40),
  "fax" character varying(40),
  "email" character varying(255),
  "importantevents" text,
  "contractsize" double precision,
  "baseratio" double precision,
  "sourceid" character varying(32),
  "issuer" character varying(255),
  "issuername" character varying(255),
  "ongoingcharge" double precision,
  "fundyearlymgmtfee" double precision,
  "fundppmfee" double precision,
  "fundleverage" double precision,
  "funddirection" character varying(5),
  "fundbenchmark" character varying(255),
  "fundbenchmarkinsref" numeric(20),
  "fundppmtype" character varying(255),
  "fundrisk" smallint,
  "prospectus" text,
  "geofocusregion" character varying(20),
  "geofocuscountry" character varying(20),
  "openinterest" double precision,
  "geniumid" integer,
  "cusip" character varying(9),
  "wkn" character varying(6),
  "ucits" smallint,
  "inceptiondate" date,
  "barrierprice" double precision,
  "ceoadmissiondate" date,
  "chairmanadmissiondate" date,
  "coupondate" date,
  "couponrate" double precision,
  "couponfrequency" smallint,
  "fundmcap" double precision,
  "fundminadditionalamount" double precision,
  "fundminstartamount" double precision,
  "fundminsubscriptionamount" double precision,
  "fundperformancefee" double precision,
  "purchasefee" double precision,
  "salesfee" double precision,
  "totalfee" double precision,
  "morningstarrating" smallint,
  "tradedthroughdate" date,
  "dividendtype" smallint,
  "dividendfrequency" smallint,
  "pricingfrequency" smallint,
  "eusipa" integer,
  "convertfromdate" date,
  "converttodate" date,
  "conversionprice" double precision,
  "specialcondition" integer,
  "settlementtype" smallint,
  "votingpower" double precision,
  "cap" double precision,
  "pricetype" smallint,
  "volumedimension" smallint,
  "quotingtype" smallint,
  "asiantailstart" date,
  "asiantailend" date,
  "logotype" text,
  "ticktable" numeric(20),
  "contractvalue" double precision,
  "financinglevel" double precision,
  "unitlinkcompany" character varying(255),
  "participationrate" double precision,
  "issueprice" double precision,
  "fiinstitutenumber" numeric(20),
  "kiid" text,
  "cfi" character(6),
  "maxlevel" double precision,
  "outstandingamount" double precision,
  "interestrate" double precision,
  "marketmaker" character varying(255),
  "marketopendays" integer,
  "marketopen" time without time zone,
  "marketclose" time without time zone,
  "marketearlyclose" time without time zone,
  "legalstructure" character varying(255),
  "productcode" character varying(20),
  "latestyearendreport" character varying(4),
  "csr" double precision,
  "activeshare" double precision,
  "trackingerror" double precision,
  "figi" character varying(12),
  "figicomposite" character varying(12),
  "figishareclass" character varying(12),
  "figisecuritytype" character varying(40),
  "daycountconvention" smallint,
  "expirationtype" smallint,
  "tenor" character varying(5),
  "swingfactor" double precision,
  "swingfactorsub" double precision,
  "swingmethod" smallint,
  "clearing" character varying(255),
  "applicablenav" character varying(10),
  "fundcutofftime" character varying(20),
  "shareclass" character varying(4),
  "lastmodified" timestamp without time zone,
  "time" time without time zone,
  "date" date,
  CONSTRAINT instruments_pk PRIMARY KEY ("insref")
);

CREATE TABLE listmappings
(
  "list" numeric(20) NOT NULL,
  "insref" numeric(20) NOT NULL,
  CONSTRAINT listmappings_pk PRIMARY KEY ("list","insref")
);
CREATE INDEX idx_listmappings ON listmappings ("insref");

CREATE TABLE news
(
  "newsref" numeric(20) NOT NULL,
  "headline" character varying(255) NOT NULL,
  "text" text,
  "newstype" smallint,
  "subject" smallint,
  "regulatory" smallint,
  "language" character(2),
  "newsid" character(36) NOT NULL,
  "groupid" character(36),
  "replaces" character(36),
  "originalcode" character varying(255),
  "rank" smallint,
  "impact" smallint,
  "package" numeric(20),
  "lastmodified" timestamp without time zone,
  "time" time without time zone NOT NULL,
  "date" date NOT NULL,
  CONSTRAINT news_pk PRIMARY KEY ("newsid")
);

CREATE INDEX idx_news ON news ("newsref","date");

CREATE TABLE orderbooks
(
  "insref" numeric(20) NOT NULL,
  "price" double precision NOT NULL,
  "quantity" double precision,
  "side" character(1) NOT NULL,
  "numorders" smallint,
  "counterparties" character varying(255),
  "mmo" smallint,
  "time" time without time zone NOT NULL,
  "date" date NOT NULL,
  CONSTRAINT orderbook_pk PRIMARY KEY ("insref","price","side")
);

CREATE TABLE mbo
(
  "insref" numeric(20) NOT NULL,
  "id" numeric(20) NOT NULL,
  "id_source" character varying(255),
  "side" smallint,
  "priority" numeric(20),
  "price" double precision,
  "quantity" double precision,
  "participant" character varying(255),
  "mmo" smallint,
  "time" time without time zone NOT NULL,
  "date" date NOT NULL,
  CONSTRAINT mbo_pk PRIMARY KEY ("insref","id")
);

CREATE TABLE pricehistory
(
  "insref" numeric(20) NOT NULL,
  "type" smallint,
  "closebidprice" double precision,
  "closeaskprice" double precision,
  "closetradeprice" double precision,
  "closeprice" double precision,
  "closedayhighprice" double precision,
  "closedaylowprice" double precision,
  "closequantity" numeric(20,0),
  "closeinternalquantity" numeric(20,0),
  "closeoffbookquantity" numeric(20,0),
  "closedarkquantity" numeric(20,0),
  "closeturnover" numeric(38,7),
  "closeinternalturnover" numeric(38,7),
  "closeoffbookturnover" numeric(38,7),
  "closedarkturnover" numeric(38,7),
  "openprice" double precision,
  "numtrades" numeric(20),
  "openyield" double precision,
  "closebidyield" double precision,
  "closeaskyield" double precision,
  "closeyield" double precision,
  "closedayhighyield" double precision,
  "closedaylowyield" double precision,
  "closenav" double precision,
  "closetis" double precision,
  "closevwap" double precision,
  "mcap" numeric(38,7),
  "settlementprice" double precision,
  "lastmodified" timestamp without time zone,
  "time" time without time zone NOT NULL,
  "date" date NOT NULL,
  CONSTRAINT pricehistory_pk PRIMARY KEY ("insref", "date")
);

CREATE TABLE adjustedpricehistory
(
  "insref" numeric(20) NOT NULL,
  "type" smallint,
  "closebidprice" double precision,
  "closeaskprice" double precision,
  "closetradeprice" double precision,
  "closeprice" double precision,
  "closedayhighprice" double precision,
  "closedaylowprice" double precision,
  "closequantity" numeric(20,0),
  "closeinternalquantity" numeric(20,0),
  "closeoffbookquantity" numeric(20,0),
  "closedarkquantity" numeric(20,0),
  "closeturnover" numeric(38,7),
  "closeinternalturnover" numeric(38,7),
  "closeoffbookturnover" numeric(38,7),
  "closedarkturnover" numeric(38,7),
  "openprice" double precision,
  "numtrades" numeric(20),
  "openyield" double precision,
  "closebidyield" double precision,
  "closeaskyield" double precision,
  "closeyield" double precision,
  "closedayhighyield" double precision,
  "closedaylowyield" double precision,
  "closenav" double precision,
  "closetis" double precision,
  "closevwap" double precision,
  "settlementprice" double precision,
  "mcap" numeric(38,7),
  "lastmodified" timestamp without time zone,
  "time" time without time zone NOT NULL,
  "date" date NOT NULL,
  CONSTRAINT adjustedpricehistory_pk PRIMARY KEY ("insref", "date")
);

CREATE TABLE quotes
(
  "insref" numeric(20) NOT NULL,
  "bidprice" double precision,
  "bidquantity" double precision,
  "askprice" double precision,
  "askquantity" double precision,
  "lastprice" double precision,
  "dayhighprice" double precision,
  "daylowprice" double precision,
  "quantity" numeric(20,0),
  "internalquantity" numeric(20,0),
  "offbookquantity" numeric(20,0),
  "darkquantity" numeric(20,0),
  "turnover" numeric(38,7),
  "internalturnover" numeric(38,7),
  "offbookturnover" numeric(38,7),
  "darkturnover" numeric(38,7),
  "numtrades" numeric(20,0),
  "openprice" double precision,
  "bidyield" double precision,
  "askyield" double precision,
  "lastyield" double precision,
  "openyield" double precision,
  "dayhighyield" double precision,
  "daylowyield" double precision,
  "nav" double precision,
  "tis" double precision,
  "unchangedpaid" integer,
  "pluspaid" integer,
  "minuspaid" integer,
  "vwap" double precision,
  "duration" double precision,
  "settlementprice" double precision,
  "time" time without time zone,
  "date" date,
  CONSTRAINT quotes_pk PRIMARY KEY ("insref")
);

CREATE TABLE quotesex
(
  "insref" numeric(20) NOT NULL,
  "bidprice" double precision,
  "bidquantity" double precision,
  "askprice" double precision,
  "askquantity" double precision,
  "lastprice" double precision,
  "dayhighprice" double precision,
  "daylowprice" double precision,
  "quantity" numeric(20,0),
  "turnover" numeric(38,7),
  "numtrades" numeric(20,0),
  "time" time without time zone,
  "date" date,
  CONSTRAINT quotesex_pk PRIMARY KEY ("insref")
);

CREATE TABLE stats
(
  "name" character varying(255) NOT NULL,
  "value" character varying(255) NOT NULL,
  CONSTRAINT stats_pk PRIMARY KEY ("name")
);

CREATE TABLE trades
(
  "insref" numeric(20) NOT NULL,
  "tradeprice" double precision,
  "tradeyield" double precision,
  "tradequantity" double precision,
  "tradereference" character varying(255) NOT NULL,
  "tradecode" integer NOT NULL,
  "mmt" character(14),
  "tradetype" character varying(10),
  "buyer" character varying(64),
  "seller" character varying(64),
  "executedside" character(1),
  "canceltime" time without time zone,
  "agreementtime" time without time zone,
  "agreementdate" date,
  "executionvenue" character varying(255),
  "currency" character varying(4),
  "time" time without time zone NOT NULL,
  "date" date NOT NULL,
  CONSTRAINT trades_pk PRIMARY KEY ("insref","date","tradereference")
);

CREATE TABLE fundamentals (
  "insref" numeric(20) NOT NULL,
  "sales" double precision,
  "ebit" double precision,
  "ebita" double precision,
  "ebitda" double precision,
  "financialincome" double precision,
  "financialcost" double precision,
  "ptp" double precision,
  "np" double precision,
  "eps" double precision,
  "eps_ttm" double precision,
  "eps_last" double precision,
  "dilutedeps" double precision,
  "netfinancialincome" double precision,
  "equityratio" double precision,
  "numberofshares" double precision,
  "operatingcashflow" double precision,
  "gp" double precision,
  "intangibleasset" double precision,
  "goodwill" double precision,
  "fixedasset" double precision,
  "financialasset" double precision,
  "noncurrentasset" double precision,
  "inventory" double precision,
  "othercurrentasset" double precision,
  "accountsreceivable" double precision,
  "otherreceivables" double precision,
  "shortterminv" double precision,
  "cce" double precision,
  "currentassets" double precision,
  "totalassets" double precision,
  "shequity" double precision,
  "minorityinterest" double precision,
  "provisions" double precision,
  "ltliabilities" double precision,
  "curliabilities" double precision,
  "totsheqliabilities" double precision,
  "nibl" double precision,
  "ibl" double precision,
  "cashflowbwc" double precision,
  "cashflowawc" double precision,
  "cashflowia" double precision,
  "cashflowfa" double precision,
  "cashflowtotal" double precision,
  "fcff" double precision,
  "netinterestincome" double precision,
  "interestincome" double precision,
  "otherfinancialincome" double precision,
  "interestexpense" double precision,
  "otherfinancialexpense" double precision,
  "minorityinterestres" double precision,
  "capex" double precision,
  "rouamortization" double precision,
  "accountspayable" double precision,
  "eventlink" character(36),
  "eventlinklanguages" character varying(255),
  "numemployees" double precision,
  "dividend" double precision,
  "incomepropman" double precision,
  "period" character varying(7) NOT NULL,
  "fiscalperiod" character(19),
  "currency" character(3) NOT NULL,
  "adjustmentfactor" double precision,
  "source" character(15) NOT NULL default 'Millistream',
  "date" date NOT NULL,
  "announcementdate" date,
  "dy" double precision,
  "per_ttm" double precision,
  "per_last" double precision,
  "psr_ttm" double precision,
  "psr_last" double precision,
  "pbr" double precision,
  "pcf_ttm" double precision,
  "pcf_last" double precision,
  "sps_ttm" double precision,
  "sps_last" double precision,
  "bvps" double precision,
  "cfps_ttm" double precision,
  "cfps_last" double precision,
  "roe_ttm" double precision,
  "roe_last" double precision,
  "roa_ttm" double precision,
  "roa_last" double precision,
  "gm" double precision,
  "gm_ttm" double precision,
  "om" double precision,
  "om_ttm" double precision,
  "pm" double precision,
  "pm_ttm" double precision,
  "der" double precision,
  "nd_ebitda_ttm" double precision,
  "nd_ebitda_last" double precision,
  "dpr" double precision,
  "roic_ttm" double precision,
  "roic_last" double precision,
  "peg_ttm" double precision,
  "peg_last" double precision,
  "closeprice" double precision,
  "lastmodified" timestamp without time zone,
  CONSTRAINT fundamentals_pk PRIMARY KEY ("insref","period","currency","source")
);
CREATE INDEX idx_fundamentals ON fundamentals ("insref","period");

CREATE TABLE estimates (
  "insref" numeric(20) NOT NULL,
  "period" character varying(7) NOT NULL,
  "field" character varying(30) NOT NULL,
  "aspect" character varying(10) NOT NULL,
  "type" character varying(20) NOT NULL,
  "unit" character varying(255),
  "average" double precision,
  "min" double precision,
  "max" double precision,
  "count" integer,
  "currency" character(3) NOT NULL,
  "source" character(15) NOT NULL,
  "lastmodified" timestamp without time zone,
  "date" date NOT NULL,
  "time" time NOT NULL,
  CONSTRAINT estimates_pk PRIMARY KEY ("insref","period","field","aspect","type","currency","source")
);

CREATE TABLE estimateshistory (
  "insref" numeric(20) NOT NULL,
  "period" character varying(7) NOT NULL,
  "field" character varying(30) NOT NULL,
  "aspect" character varying(10) NOT NULL,
  "type" character varying(20) NOT NULL,
  "unit" character varying(255),
  "average" double precision,
  "min" double precision,
  "max" double precision,
  "count" integer,
  "currency" character(3) NOT NULL,
  "source" character(15) NOT NULL,
  "lastmodified" timestamp without time zone,
  "date" date NOT NULL,
  "time" time NOT NULL,
  CONSTRAINT estimateshistory_pk PRIMARY KEY ("insref","date","period","field","aspect","type","currency","source")
);

CREATE TABLE performance (
  "insref" numeric(20) NOT NULL,
  "closebidprice1d" double precision,
  "closebidprice1w" double precision,
  "closeprice" double precision,
  "closeprice1d" double precision,
  "closeprice1w" double precision,
  "closeprice2w" double precision,
  "closeprice1m" double precision,
  "closeprice3m" double precision,
  "closeprice6m" double precision,
  "closeprice9m" double precision,
  "closeprice1y" double precision,
  "closeprice2y" double precision,
  "closeprice3y" double precision,
  "closeprice4y" double precision,
  "closeprice5y" double precision,
  "closeprice6y" double precision,
  "closeprice7y" double precision,
  "closeprice8y" double precision,
  "closeprice9y" double precision,
  "closeprice10y" double precision,
  "closepricewtd" double precision,
  "closepricemtd" double precision,
  "closepriceqtd" double precision,
  "closepriceytd" double precision,
  "closepricepytd" double precision,
  "closepriceld" double precision,
  "closebidyield1d" double precision,
  "closebidyield1w" double precision,
  "closeyield1d" double precision,
  "closeyield1w" double precision,
  "closeyield2w" double precision,
  "closeyield1m" double precision,
  "closeyield3m" double precision,
  "closeyield6m" double precision,
  "closeyield9m" double precision,
  "closeyield1y" double precision,
  "closeyield2y" double precision,
  "closeyield3y" double precision,
  "closeyield4y" double precision,
  "closeyield5y" double precision,
  "closeyield6y" double precision,
  "closeyield7y" double precision,
  "closeyield8y" double precision,
  "closeyield9y" double precision,
  "closeyield10y" double precision,
  "closeyieldwtd" double precision,
  "closeyieldmtd" double precision,
  "closeyieldqtd" double precision,
  "closeyieldytd" double precision,
  "closeyieldpytd" double precision,
  "closeyieldld" double precision,
  "ath" double precision,
  "atl" double precision,
  "highprice1y" double precision,
  "lowprice1y" double precision,
  "highprice3y" double precision,
  "lowprice3y" double precision,
  "highprice5y" double precision,
  "lowprice5y" double precision,
  "highprice10y" double precision,
  "lowprice10y" double precision,
  "highpriceytd" double precision,
  "lowpriceytd" double precision,
  "closepricedate" date,
  "closeprice1ddate" date,
  "athdate" date,
  "atldate" date,
  "highprice1ydate" date,
  "lowprice1ydate" date,
  "highpriceytddate" date,
  "lowpriceytddate" date,
  "athyield" double precision,
  "atlyield" double precision,
  "highyield1y" double precision,
  "lowyield1y" double precision,
  "highyieldytd" double precision,
  "lowyieldytd" double precision,
  "athyielddate" date,
  "atlyielddate" date,
  "highyield1ydate" date,
  "lowyield1ydate" date,
  "highyieldytddate" date,
  "lowyieldytddate" date,
  "diffbid1d" double precision,
  "diffbid1w" double precision,
  "diff1d" double precision,
  "diffex1d" double precision,
  "diff1w" double precision,
  "diff2w" double precision,
  "diff1m" double precision,
  "diff3m" double precision,
  "diff6m" double precision,
  "diff9m" double precision,
  "diff1y" double precision,
  "diff2y" double precision,
  "diff3y" double precision,
  "diff4y" double precision,
  "diff5y" double precision,
  "diff6y" double precision,
  "diff7y" double precision,
  "diff8y" double precision,
  "diff9y" double precision,
  "diff10y" double precision,
  "diffld" double precision,
  "diffwtd" double precision,
  "diffmtd" double precision,
  "diffqtd" double precision,
  "diffytd" double precision,
  "diffpytd" double precision,
  "diffbid1dprc" double precision,
  "diffbid1wprc" double precision,
  "diff1dprc" double precision,
  "diffex1dprc" double precision,
  "diff1wprc" double precision,
  "diff2wprc" double precision,
  "diff1mprc" double precision,
  "diff3mprc" double precision,
  "diff6mprc" double precision,
  "diff9mprc" double precision,
  "diff1yprc" double precision,
  "diff2yprc" double precision,
  "diff3yprc" double precision,
  "diff4yprc" double precision,
  "diff5yprc" double precision,
  "diff6yprc" double precision,
  "diff7yprc" double precision,
  "diff8yprc" double precision,
  "diff9yprc" double precision,
  "diff10yprc" double precision,
  "diffldprc" double precision,
  "diffwtdprc" double precision,
  "diffmtdprc" double precision,
  "diffqtdprc" double precision,
  "diffytdprc" double precision,
  "diffpytdprc" double precision,
  "diffbidyield1d" double precision,
  "diffbidyield1w" double precision,
  "diffyield1d" double precision,
  "diffyield1w" double precision,
  "diffyield2w" double precision,
  "diffyield1m" double precision,
  "diffyield3m" double precision,
  "diffyield6m" double precision,
  "diffyield9m" double precision,
  "diffyield1y" double precision,
  "diffyield2y" double precision,
  "diffyield3y" double precision,
  "diffyield4y" double precision,
  "diffyield5y" double precision,
  "diffyield6y" double precision,
  "diffyield7y" double precision,
  "diffyield8y" double precision,
  "diffyield9y" double precision,
  "diffyield10y" double precision,
  "diffyieldld" double precision,
  "diffyieldwtd" double precision,
  "diffyieldmtd" double precision,
  "diffyieldqtd" double precision,
  "diffyieldytd" double precision,
  "diffyieldpytd" double precision,
  "diffbidyield1dprc" double precision,
  "diffbidyield1wprc" double precision,
  "diffyield1dprc" double precision,
  "diffyield1wprc" double precision,
  "diffyield2wprc" double precision,
  "diffyield1mprc" double precision,
  "diffyield3mprc" double precision,
  "diffyield6mprc" double precision,
  "diffyield9mprc" double precision,
  "diffyield1yprc" double precision,
  "diffyield2yprc" double precision,
  "diffyield3yprc" double precision,
  "diffyield4yprc" double precision,
  "diffyield5yprc" double precision,
  "diffyield6yprc" double precision,
  "diffyield7yprc" double precision,
  "diffyield8yprc" double precision,
  "diffyield9yprc" double precision,
  "diffyield10yprc" double precision,
  "diffyieldldprc" double precision,
  "diffyieldwtdprc" double precision,
  "diffyieldmtdprc" double precision,
  "diffyieldqtdprc" double precision,
  "diffyieldytdprc" double precision,
  "diffyieldpytdprc" double precision,
  "annualizedreturn1y" double precision,
  "annualizedreturn2y" double precision,
  "annualizedreturn3y" double precision,
  "annualizedreturn4y" double precision,
  "annualizedreturn5y" double precision,
  "annualizedreturn10y" double precision,
  "standarddeviation3y" double precision,
  "sharperatio3y" double precision,
  "normanamount" double precision,
  "avgturnover1w" double precision,
  "avgturnover1m" double precision,
  "avgturnover3m" double precision,
  "avgturnover1y" double precision,
  "avgturnover1ytd" double precision,
  "avgturnoverytd" double precision,
  "time" time without time zone,
  "date" date,
  CONSTRAINT performance_pk PRIMARY KEY ("insref")
);

CREATE TABLE keyratios (
  "insref" numeric(20) NOT NULL,
  "dividendyield" double precision,
  "per" double precision,
  "per_ttm" double precision,
  "per_last" double precision,
  "psr" double precision,
  "psr_ttm" double precision,
  "psr_last" double precision,
  "pbr" double precision,
  "pbr_last" double precision,
  "pcf" double precision,
  "pcf_ttm" double precision,
  "pcf_last" double precision,
  "dps" double precision,
  "eps" double precision,
  "eps_ttm" double precision,
  "eps_last" double precision,
  "sps" double precision,
  "sps_ttm" double precision,
  "sps_last" double precision,
  "bvps" double precision,
  "bvps_last" double precision,
  "cfps" double precision,
  "cfps_ttm" double precision,
  "cfps_last" double precision,
  "roe" double precision,
  "roe_ttm" double precision,
  "roe_last" double precision,
  "roa" double precision,
  "roa_ttm" double precision,
  "roa_last" double precision,
  "gm" double precision,
  "gm_ttm" double precision,
  "gm_last" double precision,
  "om" double precision,
  "om_ttm" double precision,
  "om_last" double precision,
  "pm" double precision,
  "pm_ttm" double precision,
  "pm_last" double precision,
  "mcap" double precision,
  "sma20" double precision,
  "sma50" double precision,
  "sma200" double precision,
  "rsi14" double precision,
  "macd" double precision,
  "der" double precision,
  "der_last" double precision,
  "nd_ebitda" double precision,
  "nd_ebitda_ttm" double precision,
  "nd_ebitda_last" double precision,
  "dpr" double precision,
  "roic" double precision,
  "roic_ttm" double precision,
  "roic_last" double precision,
  "peg" double precision,
  "peg_ttm" double precision,
  "peg_last" double precision,
  "pre_peg" double precision,
  "pre_peg_ttm" double precision,
  "pre_peg_last" double precision,
  "time" time without time zone,
  "date" date,
  CONSTRAINT keyratios_pk PRIMARY KEY ("insref")
);

CREATE TABLE greeks (
  "insref" numeric(20) NOT NULL,
  "iv" double precision,
  "ivbid" double precision,
  "ivask" double precision,
  "delta" double precision,
  "gamma" double precision,
  "rho" double precision,
  "theta" double precision,
  "vega" double precision,
  "time" time without time zone,
  "date" date,
  CONSTRAINT greeks_pk PRIMARY KEY ("insref")
);

CREATE TABLE newscoding (
  "newsref" numeric(20) NOT NULL,
  "newsid" character(36) NOT NULL,
  "isin" character(12) NOT NULL,
  "company" numeric(20) NOT NULL,
  "date" date,
  CONSTRAINT newscoding_pk PRIMARY KEY ("newsid","newsref","isin","company")
);
CREATE INDEX idx_newscoding ON newscoding ("isin","newsid");
CREATE INDEX idx_newscoding2 ON newscoding ("company","newsid");

CREATE TABLE newstags (
  "newsref" numeric(20) NOT NULL,
  "newsid" character(36) NOT NULL,
  "tag" character(30) NOT NULL,
  "date" date NOT NULL,
  CONSTRAINT newstags_pk PRIMARY KEY ("newsid","newsref","tag")
);
CREATE INDEX idx_newstags ON newstags ("tag","newsid");

CREATE TABLE noii (
  "insref" numeric(20) NOT NULL,
  "bidprice" double precision,
  "askprice" double precision,
  "bidquantity" double precision,
  "askquantity" double precision,
  "lastprice" double precision,
  "quantity" double precision,
  "imbalance" double precision,
  "direction" smallint NULL,
  "type" smallint NULL,
  "time" time without time zone,
  "date" date,
  CONSTRAINT noii_pk PRIMARY KEY ("insref")
);

CREATE TABLE constituents (
  "insref" numeric(20) NOT NULL,
  "constituent" numeric(20) NOT NULL,
  "weight" double precision,
  "isin" character varying(12),
  "currency" character varying(4),
  CONSTRAINT constituents_pk PRIMARY KEY ("insref","constituent")
);

CREATE INDEX idx_constituents ON constituents ("constituent");

CREATE TABLE ticksize (
  "insref" numeric(20) NOT NULL,
  "threshold" double precision NOT NULL,
  "increment" double precision NOT NULL,
  CONSTRAINT ticksize_pk PRIMARY KEY ("insref","threshold")
);

CREATE TABLE l10n (
  "insref" numeric(20) NOT NULL,
  "language" character(2) NOT NULL,
  "name" character varying(255),
  "shortdescription" text,
  "description" text,
  "importantevents" text,
  "prospectus" text,
  "kiid" text,
  "priipkid" text,
  Past_Performance_Link text,
  Previous_Performance_Scenarios_Calculation_Link text,
  "sustaindescription" text,
  "sustaininvesting1" text,
  "sustaininvesting2" text,
  "sustaindivesting1" text,
  "sustaindivesting2" text,
  "sustaininfluence" text,
  "sustainmonitoring1" text,
  "sustainmonitoring2" text,
  "sustaincomment" text,
  Comprehension_Alert_Portfolio character(1),
  Intended_target_market_retail_investor_Portfolio character varying(4000),
  Investment_objective_Portfolio character varying(8000),
  Risk_narrative_Portfolio character varying(300),
  Other_materially_relevant_risk_narrative_Portfolio character varying(200),
  Type_of_underlying_Investment_Option character varying(300),
  Capital_Guarantee character(1),
  Capital_Guarantee_Level double precision,
  Capital_Guarantee_Limitations character varying(300),
  Capital_Guarantee_Early_Exit_Conditions date,
  Capital_guarantee_Portfolio character varying(2500),
  Possible_maximum_loss_Portfolio double precision,
  Description_Past_Interval_Unfavourable_Scenario character varying(300),
  Description_Past_Interval_Moderate_Scenario character varying(300),
  Description_Past_Interval_Favourable_Scenario character varying(300),
  Portfolio_Performance_Fees_Narrative character varying(300),
  Portolio_Carried_Interest_Narrative character varying(300),
  One_Off_Cost_Portfolio_Entry_Cost_Description character varying(300),
  One_Off_Cost_Portfolio_Exit_Cost_Description character varying(300),
  Ongoing_Costs_Portfolio_Management_Costs_Description character varying(150),
  Cost_Dependence_Explanation character varying(150),
  Other_comment text default NULL,
  "date" date,
  CONSTRAINT l10n_pk PRIMARY KEY ("insref","language")
);

CREATE TABLE brokers (
  "insref" numeric(20) NOT NULL,
  "symbol" character varying(255) NOT NULL,
  "name" character varying(255) NOT NULL,
  CONSTRAINT brokers_pk PRIMARY KEY ("insref","symbol")
);

CREATE TABLE ci (
  "insref" numeric(20) NOT NULL,
  "type" smallint NOT NULL,
  "subtype" smallint,
  "sequence" integer NOT NULL,
  "s1" character varying(255),
  "s2" character varying(255),
  "s3" character varying(255),
  "s4" character varying(255),
  "s5" character varying(255),
  "s6" character varying(255),
  "s7" character varying(255),
  "s8" character varying(255),
  "s9" character varying(255),
  "s10" character varying(255),
  "s11" character varying(255),
  "s12" character varying(255),
  "s13" character varying(255),
  "s14" character varying(255),
  "s15" character varying(255),
  "n1" double precision,
  "n2" double precision,
  "n3" double precision,
  "n4" double precision,
  "n5" double precision,
  "n6" double precision,
  "n7" double precision,
  "n8" double precision,
  "n9" double precision,
  "n10" double precision,
  "i1" integer,
  "i2" integer,
  "i3" integer,
  "i4" integer,
  "i5" integer,
  "i6" integer,
  "i7" integer,
  "i8" integer,
  "i9" integer,
  "i10" integer,
  "insref1" numeric(20),
  "insref2" numeric(20),
  "insref3" numeric(20),
  "insref4" numeric(20),
  "insref5" numeric(20),
  "d1" date,
  "d2" date,
  "d3" date,
  "eventlink" character(36),
  "eventlinklanguages" character varying(255),
  "eventstatus" smallint,
  "lastmodified" timestamp without time zone,
  CONSTRAINT ci_pk PRIMARY KEY ("insref","type","sequence")
);

CREATE TABLE cihistory (
  "insref" numeric(20) NOT NULL,
  "type" smallint NOT NULL,
  "subtype" smallint,
  "sequence" integer NOT NULL,
  "date" date NOT NULL,
  "s1" character varying(255),
  "s2" character varying(255),
  "s3" character varying(255),
  "s4" character varying(255),
  "s5" character varying(255),
  "s6" character varying(255),
  "s7" character varying(255),
  "s8" character varying(255),
  "s9" character varying(255),
  "s10" character varying(255),
  "s11" character varying(255),
  "s12" character varying(255),
  "s13" character varying(255),
  "s14" character varying(255),
  "s15" character varying(255),
  "n1" double precision,
  "n2" double precision,
  "n3" double precision,
  "n4" double precision,
  "n5" double precision,
  "n6" double precision,
  "n7" double precision,
  "n8" double precision,
  "n9" double precision,
  "n10" double precision,
  "i1" integer,
  "i2" integer,
  "i3" integer,
  "i4" integer,
  "i5" integer,
  "i6" integer,
  "i7" integer,
  "i8" integer,
  "i9" integer,
  "i10" integer,
  "insref1" numeric(20),
  "insref2" numeric(20),
  "insref3" numeric(20),
  "insref4" numeric(20),
  "insref5" numeric(20),
  "d1" date,
  "d2" date,
  "d3" date,
  "eventlink" character(36),
  "eventlinklanguages" character varying(255),
  "eventstatus" smallint,
  "lastmodified" timestamp without time zone,
  CONSTRAINT cihistory_pk PRIMARY KEY ("insref","type","sequence","date")
);

CREATE TABLE "priip" (
	insref numeric(20) NOT NULL,
	EPT_Version character varying(3),
	EPT_Producer_Name character varying(255),
	EPT_Producer_Email character varying(255),
	File_Generation_Date_And_Time timestamp without time zone,
	EPT_Data_Reporting_Narratives character(1),
	EPT_Data_Reporting_Costs character(1),
	EPT_Data_Reporting_Additional_Requirements_German_MOPs character(1),
	EPT_Additional_Information_Structured_Products character(1),
	Portfolio_Issuer_Name character varying(255),
	Portfolio_Manufacturer_Group_Name character varying(255),
	Portfolio_Manufacturer_LEI character varying(20),
	Portfolio_Manufacturer_Email character varying(255),
	Portfolio_Guarantor_Name character varying(255),
	Portfolio_Identifying_Data character varying(255),
	Type_Of_Identification_Code_For_The_Fund_Share_Or_Portfolio smallint,
	Portfolio_Name character varying(255),
	Share_Class_Currency character(3),
	Reference_Date date,
	PRIIPs_KID_Web_Address text,
	Portfolio_PRIIPS_Category smallint,
	Fund_CIC_code character(4),
	Is_An_Autocallable_Product character(1),
	EOS_portfolio character(1),
	Valuation_Frequency smallint,
	Portfolio_VEV_Reference double precision,
	IS_Flexible character(1),
	Flex_VEV_Historical double precision,
	Flex_VEV_Ref_Asset_Allocation double precision,
	IS_Risk_Limit_Relevant character(1),
	Flex_VEV_Risk_Limit double precision,
	Existing_Credit_Risk character(1),
	SRI smallint,
	IS_SRI_Adjusted character(1),
	MRM smallint,
	CRM smallint,
	Recommended_Holding_Period double precision,
	Has_A_Contractual_Maturity_Date character(1),
	Maturity_Date date,
	Liquidity_Risk character(1),
	Portfolio_return_unfavorable_scenario_1_year double precision,
	Portfolio_return_unfavorable_scenario_half_RHP double precision,
	Portfolio_return_unfavorable_scenario_RHP double precision,
	Autocall_Applied_Unfavourable_Scenario character(1),
	Autocall_Date_Unfavourable_Scenario date,
	Portfolio_return_moderate_scenario_1_year double precision,
	Portfolio_return_moderate_scenario_half_RHP double precision,
	Portfolio_return_moderate_scenario_RHP double precision,
	Autocall_Applied_Moderate_Scenario character(1),
	Autocall_Date_Moderate_Scenario date,
	Portfolio_return_favorable_scenario_1_year double precision,
	Portfolio_return_favorable_scenario_half_RHP double precision,
	Autocall_Applied_Favourable_Scenario character(1),
	Autocall_Date_Favourable_Scenario date,
	Portfolio_return double precision,
	Portfolio_return_stress_scenario_1_year double precision,
	Portfolio_return_stress_scenario_half_RHP double precision,
	Portfolio_return_stress_scenario_RHP double precision,
	Autocall_Applied_Stress_Scenario character(1),
	Autocall_Date_Stress_Scenario date,
	Portfolio_number_of_observed_return_M0 double precision,
	Portfolio_mean_observed_returns_M1 double precision,
	Portfolio_observed_Sigma double precision,
	Portfolio_observed_Skewness double precision,
	Portfolio_observed_Excess_Kurtosis double precision,
	Portfolio_observed_Stressed_Volatility double precision,
	Portfolio_Past_Performance_Disclosure_Required character(1),
	Past_Performance_Link text,
	Previous_Performance_Scenarios_Calculation_Link text,
	Past_Performance_Number_Of_Years smallint,
	Reference_Invested_Amount double precision,
	One_off_cost_Portfolio_entry_cost double precision,
	One_off_cost_Portfolio_entry_cost_Acquired double precision,
	One_off_costs_Portfolio_exit_cost_at_RHP double precision,
	One_off_costs_Portfolio_exit_cost_at_1_year double precision,
	One_off_costs_Portfolio_exit_cost_at_half_RHP double precision,
	One_off_costs_Portfolio_sliding_exit_cost_Indicator character(1),
	Ongoing_costs_Portfolio_other_costs double precision,
	Ongoing_costs_Portfolio_management_costs double precision,
	Ongoing_costs_Portfolio_transaction_costs double precision,
	Existing_performance_fees character(1),
	Incidental_costs_Portfolio_performance_fees double precision,
	Existing_carried_interest_fees character(1),
	Incidental_costs_Portfolio_carried_interest double precision,
	Reference_Language character(2),
	Comprehension_Alert_Portfolio character(1),
	Intended_target_market_retail_investor_Portfolio character varying(4000),
	Investment_objective_Portfolio character varying(8000),
	Risk_narrative_Portfolio character varying(300),
	Other_materially_relevant_risk_narrative_Portfolio character varying(200),
	Type_of_underlying_Investment_Option character varying(300),
	Capital_Guarantee character(1),
	Capital_Guarantee_Level double precision,
	Capital_Guarantee_Limitations character varying(300),
	Capital_Guarantee_Early_Exit_Conditions date,
	Capital_guarantee_Portfolio character varying(2500),
	Possible_maximum_loss_Portfolio double precision,
	Description_Past_Interval_Unfavourable_Scenario character varying(300),
	Description_Past_Interval_Moderate_Scenario character varying(300),
	Description_Past_Interval_Favourable_Scenario character varying(300),
	Was_Benchmark_Used_Performance_Calculation character(1),
 	Portfolio_Performance_Fees_Narrative character varying(300),
	Portolio_Carried_Interest_Narrative character varying(300),
	One_Off_Cost_Portfolio_Entry_Cost_Description character varying(300),
	One_Off_Cost_Portfolio_Exit_Cost_Description character varying(300),
	Ongoing_Costs_Portfolio_Management_Costs_Description character varying(150),
	Do_Costs_Depend_On_Invested_Amount character(1),
	Cost_Dependence_Explanation character varying(150),
	German_MOPs_Reference_Date date,
	Other_comment text default NULL,
	PRIIP_data_delivery character(1),
	UCITS_data_delivery character(1),
	Portfolio_UCITS_SRRI smallint,
	Portfolio_UCITS_Vol double precision,
	Ongoing_costs_Portfolio_other_costs_UCITS double precision,
	Ongoing_costs_Portfolio_transaction_costs_UCITS double precision,
	Transactions_costs_methodology character varying(255),
	Incidental_costs_Portfolio_performance_fees_UCITS double precision,
	Incidental_costs_Portfolio_carried_interest_UCITS double precision,
	UCITS_KID_Web_Address text default NULL,
	Bonds_Weight double precision,
	Annualized_Return_Volatility double precision,
	Duration_Bonds double precision,
	Existing_Capital_Preservation character(1),
	Capital_Preservation_Level double precision,
	Time_Interval_Maximum_Loss character varying(10),
	Uses_PI character(1),
	Multiplier_PI double precision,
	First_Possible_Call_Date date,
	Total_cost_1_year double precision,
	RIY_1_year double precision,
	Total_cost_half_RHP double precision,
	RIY_half_RHP double precision,
	Total_cost_RHP double precision,
	RIY_RHP double precision,
	One_off_costs_Portfolio_entry_cost_RIY double precision,
	One_off_costs_Portfolio_exit_cost_RIY double precision,
	Ongoing_costs_Portfolio_transaction_costs_RIY double precision,
	Ongoing_costs_Other_ongoing_costs_RIY double precision,
	Incidental_costs_Portfolio_performance_fees_RIY double precision,
	Incidental_costs_Portfolio_carried_interests_RIY double precision,
	p08010 character varying(7),
	p08020 double precision,
	p08030 smallint,
	p08040 double precision,
	p08045 date,
	p08050 date,
	p08060 text,
	p08070 text,
	p08080 text,
	p08090 text,
	p08100 text,
	p08110 text,
	p08120 text,
	p08130 text,
	p08140 double precision,
	p08150 date,
	p08160 text,
	p08170 smallint,
	p08180 double precision,
	p08190 character(1),
	p08200 double precision,
	lastmodified timestamp without time zone,
	CONSTRAINT priip_pk PRIMARY KEY ("insref")
);

CREATE TABLE "mifid" (
	insref numeric(20) NOT NULL,
	fisn character varying(35),
	lei character(20),
	EMT_Version character(4),
	EMT_Producer_Name character varying(255),
	EMT_Producer_LEI character(20),
	EMT_Producer_Email character varying(255),
	File_Generation_Date_and_Time timestamp without time zone,
	EMT_Data_Reporting_Target_Market character(1),
	EMT_Data_Reporting_ExAnte character(1),
	EMT_Data_Reporting_ExPost character(1),
	Financial_Instrument_Identifying_Data character varying(255),
	Type_Of_Identification_Code_For_The_Financial_Instrument smallint,
	Financial_Instrument_Name character varying(255),
	Financial_Instrument_Currency character(3),
	Financial_Instrument_Performance_Fee character(1),
	Financial_Instrument_Distribution_Of_Cash character(1),
	Reporting_Date date,
	Financial_Instrument_Legal_Structure character varying(2),
	m00065 date,
	m00067 character(1),
	Financial_Instrument_Issuer_Name character varying(255),
	Financial_Instrument_Manufacturer_LEI character varying(20),
	Financial_Instrument_Manufacturer_Email character varying(255),
	Financial_Instrument_Manufacturer_Product_Governance_Process character(1),
	Financial_Instrument_Guarantor_Name character varying(255),
	Financial_Instrument_Type_Notional_or_Item_Based character(1),
	Product_Category_or_Nature character varying(255),
	m00096 character(1),
	Structured_Securities_Product_Category_or_Nature integer,
	Structured_Securities_Quotation character(1),
	Leveraged_Financial_Instrument_or_Contingent_LiabilityInstrumen character(1),
	Fund_Share_Class_Without_Retrocession character(1),
	Ex_Post_Cost_Calculation_Basis_Italy character(1),
	Target_Market_Reference_Date date,
	Investor_Type_Retail character(1),
	Investor_Type_Professional character(1),
	Investor_Type_Eligible_Counterparty character(1),
	Basic_Investor character(1),
	Informed_Investor character(1),
	Advanced_Investor character(1),
	Expert_Investor_Germany character(1),
	No_Capital_Loss character(1),
	Limited_Capital_Loss character(1),
	Limited_Capital_Loss_Level double precision,
	No_Capital_Guarantee character(1),
	Loss_Beyond_Capital character(1),
	Risk_Tolerance_PRIIPS_Methodology smallint,
	Risk_Tolerance_UCITS_Metholodology smallint,
	Risk_Tolerance_Internal_Methodology_For_Non_PRIIPS_and_NonUCITS character(1),
	Risk_Tolerance_For_Non_PRIIPS_and_Non_UCITS_Spain smallint,
	Not_For_Investors_With_The_Lowest_Risk_Tolerance_Germany character(1),
	Return_Profile_Preservation character(1),
	Return_Profile_Growth character(1),
	Return_Profile_Income character(1),
	Return_Profile_Hedging character(1),
	Option_or_Leveraged_Return_Profile character(1),
	Return_Profile_Other character(1),
	Return_Profile_Pension_Scheme_Germany character(1),
	Time_Horizon1 character(1),
	Time_Horizon2 double precision,
	m05090 date,
	Maturity_Date date,
	May_Be_Terminated_Early character(1),
	Intended_Compatible_With_Clients_Having_ESG_Preferences character(1),
	Specific_Investment_Need character(1),
	Other_Specific_Investment_Need character(1),
	Execution_Only character(1),
	Execution_With_Appropriateness_Test_Or_Non_Advised_Services character(1),
	Investment_Advice character(1),
	Portfolio_Management character(1),
	OO_Financial_Instrument_entry_cost double precision,
	Net_OO_cost_Financial_Instrument_entry_cost_non_acquired double precision,
	OO_Financial_Instrument_maximum_entry_cost_fixed_amount_Italy double precision,
	OO_Financial_Instrument_maximum_entry_cost_acquired double precision,
	OO_Financial_Instrument_maximum_exit_cost double precision,
	OO_Financial_Instrument_maximum_exit_cost_fixed_amount_Italy double precision,
	OO_Financial_Instrument_maximum_exit_cost_acquired double precision,
	OO_Financial_Instrument_Typical_exit_cost double precision,
	OO_Financial_Instrument_exit_cost_structrd_securities_prior_RHP double precision,
	Financial_Instrument_Ongoing_costs double precision,
	Financial_Instrument_Gearing_costs_ex_ante_UK double precision,
	Financial_Instrument_Management_fee double precision,
	Financial_Instrument_Distribution_fee double precision,
	Financial_Instrument_Transaction_costs_ex_ante double precision,
	Financial_Instrument_Incidental_costs_ex_ante double precision,
	Structured_Securities_Reference_Price_ex_ante double precision,
	Structured_Securities_Notional_Reference_Amount_ex_ante double precision,
	Ex_Ante_Costs_Reference_Date date,
	OO_Structured_Securities_entry_cost_ex_post double precision,
	Net_OO_cost_Structured_Securities_entry_cost_ex_post double precision,
	OO_Structured_Securities_exit_cost_ex_post double precision,
	OO_cost_Financial_Instrument_entry_cost_acquired double precision,
	Financial_Instrument_Ongoing_costs_ex_post double precision,
	Structured_Securities_Ongoing_costs_ex_post_accumulated double precision,
	Financial_Instrument_Borrowing_Costs_Ex_Post_UK double precision,
	Financial_Instrument_Management_fee_ex_post double precision,
	Financial_Instrument_Distribution_fee_ex_post double precision,
	Financial_Instrument_Transaction_costs_ex_post double precision,
	Financial_Instrument_Incidental_costs_ex_post double precision,
	Beginning_Of_Calculation_Period date,
	End_Of_Calculation_Period date,
	Structured_Securities_Reference_Price_ex_post double precision,
	Structured_Securities_Notional_Reference_Amount double precision,
	m09010 double precision,
	m09020 double precision,
	m09030 character(1),
	m09040 character(1),
	m09050 character(1),
	m09060 character(1),
	m09070 character(1),
	m09080 text,
	m09090 date,
	m09100 date,
	m10000 double precision,
	m10010 double precision,
	m10020 double precision,
	m10030 double precision,
	m10040 double precision,
	m10050 double precision,
	m10060 character(1),
	lastmodified timestamp without time zone,
	CONSTRAINT mifid_pk PRIMARY KEY ("insref")
);

CREATE TABLE "mifidhistory" (
	insref numeric(20) NOT NULL,
	Reporting_Date date,
	OO_Structured_Securities_entry_cost_ex_post double precision,
	Net_OO_cost_Structured_Securities_entry_cost_ex_post double precision,
	OO_Structured_Securities_exit_cost_ex_post double precision,
	OO_cost_Financial_Instrument_entry_cost_acquired double precision,
	Financial_Instrument_Ongoing_costs_ex_post double precision,
	Structured_Securities_Ongoing_costs_ex_post_accumulated double precision,
	Financial_Instrument_Borrowing_Costs_Ex_Post_UK double precision,
	Financial_Instrument_Management_fee_ex_post double precision,
	Financial_Instrument_Distribution_fee_ex_post double precision,
	Financial_Instrument_Transaction_costs_ex_post double precision,
	Financial_Instrument_Incidental_costs_ex_post double precision,
	Beginning_Of_Calculation_Period date,
	End_Of_Calculation_Period date,
	Structured_Securities_Reference_Price_ex_post double precision,
	Structured_Securities_Notional_Reference_Amount double precision,
	lastmodified timestamp without time zone,
	CONSTRAINT mifidhistory_pk PRIMARY KEY (insref, Reporting_Date)
);

CREATE TABLE "underlyings" (
	"insref" numeric(20) NOT NULL,
	"isin" character varying(12) NOT NULL,
	"currency" character varying(4),
	CONSTRAINT underlyings_pk PRIMARY KEY ("insref","isin")
);

CREATE INDEX idx_underlyings ON underlyings ("isin");

CREATE TABLE "sectors" (
	"insref" numeric(20) NOT NULL,
	"sector" numeric(20) NOT NULL,
	"marketplace" numeric(20) NOT NULL,
	CONSTRAINT sectors_pk PRIMARY KEY ("insref","sector")
);
CREATE INDEX idx_sectora ON sectors ("sector", "marketplace");

CREATE TABLE combolegs
(
  "insref" numeric(20) NOT NULL,
  "leg" numeric(20) NOT NULL,
  "ratio" integer,
  "side" smallint,
  CONSTRAINT combolegs_pk PRIMARY KEY ("insref","leg")
);

CREATE TABLE aggtrades
(
  "insref" numeric(20) NOT NULL,
  "openprice" double precision,
  "highprice" double precision,
  "lowprice" double precision,
  "closeprice" double precision,
  "openyield" double precision,
  "highyield" double precision,
  "lowyield" double precision,
  "closeyield" double precision,
  "quantity" double precision,
  "turnover" double precision,
  "time" timestamp without time zone NOT NULL,
  CONSTRAINT aggtrades_pk PRIMARY KEY ("insref","time")
);

CREATE TABLE "eet" (
	insref numeric(20) NOT NULL,
	"date" date NOT NULL,
	e00010 character(6),
	e00020 character varying(255),
	e00030 character varying(255),
	e00040 character varying(255),
	e00050 timestamp without time zone,
	e00060 character(1),
	e00070 character(1),
	e00080 character(1),
	e00090 character(1),
	e00100 character(1),
	e10000 character varying(255),
	e10010 character(1),
	e10020 character varying(255),
	e10030 character varying(255),
	e10040 date,
	e11000 character(1),
	e11011 double precision,
	e11020 character(1),
	e11030 character(1),
	e11040 character varying(50),
	e12000 character varying(50),
	e13000 character varying(255),
	e20000 character varying(255),
	e20010 smallint,
	e20020 character varying(255),
	e20030 character(3),
	e20040 smallint,
	e20050 smallint,
	e20060 character varying(50),
	e20070 double precision,
	e20080 double precision,
	e20090 character varying(2),
	e20100 character(1),
	e20110 text,
	e20120 text,
	e20130 text,
	e20140 text,
	e20150 date,
	e20160 text,
	e20170 character(1),
	e20180 double precision,
	e20190 character(1),
	e20200 character(1),
	e20210 character(1),
	e20220 double precision,
	e20230 character(1),
	e20240 character(1),
	e20250 double precision,
	e20260 character(1),
	e20270 character varying(50),
	e20280 character varying(50),
	e20290 character varying(50),
	e20300 character varying(50),
	e20310 double precision,
	e20320 smallint,
	e20330 double precision,
	e20340 smallint,
	e20350 double precision,
	e20360 smallint,
	e20370 character(1),
	e20380 character varying(500),
	e20390 date,
	e20400 double precision,
	e20410 character varying(50),
	e20420 double precision,
	e20430 double precision,
	e20440 double precision,
	e20450 double precision,
	e20460 double precision,
	e20470 double precision,
	e20480 date,
	e20490 double precision,
	e20500 double precision,
	e20510 double precision,
	e20520 double precision,
	e20530 double precision,
	e20540 double precision,
	e20550 double precision,
	e20560 double precision,
	e20570 character(1),
	e20580 character(1),
	e20590 character(1),
	e20600 double precision,
	e20610 double precision,
	e20620 character(1),
	e20630 character(1),
	e20640 double precision,
	e20650 double precision,
	e20660 double precision,
	e20670 double precision,
	e20680 double precision,
	e20690 double precision,
	e20700 double precision,
	e20710 double precision,
	e20721 double precision,
	e20731 double precision,
	e20741 double precision,
	e20751 double precision,
	e20761 double precision,
	e20771 double precision,
	e20780 double precision,
	e20790 double precision,
	e30000 character(1),
	e30010 date,
	e30020 double precision,
	e30030 character(1),
	e30040 double precision,
	e30050 double precision,
	e30060 double precision,
	e30070 character(1),
	e30080 double precision,
	e30090 double precision,
	e30100 double precision,
	e30110 character(1),
	e30120 double precision,
	e30130 double precision,
	e30140 double precision,
	e30150 character(1),
	e30160 double precision,
	e30170 double precision,
	e30180 double precision,
	e30190 character(1),
	e30200 double precision,
	e30210 double precision,
	e30220 double precision,
	e30230 character(1),
	e30240 double precision,
	e30250 double precision,
	e30260 double precision,
	e30270 character(1),
	e30280 double precision,
	e30290 double precision,
	e30300 double precision,
	e30310 character(1),
	e30320 double precision,
	e30330 double precision,
	e30340 double precision,
	e30350 character(1),
	e30360 double precision,
	e30370 double precision,
	e30380 double precision,
	e30390 character(1),
	e30400 double precision,
	e30410 double precision,
	e30420 double precision,
	e30430 character(1),
	e30440 double precision,
	e30450 double precision,
	e30460 double precision,
	e30470 character(1),
	e30480 double precision,
	e30490 double precision,
	e30500 double precision,
	e30510 character(1),
	e30520 double precision,
	e30530 double precision,
	e30540 double precision,
	e30550 character(1),
	e30560 double precision,
	e30570 double precision,
	e30580 double precision,
	e30590 character(1),
	e30600 double precision,
	e30610 double precision,
	e30620 double precision,
	e30630 character(1),
	e30640 double precision,
	e30650 double precision,
	e30660 double precision,
	e30670 character(1),
	e30680 double precision,
	e30690 double precision,
	e30700 double precision,
	e30710 character(1),
	e30720 double precision,
	e30730 double precision,
	e30740 double precision,
	e30750 character(1),
	e30760 double precision,
	e30770 double precision,
	e30780 double precision,
	e30790 character(1),
	e30800 double precision,
	e30810 double precision,
	e30820 double precision,
	e30830 character(1),
	e30840 double precision,
	e30850 double precision,
	e30860 double precision,
	e30870 character(1),
	e30880 double precision,
	e30890 double precision,
	e30900 double precision,
	e30910 character(1),
	e30920 double precision,
	e30930 double precision,
	e30940 double precision,
	e30950 character(1),
	e30960 double precision,
	e30970 double precision,
	e30980 double precision,
	e30990 character(1),
	e31000 double precision,
	e31010 double precision,
	e31020 double precision,
	e31030 character(1),
	e31040 double precision,
	e31045 double precision,
	e31050 double precision,
	e31060 character(1),
	e31070 double precision,
	e31080 double precision,
	e31090 double precision,
	e31100 character(1),
	e31110 double precision,
	e31120 double precision,
	e31130 double precision,
	e31140 character(1),
	e31150 double precision,
	e31160 double precision,
	e31170 double precision,
	e31180 character(1),
	e31190 double precision,
	e31200 double precision,
	e31210 smallint,
	e31220 character(1),
	e31230 double precision,
	e31240 double precision,
	e31250 double precision,
	e31260 character(1),
	e31270 double precision,
	e31280 double precision,
	e31290 double precision,
	e31300 character(1),
	e31310 double precision,
	e31320 double precision,
	e31330 double precision,
	e31340 character(1),
	e31350 double precision,
	e31360 double precision,
	e31370 double precision,
	e31380 character(1),
	e31390 double precision,
	e31400 double precision,
	e31410 double precision,
	e31420 character(1),
	e31430 double precision,
	e31440 double precision,
	e31450 double precision,
	e31460 character(1),
	e31470 double precision,
	e31480 double precision,
	e31490 double precision,
	e31500 character(1),
	e31505 double precision,
	e31510 double precision,
	e31520 double precision,
	e31530 character(1),
	e31540 double precision,
	e31550 double precision,
	e31560 double precision,
	e31570 character(1),
	e31580 double precision,
	e31590 double precision,
	e31600 double precision,
	e31610 character(1),
	e31620 double precision,
	e31630 double precision,
	e31640 double precision,
	e31650 character(1),
	e31660 double precision,
	e31670 double precision,
	e31671 double precision,
	e31672 character(1),
	e31673 double precision,
	e31674 double precision,
	e31680 double precision,
	e31690 character(1),
	e31700 double precision,
	e31710 double precision,
	e31720 double precision,
	e31730 character(1),
	e31740 double precision,
	e31750 double precision,
	e31760 double precision,
	e31770 character(1),
	e31780 double precision,
	e31790 double precision,
	e31800 double precision,
	e31810 character(1),
	e31820 double precision,
	e31830 double precision,
	e31840 double precision,
	e31850 character(1),
	e31860 double precision,
	e31870 double precision,
	e31871 double precision,
	e31872 character(1),
	e31873 double precision,
	e31874 double precision,
	e31875 double precision,
	e31876 character(1),
	e31877 double precision,
	e31878 double precision,
	e31880 double precision,
	e31890 character(1),
	e31900 double precision,
	e31910 double precision,
	e31920 double precision,
	e31930 character(1),
	e31940 double precision,
	e31950 double precision,
	e31960 double precision,
	e31970 character(1),
	e31980 double precision,
	e31990 double precision,
	e32000 double precision,
	e32010 character(1),
	e32020 double precision,
	e32030 double precision,
	e32040 double precision,
	e32050 character(1),
	e32060 double precision,
	e32070 double precision,
	e32080 double precision,
	e32090 character(1),
	e32100 double precision,
	e32110 double precision,
	e32120 double precision,
	e32130 character(1),
	e32140 double precision,
	e32150 double precision,
	e32160 double precision,
	e32170 character(1),
	e32180 double precision,
	e32190 double precision,
	e32200 double precision,
	e32210 character(1),
	e32220 double precision,
	e32230 double precision,
	e32240 double precision,
	e32250 character(1),
	e32260 double precision,
	e32270 double precision,
	e32280 double precision,
	e32290 character(1),
	e32300 double precision,
	e32310 double precision,
	e32320 double precision,
	e32330 character(1),
	e32340 double precision,
	e32350 double precision,
	e32360 double precision,
	e32370 character(1),
	e32380 double precision,
	e32390 double precision,
	e32400 double precision,
	e32410 character(1),
	e32420 double precision,
	e32430 double precision,
	e32440 double precision,
	e32450 character(1),
	e32460 double precision,
	e32470 double precision,
	e32480 double precision,
	e32490 character(1),
	e32500 double precision,
	e32510 double precision,
	e32520 double precision,
	e32530 character(1),
	e32540 double precision,
	e32550 double precision,
	e32560 double precision,
	e32570 character(1),
	e32580 double precision,
	e32590 double precision,
	e32640 double precision,
	e32650 character(1),
	e32660 double precision,
	e32670 double precision,
	e32680 double precision,
	e32690 character(1),
	e32700 double precision,
	e32710 double precision,
	e32720 double precision,
	e32730 character(1),
	e32740 double precision,
	e32750 double precision,
	e32760 double precision,
	e32770 character(1),
	e32780 double precision,
	e32790 double precision,
	e32800 double precision,
	e32810 character(1),
	e32820 double precision,
	e32830 double precision,
	e32840 double precision,
	e32850 character(1),
	e32860 double precision,
	e32870 double precision,
	e32880 double precision,
	e32890 character(1),
	e32900 double precision,
	e32910 double precision,
	e32920 double precision,
	e32930 character(1),
	e32940 double precision,
	e32950 double precision,
	e32960 double precision,
	e32970 character(1),
	e32980 double precision,
	e32990 double precision,
	e33000 double precision,
	e33010 character(1),
	e33020 double precision,
	e33030 double precision,
	e33040 double precision,
	e33050 character(1),
	e33060 double precision,
	e33070 double precision,
	e33080 double precision,
	e33090 character(1),
	e33100 double precision,
	e33110 double precision,
	e33120 double precision,
	e33130 character(1),
	e33140 double precision,
	e33145 double precision,
	e33150 double precision,
	e33160 character(1),
	e33170 double precision,
	e33180 double precision,
	e33190 double precision,
	e33200 character(1),
	e33210 double precision,
	e33220 double precision,
	e33230 double precision,
	e33240 character(1),
	e33250 double precision,
	e33260 double precision,
	e33265 double precision,
	e33270 character(1),
	e33280 double precision,
	e33290 double precision,
	e33295 double precision,
	e33300 character(1),
	e33310 double precision,
	e33320 double precision,
	e33330 double precision,
	e33340 character(1),
	e33350 double precision,
	e33360 double precision,
	e33370 double precision,
	e33380 character(1),
	e33390 double precision,
	e33400 double precision,
	e33410 double precision,
	e33420 character(1),
	e33430 double precision,
	e33440 double precision,
	e40000 character(1),
	e40010 text,
	e50100 character(1),
	e50110 character(1),
	e50120 double precision,
	e50130 character varying(3),
	e50200 character(1),
	e50210 character(1),
	e50220 double precision,
	e50230 character varying(3),
	e50300 character(1),
	e50310 character(1),
	e50320 double precision,
	e50330 character varying(3),
	e50400 character(1),
	e50410 character(1),
	e50420 double precision,
	e50430 character varying(3),
	e50500 character(1),
	e50510 character(1),
	e50520 double precision,
	e50530 character varying(3),
	e50600 character(1),
	e50610 character(1),
	e50620 double precision,
	e50630 character varying(3),
	e50640 double precision,
	e50650 double precision,
	e50660 character(1),
	e50700 character(1),
	e50710 character(1),
	e50720 double precision,
	e50730 character varying(3),
	e50800 character(1),
	e50810 character(1),
	e50820 double precision,
	e50830 character varying(3),
	e50900 character(1),
	e50910 character(1),
	e50920 double precision,
	e50930 character varying(3),
	e51000 character(1),
	e51010 character(1),
	e51020 double precision,
	e51030 character varying(3),
	e51040 double precision,
	e51050 double precision,
	e51060 character(1),
	e51100 character(1),
	e51110 character(1),
	e51120 double precision,
	e51130 character varying(3),
	e51200 character(1),
	e51210 character(1),
	e51220 double precision,
	e51230 character varying(3),
	e51300 character(1),
	e51310 character(1),
	e51320 double precision,
	e51400 character(1),
	e51410 character(1),
	e51420 double precision,
	e51430 character varying(3),
	e51500 character(1),
	e51510 character(1),
	e51520 double precision,
	e51530 character varying(3),
	e51540 double precision,
	e51550 double precision,
	e51560 character(1),
	e51600 character(1),
	e51610 character(1),
	e51620 double precision,
	e51630 character varying(3),
	e51640 double precision,
	e51650 double precision,
	e51660 character(1),
	e51700 character(1),
	e51710 character(1),
	e51720 double precision,
	e51730 character varying(3),
	e51800 character(1),
	e51810 character(1),
	e51820 double precision,
	e51830 character varying(3),
	e51900 character(1),
	e51910 character(1),
	e51920 double precision,
	e51930 character varying(3),
	e52000 character(1),
	e52010 character(1),
	e52020 double precision,
	e52030 character varying(3),
	e52100 character(1),
	e52110 character(1),
	e52120 double precision,
	e52130 character varying(3),
	e52200 character(1),
	e52210 character(1),
	e52220 character(1),
	e53000 character(1),
	e53010 character(1),
	e53020 character(1),
	e53030 character(1),
	e53040 character(1),
	e53050 character(1),
	e53060 character(1),
	e54000 character(1),
	e54010 character(1),
	e54020 character(1),
	e54030 character(1),
	e54040 character(1),
	e54050 character(1),
	e54060 character(1),
	e54070 character(1),
	e60400 smallint,
	e60410 character varying(50),
	e60420 character varying(50),
	e60430 character varying(50),
	e60440 character varying(50),
	e70000 character(1),
	e70010 double precision,
	e80000 character(1),
	e80010 character(1),
	e80020 double precision,
	e80030 double precision,
	e80040 double precision,
	e80050 double precision,
	e90000 character(1),
	e90010 double precision,
	e90020 double precision,
	e90030 character(1),
	e90040 double precision,
	e90050 double precision,
	e90060 double precision,
	e90070 double precision,
	e90080 double precision,
	e90090 double precision,
	e90100 double precision,
	e90110 double precision,
	e90120 double precision,
	e90130 double precision,
	e90140 double precision,
	e90150 double precision,
	e90160 double precision,
	e90170 double precision,
	e90180 double precision,
	e90190 double precision,
	e90200 double precision,
	e90210 double precision,
	e90220 double precision,
	e90230 double precision,
	e90240 double precision,
	e90250 double precision,
	e100000 text,
	e100010 text,
	lastmodified timestamp without time zone NOT NULL,
	CONSTRAINT eet_pk PRIMARY KEY (insref)
);
