-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
71cd803
commit 49158b2
Showing
13 changed files
with
3,643 additions
and
191 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 |
---|---|---|
|
@@ -36,4 +36,6 @@ yarn-error.log* | |
# typescript | ||
*.tsbuildinfo | ||
.idea/ | ||
.vscode/ | ||
.vscode/ | ||
|
||
dev-db |
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 @@ | ||
import { Connection, createConnection } from 'typeorm'; | ||
|
||
export default async function initDb(): Promise<Connection> { | ||
return await createConnection(); | ||
} |
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,27 @@ | ||
import { Column, Entity, ManyToOne, PrimaryGeneratedColumn } from 'typeorm'; | ||
import { ExecutionType } from '../..'; | ||
import { Trade } from './Trade'; | ||
|
||
@Entity() | ||
export class Execution { | ||
@PrimaryGeneratedColumn('uuid') id: string; | ||
@Column() symbol: string; | ||
@Column() executionTimestamp: Date; | ||
@Column({ | ||
type: 'enum', | ||
enum: ExecutionType, | ||
}) | ||
executionType: ExecutionType; | ||
|
||
@Column() quantity: number; | ||
|
||
@Column('money') pricePerShare: number; | ||
@Column('int') pricePerShareScale: number; | ||
|
||
@Column('money') totalOutflow: number; | ||
@Column('int') totalOutflowScale: number; | ||
|
||
@Column() currency: string; | ||
|
||
@ManyToOne(() => Trade, (trade) => trade.executions) trade: Trade; | ||
} |
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,25 @@ | ||
import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from 'typeorm'; | ||
import { Execution } from './Execution'; | ||
|
||
@Entity() | ||
export class Trade { | ||
@PrimaryGeneratedColumn('uuid') id: string; | ||
@Column() symbol: string; | ||
|
||
@OneToMany(() => Execution, (execution) => execution.trade) | ||
executions: Execution[]; | ||
|
||
@Column() quantity: number; | ||
|
||
@Column('bool') isOpen: boolean; | ||
|
||
@Column('bool') isShort: boolean; | ||
|
||
@Column('money') closedPl: number; | ||
@Column('int') closedPlScale: number; | ||
|
||
@Column('money') outflow: number; | ||
@Column('int') outflowScale: number; | ||
|
||
@Column() currency: string; | ||
} |
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 @@ | ||
require('dotenv/config'); | ||
|
||
const database = { | ||
development: 'traderperf_dev', | ||
production: 'prod-db', | ||
test: 'test-db', | ||
}; | ||
|
||
module.exports = { | ||
type: 'postgres', | ||
host: 'localhost', | ||
port: 5432, | ||
username: 'postgres', | ||
password: 'password', | ||
database: database[process.env.NODE_ENV], | ||
entities: ['./model/db/entity/*{.ts,.js}'], | ||
synchronize: process.env.NODE_ENV !== 'production', | ||
migrationsTableName: 'migration', | ||
migrations: ['migration/*.js'], | ||
cli: { | ||
migrationsDir: 'migration', | ||
}, | ||
}; |
Oops, something went wrong.