This repository has been archived by the owner on Aug 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add funding rate history (#91)
* feat: add funding rate db objects and initial data * chore: add support sql quesries * chore: add funding rate repo * chore: add funding rate handling * test: add funding rate repo tests * feat: add funding yields over few tenors * fix: fix data insert in case table exists * fix: including services folder to build * fix: insertion of exchange id foreign key Co-authored-by: Sebastien Verreault <[email protected]>
- Loading branch information
1 parent
f765828
commit 76b93e6
Showing
27 changed files
with
4,244 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
-- Up Migration | ||
CREATE AGGREGATE mul(decimal) ( SFUNC = numeric_mul, STYPE=decimal ); | ||
|
||
-- Down Migration | ||
DROP AGGREGATE IF EXISTS mul(decimal); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
-- Up Migration | ||
CREATE TABLE "dealer"."exchanges" ( | ||
"id" serial PRIMARY KEY, | ||
"exchange_name" varchar(64) NOT NULL UNIQUE, | ||
"updated_timestamp" varchar(256) DEFAULT current_timestamp NOT NULL, | ||
"created_timestamp" varchar(256) DEFAULT current_timestamp NOT NULL | ||
); | ||
|
||
-- Down Migration | ||
DROP TABLE IF EXISTS "dealer"."exchanges" CASCADE; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
-- Up Migration | ||
INSERT INTO "dealer"."exchanges" | ||
("exchange_name") | ||
VALUES | ||
( 'bitmex' ), | ||
( 'okex' ), | ||
( 'deribit' ), | ||
( 'kraken' ), | ||
( 'ftx' ), | ||
( 'bitfinex' ), | ||
( 'binance' ), | ||
( 'bybit' ), | ||
( 'huobi' ); | ||
|
||
-- Down Migration | ||
TRUNCATE TABLE "dealer"."exchanges"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
-- Up Migration | ||
CREATE TABLE "dealer"."funding_rates" ( | ||
"id" serial PRIMARY KEY, | ||
|
||
"timestamp" timestamptz NOT NULL, | ||
"funding_time" bigint NOT NULL, | ||
"instrument_id" varchar(64) NOT NULL, | ||
"exchange_id" integer NOT NULL, | ||
|
||
"funding_rate" DECIMAL NOT NULL, | ||
|
||
"updated_timestamp" timestamptz DEFAULT current_timestamp NOT NULL, | ||
"created_timestamp" timestamptz DEFAULT current_timestamp NOT NULL, | ||
|
||
CONSTRAINT fk_exchange_id FOREIGN KEY(exchange_id) REFERENCES dealer.exchanges(id) | ||
|
||
); | ||
CREATE INDEX "funding_rates_time_instrument_exchange_idx" ON "dealer"."funding_rates" ("funding_time", "instrument_id", "exchange_id"); | ||
|
||
-- Down Migration | ||
DROP INDEX "dealer"."funding_rates_time_instrument_exchange_idx"; | ||
DROP TABLE IF EXISTS "dealer"."funding_rates" CASCADE; | ||
|
3,123 changes: 3,123 additions & 0 deletions
3,123
dealer/migrations/20220408065056920_init-funding-rates.sql
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.