summaryrefslogtreecommitdiff
path: root/app/trading/admin.py
diff options
context:
space:
mode:
Diffstat (limited to 'app/trading/admin.py')
-rw-r--r--app/trading/admin.py57
1 files changed, 57 insertions, 0 deletions
diff --git a/app/trading/admin.py b/app/trading/admin.py
new file mode 100644
index 0000000..f95a272
--- /dev/null
+++ b/app/trading/admin.py
@@ -0,0 +1,57 @@
+from django.contrib import admin
+from markdownx.widgets import AdminMarkdownxWidget
+from django.db import models
+from .models import TradeJrnl, OptionsTrade
+from utils.widgets import AdminImageWidget, LGEntryForm
+
+
+@admin.register(TradeJrnl)
+class TradingJrnlAdmin(admin.ModelAdmin):
+ form = LGEntryForm
+ formfield_overrides = {
+ models.TextField: {'widget': AdminMarkdownxWidget},
+ }
+ class Media:
+ js = ('image-loader.js', 'next-prev-links.js')
+ css = {
+ "all": ("my_styles.css",)
+ }
+
+
+@admin.register(OptionsTrade)
+class OptionsTradeAdmin(admin.ModelAdmin):
+ list_display = ('symbol', 'date', 'buy_sell', 'open_close', 'quantity')
+ list_filter = ['buy_sell']
+ class Media:
+ js = ('image-loader.js', 'next-prev-links.js')
+ css = {
+ "all": ("my_styles.css",)
+ }
+
+"""
+ date = models.DateTimeField()
+ symbol = models.ForeignKey(Ticker, null=True, on_delete=models.SET_NULL)
+ TRANSACTION_CODE = (
+ ('Trade', 'Trade'),
+ )
+ transaction_code = models.CharField(choices=TRANSACTION_CODE, max_length=25)
+ TRANSACTION_SUBCODE = (
+ ('Buy to Open', 'Buy to Open'),
+ ('Sell to Open', 'Sell to Open'),
+ ('Sell to Close', 'Sell to Close'),
+ )
+ transaction_subcode = models.CharField(choices=TRANSACTION_SUBCODE, max_length=25)
+ open_close = models.CharField(choices=OPEN_CLOSE, max_length=5)
+ quantity = models.FloatField()
+ expiration_date = models.DateTimeField()
+ strike = models.FloatField()
+ CALL_PUT = (
+ ('C', 'Call'),
+ ('P', 'Put'),
+ )
+ call_put = models.CharField(choices=CALL_PUT, max_length=4)
+ price = models.FloatField()
+ fees = models.FloatField()
+ amount = models.FloatField()
+ description = models.TextField(blank=True)
+"""