aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Anshul Gupta <ansg191@anshulg.com> 2024-08-11 13:13:10 -0700
committerGravatar Anshul Gupta <ansg191@anshulg.com> 2024-08-11 13:13:10 -0700
commit29c6040a51616e9e4cf6c70ee16391b2a3b238c9 (patch)
tree049140ef28899831b633b8323a3f43d6240d6c33
parent7d1d986d3a0a1ad19d3ed969b31064627e79d653 (diff)
parent0a5cc39b5223e4301bc67e1e1b4bcd1f23574b46 (diff)
downloadibd-trader-29c6040a51616e9e4cf6c70ee16391b2a3b238c9.tar.gz
ibd-trader-29c6040a51616e9e4cf6c70ee16391b2a3b238c9.tar.zst
ibd-trader-29c6040a51616e9e4cf6c70ee16391b2a3b238c9.zip
Merge remote-tracking branch 'api/main'
-rw-r--r--api/.github/workflows/buf-ci.yaml18
-rw-r--r--api/.gitignore117
-rw-r--r--api/Makefile22
-rw-r--r--api/buf.gen.js.yaml10
-rw-r--r--api/buf.gen.yaml18
-rw-r--r--api/buf.lock6
-rw-r--r--api/buf.yaml11
-rw-r--r--api/proto/idb/stock/v1/stock.proto136
-rw-r--r--api/proto/idb/user/v1/user.proto67
9 files changed, 405 insertions, 0 deletions
diff --git a/api/.github/workflows/buf-ci.yaml b/api/.github/workflows/buf-ci.yaml
new file mode 100644
index 0000000..4eb4862
--- /dev/null
+++ b/api/.github/workflows/buf-ci.yaml
@@ -0,0 +1,18 @@
+name: Buf CI
+
+on:
+ push:
+ pull_request:
+ types: [opened, synchronize, reopened, labeled, unlabeled]
+ delete:
+
+permissions:
+ contents: read
+ pull-requests: write
+
+jobs:
+ buf:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ - uses: bufbuild/buf-action@v1
diff --git a/api/.gitignore b/api/.gitignore
new file mode 100644
index 0000000..57e2347
--- /dev/null
+++ b/api/.gitignore
@@ -0,0 +1,117 @@
+gen/
+
+# Created by https://www.toptal.com/developers/gitignore/api/visualstudiocode
+# Edit at https://www.toptal.com/developers/gitignore?templates=visualstudiocode
+
+### VisualStudioCode ###
+.vscode/*
+!.vscode/settings.json
+!.vscode/tasks.json
+!.vscode/launch.json
+!.vscode/extensions.json
+!.vscode/*.code-snippets
+
+# Local History for Visual Studio Code
+.history/
+
+# Built Visual Studio Code Extensions
+*.vsix
+
+### VisualStudioCode Patch ###
+# Ignore all local history of files
+.history
+.ionide
+
+# End of https://www.toptal.com/developers/gitignore/api/visualstudiocode
+# Created by https://www.toptal.com/developers/gitignore/api/intellij+all
+# Edit at https://www.toptal.com/developers/gitignore?templates=intellij+all
+
+### Intellij+all ###
+# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
+# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
+
+# User-specific stuff
+.idea/**/workspace.xml
+.idea/**/tasks.xml
+.idea/**/usage.statistics.xml
+.idea/**/dictionaries
+.idea/**/shelf
+
+# AWS User-specific
+.idea/**/aws.xml
+
+# Generated files
+.idea/**/contentModel.xml
+
+# Sensitive or high-churn files
+.idea/**/dataSources/
+.idea/**/dataSources.ids
+.idea/**/dataSources.local.xml
+.idea/**/sqlDataSources.xml
+.idea/**/dynamic.xml
+.idea/**/uiDesigner.xml
+.idea/**/dbnavigator.xml
+
+# Gradle
+.idea/**/gradle.xml
+.idea/**/libraries
+
+# Gradle and Maven with auto-import
+# When using Gradle or Maven with auto-import, you should exclude module files,
+# since they will be recreated, and may cause churn. Uncomment if using
+# auto-import.
+# .idea/artifacts
+# .idea/compiler.xml
+# .idea/jarRepositories.xml
+# .idea/modules.xml
+# .idea/*.iml
+# .idea/modules
+# *.iml
+# *.ipr
+
+# CMake
+cmake-build-*/
+
+# Mongo Explorer plugin
+.idea/**/mongoSettings.xml
+
+# File-based project format
+*.iws
+
+# IntelliJ
+out/
+
+# mpeltonen/sbt-idea plugin
+.idea_modules/
+
+# JIRA plugin
+atlassian-ide-plugin.xml
+
+# Cursive Clojure plugin
+.idea/replstate.xml
+
+# SonarLint plugin
+.idea/sonarlint/
+
+# Crashlytics plugin (for Android Studio and IntelliJ)
+com_crashlytics_export_strings.xml
+crashlytics.properties
+crashlytics-build.properties
+fabric.properties
+
+# Editor-based Rest Client
+.idea/httpRequests
+
+# Android studio 3.1+ serialized cache file
+.idea/caches/build_file_checksums.ser
+
+### Intellij+all Patch ###
+# Ignore everything but code style settings and run configurations
+# that are supposed to be shared within teams.
+
+.idea/*
+
+!.idea/codeStyles
+!.idea/runConfigurations
+
+# End of https://www.toptal.com/developers/gitignore/api/intellij+all
diff --git a/api/Makefile b/api/Makefile
new file mode 100644
index 0000000..81f3748
--- /dev/null
+++ b/api/Makefile
@@ -0,0 +1,22 @@
+# Variables
+GEN_DIR = gen
+
+# Commands
+BUF = buf
+
+# Targets
+.PHONY: all lint generate generate-js clean
+
+all: lint generate
+
+lint:
+ $(BUF) lint
+
+generate:
+ $(BUF) generate --template buf.gen.yaml
+
+generate-js:
+ $(BUF) generate --template buf.gen.js.yaml --include-imports
+
+clean:
+ rm -rf $(GEN_DIR)
diff --git a/api/buf.gen.js.yaml b/api/buf.gen.js.yaml
new file mode 100644
index 0000000..5c4767a
--- /dev/null
+++ b/api/buf.gen.js.yaml
@@ -0,0 +1,10 @@
+version: v2
+managed:
+ enabled: true
+plugins:
+ - remote: buf.build/bufbuild/es:v1.10.0
+ out: gen
+ - remote: buf.build/connectrpc/es:v1.4.0
+ out: gen
+inputs:
+ - directory: proto
diff --git a/api/buf.gen.yaml b/api/buf.gen.yaml
new file mode 100644
index 0000000..7713112
--- /dev/null
+++ b/api/buf.gen.yaml
@@ -0,0 +1,18 @@
+version: v2
+managed:
+ enabled: true
+ disable:
+ - module: buf.build/googleapis/googleapis
+ override:
+ - file_option: go_package_prefix
+ value: github.com/ansg191/ibd-trader-backend/api/gen
+plugins:
+ - remote: buf.build/protocolbuffers/go
+ out: gen
+ opt: paths=source_relative
+ - remote: buf.build/grpc/go
+ out: gen
+ opt:
+ - paths=source_relative
+inputs:
+ - directory: proto
diff --git a/api/buf.lock b/api/buf.lock
new file mode 100644
index 0000000..5888dc0
--- /dev/null
+++ b/api/buf.lock
@@ -0,0 +1,6 @@
+# Generated by buf. DO NOT EDIT.
+version: v2
+deps:
+ - name: buf.build/googleapis/googleapis
+ commit: 8bc2c51e08c447cd8886cdea48a73e14
+ digest: b5:b7e0ac9d192bd0eae88160101269550281448c51f25121cd0d51957661a350aab07001bc145fe9029a8da10b99ff000ae5b284ecaca9c75f2a99604a04d9b4ab
diff --git a/api/buf.yaml b/api/buf.yaml
new file mode 100644
index 0000000..5fdfa74
--- /dev/null
+++ b/api/buf.yaml
@@ -0,0 +1,11 @@
+version: v2
+modules:
+ - path: proto
+lint:
+ use:
+ - DEFAULT
+breaking:
+ use:
+ - FILE
+deps:
+ - buf.build/googleapis/googleapis \ No newline at end of file
diff --git a/api/proto/idb/stock/v1/stock.proto b/api/proto/idb/stock/v1/stock.proto
new file mode 100644
index 0000000..e4e32ba
--- /dev/null
+++ b/api/proto/idb/stock/v1/stock.proto
@@ -0,0 +1,136 @@
+syntax = "proto3";
+
+package idb.stock.v1;
+
+import "google/longrunning/operations.proto";
+import "google/protobuf/timestamp.proto";
+import "google/type/money.proto";
+
+// Stock represents a stock.
+message Stock {
+ // The ticker symbol of the stock (e.g. "AAPL").
+ string symbol = 1;
+ // The name of the stock (e.g. "Apple Inc.").
+ string name = 2;
+ // The URL to the IBD page for the stock.
+ optional string ibd_url = 3;
+ // The most recent ratings for the stock.
+ StockRatings ratings = 4;
+}
+
+// StockListType represents the name of a stock list.
+enum StockListType {
+ // Unspecified stock list type.
+ STOCK_LIST_TYPE_UNSPECIFIED = 0;
+ // The IBD50 stock list.
+ STOCK_LIST_TYPE_IBD50 = 1;
+ // The Cap20 stock list.
+ STOCK_LIST_TYPE_CAP20 = 2;
+}
+
+// LetterGrade represents a letter grade from E to A+.
+enum LetterGrade {
+ LETTER_GRADE_UNSPECIFIED = 0;
+ LETTER_GRADE_A_PLUS = 1;
+ LETTER_GRADE_A = 2;
+ LETTER_GRADE_A_MINUS = 3;
+ LETTER_GRADE_B_PLUS = 4;
+ LETTER_GRADE_B = 5;
+ LETTER_GRADE_B_MINUS = 6;
+ LETTER_GRADE_C_PLUS = 7;
+ LETTER_GRADE_C = 8;
+ LETTER_GRADE_C_MINUS = 9;
+ LETTER_GRADE_D_PLUS = 10;
+ LETTER_GRADE_D = 11;
+ LETTER_GRADE_D_MINUS = 12;
+ LETTER_GRADE_E_PLUS = 13;
+ LETTER_GRADE_E = 14;
+}
+
+// StockRatings represents the ratings for a stock scraped from IBD.
+message StockRatings {
+ // Unique identifier for this stock rating instance.
+ string id = 1;
+
+ // Ratings for the stock.
+ message Ratings {
+ // The composite rating. (1-99)
+ uint32 composite = 1;
+ // The EPS rating. (1-99)
+ uint32 eps = 2;
+ // The relative strength rating. (1-99)
+ uint32 relative_strength = 3;
+ // The group relative strength rating. (E-A+)
+ LetterGrade group_rel_strength = 4;
+ // The SMR rating. (E-A+)
+ LetterGrade smr = 5;
+ // The accumulation/distribution rating. (E-A+)
+ LetterGrade acc_dis = 6;
+ }
+ // The ratings for the stock.
+ Ratings ratings = 3;
+
+ // The price of the stock at the time of the ratings being scraped.
+ google.type.Money price = 4;
+ // The time the ratings were scraped.
+ google.protobuf.Timestamp last_update = 5;
+
+ // The chart analysis for the stock.
+ ChartAnalysis chart_analysis = 6;
+}
+
+// ChartAnalysis represents the chart analysis for a stock.
+message ChartAnalysis {
+ // Unique identifier for this chart analysis instance.
+ string id = 1;
+ // The raw analysis.
+ string raw_analysis = 2;
+}
+
+message StockScrapeOperationMetadata {
+ string symbol = 1;
+ google.protobuf.Timestamp start_time = 2;
+}
+
+// StockService provides methods for interacting with stock data.
+service StockService {
+ rpc CreateStock(CreateStockRequest) returns (CreateStockResponse) {
+ option (google.longrunning.operation_info) = {
+ response_type: "Stock"
+ metadata_type: "StockScrapeOperationMetadata"
+ };
+ }
+ // GetStock returns a stock by symbol.
+ rpc GetStock(GetStockRequest) returns (GetStockResponse);
+ // ListStocks returns a list of stocks.
+ rpc ListStocks(ListStocksRequest) returns (ListStocksResponse);
+}
+
+message CreateStockRequest {
+ string symbol = 1;
+}
+
+message CreateStockResponse {
+ google.longrunning.Operation operation = 1;
+}
+
+message GetStockRequest {
+ string symbol = 1;
+}
+
+message GetStockResponse {
+ Stock stock = 1;
+}
+
+message ListStocksRequest {
+ StockListType type = 1;
+
+ int32 page_size = 2;
+ string page_token = 3;
+}
+
+message ListStocksResponse {
+ repeated Stock stocks = 1;
+ google.protobuf.Timestamp last_update = 2;
+ string next_page_token = 3;
+}
diff --git a/api/proto/idb/user/v1/user.proto b/api/proto/idb/user/v1/user.proto
new file mode 100644
index 0000000..8a2f0bc
--- /dev/null
+++ b/api/proto/idb/user/v1/user.proto
@@ -0,0 +1,67 @@
+syntax = "proto3";
+
+package idb.user.v1;
+
+import "google/protobuf/field_mask.proto";
+
+message User {
+ // The subject of the user returned from Auth0.
+ string subject = 1;
+ // The username of the user's IBD account.
+ optional string ibd_username = 2;
+ // The password of the user's IBD account.
+ // The password is optional because it is never returned from the server.
+ // It is only used when updating a user.
+ optional string ibd_password = 3;
+}
+
+// The user service provides methods for interacting with user data.
+service UserService {
+ rpc CreateUser(CreateUserRequest) returns (CreateUserResponse);
+ rpc GetUser(GetUserRequest) returns (GetUserResponse);
+ rpc UpdateUser(UpdateUserRequest) returns (UpdateUserResponse);
+
+ rpc CheckIBDUsername(CheckIBDUsernameRequest) returns (CheckIBDUsernameResponse);
+ rpc AuthenticateUser(AuthenticateUserRequest) returns (AuthenticateUserResponse);
+}
+
+message CreateUserRequest {
+ string subject = 1;
+}
+
+message CreateUserResponse {
+ User user = 1;
+}
+
+message GetUserRequest {
+ string subject = 1;
+}
+
+message GetUserResponse {
+ User user = 1;
+}
+
+message UpdateUserRequest {
+ User user = 1;
+ google.protobuf.FieldMask update_mask = 2;
+}
+
+message UpdateUserResponse {
+ User user = 1;
+}
+
+message CheckIBDUsernameRequest {
+ string ibd_username = 1;
+}
+
+message CheckIBDUsernameResponse {
+ bool exists = 1;
+}
+
+message AuthenticateUserRequest {
+ string subject = 1;
+}
+
+message AuthenticateUserResponse {
+ bool authenticated = 1;
+}