-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
966: Feat/track pnl r=da-kami a=da-kami Especially the first commit will be interesting for everybody to see - we are finally associating the `positions` with the contracts - Thanks for the great pairing session `@luckysori` :) note: This PR only handles the realized pnl, I will see to add tracking for the unrealized pnl in a follow up. related ticket: #932 (I'll add the *fixes* to the follow up :) Co-authored-by: Daniel Karzel <[email protected]>
- Loading branch information
Showing
13 changed files
with
331 additions
and
115 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
coordinator/migrations/2023-07-19-055140_associate_position_with_dlc/down.sql
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,3 @@ | ||
-- This file should undo anything in `up.sql` | ||
ALTER TABLE | ||
"positions" DROP COLUMN "temporary_contract_id"; |
5 changes: 5 additions & 0 deletions
5
coordinator/migrations/2023-07-19-055140_associate_position_with_dlc/up.sql
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 @@ | ||
-- Your SQL goes here | ||
ALTER TABLE | ||
positions | ||
ADD | ||
COLUMN "temporary_contract_id" TEXT; |
7 changes: 7 additions & 0 deletions
7
coordinator/migrations/2023-07-19-055143_closed_positions/down.sql
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,7 @@ | ||
-- This file should undo anything in `up.sql` | ||
-- ... but in this case it does not fully. | ||
-- Postgres does not allow removing enum type values. One can only re-create an enum type with fewer values and replace the references. | ||
-- However, there is no proper way to replace the values to be removed where they are used (i.e. referenced in `positions` table) | ||
-- We opt to NOT remove enum values that were added at a later point. | ||
ALTER TABLE | ||
"positions" DROP COLUMN "realized_pnl"; |
10 changes: 10 additions & 0 deletions
10
coordinator/migrations/2023-07-19-055143_closed_positions/up.sql
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 @@ | ||
-- Your SQL goes here | ||
-- Note that the `IF NOT EXISTS` is essential because there is no `down` migration for removing this value because it is not really feasible to remove enum values! | ||
-- In order to allow re-running this migration we thus have to make sure to only add the value if it does not exist yet. | ||
ALTER TYPE "PositionState_Type" | ||
ADD | ||
VALUE IF NOT EXISTS 'Closed'; | ||
ALTER TABLE | ||
positions | ||
ADD | ||
COLUMN "realized_pnl" BIGINT; |
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.