diff options
author | 2024-08-05 18:21:39 -0700 | |
---|---|---|
committer | 2024-08-05 18:21:39 -0700 | |
commit | 745531ce8d97a908cb4f2b8d6e032840d8936016 (patch) | |
tree | 882ce8f5814eda5c8a31d61e1abf4027d09faba8 /api | |
download | ibd-trader-745531ce8d97a908cb4f2b8d6e032840d8936016.tar.gz ibd-trader-745531ce8d97a908cb4f2b8d6e032840d8936016.tar.zst ibd-trader-745531ce8d97a908cb4f2b8d6e032840d8936016.zip |
Initial Commit
Diffstat (limited to 'api')
-rw-r--r-- | api/.gitignore | 117 | ||||
-rw-r--r-- | api/Makefile | 19 | ||||
-rw-r--r-- | api/buf.gen.yaml | 18 | ||||
-rw-r--r-- | api/buf.lock | 6 | ||||
-rw-r--r-- | api/buf.yaml | 11 | ||||
-rw-r--r-- | api/proto/idb/stock/v1/stock.proto | 136 | ||||
-rw-r--r-- | api/proto/idb/user/v1/user.proto | 48 |
7 files changed, 355 insertions, 0 deletions
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..04e9509 --- /dev/null +++ b/api/Makefile @@ -0,0 +1,19 @@ +# Variables +GEN_DIR = gen + +# Commands +BUF = buf + +# Targets +.PHONY: all lint generate clean + +all: lint generate + +lint: + $(BUF) lint + +generate: + $(BUF) generate + +clean: + rm -rf $(GEN_DIR) diff --git a/api/buf.gen.yaml b/api/buf.gen.yaml new file mode 100644 index 0000000..44b1c4b --- /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/api/gen +plugins: + - remote: buf.build/protocolbuffers/go + out: gen + opt: paths=source_relative + - remote: buf.build/grpc/go:v1.5.1 + out: gen + opt: + - paths=source_relative +inputs: + - directory: proto
\ No newline at end of file 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..5728163 --- /dev/null +++ b/api/proto/idb/user/v1/user.proto @@ -0,0 +1,48 @@ +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); +} + +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; +} |