feat(Fundamentals): add fundamentals service

This commit is contained in:
2026-08-09 21:01:39 +02:00
parent e0778b88ea
commit 605e41cfeb
21 changed files with 3122 additions and 0 deletions
@@ -0,0 +1,255 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace FinlyticFundamentals.Migrations
{
/// <inheritdoc />
public partial class Init : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "AssetFundamentals",
columns: table => new
{
Isin = table.Column<string>(type: "text", nullable: false),
PrimaryTicker = table.Column<string>(type: "text", nullable: false),
CompanyName = table.Column<string>(type: "text", nullable: false),
BusinessSummary = table.Column<string>(type: "text", nullable: true),
Sector = table.Column<string>(type: "text", nullable: true),
Industry = table.Column<string>(type: "text", nullable: true),
Country = table.Column<string>(type: "text", nullable: true),
Employees = table.Column<int>(type: "integer", nullable: true),
PercentHeldByInstitutions = table.Column<decimal>(type: "numeric", nullable: true),
PercentHeldByInsiders = table.Column<decimal>(type: "numeric", nullable: true),
ShortRatio = table.Column<decimal>(type: "numeric", nullable: true),
ShortPercentOfFloat = table.Column<decimal>(type: "numeric", nullable: true),
ConsensusRating = table.Column<string>(type: "text", nullable: true),
PriceTargetLow = table.Column<decimal>(type: "numeric", nullable: true),
PriceTargetHigh = table.Column<decimal>(type: "numeric", nullable: true),
PriceTargetMedian = table.Column<decimal>(type: "numeric", nullable: true),
PriceTargetMean = table.Column<decimal>(type: "numeric", nullable: true),
ExDividendDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
NextEarningsDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
LastUpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
LastStaticUpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_AssetFundamentals", x => x.Isin);
});
migrationBuilder.CreateTable(
name: "Settings",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
CacheTtlHours = table.Column<int>(type: "integer", nullable: false),
EnableYahooFallback = table.Column<bool>(type: "boolean", nullable: false),
UpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Settings", x => x.Id);
});
migrationBuilder.CreateTable(
name: "CompanyExecutives",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
Isin = table.Column<string>(type: "text", nullable: false),
Name = table.Column<string>(type: "text", nullable: false),
Title = table.Column<string>(type: "text", nullable: false),
Age = table.Column<int>(type: "integer", nullable: true),
Compensation = table.Column<decimal>(type: "numeric", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_CompanyExecutives", x => x.Id);
table.ForeignKey(
name: "FK_CompanyExecutives_AssetFundamentals_Isin",
column: x => x.Isin,
principalTable: "AssetFundamentals",
principalColumn: "Isin",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "FinancialStatements",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
Isin = table.Column<string>(type: "text", nullable: false),
PeriodType = table.Column<string>(type: "text", nullable: false),
EndDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
TotalRevenue = table.Column<decimal>(type: "numeric", nullable: true),
CostOfRevenue = table.Column<decimal>(type: "numeric", nullable: true),
GrossProfit = table.Column<decimal>(type: "numeric", nullable: true),
OperatingExpenses = table.Column<decimal>(type: "numeric", nullable: true),
OperatingIncome = table.Column<decimal>(type: "numeric", nullable: true),
Ebitda = table.Column<decimal>(type: "numeric", nullable: true),
NetIncome = table.Column<decimal>(type: "numeric", nullable: true),
EpsBasic = table.Column<decimal>(type: "numeric", nullable: true),
EpsDiluted = table.Column<decimal>(type: "numeric", nullable: true),
CashAndCashEquivalents = table.Column<decimal>(type: "numeric", nullable: true),
AccountsReceivable = table.Column<decimal>(type: "numeric", nullable: true),
Inventory = table.Column<decimal>(type: "numeric", nullable: true),
TotalCurrentAssets = table.Column<decimal>(type: "numeric", nullable: true),
TotalNonCurrentAssets = table.Column<decimal>(type: "numeric", nullable: true),
CurrentLiabilities = table.Column<decimal>(type: "numeric", nullable: true),
LongTermDebt = table.Column<decimal>(type: "numeric", nullable: true),
TotalLiabilities = table.Column<decimal>(type: "numeric", nullable: true),
TotalStockholdersEquity = table.Column<decimal>(type: "numeric", nullable: true),
OperatingCashFlow = table.Column<decimal>(type: "numeric", nullable: true),
InvestingCashFlow = table.Column<decimal>(type: "numeric", nullable: true),
CapitalExpenditures = table.Column<decimal>(type: "numeric", nullable: true),
FinancingCashFlow = table.Column<decimal>(type: "numeric", nullable: true),
FreeCashFlow = table.Column<decimal>(type: "numeric", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_FinancialStatements", x => x.Id);
table.ForeignKey(
name: "FK_FinancialStatements_AssetFundamentals_Isin",
column: x => x.Isin,
principalTable: "AssetFundamentals",
principalColumn: "Isin",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "ForwardEstimates",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
Isin = table.Column<string>(type: "text", nullable: false),
Period = table.Column<string>(type: "text", nullable: false),
ExpectedRevenue = table.Column<decimal>(type: "numeric", nullable: true),
ExpectedEps = table.Column<decimal>(type: "numeric", nullable: true),
ExpectedGrowthRate = table.Column<decimal>(type: "numeric", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_ForwardEstimates", x => x.Id);
table.ForeignKey(
name: "FK_ForwardEstimates_AssetFundamentals_Isin",
column: x => x.Isin,
principalTable: "AssetFundamentals",
principalColumn: "Isin",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "TickerFundamentals",
columns: table => new
{
Ticker = table.Column<string>(type: "text", nullable: false),
Isin = table.Column<string>(type: "text", nullable: false),
Exchange = table.Column<string>(type: "text", nullable: true),
TradingCurrency = table.Column<string>(type: "text", nullable: true),
CurrentPrice = table.Column<decimal>(type: "numeric", nullable: false),
DayChangeAbsolute = table.Column<decimal>(type: "numeric", nullable: false),
DayChangePercent = table.Column<decimal>(type: "numeric", nullable: false),
FiftyTwoWeekHigh = table.Column<decimal>(type: "numeric", nullable: false),
FiftyTwoWeekLow = table.Column<decimal>(type: "numeric", nullable: false),
MarketCapitalization = table.Column<decimal>(type: "numeric", nullable: false),
EnterpriseValue = table.Column<decimal>(type: "numeric", nullable: false),
PeRatioTrailing = table.Column<decimal>(type: "numeric", nullable: true),
PeRatioForward = table.Column<decimal>(type: "numeric", nullable: true),
PegRatio = table.Column<decimal>(type: "numeric", nullable: true),
PbRatio = table.Column<decimal>(type: "numeric", nullable: true),
PsRatio = table.Column<decimal>(type: "numeric", nullable: true),
EvToEbitda = table.Column<decimal>(type: "numeric", nullable: true),
EvToRevenue = table.Column<decimal>(type: "numeric", nullable: true),
GrossMargin = table.Column<decimal>(type: "numeric", nullable: true),
OperatingMargin = table.Column<decimal>(type: "numeric", nullable: true),
NetProfitMargin = table.Column<decimal>(type: "numeric", nullable: true),
ReturnOnEquity = table.Column<decimal>(type: "numeric", nullable: true),
ReturnOnAssets = table.Column<decimal>(type: "numeric", nullable: true),
ReturnOnInvestedCapital = table.Column<decimal>(type: "numeric", nullable: true),
DebtToEquity = table.Column<decimal>(type: "numeric", nullable: true),
CurrentRatio = table.Column<decimal>(type: "numeric", nullable: true),
QuickRatio = table.Column<decimal>(type: "numeric", nullable: true),
InterestCoverage = table.Column<decimal>(type: "numeric", nullable: true),
DividendYield = table.Column<decimal>(type: "numeric", nullable: true),
PayoutRatio = table.Column<decimal>(type: "numeric", nullable: true),
ExDividendDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
LastUpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_TickerFundamentals", x => x.Ticker);
table.ForeignKey(
name: "FK_TickerFundamentals_AssetFundamentals_Isin",
column: x => x.Isin,
principalTable: "AssetFundamentals",
principalColumn: "Isin",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_AssetFundamentals_PrimaryTicker",
table: "AssetFundamentals",
column: "PrimaryTicker",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_CompanyExecutives_Isin",
table: "CompanyExecutives",
column: "Isin");
migrationBuilder.CreateIndex(
name: "IX_FinancialStatements_Isin",
table: "FinancialStatements",
column: "Isin");
migrationBuilder.CreateIndex(
name: "IX_FinancialStatements_Isin_PeriodType_EndDate",
table: "FinancialStatements",
columns: new[] { "Isin", "PeriodType", "EndDate" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_ForwardEstimates_Isin",
table: "ForwardEstimates",
column: "Isin");
migrationBuilder.CreateIndex(
name: "IX_ForwardEstimates_Isin_Period",
table: "ForwardEstimates",
columns: new[] { "Isin", "Period" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_TickerFundamentals_Isin",
table: "TickerFundamentals",
column: "Isin");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "CompanyExecutives");
migrationBuilder.DropTable(
name: "FinancialStatements");
migrationBuilder.DropTable(
name: "ForwardEstimates");
migrationBuilder.DropTable(
name: "Settings");
migrationBuilder.DropTable(
name: "TickerFundamentals");
migrationBuilder.DropTable(
name: "AssetFundamentals");
}
}
}