diff --git a/applications/backend/django_server/news/admin.py b/applications/backend/django_server/news/admin.py index 53bfd9e..9999c25 100644 --- a/applications/backend/django_server/news/admin.py +++ b/applications/backend/django_server/news/admin.py @@ -1,6 +1,7 @@ from django.contrib import admin -from .models import News, Ticker +from .models import News, Ticker, Analysis admin.site.register(News) admin.site.register(Ticker) +admin.site.register(Analysis) diff --git a/applications/backend/django_server/news/migrations/0005_analysis.py b/applications/backend/django_server/news/migrations/0005_analysis.py new file mode 100644 index 0000000..fbf30ff --- /dev/null +++ b/applications/backend/django_server/news/migrations/0005_analysis.py @@ -0,0 +1,37 @@ +# Generated by Django 4.2.7 on 2023-12-11 12:52 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("news", "0004_alter_news_img_src_url_alter_news_src_url"), + ] + + operations = [ + migrations.CreateModel( + name="Analysis", + fields=[ + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("category", models.CharField(max_length=100)), + ("symbol", models.CharField(max_length=100)), + ("date", models.DateField()), + ("average_sentiment", models.FloatField()), + ("total_news", models.IntegerField()), + ("positive_news", models.IntegerField()), + ("negative_news", models.IntegerField()), + ("need_attention", models.BooleanField()), + ], + options={ + "unique_together": {("symbol", "date")}, + }, + ), + ] diff --git a/applications/backend/django_server/news/models.py b/applications/backend/django_server/news/models.py index 5f8caf3..ed273a0 100644 --- a/applications/backend/django_server/news/models.py +++ b/applications/backend/django_server/news/models.py @@ -28,3 +28,24 @@ class Ticker(models.Model): def __str__(self): return self.ticker + + +class Analysis(models.Model): + category = models.CharField(max_length=100) + symbol = models.CharField(max_length=100) + + date = models.DateField() + average_sentiment = models.FloatField() + total_news = models.IntegerField() + + positive_news = models.IntegerField() + negative_news = models.IntegerField() + + need_attention = models.BooleanField() + + class Meta: + unique_together = ("symbol", "date") + + def __str__(self): + return f"{self.symbol} - {self.date}" +