diff --git a/.github/workflows/clientProdDeploy b/.github/workflows/clientProdDeploy deleted file mode 100644 index 1a98b559..00000000 --- a/.github/workflows/clientProdDeploy +++ /dev/null @@ -1,39 +0,0 @@ -name: Client Prod Deploy CI - -on: - push: - branches: [ main ] - -env: - REACT_APP_SERVER_HOST: ${{ vars.CLIENT_PROD_SERVER_HOST }} - REACT_APP_SERVER_TYPE: ${{ vars.CLIENT_PROD_SERVER_TYPE }} - REACT_APP_PAYPAL_CLIENT_ID: ${{ vars.CLIENT_PROD_PAYPAL_CLIENT_ID }} - REACT_APP_CONTACT_EMAIL: ${{ vars.CLIENT_PROD_CONTACT_EMAIL }} - REACT_APP_IS_MAINTAINING: ${{ vars.CLIENT_PROD_IS_MAINTAINING }} - -jobs: - build: - runs-on: ubuntu-latest - strategy: - matrix: - node-version: [18.12.1] - steps: - - uses: actions/checkout@v3 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node-version }} - cache: 'npm' - - run: npm ci - - run: npm run build:client - - name: Push dist files - uses: dmnemec/copy_file_to_another_repo_action@main - env: - API_TOKEN_GITHUB: ${{ secrets.CLIENT_DEPLOY_TOKEN }} - with: - source_file: './client/dist/.' - destination_repo: 'ValueMelody/melody-prod' - destination_folder: './' - user_email: 'byn9826@gmail.com' - user_name: 'Baozier' - commit_message: 'Production deploy' diff --git a/.github/workflows/pullRequest.yml b/.github/workflows/pullRequest.yml index 2111a35d..ea7e22d2 100644 --- a/.github/workflows/pullRequest.yml +++ b/.github/workflows/pullRequest.yml @@ -21,4 +21,3 @@ jobs: - run: npm run lint - run: npm run shared - run: npm run tsc - - run: npm run test diff --git a/README.md b/README.md index a6105a7e..09f91675 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Prerequisite +# Environment ``` # setup redis sudo apt install redis-server @@ -15,76 +15,60 @@ sudo apt-get install -y nodejs sudo npm install -g pm2 ``` +# Prerequisite +- Create a postgres database "melody-invest" +- Get a Tiingo API KEY + # Quick Start ``` -cp ./client/.env.example ./client/.env -cp ./server/.env.example ./server/.env +cp ./client/.env.example ./client/.env # Replace env vars if needed +cp ./server/.env.example ./server/.env # Replace env vars if needed, including redis, database, mailer configs npm install -npm run basic -npm run dev +npm run shared +cd server +npm run migrate +cd ../ +npm run dev # open http://127.0.0.1:3099 in browser ``` -# Project Structure: +# Data Preparation +## Initial Preparation +Save your Tiingo key on "Profile" page +Create tickers on "Manage Tickers" Page ``` -scripts -> - mocks -> files used by unit test - devOps -> files used by devOps - -interfaces -> shared interfaces for the whole project -constants -> shared constants for the whole project -helpers -> shared functions for the whole project - -client -> frontend site for general users - index.tsx -> React root - index.css -> basic global styles - locales -> translation files used by client only - containers -> React components - blocks -> larger reusable components depend on state - elements -> smaller reusable components do not depend on state - enums -> constants used by client only - tools -> pure functions used by client only - adapters -> wrappers for outer resources - hooks -> general hooks to handle specific tasks - actions -> Redux actions and async actions - selectors -> Redux selectors - stores -> Redux stores - -server -> backend APIs for the whole project - index.ts -> Express root - cli.ts -> NPM command root - cron.ts -> Node Cron root - adapters -> wrappers for outer resources - tools -> pure functions used by server only - enums -> constants used by server only - locales -> translation files by server only - middlewares -> Express middlewares - models -> database representative functions - routers -> Express routers - logics -> specific business logic functions - services -> api or cli request handlers - shared -> single purpose data parsing functions - tasks -> cli command handlers - templates -> email templates - migrations -> Knex migrations +cd server +npm run build ``` -# Manual Schedules -Daily: +## Daily Preparation ``` -npm run syncTickerPrices +# Sync prices of your tickers +npm run syncTickerPrices yyyy-MM-DD + +# Calculate price movements based on ticker prices npm run calcPriceMovements + +# Prepare daily ticker data for final calculation npm run calcDailyTickers ``` -Weekly: + +## Weekly Preparation ``` -npm run syncTickerFinancials +# Sync financial statements of your tickers +npm run syncTickerFinancials yyyy-MM + +# Calculate financial movements based on financial data npm run calcFinancialMovements -npm run calcDailyTickers + +# Update indicator tables with most up to date data +# Calculate economy indicator movemeents based on economy data npm run calcIndicatorMovements + +# Prepare daily indicator data for final calculation npm run calcDailyIndicators ``` -# Indicator Data Collect +## Indicator Data References Yearly Inflation: https://www.usinflationcalculator.com/inflation/current-inflation-rates/ Yearly GDP: https://en.wikipedia.org/wiki/Economy_of_the_United_States Quarterly Seasonal GDP: https://fred.stlouisfed.org/series/NA000254Q diff --git a/client/src/containers/traders/profiles/ProfileDashboard.tsx b/client/src/containers/traders/profiles/ProfileDashboard.tsx index 80a908c2..eccfa32c 100644 --- a/client/src/containers/traders/profiles/ProfileDashboard.tsx +++ b/client/src/containers/traders/profiles/ProfileDashboard.tsx @@ -67,7 +67,7 @@ const ProfileDashboard = () => { { return knex.schema .createTable('entity', (table) => { table.increments('id') - table.string('dataKey', 20) + table.text('dataKey') + table.string('dataSource', 20) table.boolean('isValidKey') }) } diff --git a/server/migrations/test-tables/email.js b/server/migrations/0002_email.js similarity index 100% rename from server/migrations/test-tables/email.js rename to server/migrations/0002_email.js diff --git a/server/migrations/test-tables/user.js b/server/migrations/0003_user.js similarity index 100% rename from server/migrations/test-tables/user.js rename to server/migrations/0003_user.js diff --git a/server/migrations/test-tables/policy.js b/server/migrations/0004_policy.js similarity index 100% rename from server/migrations/test-tables/policy.js rename to server/migrations/0004_policy.js diff --git a/server/migrations/test-tables/ticker.js b/server/migrations/0005_ticker.js similarity index 95% rename from server/migrations/test-tables/ticker.js rename to server/migrations/0005_ticker.js index 3ff431f4..e84f5b9c 100644 --- a/server/migrations/test-tables/ticker.js +++ b/server/migrations/0005_ticker.js @@ -4,7 +4,6 @@ exports.up = (knex) => { table.increments('id') table.integer('entityId').notNullable() table.foreign('entityId').references('id').inTable('entity') - table.string('name', 50).notNullable() table.string('symbol', 10).notNullable() table.boolean('isDelisted').defaultTo(false).notNullable() table.specificType('region', 'CHAR(2)').notNullable() diff --git a/server/migrations/test-tables/daily_tickers.js b/server/migrations/0006_daily_tickers.js similarity index 100% rename from server/migrations/test-tables/daily_tickers.js rename to server/migrations/0006_daily_tickers.js diff --git a/server/migrations/test-tables/indicator_monthly.js b/server/migrations/0007_indicator_monthly.js similarity index 100% rename from server/migrations/test-tables/indicator_monthly.js rename to server/migrations/0007_indicator_monthly.js diff --git a/server/migrations/test-tables/indicator_quarterly.js b/server/migrations/0008_indicator_quarterly.js similarity index 100% rename from server/migrations/test-tables/indicator_quarterly.js rename to server/migrations/0008_indicator_quarterly.js diff --git a/server/migrations/test-tables/indicator_yearly.js b/server/migrations/0009_indicator_yearly.js similarity index 100% rename from server/migrations/test-tables/indicator_yearly.js rename to server/migrations/0009_indicator_yearly.js diff --git a/server/migrations/test-tables/ticker_daily.js b/server/migrations/0010_ticker_daily.js similarity index 100% rename from server/migrations/test-tables/ticker_daily.js rename to server/migrations/0010_ticker_daily.js diff --git a/server/migrations/test-tables/ticker_yearly.js b/server/migrations/0011_ticker_yearly.js similarity index 100% rename from server/migrations/test-tables/ticker_yearly.js rename to server/migrations/0011_ticker_yearly.js diff --git a/server/migrations/test-tables/ticker_quarterly.js b/server/migrations/0012_ticker_quarterly.js similarity index 100% rename from server/migrations/test-tables/ticker_quarterly.js rename to server/migrations/0012_ticker_quarterly.js diff --git a/server/migrations/test-tables/trader_env.js b/server/migrations/0013_trader_env.js similarity index 100% rename from server/migrations/test-tables/trader_env.js rename to server/migrations/0013_trader_env.js diff --git a/server/migrations/test-tables/user_payment.js b/server/migrations/0014_user_payment.js similarity index 100% rename from server/migrations/test-tables/user_payment.js rename to server/migrations/0014_user_payment.js diff --git a/server/migrations/test-tables/trader_pattern.js b/server/migrations/0015_trader_pattern.js similarity index 100% rename from server/migrations/test-tables/trader_pattern.js rename to server/migrations/0015_trader_pattern.js diff --git a/server/migrations/test-tables/trader.js b/server/migrations/0016_trader.js similarity index 100% rename from server/migrations/test-tables/trader.js rename to server/migrations/0016_trader.js diff --git a/server/migrations/test-tables/ticker_holder.js b/server/migrations/0017_ticker_holder.js similarity index 100% rename from server/migrations/test-tables/ticker_holder.js rename to server/migrations/0017_ticker_holder.js diff --git a/server/migrations/test-tables/trader_combo.js b/server/migrations/0018_trader_combo.js similarity index 100% rename from server/migrations/test-tables/trader_combo.js rename to server/migrations/0018_trader_combo.js diff --git a/server/migrations/test-tables/trader_combo_follower.js b/server/migrations/0019_trader_combo_follower.js similarity index 100% rename from server/migrations/test-tables/trader_combo_follower.js rename to server/migrations/0019_trader_combo_follower.js diff --git a/server/migrations/test-tables/trader_follower.js b/server/migrations/0020_trader_follower.js similarity index 100% rename from server/migrations/test-tables/trader_follower.js rename to server/migrations/0020_trader_follower.js diff --git a/server/migrations/test-tables/trader_holding.js b/server/migrations/0021_trader_holding.js similarity index 100% rename from server/migrations/test-tables/trader_holding.js rename to server/migrations/0021_trader_holding.js diff --git a/server/migrations/test-tables/trader_env_follower.js b/server/migrations/0022_trader_env_follower.js similarity index 100% rename from server/migrations/test-tables/trader_env_follower.js rename to server/migrations/0022_trader_env_follower.js diff --git a/server/migrations/0023_policy_seed.js b/server/migrations/0023_policy_seed.js new file mode 100644 index 00000000..4fcbebe0 --- /dev/null +++ b/server/migrations/0023_policy_seed.js @@ -0,0 +1,17 @@ +exports.up = (knex) => { + return knex('policy').insert([ + { + type: 1, + content: 'Privacy policy', + createdAt: new Date(), + }, + { + type: 2, + content: 'Terms and Conditions', + createdAt: new Date(), + }, + ]) +} + +exports.down = (knex) => { +} \ No newline at end of file diff --git a/server/migrations/20230521210000_create_daily_indicators_table.js b/server/migrations/0024_daily_indicators.js similarity index 99% rename from server/migrations/20230521210000_create_daily_indicators_table.js rename to server/migrations/0024_daily_indicators.js index c0b3ce9d..5ffaa305 100644 --- a/server/migrations/20230521210000_create_daily_indicators_table.js +++ b/server/migrations/0024_daily_indicators.js @@ -10,4 +10,4 @@ exports.up = (knex) => { exports.down = (knex) => { return knex.schema.dropTable('daily_indicators') -} +} \ No newline at end of file diff --git a/server/migrations/20230416150000_create_entity_table.js b/server/migrations/20230416150000_create_entity_table.js deleted file mode 100644 index 2e1d733b..00000000 --- a/server/migrations/20230416150000_create_entity_table.js +++ /dev/null @@ -1,20 +0,0 @@ -exports.up = (knex) => { - return knex.schema - .createTable('entity', (table) => { - table.increments('id') - table.string('dataKey', 20) - table.boolean('isValidKey') - }) - .table('user', (table) => { - table.integer('entityId').notNullable() - table.foreign('entityId').references('id').inTable('entity') - }) -} - -exports.down = (knex) => { - return knex.schema - .table('user', (table) => { - table.dropColumn('userEntityId') - }) - .dropTable('entity') -} diff --git a/server/migrations/20230416155000_add_entityId_to_resource_tables.js b/server/migrations/20230416155000_add_entityId_to_resource_tables.js deleted file mode 100644 index 8ebd82cb..00000000 --- a/server/migrations/20230416155000_add_entityId_to_resource_tables.js +++ /dev/null @@ -1,51 +0,0 @@ -exports.up = (knex) => { - return knex.schema - .table('ticker', (table) => { - table.integer('entityId').notNullable() - table.foreign('entityId').references('id').inTable('entity') - table.dropUnique([], 'ticker_ukey') - table.unique(['entityId', 'symbol', 'region'], 'ticker_ukey') - }) - .table('daily_tickers', (table) => { - table.integer('entityId').notNullable() - table.foreign('entityId').references('id').inTable('entity') - table.dropUnique([], 'daily_tickers_ukey') - table.unique(['entityId', 'date'], 'daily_tickers_ukey') - }) - .table('trader_env', (table) => { - table.integer('entityId').notNullable() - table.foreign('entityId').references('id').inTable('entity') - table.dropUnique([], 'trader_env_ukey') - table.unique(['entityId', 'startDate', 'tickerIds'], 'trader_env_ukey') - }) - .table('trader_combo', (table) => { - table.integer('entityId').notNullable() - table.foreign('entityId').references('id').inTable('entity') - table.dropUnique([], 'trader_combo_ukey') - table.unique(['entityId', 'traderIds'], 'trader_combo_ukey') - }) -} - -exports.down = (knex) => { - return knex.schema - .table('ticker', (table) => { - table.dropColumn('entityId') - table.dropUnique([], 'ticker_ukey') - table.unique(['symbol', 'region'], 'ticker_ukey') - }) - .table('daily_tickers', (table) => { - table.dropColumn('entityId') - table.dropUnique([], 'daily_tickers_ukey') - table.unique(['date'], 'daily_tickers_ukey') - }) - .table('trader_env', (table) => { - table.dropColumn('entityId') - table.dropUnique([], 'trader_env_ukey') - table.unique(['startDate', 'tickerIds'], 'trader_env_ukey') - }) - .table('trader_combo', (table) => { - table.dropColumn('entityId') - table.dropUnique([], 'trader_combo_ukey') - table.unique(['traderIds'], 'trader_combo_ukey') - }) -} diff --git a/server/migrations/20230416200000_drop_ticker_category_table.js b/server/migrations/20230416200000_drop_ticker_category_table.js deleted file mode 100644 index 3a9fc4f8..00000000 --- a/server/migrations/20230416200000_drop_ticker_category_table.js +++ /dev/null @@ -1,21 +0,0 @@ -exports.up = (knex) => { - return knex.schema - .table('ticker', (table) => { - table.dropColumn('tickerCategoryId') - }) - .dropTable('ticker_category') -} - -exports.down = (knex) => { - return knex.schema - .createTable('ticker_category', (table) => { - table.increments('id') - table.string('name', 50).notNullable() - table.string('desc', 50).notNullable() - table.unique('name', 'ticker_category_ukey') - }) - .table('ticker', (table) => { - table.integer('tickerCategoryId') - table.foreign('tickerCategoryId').references('id').inTable('ticker_category') - }) -} diff --git a/server/migrations/20230416213000_remove_isSystem_to_env_table.js b/server/migrations/20230416213000_remove_isSystem_to_env_table.js deleted file mode 100644 index 2397ab53..00000000 --- a/server/migrations/20230416213000_remove_isSystem_to_env_table.js +++ /dev/null @@ -1,15 +0,0 @@ -exports.up = (knex) => { - return knex.schema - .table('trader_env', (table) => { - table.dropColumn('isSystem') - table.dropColumn('name') - }) -} - -exports.down = (knex) => { - return knex.schema - .table('trader_env', (table) => { - table.boolean('isSystem').notNullable() - table.string('name', 20) - }) -} diff --git a/server/migrations/20230418203000_remove_name_to_ticker_table.js b/server/migrations/20230418203000_remove_name_to_ticker_table.js deleted file mode 100644 index 69acedba..00000000 --- a/server/migrations/20230418203000_remove_name_to_ticker_table.js +++ /dev/null @@ -1,13 +0,0 @@ -exports.up = (knex) => { - return knex.schema - .table('ticker', (table) => { - table.dropColumn('name') - }) -} - -exports.down = (knex) => { - return knex.schema - .table('ticker', (table) => { - table.string('name', 50) - }) -} diff --git a/server/migrations/20230422180000_add_dataSource_to_entity_tables.js b/server/migrations/20230422180000_add_dataSource_to_entity_tables.js deleted file mode 100644 index 7d195814..00000000 --- a/server/migrations/20230422180000_add_dataSource_to_entity_tables.js +++ /dev/null @@ -1,15 +0,0 @@ -exports.up = (knex) => { - return knex.schema - .table('entity', (table) => { - table.string('dataSource', 20) - table.text('dataKey').alter() - }) -} - -exports.down = (knex) => { - return knex.schema - .table('ticker', (table) => { - table.dropColumn('dataSource') - table.string('dataKey', 20).alter() - }) -} diff --git a/server/migrations/20230423160000_alter_volume_to_ticker_daily_table.js b/server/migrations/20230423160000_alter_volume_to_ticker_daily_table.js deleted file mode 100644 index 2adc9777..00000000 --- a/server/migrations/20230423160000_alter_volume_to_ticker_daily_table.js +++ /dev/null @@ -1,15 +0,0 @@ -exports.up = (knex) => { - return knex.schema - .table('ticker_daily', (table) => { - table.integer('volume').alter() - table.dropColumn('dividendAmount') - }) -} - -exports.down = (knex) => { - return knex.schema - .table('ticker_daily', (table) => { - table.string('volume', 20).alter() - table.string('dividendAmount', 10).notNullable() - }) -} diff --git a/server/migrations/20230423200000_add_more_financial_indicators_to_ticker_tables.js b/server/migrations/20230423200000_add_more_financial_indicators_to_ticker_tables.js deleted file mode 100644 index 0e86e814..00000000 --- a/server/migrations/20230423200000_add_more_financial_indicators_to_ticker_tables.js +++ /dev/null @@ -1,87 +0,0 @@ -exports.up = (knex) => { - return knex.schema - .table('ticker', (table) => { - table.specificType('firstFinancialYear', 'CHAR(4)') - table.specificType('lastFinancialYear', 'CHAR(4)') - table.specificType('firstFinancialQuarter', 'CHAR(7)') - table.specificType('lastFinancialQuarter', 'CHAR(7)') - table.dropColumn('firstEPSYear') - table.dropColumn('lastEPSYear') - table.dropColumn('firstEPSQuarter') - table.dropColumn('lastEPSQuarter') - table.dropColumn('firstIncomeYear') - table.dropColumn('lastIncomeYear') - table.dropColumn('firstIncomeQuarter') - table.dropColumn('lastIncomeQuarter') - }) - .table('ticker_quarterly', (table) => { - table.string('equity', 20) - table.string('totalAssets', 20) - table.string('totalLiabilities', 20) - table.string('freeCashFlow', 20) - table.string('grossMargin', 20) - table.string('debtEquity', 20) - table.string('roa', 20) - table.string('roe', 20) - table.string('outstandingShares', 20) - table.string('epsQoQ', 5) - table.string('revenueQoQ', 5) - table.dropColumn('earningReportDate') - table.dropColumn('estimatedEPS') - table.dropColumn('epsSurprisePercent') - table.dropColumn('epsQuarterlyBeat') - table.dropColumn('epsQuarterlyMiss') - }) - .table('ticker_yearly', (table) => { - table.specificType('year', 'CHAR(7)').alter() - table.string('totalLiabilities', 20) - table.string('totalAssets', 20) - table.string('equity', 20) - table.string('outstandingShares', 20) - table.string('freeCashFlow', 20) - }) -} - -exports.down = (knex) => { - return knex.schema - .table('ticker', (table) => { - table.dropColumn('firstFinancialYear') - table.dropColumn('lastFinancialYear') - table.dropColumn('firstFinancialQuarter') - table.dropColumn('lastFinancialQuarter') - table.specificType('firstEPSYear', 'CHAR(4)') - table.specificType('lastEPSYear', 'CHAR(4)') - table.specificType('firstEPSQuarter', 'CHAR(7)') - table.specificType('lastEPSQuarter', 'CHAR(7)') - table.specificType('firstIncomeYear', 'CHAR(4)') - table.specificType('lastIncomeYear', 'CHAR(4)') - table.specificType('firstIncomeQuarter', 'CHAR(7)') - table.specificType('lastIncomeQuarter', 'CHAR(7)') - }) - .table('ticker_quarterly', (table) => { - table.specificType('earningReportDate', 'CHAR(10)') - table.dropColumn('equity') - table.dropColumn('totalAssets') - table.dropColumn('totalLiabilities') - table.dropColumn('freeCashFlow') - table.dropColumn('grossMargin') - table.dropColumn('debtEquity') - table.dropColumn('roa') - table.dropColumn('roe') - table.dropColumn('epsQoQ') - table.dropColumn('revenueQoQ') - table.dropColumn('outstandingShares') - table.string('estimatedEPS', 10) - table.string('epsSurprisePercent', 5) - table.smallint('epsQuarterlyBeat') - table.smallint('epsQuarterlyMiss') - }) - .table('ticker_yearly', (table) => { - table.specificType('year', 'CHAR(4)').alter() - table.dropColumn('totalLiabilities') - table.dropColumn('totalAssets') - table.dropColumn('equity') - table.dropColumn('freeCashFlow') - table.dropColumn('outstandingShares') - }) -} diff --git a/server/migrations/20230426200000_alter_yearly_financial_to_ticker_table.js b/server/migrations/20230426200000_alter_yearly_financial_to_ticker_table.js deleted file mode 100644 index 6c0f22ff..00000000 --- a/server/migrations/20230426200000_alter_yearly_financial_to_ticker_table.js +++ /dev/null @@ -1,15 +0,0 @@ -exports.up = (knex) => { - return knex.schema - .table('ticker', (table) => { - table.specificType('firstFinancialYear', 'CHAR(7)').alter() - table.specificType('lastFinancialYear', 'CHAR(7)').alter() - }) -} - -exports.down = (knex) => { - return knex.schema - .table('ticker', (table) => { - table.specificType('firstFinancialYear', 'CHAR(4)').alter() - table.specificType('lastFinancialYear', 'CHAR(4)').alter() - }) -} diff --git a/server/migrations/20230501200000_add_more_metrix_to_ticker_quarterly_and_yearly_tables.js b/server/migrations/20230501200000_add_more_metrix_to_ticker_quarterly_and_yearly_tables.js deleted file mode 100644 index 5b571215..00000000 --- a/server/migrations/20230501200000_add_more_metrix_to_ticker_quarterly_and_yearly_tables.js +++ /dev/null @@ -1,109 +0,0 @@ -exports.up = (knex) => { - return knex.schema - .table('ticker_yearly', (table) => { - table.string('peRatio', 5) - table.string('pbRatio', 5) - table.string('psRatio', 5) - table.smallint('peYearlyIncrease') - table.smallint('peYearlyDecrease') - table.smallint('pbYearlyIncrease') - table.smallint('pbYearlyDecrease') - table.smallint('psYearlyIncrease') - table.smallint('psYearlyDecrease') - table.smallint('epsYearlyIncrease') - table.smallint('epsYearlyDecrease') - table.smallint('ebitdaYearlyIncrease') - table.smallint('ebitdaYearlyDecrease') - table.smallint('bookValueYearlyIncrease') - table.smallint('bookValueYearlyDecrease') - table.smallint('equityYearlyIncrease') - table.smallint('equityYearlyDecrease') - table.smallint('freeCashFlowYearlyIncrease') - table.smallint('freeCashFlowYearlyDecrease') - }) - .table('ticker_quarterly', (table) => { - table.string('peRatio', 5) - table.string('pbRatio', 5) - table.string('psRatio', 5) - table.smallint('peQuarterlyIncrease') - table.smallint('peQuarterlyDecrease') - table.smallint('pbQuarterlyIncrease') - table.smallint('pbQuarterlyDecrease') - table.smallint('psQuarterlyIncrease') - table.smallint('psQuarterlyDecrease') - table.smallint('grossMarginQuarterlyIncrease') - table.smallint('grossMarginQuarterlyDecrease') - table.string('grossMarginChangePercent', 5) - table.smallint('debtEquityQuarterlyIncrease') - table.smallint('debtEquityQuarterlyDecrease') - table.smallint('epsQuarterlyIncrease') - table.smallint('epsQuarterlyDecrease') - table.smallint('ebitdaQuarterlyIncrease') - table.smallint('ebitdaQuarterlyDecrease') - table.smallint('bookValueQuarterlyIncrease') - table.smallint('bookValueQuarterlyDecrease') - table.smallint('equityQuarterlyIncrease') - table.smallint('equityQuarterlyDecrease') - table.smallint('freeCashFlowQuarterlyIncrease') - table.smallint('freeCashFlowQuarterlyDecrease') - table.smallint('roaQuarterlyIncrease') - table.smallint('roaQuarterlyDecrease') - table.smallint('roeQuarterlyIncrease') - table.smallint('roeQuarterlyDecrease') - }) -} - -exports.down = (knex) => { - return knex.schema - .table('ticker_yearly', (table) => { - table.dropColumn('peRatio') - table.dropColumn('pbRatio') - table.dropColumn('psRatio') - table.dropColumn('peYearlyIncrease') - table.dropColumn('peYearlyDecrease') - table.dropColumn('pbYearlyIncrease') - table.dropColumn('pbYearlyDecrease') - table.dropColumn('psYearlyIncrease') - table.dropColumn('psYearlyDecrease') - table.dropColumn('epsYearlyIncrease') - table.dropColumn('epsYearlyDecrease') - table.dropColumn('ebitdaYearlyIncrease') - table.dropColumn('ebitdaYearlyDecrease') - table.dropColumn('bookValueYearlyIncrease') - table.dropColumn('bookValueYearlyDecrease') - table.dropColumn('equityYearlyIncrease') - table.dropColumn('equityYearlyDecrease') - table.dropColumn('freeCashFlowYearlyIncrease') - table.dropColumn('freeCashFlowYearlyDecrease') - }) - .table('ticker_quarterly', (table) => { - table.dropColumn('peRatio') - table.dropColumn('pbRatio') - table.dropColumn('psRatio') - table.dropColumn('peQuarterlyIncrease') - table.dropColumn('peQuarterlyDecrease') - table.dropColumn('pbQuarterlyIncrease') - table.dropColumn('pbQuarterlyDecrease') - table.dropColumn('psQuarterlyIncrease') - table.dropColumn('psQuarterlyDecrease') - table.dropColumn('grossMarginQuarterlyIncrease') - table.dropColumn('grossMarginQuarterlyDecrease') - table.dropColumn('grossMarginChangePercent') - table.dropColumn('debtEquityQuarterlyIncrease') - table.dropColumn('debtEquityQuarterlyDecrease') - table.dropColumn('epsQuarterlyIncrease') - table.dropColumn('epsQuarterlyDecrease') - table.dropColumn('ebitdaQuarterlyIncrease') - table.dropColumn('ebitdaQuarterlyDecrease') - table.dropColumn('bookValueQuarterlyIncrease') - table.dropColumn('bookValueQuarterlyDecrease') - table.dropColumn('equityQuarterlyIncrease') - table.dropColumn('equityQuarterlyDecrease') - table.dropColumn('freeCashFlowQuarterlyIncrease') - table.dropColumn('freeCashFlowQuarterlyDecrease') - table.dropColumn('roaQuarterlyIncrease') - table.dropColumn('roaQuarterlyDecrease') - table.dropColumn('roeQuarterlyIncrease') - table.dropColumn('roeQuarterlyDecrease') - }) -} diff --git a/server/migrations/20230510210000_adjust_ticker_quarterly_and_yearly_tables.js b/server/migrations/20230510210000_adjust_ticker_quarterly_and_yearly_tables.js deleted file mode 100644 index 242d3e64..00000000 --- a/server/migrations/20230510210000_adjust_ticker_quarterly_and_yearly_tables.js +++ /dev/null @@ -1,36 +0,0 @@ -exports.up = (knex) => { - return knex.schema - .table('ticker_yearly', (table) => { - table.string('bookValue', 20) - table.string('peRatio', 7).alter() - table.string('pbRatio', 7).alter() - table.string('psRatio', 7).alter() - }) - .table('ticker_quarterly', (table) => { - table.string('bookValue', 20) - table.string('peRatio', 7).alter() - table.string('pbRatio', 7).alter() - table.string('psRatio', 7).alter() - table.dropColumn('grossMarginChangePercent') - table.string('grossMarginQoQ', 7) - table.string('debtEquityQoQ', 7) - }) -} - -exports.down = (knex) => { - return knex.schema - .table('ticker_yearly', (table) => { - table.dropColumn('bookValue') - table.string('peRatio', 5).alter() - table.string('pbRatio', 5).alter() - table.string('psRatio', 5).alter() - }) - .table('ticker_quarterly', (table) => { - table.dropColumn('bookValue') - table.string('peRatio', 5).alter() - table.string('pbRatio', 5).alter() - table.string('psRatio', 5).alter() - table.dropColumn('grossMarginQoQ') - table.dropColumn('debtEquityQoQ') - }) -} diff --git a/server/migrations/20230520223000_adjust_indicator_tables.js b/server/migrations/20230520223000_adjust_indicator_tables.js deleted file mode 100644 index f9976844..00000000 --- a/server/migrations/20230520223000_adjust_indicator_tables.js +++ /dev/null @@ -1,29 +0,0 @@ -exports.up = (knex) => { - return knex.schema - .table('indicator_quarterly', (table) => { - table.dropColumn('reportMonth') - table.dropColumn('gdpQuarterlyChangePercent') - table.dropColumn('gdpQuarterlyYoYChangePercent') - table.string('gdpQuarterlyQoQ', 7) - table.string('gdpQuarterlyYoY', 7) - }) - .table('indicator_yearly', (table) => { - table.dropColumn('realGDP') - table.string('gdp', 12) - }) -} - -exports.down = (knex) => { - return knex.schema - .table('indicator_quarterly', (table) => { - table.specificType('reportMonth', 'CHAR(7)') - table.specificType('gdpQuarterlyChangePercent', 'CHAR(5)') - table.specificType('gdpQuarterlyYoYChangePercent', 'CHAR(5)') - table.dropColumn('gdpQuarterlyQoQ') - table.dropColumn('gdpQuarterlyYoY') - }) - .table('indicator_yearly', (table) => { - table.dropColumn('gdp') - table.string('realGDP', 12) - }) -} diff --git a/server/migrations/20230521120000_adjust_indicator_quarterly_table.js b/server/migrations/20230521120000_adjust_indicator_quarterly_table.js deleted file mode 100644 index a4cdceaa..00000000 --- a/server/migrations/20230521120000_adjust_indicator_quarterly_table.js +++ /dev/null @@ -1,23 +0,0 @@ -exports.up = (knex) => { - return knex.schema - .table('indicator_quarterly', (table) => { - table.dropColumn('realGDP') - table.dropColumn('gdpQuarterlyQoQ') - table.dropColumn('gdpQuarterlyYoY') - table.string('seasonalGDP', 12) - table.string('seasonalGDPQoQ', 7) - table.string('seasonalGDPYoY', 7) - }) -} - -exports.down = (knex) => { - return knex.schema - .table('indicator_quarterly', (table) => { - table.dropColumn('seasonalGDP') - table.dropColumn('seasonalGDPQoQ') - table.dropColumn('seasonalGDPYoY') - table.string('realGDP', 12) - table.string('gdpQuarterlyQoQ', 7) - table.string('gdpQuarterlyYoY', 7) - }) -} diff --git a/server/migrations/20230521130000_adjust_indicator_monthly_table.js b/server/migrations/20230521130000_adjust_indicator_monthly_table.js deleted file mode 100644 index dab1d316..00000000 --- a/server/migrations/20230521130000_adjust_indicator_monthly_table.js +++ /dev/null @@ -1,15 +0,0 @@ -exports.up = (knex) => { - return knex.schema - .table('indicator_monthly', (table) => { - table.renameColumn('inflationExpectation', 'inflation') - table.dropColumn('retailSales') - table.dropColumn('durableGoods') - }) -} - -exports.down = (knex) => { - return knex.schema - .table('indicator_monthly', (table) => { - table.renameColumn('inflation', 'inflationExpectation') - }) -} diff --git a/server/migrations/20230521143000_remove_unused_behavior_table.js b/server/migrations/20230521143000_remove_unused_behavior_table.js deleted file mode 100644 index c664dfc7..00000000 --- a/server/migrations/20230521143000_remove_unused_behavior_table.js +++ /dev/null @@ -1,16 +0,0 @@ -exports.up = (knex) => { - return knex.schema - .table('trader_pattern', (table) => { - table.dropColumn('durableGoodsMonthlyIncreaseBuy') - table.dropColumn('durableGoodsMonthlyDecreaseBuy') - table.dropColumn('durableGoodsMonthlyIncreaseSell') - table.dropColumn('durableGoodsMonthlyDecreaseSell') - table.dropColumn('retailSalesMonthlyIncreaseBuy') - table.dropColumn('retailSalesMonthlyDecreaseBuy') - table.dropColumn('retailSalesMonthlyIncreaseSell') - table.dropColumn('retailSalesMonthlyDecreaseSell') - }) -} - -exports.down = () => { -} diff --git a/server/migrations/20230521163000_add_more_yearly_indicators.js b/server/migrations/20230521163000_add_more_yearly_indicators.js deleted file mode 100644 index b472b65c..00000000 --- a/server/migrations/20230521163000_add_more_yearly_indicators.js +++ /dev/null @@ -1,23 +0,0 @@ -exports.up = (knex) => { - return knex.schema - .table('indicator_yearly', (table) => { - table.smallint('gdpYearlyIncrease') - table.smallint('gdpYearlyDecrease') - }) - .table('indicator_quarterly', (table) => { - table.smallint('seasonalGDPQuarterlyIncrease') - table.smallint('seasonalGDPQuarterlyDecrease') - }) -} - -exports.down = (knex) => { - return knex.schema - .table('indicator_yearly', (table) => { - table.dropColumn('gdpYearlyIncrease') - table.dropColumn('gdpYearlyDecrease') - }) - .table('indicator_quarterly', (table) => { - table.dropColumn('seasonalGDPQuarterlyIncrease') - table.dropColumn('seasonalGDPQuarterlyDecrease') - }) -} diff --git a/server/migrations/20230521203000_remove_unused_monthly_indicators.js b/server/migrations/20230521203000_remove_unused_monthly_indicators.js deleted file mode 100644 index ae8d407c..00000000 --- a/server/migrations/20230521203000_remove_unused_monthly_indicators.js +++ /dev/null @@ -1,12 +0,0 @@ -exports.up = (knex) => { - return knex.schema - .table('indicator_monthly', (table) => { - table.dropColumn('durableGoodsMonthlyIncrease') - table.dropColumn('durableGoodsMonthlyDecrease') - table.dropColumn('retailSalesMonthlyIncrease') - table.dropColumn('retailSalesMonthlyDecrease') - }) -} - -exports.down = () => { -} diff --git a/server/migrations/20230603172000_adjust_daily_tickers_table.js b/server/migrations/20230603172000_adjust_daily_tickers_table.js deleted file mode 100644 index d93f0904..00000000 --- a/server/migrations/20230603172000_adjust_daily_tickers_table.js +++ /dev/null @@ -1,17 +0,0 @@ -exports.up = (knex) => { - return knex.schema - .table('daily_tickers', (table) => { - table.dropColumn('indicators') - table.renameColumn('tickers', 'tickerInfos') - table.renameColumn('nearestPrices', 'priceInfo') - }) -} - -exports.down = (knex) => { - return knex.schema - .table('daily_tickers', (table) => { - table.jsonb('indicators') - table.renameColumn('tickerInfos', 'tickers') - table.renameColumn('priceInfo', 'nearestPrices') - }) -} diff --git a/server/migrations/20230606220000_update_pattern_table.js b/server/migrations/20230606220000_update_pattern_table.js deleted file mode 100644 index 6dc00fc6..00000000 --- a/server/migrations/20230606220000_update_pattern_table.js +++ /dev/null @@ -1,155 +0,0 @@ -exports.up = (knex) => { - return knex.schema - .table('trader_pattern', (table) => { - table.renameColumn('gdpQuarterlyChangeAboveBuy', 'seasonalGDPQoQAboveBuy') - table.renameColumn('gdpQuarterlyChangeAboveSell', 'seasonalGDPQoQAboveSell') - table.renameColumn('gdpQuarterlyChangeBelowBuy', 'seasonalGDPQoQBelowBuy') - table.renameColumn('gdpQuarterlyChangeBelowSell', 'seasonalGDPQoQBelowSell') - table.renameColumn('gdpQuarterlyYoYChangeAboveBuy', 'seasonalGDPYoYAboveBuy') - table.renameColumn('gdpQuarterlyYoYChangeAboveSell', 'seasonalGDPYoYAboveSell') - table.renameColumn('gdpQuarterlyYoYChangeBelowBuy', 'seasonalGDPYoYBelowBuy') - table.renameColumn('gdpQuarterlyYoYChangeBelowSell', 'seasonalGDPYoYBelowSell') - table.smallint('peQuarterlyIncreaseBuy') - table.smallint('peQuarterlyIncreaseSell') - table.smallint('peQuarterlyDecreaseBuy') - table.smallint('peQuarterlyDecreaseSell') - table.smallint('pbQuarterlyIncreaseBuy') - table.smallint('pbQuarterlyIncreaseSell') - table.smallint('pbQuarterlyDecreaseBuy') - table.smallint('pbQuarterlyDecreaseSell') - table.smallint('psQuarterlyIncreaseBuy') - table.smallint('psQuarterlyIncreaseSell') - table.smallint('psQuarterlyDecreaseBuy') - table.smallint('psQuarterlyDecreaseSell') - table.smallint('epsQuarterlyIncreaseBuy') - table.smallint('epsQuarterlyIncreaseSell') - table.smallint('epsQuarterlyDecreaseBuy') - table.smallint('epsQuarterlyDecreaseSell') - table.smallint('ebitdaQuarterlyIncreaseBuy') - table.smallint('ebitdaQuarterlyIncreaseSell') - table.smallint('ebitdaQuarterlyDecreaseBuy') - table.smallint('ebitdaQuarterlyDecreaseSell') - table.smallint('freeCashFlowQuarterlyIncreaseBuy') - table.smallint('freeCashFlowQuarterlyIncreaseSell') - table.smallint('freeCashFlowQuarterlyDecreaseBuy') - table.smallint('freeCashFlowQuarterlyDecreaseSell') - table.smallint('roaQuarterlyIncreaseBuy') - table.smallint('roaQuarterlyIncreaseSell') - table.smallint('roaQuarterlyDecreaseBuy') - table.smallint('roaQuarterlyDecreaseSell') - table.smallint('roeQuarterlyIncreaseBuy') - table.smallint('roeQuarterlyIncreaseSell') - table.smallint('roeQuarterlyDecreaseBuy') - table.smallint('roeQuarterlyDecreaseSell') - table.smallint('grossMarginQuarterlyIncreaseBuy') - table.smallint('grossMarginQuarterlyIncreaseSell') - table.smallint('grossMarginQuarterlyDecreaseBuy') - table.smallint('grossMarginQuarterlyDecreaseSell') - table.smallint('debtEquityQuarterlyIncreaseBuy') - table.smallint('debtEquityQuarterlyIncreaseSell') - table.smallint('debtEquityQuarterlyDecreaseBuy') - table.smallint('debtEquityQuarterlyDecreaseSell') - table.smallint('peRatioQuarterlyAboveBuy') - table.smallint('peRatioQuarterlyAboveSell') - table.smallint('peRatioQuarterlyBelowBuy') - table.smallint('peRatioQuarterlyBelowSell') - table.smallint('pbRatioQuarterlyAboveBuy') - table.smallint('pbRatioQuarterlyAboveSell') - table.smallint('pbRatioQuarterlyBelowBuy') - table.smallint('pbRatioQuarterlyBelowSell') - table.smallint('psRatioQuarterlyAboveBuy') - table.smallint('psRatioQuarterlyAboveSell') - table.smallint('psRatioQuarterlyBelowBuy') - table.smallint('psRatioQuarterlyBelowSell') - table.smallint('roaQuarterlyAboveBuy') - table.smallint('roaQuarterlyAboveSell') - table.smallint('roaQuarterlyBelowBuy') - table.smallint('roaQuarterlyBelowSell') - table.smallint('roeQuarterlyAboveBuy') - table.smallint('roeQuarterlyAboveSell') - table.smallint('roeQuarterlyBelowBuy') - table.smallint('roeQuarterlyBelowSell') - table.smallint('grossMarginQuarterlyAboveBuy') - table.smallint('grossMarginQuarterlyAboveSell') - table.smallint('grossMarginQuarterlyBelowBuy') - table.smallint('grossMarginQuarterlyBelowSell') - table.smallint('debtEquityQuarterlyAboveBuy') - table.smallint('debtEquityQuarterlyAboveSell') - table.smallint('debtEquityQuarterlyBelowBuy') - table.smallint('debtEquityQuarterlyBelowSell') - table.smallint('peYearlyIncreaseBuy') - table.smallint('peYearlyIncreaseSell') - table.smallint('peYearlyDecreaseBuy') - table.smallint('peYearlyDecreaseSell') - table.smallint('pbYearlyIncreaseBuy') - table.smallint('pbYearlyIncreaseSell') - table.smallint('pbYearlyDecreaseBuy') - table.smallint('pbYearlyDecreaseSell') - table.smallint('psYearlyIncreaseBuy') - table.smallint('psYearlyIncreaseSell') - table.smallint('psYearlyDecreaseBuy') - table.smallint('psYearlyDecreaseSell') - table.smallint('epsYearlyIncreaseBuy') - table.smallint('epsYearlyIncreaseSell') - table.smallint('epsYearlyDecreaseBuy') - table.smallint('epsYearlyDecreaseSell') - table.smallint('ebitdaYearlyIncreaseBuy') - table.smallint('ebitdaYearlyIncreaseSell') - table.smallint('ebitdaYearlyDecreaseBuy') - table.smallint('ebitdaYearlyDecreaseSell') - table.smallint('freeCashFlowYearlyIncreaseBuy') - table.smallint('freeCashFlowYearlyIncreaseSell') - table.smallint('freeCashFlowYearlyDecreaseBuy') - table.smallint('freeCashFlowYearlyDecreaseSell') - table.smallint('peRatioYearlyAboveBuy') - table.smallint('peRatioYearlyAboveSell') - table.smallint('peRatioYearlyBelowBuy') - table.smallint('peRatioYearlyBelowSell') - table.smallint('pbRatioYearlyAboveBuy') - table.smallint('pbRatioYearlyAboveSell') - table.smallint('pbRatioYearlyBelowBuy') - table.smallint('pbRatioYearlyBelowSell') - table.smallint('psRatioYearlyAboveBuy') - table.smallint('psRatioYearlyAboveSell') - table.smallint('psRatioYearlyBelowBuy') - table.smallint('psRatioYearlyBelowSell') - table.smallint('fundsRateMonthlyAboveBuy') - table.smallint('fundsRateMonthlyAboveSell') - table.smallint('fundsRateMonthlyBelowBuy') - table.smallint('fundsRateMonthlyBelowSell') - table.smallint('tenYearsTreasuryMonthlyAboveBuy') - table.smallint('tenYearsTreasuryMonthlyAboveSell') - table.smallint('tenYearsTreasuryMonthlyBelowBuy') - table.smallint('tenYearsTreasuryMonthlyBelowSell') - table.smallint('thirtyYearsTreasuryMonthlyAboveBuy') - table.smallint('thirtyYearsTreasuryMonthlyAboveSell') - table.smallint('thirtyYearsTreasuryMonthlyBelowBuy') - table.smallint('thirtyYearsTreasuryMonthlyBelowSell') - table.smallint('inflationMonthlyAboveBuy') - table.smallint('inflationMonthlyAboveSell') - table.smallint('inflationMonthlyBelowBuy') - table.smallint('inflationMonthlyBelowSell') - table.smallint('consumerSentimentMonthlyAboveBuy') - table.smallint('consumerSentimentMonthlyAboveSell') - table.smallint('consumerSentimentMonthlyBelowBuy') - table.smallint('consumerSentimentMonthlyBelowSell') - table.smallint('nonfarmPayrollMonthlyAboveBuy') - table.smallint('nonfarmPayrollMonthlyAboveSell') - table.smallint('nonfarmPayrollMonthlyBelowBuy') - table.smallint('nonfarmPayrollMonthlyBelowSell') - table.smallint('seasonalGDPQuarterlyIncreaseBuy') - table.smallint('seasonalGDPQuarterlyIncreaseSell') - table.smallint('seasonalGDPQuarterlyDecreaseBuy') - table.smallint('seasonalGDPQuarterlyDecreaseSell') - table.smallint('gdpYearlyIncreaseBuy') - table.smallint('gdpYearlyIncreaseSell') - table.smallint('gdpYearlyDecreaseBuy') - table.smallint('gdpYearlyDecreaseSell') - table.smallint('inflationYearlyAboveBuy') - table.smallint('inflationYearlyAboveSell') - table.smallint('inflationYearlyBelowBuy') - table.smallint('inflationYearlyBelowSell') - }) -} - -exports.down = () => {} diff --git a/server/migrations/20230625060000_rename_yearly_inflation_column.js b/server/migrations/20230625060000_rename_yearly_inflation_column.js deleted file mode 100644 index 1666dab3..00000000 --- a/server/migrations/20230625060000_rename_yearly_inflation_column.js +++ /dev/null @@ -1,13 +0,0 @@ -exports.up = (knex) => { - return knex.schema - .table('indicator_yearly', (table) => { - table.renameColumn('inflation', 'annualInflation') - }) -} - -exports.down = (knex) => { - return knex.schema - .table('indicator_yearly', (table) => { - table.renameColumn('annualInflation', 'inflation') - }) -} diff --git a/server/migrations/20231009130000_rename_yearly_ratio_columns.js b/server/migrations/20231009130000_rename_yearly_ratio_columns.js deleted file mode 100644 index fc84a750..00000000 --- a/server/migrations/20231009130000_rename_yearly_ratio_columns.js +++ /dev/null @@ -1,17 +0,0 @@ -exports.up = (knex) => { - return knex.schema - .table('ticker_yearly', (table) => { - table.renameColumn('peRatio', 'annualPeRatio') - table.renameColumn('pbRatio', 'annualPbRatio') - table.renameColumn('psRatio', 'annualPsRatio') - }) -} - -exports.down = (knex) => { - return knex.schema - .table('ticker_yearly', (table) => { - table.renameColumn('annualPeRatio', 'peRatio') - table.renameColumn('annualPbRatio', 'pbRatio') - table.renameColumn('annualPsRatio', 'psRatio') - }) -} diff --git a/server/migrations/test-seeds/daily_tickers.js b/server/migrations/test-seeds/daily_tickers.js deleted file mode 100644 index d1aa7f20..00000000 --- a/server/migrations/test-seeds/daily_tickers.js +++ /dev/null @@ -1,12 +0,0 @@ -exports.seed = (knex) => { - return knex('daily_tickers').insert([ - { - date: '2022-01-01', - entityId: 1, - tickerInfos: {}, - priceInfo: {}, - }, - ]) -} - -exports.down = () => {} diff --git a/server/migrations/test-seeds/email.js b/server/migrations/test-seeds/email.js deleted file mode 100644 index c107b6e6..00000000 --- a/server/migrations/test-seeds/email.js +++ /dev/null @@ -1,39 +0,0 @@ -exports.seed = (knex) => { - return knex('email').insert([ - { - id: '5ed6d4c8-c159-4588-b966-364a4bdbd3a1', - sendTo: 'a@company.com', - sendBy: 'test@email.com', - title: 'activation email', - content: 'This is an activation email', - status: 2, - response: { completed: true }, - createdAt: '2019-01-01', - sentAt: '2019-01-02', - }, - { - id: '5ed6d4c8-c159-4588-b966-364a4bdbd3a2', - sendTo: 'b@company.com', - sendBy: 'test@email.com', - title: 'activation email', - content: 'This is an activation email', - status: 0, - response: null, - createdAt: '2019-01-01', - sentAt: null, - }, - { - id: '5ed6d4c8-c159-4588-b966-364a4bdbd3a3', - sendTo: 'c@company.com', - sendBy: 'test@email.com', - title: 'set password email', - content: 'This is reset password email', - status: 0, - response: null, - createdAt: '2019-01-02', - sentAt: null, - }, - ]) -} - -exports.down = () => {} diff --git a/server/migrations/test-seeds/entity.js b/server/migrations/test-seeds/entity.js deleted file mode 100644 index 7456d3fb..00000000 --- a/server/migrations/test-seeds/entity.js +++ /dev/null @@ -1,15 +0,0 @@ -exports.seed = (knex) => { - return knex('entity').insert([ - { - dataKey: null, - }, - { - dataKey: null, - }, - { - dataKey: null, - }, - ]) -} - -exports.down = () => {} diff --git a/server/migrations/test-seeds/indicator_monthly.js b/server/migrations/test-seeds/indicator_monthly.js deleted file mode 100644 index 60af6fae..00000000 --- a/server/migrations/test-seeds/indicator_monthly.js +++ /dev/null @@ -1,44 +0,0 @@ -exports.seed = (knex) => { - return knex('indicator_monthly').insert([ - { - month: '2021-12', - fundsRate: '1.11', - thirtyYearsTreasury: '2.22', - tenYearsTreasury: '3.33', - cpi: '4.44', - inflation: '5.55', - consumerSentiment: '6.66', - unemploymentRate: '9.99', - nonfarmPayroll: '1010', - fundsRateMonthlyIncrease: 1, - fundsRateMonthlyDecrease: 2, - thirtyYearsTreasuryMonthlyIncrease: 3, - thirtyYearsTreasuryMonthlyDecrease: 4, - tenYearsTreasuryMonthlyIncrease: 4, - tenYearsTreasuryMonthlyDecrease: 3, - inflationMonthlyIncrease: 2, - inflationMonthlyDecrease: 1, - cpiMonthlyIncrease: 0, - cpiMonthlyDecrease: 1, - consumerSentimentMonthlyIncrease: 1, - consumerSentimentMonthlyDecrease: 0, - unemploymentRateMonthlyIncrease: 2, - unemploymentRateMonthlyDecrease: 2, - nonfarmPayrollMonthlyIncrease: 1, - nonfarmPayrollMonthlyDecrease: 1, - }, - { - month: '2022-01', - fundsRate: '1.12', - thirtyYearsTreasury: '2.23', - tenYearsTreasury: '3.34', - cpi: '4.45', - inflation: '5.56', - consumerSentiment: '6.67', - unemploymentRate: '10.00', - nonfarmPayroll: '1011', - }, - ]) -} - -exports.down = () => {} diff --git a/server/migrations/test-seeds/indicator_quarterly.js b/server/migrations/test-seeds/indicator_quarterly.js deleted file mode 100644 index b724ce1e..00000000 --- a/server/migrations/test-seeds/indicator_quarterly.js +++ /dev/null @@ -1,18 +0,0 @@ -exports.seed = (knex) => { - return knex('indicator_quarterly').insert([ - { - quarter: '2021-12', - seasonalGDP: '11111111', - seasonalGDPQoQ: '1.11', - seasonalGDPYoY: '-2.22', - }, - { - quarter: '2022-03', - seasonalGDP: '11113333', - seasonalGDPQoQ: '2.22', - seasonalGDPYoY: '3.33', - }, - ]) -} - -exports.down = () => {} diff --git a/server/migrations/test-seeds/indicator_yearly.js b/server/migrations/test-seeds/indicator_yearly.js deleted file mode 100644 index 8392dd3d..00000000 --- a/server/migrations/test-seeds/indicator_yearly.js +++ /dev/null @@ -1,19 +0,0 @@ -exports.seed = (knex) => { - return knex('indicator_yearly').insert([ - { - year: '2020', - gdp: '11111111', - annualInflation: '2.22', - gdpYearlyChangePercent: '1.11', - inflationYearlyIncrease: 2, - inflationYearlyDecrease: 0, - }, - { - year: '2021', - gdp: '11112222', - annualInflation: '1.22', - }, - ]) -} - -exports.down = () => {} diff --git a/server/migrations/test-seeds/policy.js b/server/migrations/test-seeds/policy.js deleted file mode 100644 index 1b3035c0..00000000 --- a/server/migrations/test-seeds/policy.js +++ /dev/null @@ -1,19 +0,0 @@ -exports.seed = (knex) => { - return knex('policy').insert([ - { - type: 1, - content: 'Privacy policy 1', - createdAt: new Date('2022-01-01'), - }, - { - type: 2, - content: 'Terms and Conditions 1', - createdAt: new Date(), - }, - { - type: 1, - content: 'Privacy policy 2', - createdAt: new Date('2022-03-01'), - }, - ]) -} diff --git a/server/migrations/test-seeds/ticker.js b/server/migrations/test-seeds/ticker.js deleted file mode 100644 index 21725518..00000000 --- a/server/migrations/test-seeds/ticker.js +++ /dev/null @@ -1,9 +0,0 @@ -exports.seed = (knex) => { - return knex('ticker').insert([ - { entityId: 1, symbol: 'AAPL', region: 'US', isDelisted: false, name: 'Apple Inc.' }, - { entityId: 1, symbol: 'MSFT', region: 'US', isDelisted: false, name: 'Microsoft Corp' }, - { entityId: 2, symbol: 'GOOG', region: 'US', isDelisted: false, name: 'Google' }, - ]) -} - -exports.down = () => {} diff --git a/server/migrations/test-seeds/ticker_daily.js b/server/migrations/test-seeds/ticker_daily.js deleted file mode 100644 index f716f190..00000000 --- a/server/migrations/test-seeds/ticker_daily.js +++ /dev/null @@ -1,174 +0,0 @@ -exports.seed = (knex) => { - return knex('ticker_daily').insert([ - { - tickerId: 1, - date: '2021-12-31', - volume: 100000, - closePrice: 100, - splitMultiplier: '1.00000', - weeklyAverageFinalPrice: null, - monthlyAverageFinalPrice: null, - quarterlyAverageFinalPrice: null, - yearlyAverageFinalPrice: null, - priceDailyIncrease: null, - priceDailyDecrease: null, - priceWeeklyIncrease: null, - priceWeeklyDecrease: null, - priceMonthlyIncrease: null, - priceMonthlyDecrease: null, - priceQuarterlyIncrease: null, - priceQuarterlyDecrease: null, - priceYearlyIncrease: null, - priceYearlyDecrease: null, - }, - { - tickerId: 1, - date: '2022-01-01', - volume: 111111, - closePrice: 105, - splitMultiplier: '1.00000', - weeklyAverageFinalPrice: 112, - monthlyAverageFinalPrice: 113, - quarterlyAverageFinalPrice: 114, - yearlyAverageFinalPrice: 115, - priceDailyIncrease: 1, - priceDailyDecrease: 0, - priceWeeklyIncrease: null, - priceWeeklyDecrease: null, - priceMonthlyIncrease: null, - priceMonthlyDecrease: null, - priceQuarterlyIncrease: null, - priceQuarterlyDecrease: null, - priceYearlyIncrease: null, - priceYearlyDecrease: null, - }, - { - tickerId: 1, - date: '2022-01-02', - volume: 100111, - closePrice: 107, - splitMultiplier: '1.00000', - weeklyAverageFinalPrice: 111, - monthlyAverageFinalPrice: 112, - quarterlyAverageFinalPrice: 113, - yearlyAverageFinalPrice: 114, - priceDailyIncrease: 0, - priceDailyDecrease: 1, - priceWeeklyIncrease: 0, - priceWeeklyDecrease: 1, - priceMonthlyIncrease: 0, - priceMonthlyDecrease: 1, - priceQuarterlyIncrease: null, - priceQuarterlyDecrease: null, - priceYearlyIncrease: null, - priceYearlyDecrease: null, - }, - { - tickerId: 1, - date: '2022-01-03', - volume: 999999, - closePrice: 50, - splitMultiplier: '2.00000', - weeklyAverageFinalPrice: 100, - monthlyAverageFinalPrice: 104, - quarterlyAverageFinalPrice: 105, - yearlyAverageFinalPrice: 106, - priceDailyIncrease: 0, - priceDailyDecrease: 2, - priceWeeklyIncrease: 0, - priceWeeklyDecrease: 1, - priceMonthlyIncrease: 0, - priceMonthlyDecrease: 1, - priceQuarterlyIncrease: 0, - priceQuarterlyDecrease: 0, - priceYearlyIncrease: null, - priceYearlyDecrease: null, - }, - { - tickerId: 1, - date: '2022-01-04', - volume: 1022222, - closePrice: 23, - splitMultiplier: '4.00000', - weeklyAverageFinalPrice: 101, - monthlyAverageFinalPrice: 105, - quarterlyAverageFinalPrice: 106, - yearlyAverageFinalPrice: 107, - priceDailyIncrease: 1, - priceDailyDecrease: 0, - priceWeeklyIncrease: 0, - priceWeeklyDecrease: 0, - priceMonthlyIncrease: 1, - priceMonthlyDecrease: 0, - priceQuarterlyIncrease: 1, - priceQuarterlyDecrease: 0, - priceYearlyIncrease: 1, - priceYearlyDecrease: 0, - }, - { - tickerId: 2, - date: '2021-12-31', - volume: 100000, - closePrice: 32, - splitMultiplier: '1.00000', - weeklyAverageFinalPrice: 30, - monthlyAverageFinalPrice: 31, - quarterlyAverageFinalPrice: 28, - yearlyAverageFinalPrice: 35, - priceDailyIncrease: 1, - priceDailyDecrease: 0, - priceWeeklyIncrease: 2, - priceWeeklyDecrease: 0, - priceMonthlyIncrease: 3, - priceMonthlyDecrease: 0, - priceQuarterlyIncrease: 2, - priceQuarterlyDecrease: 0, - priceYearlyIncrease: 1, - priceYearlyDecrease: 0, - }, - { - tickerId: 2, - date: '2022-01-02', - volume: 120000, - closePrice: 40, - splitMultiplier: '1.00000', - weeklyAverageFinalPrice: 35, - monthlyAverageFinalPrice: 33, - quarterlyAverageFinalPrice: 31, - yearlyAverageFinalPrice: 39, - priceDailyIncrease: 2, - priceDailyDecrease: 0, - priceWeeklyIncrease: 2, - priceWeeklyDecrease: 0, - priceMonthlyIncrease: 3, - priceMonthlyDecrease: 0, - priceQuarterlyIncrease: 2, - priceQuarterlyDecrease: 0, - priceYearlyIncrease: 1, - priceYearlyDecrease: 0, - }, - { - tickerId: 3, - date: '2022-01-01', - volume: 80000, - closePrice: 1111, - splitMultiplier: '1.00000', - weeklyAverageFinalPrice: 1111, - monthlyAverageFinalPrice: 1112, - quarterlyAverageFinalPrice: 1113, - yearlyAverageFinalPrice: 1114, - priceDailyIncrease: 0, - priceDailyDecrease: 5, - priceWeeklyIncrease: 0, - priceWeeklyDecrease: 4, - priceMonthlyIncrease: 0, - priceMonthlyDecrease: 3, - priceQuarterlyIncrease: 0, - priceQuarterlyDecrease: 2, - priceYearlyIncrease: 0, - priceYearlyDecrease: 1, - }, - ]) -} - -exports.down = () => {} diff --git a/server/migrations/test-seeds/ticker_holder.js b/server/migrations/test-seeds/ticker_holder.js deleted file mode 100644 index 2dfa8e4e..00000000 --- a/server/migrations/test-seeds/ticker_holder.js +++ /dev/null @@ -1,52 +0,0 @@ -exports.seed = (knex) => { - return knex('ticker_holder').insert([ - { - tickerId: 1, - traderId: 1, - }, - { - tickerId: 2, - traderId: 1, - }, - { - tickerId: 3, - traderId: 1, - }, - { - tickerId: 1, - traderId: 2, - }, - { - tickerId: 1, - traderId: 3, - }, - { - tickerId: 1, - traderId: 4, - }, - { - tickerId: 1, - traderId: 53, - }, - { - tickerId: 2, - traderId: 53, - }, - { - tickerId: 2, - traderId: 54, - }, - { - tickerId: 2, - traderId: 55, - }, - { - tickerId: 1, - traderId: 56, - }, - { - tickerId: 2, - traderId: 56, - }, - ]) -} diff --git a/server/migrations/test-seeds/ticker_quarterly.js b/server/migrations/test-seeds/ticker_quarterly.js deleted file mode 100644 index eb3470e0..00000000 --- a/server/migrations/test-seeds/ticker_quarterly.js +++ /dev/null @@ -1,102 +0,0 @@ -exports.seed = (knex) => { - return knex('ticker_quarterly').insert([ - { - tickerId: 1, - quarter: '2021-12', - earningDate: '2021-12-31', - eps: '0.05', - ebitda: '1111111111', - netIncome: '1000000000', - grossProfit: '555555555', - totalRevenue: '150000000000', - costOfRevenue: '888888888', - profitQuarterlyIncrease: 1, - profitQuarterlyDecrease: 0, - revenueQuarterlyIncrease: 0, - revenueQuarterlyDecrease: 0, - incomeQuarterlyIncrease: 1, - incomeQuarterlyDecrease: 0, - }, - { - tickerId: 1, - quarter: '2022-03', - earningDate: '2021-03-31', - eps: '0.02', - ebitda: '999999999', - netIncome: '888888888', - grossProfit: '444444444', - totalRevenue: '10000000000', - costOfRevenue: '333333333', - profitQuarterlyIncrease: 1, - profitQuarterlyDecrease: 1, - revenueQuarterlyIncrease: 0, - revenueQuarterlyDecrease: 1, - incomeQuarterlyIncrease: 0, - incomeQuarterlyDecrease: 1, - }, - { - tickerId: 1, - quarter: '2022-06', - earningDate: '2021-06-30', - eps: '0.05', - ebitda: '1200000000', - netIncome: '99999999', - grossProfit: '66666666', - totalRevenue: '1500000000', - costOfRevenue: '22222222', - }, - { - tickerId: 2, - quarter: '2022-03', - earningDate: '2021-04-30', - eps: '0.2', - ebitda: '200000', - netIncome: '100000', - grossProfit: '300000', - totalRevenue: '700000', - costOfRevenue: '400000', - profitQuarterlyIncrease: null, - profitQuarterlyDecrease: null, - revenueQuarterlyIncrease: null, - revenueQuarterlyDecrease: null, - incomeQuarterlyIncrease: null, - incomeQuarterlyDecrease: null, - }, - { - tickerId: 2, - quarter: '2022-06', - earningDate: '2021-07-31', - eps: '0.3', - ebitda: '210000', - netIncome: '110000', - grossProfit: '310000', - totalRevenue: '710000', - costOfRevenue: '410000', - profitQuarterlyIncrease: 1, - profitQuarterlyDecrease: 0, - revenueQuarterlyIncrease: 1, - revenueQuarterlyDecrease: 0, - incomeQuarterlyIncrease: 1, - incomeQuarterlyDecrease: 0, - }, - { - tickerId: 2, - quarter: '2022-09', - earningDate: '2022-10-30', - eps: '0.3', - ebitda: '110000', - netIncome: null, - grossProfit: '150000', - totalRevenue: '360000', - costOfRevenue: '210000', - profitQuarterlyIncrease: 0, - profitQuarterlyDecrease: 1, - revenueQuarterlyIncrease: 0, - revenueQuarterlyDecrease: 1, - incomeQuarterlyIncrease: null, - incomeQuarterlyDecrease: null, - }, - ]) -} - -exports.down = () => {} diff --git a/server/migrations/test-seeds/ticker_yearly.js b/server/migrations/test-seeds/ticker_yearly.js deleted file mode 100644 index dc14fa3e..00000000 --- a/server/migrations/test-seeds/ticker_yearly.js +++ /dev/null @@ -1,72 +0,0 @@ -exports.seed = (knex) => { - return knex('ticker_yearly').insert([ - { - tickerId: 1, - year: '2020', - earningDate: '2020-09-30', - eps: '0.9', - ebitda: '555555555555', - netIncome: '333333333333', - grossProfit: '111111111111', - totalRevenue: '777777777777', - costOfRevenue: '444444444444', - profitYearlyIncrease: null, - profitYearlyDecrease: null, - revenueYearlyIncrease: null, - revenueYearlyDecrease: null, - incomeYearlyIncrease: null, - incomeYearlyDecrease: null, - }, - { - tickerId: 1, - year: '2021', - earningDate: '2021-09-30', - eps: '1.2', - ebitda: '655555555555', - netIncome: '433333333333', - grossProfit: '211111111111', - totalRevenue: '877777777777', - costOfRevenue: '544444444444', - profitYearlyIncrease: 1, - profitYearlyDecrease: 0, - revenueYearlyIncrease: 1, - revenueYearlyDecrease: 0, - incomeYearlyIncrease: 1, - incomeYearlyDecrease: 0, - }, - { - tickerId: 1, - year: '2022', - earningDate: '2022-09-30', - eps: null, - ebitda: '615555555555', - netIncome: '413333333333', - grossProfit: '201111111111', - totalRevenue: '817777777777', - costOfRevenue: '514444444444', - profitYearlyIncrease: 0, - profitYearlyDecrease: 1, - revenueYearlyIncrease: 0, - revenueYearlyDecrease: 1, - incomeYearlyIncrease: 0, - incomeYearlyDecrease: 1, - }, - { - tickerId: 2, - year: '2020', - earningDate: '2020-06-30', - eps: '1.2', - ebitda: '300000000', - netIncome: '200000000', - grossProfit: '500000000', - totalRevenue: '800000000', - costOfRevenue: '300000000', - profitYearlyIncrease: 2, - profitYearlyDecrease: 0, - revenueYearlyIncrease: 0, - revenueYearlyDecrease: 3, - incomeYearlyIncrease: 4, - incomeYearlyDecrease: 0, - }, - ]) -} diff --git a/server/migrations/test-seeds/trader.js b/server/migrations/test-seeds/trader.js deleted file mode 100644 index ecdc837b..00000000 --- a/server/migrations/test-seeds/trader.js +++ /dev/null @@ -1,219 +0,0 @@ -exports.seed = (knex) => { - return knex('trader').insert([ - { - traderPatternId: 1, - traderEnvId: 1, - isActive: true, - hasFollower: false, - hasMutation: false, - accessCode: '0AA', - yearlyPercentNumber: 30, - pastYearPercentNumber: 10, - pastQuarterPercentNumber: 5, - pastMonthPercentNumber: 20, - pastWeekPercentNumber: 3, - rankingNumber: 1, - }, - { - traderPatternId: 2, - traderEnvId: 1, - isActive: true, - hasFollower: false, - hasMutation: false, - accessCode: '000', - yearlyPercentNumber: 31, - pastYearPercentNumber: 20, - pastQuarterPercentNumber: 6, - pastMonthPercentNumber: 19, - pastWeekPercentNumber: 5, - rankingNumber: 3, - }, - { - traderPatternId: 3, - traderEnvId: 1, - isActive: true, - hasFollower: false, - hasMutation: false, - accessCode: '000', - yearlyPercentNumber: 42, - pastYearPercentNumber: 30, - pastQuarterPercentNumber: 7, - pastMonthPercentNumber: 18, - pastWeekPercentNumber: 7, - rankingNumber: 2, - }, - { - traderPatternId: 4, - traderEnvId: 1, - isActive: true, - hasFollower: false, - hasMutation: false, - accessCode: '000', - yearlyPercentNumber: 43, - pastYearPercentNumber: 40, - pastQuarterPercentNumber: 6, - pastMonthPercentNumber: 17, - pastWeekPercentNumber: 9, - }, - { - traderPatternId: 5, - traderEnvId: 1, - isActive: true, - hasFollower: false, - hasMutation: false, - accessCode: '000', - yearlyPercentNumber: 54, - pastYearPercentNumber: 60, - pastQuarterPercentNumber: 5, - pastMonthPercentNumber: 16, - pastWeekPercentNumber: 11, - }, - { - traderPatternId: 6, - traderEnvId: 1, - isActive: true, - hasFollower: false, - hasMutation: false, - accessCode: '000', - yearlyPercentNumber: 55, - pastYearPercentNumber: 50, - pastQuarterPercentNumber: 4, - pastMonthPercentNumber: 15, - pastWeekPercentNumber: 13, - }, - { traderPatternId: 7, traderEnvId: 1, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 8, traderEnvId: 1, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 9, traderEnvId: 1, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 10, traderEnvId: 1, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 11, traderEnvId: 1, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 12, traderEnvId: 1, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 13, traderEnvId: 1, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 14, traderEnvId: 1, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 15, traderEnvId: 1, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 16, traderEnvId: 1, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 17, traderEnvId: 1, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 18, traderEnvId: 1, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 19, traderEnvId: 1, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 20, traderEnvId: 1, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 21, traderEnvId: 1, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 22, traderEnvId: 1, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 23, traderEnvId: 1, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 24, traderEnvId: 1, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 25, traderEnvId: 1, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 26, traderEnvId: 1, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 27, traderEnvId: 1, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 28, traderEnvId: 1, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 29, traderEnvId: 1, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 30, traderEnvId: 1, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 31, traderEnvId: 1, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 32, traderEnvId: 1, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 33, traderEnvId: 1, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 34, traderEnvId: 1, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 35, traderEnvId: 1, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 36, traderEnvId: 1, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 37, traderEnvId: 1, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 38, traderEnvId: 1, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 39, traderEnvId: 1, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 40, traderEnvId: 1, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 41, traderEnvId: 1, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 42, traderEnvId: 1, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 43, traderEnvId: 1, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 44, traderEnvId: 1, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 45, traderEnvId: 1, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 46, traderEnvId: 1, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 47, traderEnvId: 1, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 48, traderEnvId: 1, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 49, traderEnvId: 1, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 50, traderEnvId: 1, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 51, traderEnvId: 1, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 52, traderEnvId: 1, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { - traderPatternId: 1, - traderEnvId: 2, - isActive: true, - hasFollower: false, - hasMutation: false, - accessCode: '00B', - yearlyPercentNumber: 51, - pastYearPercentNumber: 50, - pastQuarterPercentNumber: 36, - pastMonthPercentNumber: 49, - pastWeekPercentNumber: 35, - }, - { - traderPatternId: 2, - traderEnvId: 2, - isActive: true, - hasFollower: false, - hasMutation: false, - accessCode: '000', - yearlyPercentNumber: 36, - pastYearPercentNumber: 25, - pastQuarterPercentNumber: 11, - pastMonthPercentNumber: 24, - pastWeekPercentNumber: 9, - }, - { traderPatternId: 3, traderEnvId: 2, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 4, traderEnvId: 2, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 5, traderEnvId: 2, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 6, traderEnvId: 2, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 7, traderEnvId: 2, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 8, traderEnvId: 2, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 9, traderEnvId: 2, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 10, traderEnvId: 2, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 11, traderEnvId: 2, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 12, traderEnvId: 2, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 13, traderEnvId: 2, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 14, traderEnvId: 2, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 15, traderEnvId: 2, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 16, traderEnvId: 2, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 17, traderEnvId: 2, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 18, traderEnvId: 2, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 19, traderEnvId: 2, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 20, traderEnvId: 2, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 21, traderEnvId: 2, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 22, traderEnvId: 2, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 23, traderEnvId: 2, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 24, traderEnvId: 2, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 25, traderEnvId: 2, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 26, traderEnvId: 2, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 27, traderEnvId: 2, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 28, traderEnvId: 2, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 29, traderEnvId: 2, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 30, traderEnvId: 2, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 31, traderEnvId: 2, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 32, traderEnvId: 2, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 33, traderEnvId: 2, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 34, traderEnvId: 2, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 35, traderEnvId: 2, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 36, traderEnvId: 2, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 37, traderEnvId: 2, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 38, traderEnvId: 2, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 39, traderEnvId: 2, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 40, traderEnvId: 2, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 41, traderEnvId: 2, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 42, traderEnvId: 2, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 43, traderEnvId: 2, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 44, traderEnvId: 2, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 45, traderEnvId: 2, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 46, traderEnvId: 2, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 47, traderEnvId: 2, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 48, traderEnvId: 2, isActive: true, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 49, traderEnvId: 2, isActive: false, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 50, traderEnvId: 2, isActive: false, hasFollower: false, hasMutation: false, accessCode: '000' }, - { traderPatternId: 51, traderEnvId: 2, isActive: false, hasFollower: false, hasMutation: false, accessCode: '000' }, - { - traderPatternId: 52, - traderEnvId: 2, - isActive: false, - hasFollower: false, - hasMutation: false, - accessCode: '000', - totalValue: '12345', - oneYearTrends: '100,101,102,103', - oneDecadeTrends: '111,222,333,444', - }, - ]) -} - -exports.down = () => {} diff --git a/server/migrations/test-seeds/trader_combo.js b/server/migrations/test-seeds/trader_combo.js deleted file mode 100644 index 4f078392..00000000 --- a/server/migrations/test-seeds/trader_combo.js +++ /dev/null @@ -1,16 +0,0 @@ -exports.seed = (knex) => { - return knex('trader_combo').insert([ - { - entityId: 1, - traderIds: '1,2,3', - }, - { - entityId: 1, - traderIds: '4,5,6', - }, - { - entityId: 2, - traderIds: '1,2', - }, - ]) -} diff --git a/server/migrations/test-seeds/trader_combo_follower.js b/server/migrations/test-seeds/trader_combo_follower.js deleted file mode 100644 index 29333cb1..00000000 --- a/server/migrations/test-seeds/trader_combo_follower.js +++ /dev/null @@ -1,19 +0,0 @@ -exports.seed = (knex) => { - return knex('trader_combo_follower').insert([ - { - userId: 1, - traderComboId: 1, - name: 'test1', - }, - { - userId: 1, - traderComboId: 2, - name: 'test2', - }, - { - userId: 2, - traderComboId: 1, - name: 'test3', - }, - ]) -} diff --git a/server/migrations/test-seeds/trader_env.js b/server/migrations/test-seeds/trader_env.js deleted file mode 100644 index 2bc1b36f..00000000 --- a/server/migrations/test-seeds/trader_env.js +++ /dev/null @@ -1,20 +0,0 @@ -exports.seed = (knex) => { - return knex('trader_env').insert([ - { - entityId: 1, - activeTotal: 10000, - startDate: '2001-01-01', - }, - { - entityId: 2, - activeTotal: 10000, - startDate: '2012-01-01', - }, - { - entityId: 1, - activeTotal: 10000, - startDate: '2015-06-01', - tickerIds: '1,2', - }, - ]) -} diff --git a/server/migrations/test-seeds/trader_env_follower.js b/server/migrations/test-seeds/trader_env_follower.js deleted file mode 100644 index d40a978b..00000000 --- a/server/migrations/test-seeds/trader_env_follower.js +++ /dev/null @@ -1,19 +0,0 @@ -exports.seed = (knex) => { - return knex('trader_env_follower').insert([ - { - userId: 1, - traderEnvId: 1, - name: 'test1', - }, - { - userId: 1, - traderEnvId: 2, - name: 'test2', - }, - { - userId: 2, - traderEnvId: 2, - name: 'test3', - }, - ]) -} diff --git a/server/migrations/test-seeds/trader_follower.js b/server/migrations/test-seeds/trader_follower.js deleted file mode 100644 index 15baae14..00000000 --- a/server/migrations/test-seeds/trader_follower.js +++ /dev/null @@ -1,24 +0,0 @@ -exports.seed = (knex) => { - return knex('trader_follower').insert([ - { - userId: 1, - traderId: 1, - }, - { - userId: 1, - traderId: 2, - }, - { - userId: 1, - traderId: 3, - }, - { - userId: 2, - traderId: 1, - }, - { - userId: 2, - traderId: 2, - }, - ]) -} diff --git a/server/migrations/test-seeds/trader_holding.js b/server/migrations/test-seeds/trader_holding.js deleted file mode 100644 index 74a72a18..00000000 --- a/server/migrations/test-seeds/trader_holding.js +++ /dev/null @@ -1,82 +0,0 @@ -exports.seed = (knex) => { - return knex('trader_holding').insert([ - { - date: '2021-12-31', - traderId: 1, - id: '5ed6d4c8-c159-4588-b966-364a4bdbd3a1', - totalValue: '113200', - totalCash: '10000', - items: JSON.stringify([ - { - value: 100000, - shares: 1000, - splitMultiplier: 1, - tickerId: 1, - }, - { - value: 3200, - shares: 100, - splitMultiplier: 1, - tickerId: 2, - }, - ]), - }, - { - date: '2022-01-01', - traderId: 1, - id: '5ed6d4c8-c159-4588-b966-364a4bdbd3a2', - totalValue: '118200', - totalCash: '10000', - items: JSON.stringify([ - { - value: 99540, - shares: 948, - splitMultiplier: 1, - tickerId: 1, - }, - { - value: 3200, - shares: 100, - splitMultiplier: 1, - tickerId: 2, - }, - { - value: 1111, - shares: 5, - splitMultiplier: 2, - tickerId: 3, - }, - ]), - }, - { - date: '2021-12-31', - traderId: 2, - id: '5ed6d4c8-c159-4588-b966-364a4bdbd3a3', - totalValue: '105000', - totalCash: '100000', - items: JSON.stringify([ - { - value: 5000, - shares: 50, - splitMultiplier: 1, - tickerId: 1, - }, - ]), - }, - { - date: '2021-01-02', - traderId: 3, - id: '5ed6d4c8-c159-4588-b966-364a4bdbd3a4', - totalValue: '105000', - totalCash: '100000', - items: JSON.stringify([ - { - value: 4500, - shares: 10, - splitMultiplier: 1, - tickerId: 3, - }, - ]), - }, - ]) -} diff --git a/server/migrations/test-seeds/user.js b/server/migrations/test-seeds/user.js deleted file mode 100644 index aa6b4969..00000000 --- a/server/migrations/test-seeds/user.js +++ /dev/null @@ -1,33 +0,0 @@ -exports.seed = (knex) => { - return knex('user').insert([ - { - entityId: 1, - email: 'a@email.com', - type: 1, - password: 'abc', - activationCode: 'xyz', - activationSentAt: '2022-01-03', - createdAt: '2022-01-02', - updatedAt: '2022-01-03', - }, - { - entityId: 2, - email: 'b@email.com', - type: 1, - password: 'aabbcc', - createdAt: '2022-03-03', - updatedAt: '2022-03-03', - }, - { - entityId: 1, - email: 'deleted@email.com', - type: 1, - password: 'aabbcc123', - createdAt: '2022-03-03', - updatedAt: '2022-03-03', - deletedAt: '2022-03-05', - }, - ]) -} - -exports.down = () => {} diff --git a/server/models/traderEnv.ts b/server/models/traderEnv.ts index 7a66bbee..3052402a 100644 --- a/server/models/traderEnv.ts +++ b/server/models/traderEnv.ts @@ -9,7 +9,7 @@ const convertToRecord = ( raw: interfaces.traderEnvModel.Raw, ): interfaces.traderEnvModel.Record => { const record: any = raw - record.tickerIds = raw.tickerIds.split(',').map((tickerId) => parseInt(tickerId)) + record.tickerIds = raw.tickerIds ? raw.tickerIds.split(',').map((tickerId) => parseInt(tickerId)) : null return record } diff --git a/server/services/crudTraders.ts b/server/services/crudTraders.ts index 3c24ddeb..c9394fc6 100644 --- a/server/services/crudTraders.ts +++ b/server/services/crudTraders.ts @@ -14,6 +14,7 @@ import * as traderHoldingModel from 'models/traderHolding' import * as traderLogic from 'logics/trader' import * as traderModel from 'models/trader' import * as traderPatternModel from 'models/traderPattern' +import * as helpers from '@shared/helpers' import buildComboEntities from './shared/buildComboEntities' import buildHoldingValueStats from './shared/buildHoldingValueStats' @@ -140,7 +141,10 @@ export const createTraderProfile = async ( ): Promise => { const transaction = await databaseAdapter.createTransaction() try { - const patternResult = await traderPatternModel.createIfEmpty(traderPattern, transaction) + const patternResult = await traderPatternModel.createIfEmpty({ + ...traderPattern, + hashCode: helpers.toPatternHashCode(traderPattern), + }, transaction) const pattern = patternResult.record const parent = null const hasMutation = false diff --git a/server/services/crudUsers.ts b/server/services/crudUsers.ts index 99087543..beedfc21 100644 --- a/server/services/crudUsers.ts +++ b/server/services/crudUsers.ts @@ -152,22 +152,24 @@ export const createUser = async ( const subject = localeTool.getTranslation('email.activateUser') const content = emailLogic.buildActivateUserEmail(targetUser) - const transporter = emailAdapter.initTransporter() - const response = await transporter.sendMail({ - from: 'ValueMelody app@valuemelody.com', - to: targetUser.email, - subject, - html: content, - }) - - const status = generateTool.getEmailStatus(response, targetUser.email) - - await emailModel.create({ - sendTo: targetUser.email, - title: subject, - content, - status, - }, transaction) + try { + const transporter = emailAdapter.initTransporter() + const response = await transporter.sendMail({ + from: 'ValueMelody app@valuemelody.com', + to: targetUser.email, + subject, + html: content, + }) + + const status = generateTool.getEmailStatus(response, targetUser.email) + + await emailModel.create({ + sendTo: targetUser.email, + title: subject, + content, + status, + }, transaction) + } catch (e) { console.error(e) } return targetUser }) diff --git a/server/services/syncTickers.ts b/server/services/syncTickers.ts index fc555a2d..5580a785 100644 --- a/server/services/syncTickers.ts +++ b/server/services/syncTickers.ts @@ -150,9 +150,9 @@ export const syncFinancials = async ( ?.find((info) => info.dataCode === 'freeCashFlow')?.value?.toString() || null, } - const quarter = dateTool.getQuarterByDate(financial.date) const isYearlyReport = financial.quarter === 0 if (isYearlyReport) { + const quarter = dateTool.getQuarterByDate(financial.date) if ( !!ticker.lastFinancialYear && !!ticker.firstFinancialYear && ticker.lastFinancialYear >= quarter && ticker.firstFinancialYear <= quarter @@ -165,6 +165,7 @@ export const syncFinancials = async ( }, transaction) yearlyRecords.push(yearlyRecord) } else { + const quarter = dateTool.getQuarterByNumber(financial.date, financial.quarter) if ( !!ticker.lastFinancialQuarter && !!ticker.firstFinancialQuarter && ticker.lastFinancialQuarter >= quarter && ticker.firstFinancialQuarter <= quarter diff --git a/server/tools/date.ts b/server/tools/date.ts index f82d438c..da65d0f9 100644 --- a/server/tools/date.ts +++ b/server/tools/date.ts @@ -33,6 +33,23 @@ export const getYearByDate = (date: string): string => { return date.substring(0, 4) } +export const getQuarterByNumber = (date: string, number: number): string => { + const currentDate = date.substring(0, 7) + const [currentYear] = currentDate.split('-') + const year = parseInt(currentYear) + let quarter = '' + if (number === 1) { + quarter = '03' + } else if (number === 2) { + quarter = '06' + } else if (number === 3) { + quarter = '09' + } else if (number === 4) { + quarter = '12' + } + return `${year}-${quarter}` +} + export const getQuarterByDate = (date: string): string => { const currentDate = date.substring(0, 7) const [currentYear, currentMonth] = currentDate.split('-')