summaryrefslogtreecommitdiff
path: root/app/trading/views.py
diff options
context:
space:
mode:
authorluxagraf <sng@luxagraf.net>2021-07-14 09:31:15 -0400
committerluxagraf <sng@luxagraf.net>2021-07-14 09:31:15 -0400
commit39086b58106ff6181d029e0ef845593605821873 (patch)
treeb6652d1b74c1187eafbd0fbd74a3f00f4f1c9c58 /app/trading/views.py
parentc2c0421207694aa5eb148f05a57440716ae2dc8d (diff)
trading: added trading to toolset
Diffstat (limited to 'app/trading/views.py')
-rw-r--r--app/trading/views.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/app/trading/views.py b/app/trading/views.py
new file mode 100644
index 0000000..a2bc5eb
--- /dev/null
+++ b/app/trading/views.py
@@ -0,0 +1,43 @@
+from django.shortcuts import render
+from django.views.generic.edit import FormView
+from django.views.generic.edit import CreateView, DeleteView, UpdateView
+from utils.views import PaginatedListView
+
+from .models import OptionsTrade, LuxTrade
+
+
+class OptionsTradeResultsView(PaginatedListView):
+ model = OptionsTrade
+
+ def get_context_data(self, **kwargs):
+ # Call the base implementation first to get a context
+ context = super(OptionsTradeResultsView, self).get_context_data(**kwargs)
+ return context
+
+class TradeModelFormView(CreateView):
+ model = LuxTrade
+ fields = ['symbol', 'status', 'entry_price', 'stop_price', 'target_price', 'shares']
+ success_url = '/trading/'
+ template_name = 'trading/create_form.html'
+
+class LuxTradeDetailView(UpdateView):
+ model = LuxTrade
+ fields = ['symbol', 'status', 'entry_price', 'stop_price', 'target_price', 'shares', 'close_price']
+ template_name = 'trading/update_form.html'
+ success_url = '/trading/'
+
+
+class LuxTradeListView(PaginatedListView):
+ model = LuxTrade
+ template_name = 'trading/list.html'
+
+ def get_context_data(self, **kwargs):
+ # Call the base implementation first to get a context
+ context = super(LuxTradeListView, self).get_context_data(**kwargs)
+ context['open_trades'] = LuxTrade.objects.filter(status=0)
+ context['watch_trades'] = LuxTrade.objects.filter(status=2)
+ return context
+
+ def get_queryset(self):
+ queryset = super(LuxTradeListView, self).get_queryset()
+ return queryset.filter(status=1)