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.

122 lines
3.2KB

  1. CREATE SEQUENCE public.trades_id_seq
  2. INCREMENT 1
  3. MINVALUE 1
  4. MAXVALUE 9223372036854775807
  5. START 1
  6. CACHE 1;
  7. ALTER TABLE public.trades_id_seq
  8. OWNER TO jstrong;
  9. -- CREATE SEQUENCE public.exchangess_id_seq
  10. -- INCREMENT 1
  11. -- MINVALUE 1
  12. -- MAXVALUE 255
  13. -- START 1
  14. -- CACHE 1;
  15. -- ALTER TABLE public.exchangess_id_seq
  16. -- OWNER TO jstrong;
  17. --
  18. -- CREATE SEQUENCE public.currencies_id_seq
  19. -- INCREMENT 1
  20. -- MINVALUE 1
  21. -- MAXVALUE 255
  22. -- START 1
  23. -- CACHE 1;
  24. -- ALTER TABLE public.currencies_id_seq
  25. -- OWNER TO jstrong;
  26. CREATE TABLE public.exchanges
  27. (
  28. id smallint NOT NULL,
  29. symbol character varying(4) NOT NULL,
  30. CONSTRAINT exchanges_pkey PRIMARY KEY (id)
  31. ) WITH ( OIDS=FALSE );
  32. CREATE TABLE public.currencies
  33. (
  34. id smallint NOT NULL,
  35. symbol character varying(6) NOT NULL,
  36. CONSTRAINT currencies_pkey PRIMARY KEY (id)
  37. ) WITH ( OIDS=FALSE );
  38. CREATE TABLE public.trades
  39. (
  40. id integer NOT NULL DEFAULT nextval('trades_id_seq'::regclass),
  41. "time" timestamp with time zone NOT NULL,
  42. exch smallint NOT NULL,
  43. base smallint NOT NULL,
  44. quote smallint NOT NULL,
  45. amount double precision NOT NULL,
  46. price double precision NOT NULL,
  47. side smallint NULL, -- side has no fk ... bid=1, ask=2
  48. server_time timestamp with time zone NULL,
  49. CONSTRAINT trades_pkey PRIMARY KEY (id),
  50. CONSTRAINT exch_fk FOREIGN KEY (exch)
  51. REFERENCES public.exchanges (id) MATCH SIMPLE
  52. ON UPDATE NO ACTION ON DELETE NO ACTION DEFERRABLE INITIALLY DEFERRED,
  53. CONSTRAINT base_fk FOREIGN KEY (base)
  54. REFERENCES public.currencies (id) MATCH SIMPLE
  55. ON UPDATE NO ACTION ON DELETE NO ACTION DEFERRABLE INITIALLY DEFERRED,
  56. CONSTRAINT quote_fk FOREIGN KEY (quote)
  57. REFERENCES public.currencies (id) MATCH SIMPLE
  58. ON UPDATE NO ACTION ON DELETE NO ACTION DEFERRABLE INITIALLY DEFERRED
  59. )
  60. WITH (
  61. OIDS=FALSE
  62. );
  63. ALTER TABLE public.trades
  64. OWNER TO jstrong;
  65. CREATE INDEX trades_time_abcdefg
  66. ON public.trades
  67. USING btree
  68. ("time");
  69. CREATE INDEX trades_base_f6b2eeda
  70. ON public.trades
  71. USING btree
  72. (base);
  73. CREATE INDEX trades_quote_0d5895fc
  74. ON public.trades
  75. USING btree
  76. (quote);
  77. CREATE INDEX trades_exchange_5d5c6971
  78. ON public.trades
  79. USING btree
  80. (exch);
  81. -- CREATE INDEX trades_side_23985593
  82. -- ON public.trades
  83. -- USING btree
  84. -- (side);
  85. -- fill in exchanges/currencies
  86. insert into public.exchanges (id, symbol) values(1, 'plnx');
  87. insert into public.exchanges (id, symbol) values(2, 'krkn');
  88. insert into public.exchanges (id, symbol) values(3, 'gdax');
  89. insert into public.exchanges (id, symbol) values(5, 'bits');
  90. insert into public.exchanges (id, symbol) values(6, 'bmex');
  91. insert into public.exchanges (id, symbol) values(7, 'btfx');
  92. insert into public.exchanges (id, symbol) values(8, 'bnce');
  93. insert into public.exchanges (id, symbol) values(9, 'okex');
  94. insert into public.currencies (id, symbol) values(1, 'btc');
  95. insert into public.currencies (id, symbol) values(2, 'eth');
  96. insert into public.currencies (id, symbol) values(3, 'xmr');
  97. insert into public.currencies (id, symbol) values(5, 'ltc');
  98. insert into public.currencies (id, symbol) values(15, 'etc');
  99. insert into public.currencies (id, symbol) values(4, 'usdt');
  100. insert into public.currencies (id, symbol) values(100, 'usd');