Skip to content

Commit

Permalink
Export portfolio DB data and schema
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaacCheng9 committed Dec 25, 2023
1 parent 56cdb96 commit db6844c
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
2 changes: 2 additions & 0 deletions resources/portfolio_data/load.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
COPY "transaction" FROM 'resources/portfolio_data/transaction.csv' (FORMAT 'csv', quote '"', delimiter ',', header 1);
COPY portfolio FROM 'resources/portfolio_data/portfolio.csv' (FORMAT 'csv', quote '"', delimiter ',', header 1);
7 changes: 7 additions & 0 deletions resources/portfolio_data/portfolio.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
symbol,name,units,currency,paid,paid_gbp
GOOGL,Alphabet Inc.,5.013549731983323406789755807,USD,673.42,497.2465937999999938035067260
AAPL,Apple Inc.,3.891090242785158039395327531,USD,679.54,500.3928697999999789480796153
MSFT,Microsoft Corporation,0.1723025803471104978507079020,USD,77.96,48.1315551999999852395006883
BTC-USD,Bitcoin USD,0.02036431764262658968954597754,USD,1000,753.2400000000000206412664738
0P00018XAR.L,Vanguard FTSE Global All Cap In,37.41394791978449488114779587,GBP,5000,5000
VUSA.L,VANGUARD FUNDS PLC VANGUARD S&P,1490.535102101654462935338036,GBP,1000,1000
9 changes: 9 additions & 0 deletions resources/portfolio_data/schema.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@



CREATE TABLE "transaction"(transaction_id VARCHAR PRIMARY KEY, transaction_type VARCHAR NOT NULL, "timestamp" TIMESTAMP NOT NULL, ticker VARCHAR NOT NULL, platform VARCHAR NOT NULL, currency VARCHAR NOT NULL, amount VARCHAR NOT NULL, unit_price VARCHAR NOT NULL, units VARCHAR NOT NULL, amount_gbp VARCHAR NOT NULL, exchange_rate VARCHAR NOT NULL);
CREATE TABLE portfolio(symbol VARCHAR PRIMARY KEY, "name" VARCHAR NOT NULL, units VARCHAR NOT NULL, currency VARCHAR NOT NULL, paid VARCHAR NOT NULL, paid_gbp VARCHAR NOT NULL);




8 changes: 8 additions & 0 deletions resources/portfolio_data/transaction.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
transaction_id,transaction_type,timestamp,ticker,platform,currency,amount,unit_price,units,amount_gbp,exchange_rate
d375ccf2-4388-4efe-a65e-86d463f62d35,Buy,2021-10-01 15:46:42.938,GOOGL,Freetrade,USD,673.42,134.32,5.013549731983323406789755807,497.2465937999999938035067260,0.73838999999999999079847157190670259296894073486328125
4c21006d-21c3-4ecc-a8da-e1a5b1767577,Buy,2022-01-11 17:23:12.231,AAPL,Freetrade,USD,679.54,174.64,3.891090242785158039395327531,500.3928697999999789480796153,0.73636999999999996902033672085963189601898193359375
0d56180d-3cde-40a6-9f5e-d026d3fb6a75,Buy,2021-12-08 14:57:03.564,MSFT,Freetrade,USD,327.96,332.76,0.9855751893256401009736747205,248.4690551999999869270396857,0.7576199999999999601385525238583795726299285888671875
2dcc9c2d-3b6a-4510-baf4-1d70e3b17f5a,Sell,2023-05-02 15:13:32.913,MSFT,Freetrade,USD,250,307.40,0.8132726089785296031229668185,200.3375000000000016875389974,0.8013500000000000067501559897209517657756805419921875
04b8c77d-738c-400d-8a52-f4ede08f5c62,Buy,2021-12-03 12:00:34.019,BTC-USD,Freetrade,USD,1000,49105.50,0.02036431764262658968954597754,753.2400000000000206412664738,0.75324000000000002064126647383091039955615997314453125
912f755f-3b49-458a-81fd-670adfb93d01,Buy,2020-06-25 12:00:58.8,0P00018XAR.L,Vanguard,GBP,5000,133.6400000000000027819413440,37.41394791978449488114779587,5000,1
87e4fc5b-7e99-412b-a6ec-16a12bd328c7,Buy,2021-12-01 12:00:59.4,VUSA.L,Vanguard,GBP,1000,0.6709000000000000139659117604,1490.535102101654462935338036,1000,1

0 comments on commit db6844c

Please sign in to comment.