summaryrefslogtreecommitdiff
path: root/app/trading/views.py
diff options
context:
space:
mode:
Diffstat (limited to 'app/trading/views.py')
-rw-r--r--app/trading/views.py79
1 files changed, 55 insertions, 24 deletions
diff --git a/app/trading/views.py b/app/trading/views.py
index 4d33497..aece7b2 100644
--- a/app/trading/views.py
+++ b/app/trading/views.py
@@ -1,32 +1,10 @@
from datetime import datetime
-from django.shortcuts import render
-from django.views.generic.edit import FormView
-from django.views.generic.edit import CreateView, DeleteView, UpdateView
+from django.views.generic.edit import CreateView, UpdateView
from utils.views import PaginatedListView
-from .models import OptionsTrade, LuxTrade
+from .models import LuxTrade, LuxOptionsTrade
-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', 'is_wanderer']
- 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', 'notes', 'is_wanderer']
- template_name = 'trading/update_form.html'
- success_url = '/trading/'
-
class LuxTradeListView(PaginatedListView):
model = LuxTrade
template_name = 'trading/list.html'
@@ -36,6 +14,7 @@ class LuxTradeListView(PaginatedListView):
context = super(LuxTradeListView, self).get_context_data(**kwargs)
context['open_trades'] = LuxTrade.objects.filter(status=0)
context['watch_trades'] = LuxTrade.objects.filter(status=2)
+ context['options_trades'] = LuxOptionsTrade.objects.filter(status=2)
context['monthly_pl'] = LuxTrade.stats.get_month_pl()
context['month'] = datetime.now().strftime('%h')
return context
@@ -43,3 +22,55 @@ class LuxTradeListView(PaginatedListView):
def get_queryset(self):
queryset = super(LuxTradeListView, self).get_queryset()
return queryset.filter(status=1)
+
+
+class LuxTradeDetailView(UpdateView):
+ model = LuxTrade
+ fields = ['symbol', 'status', 'entry_price', 'stop_price', 'target_price', 'shares', 'close_price', 'notes', 'is_wanderer']
+ template_name = 'trading/update_form.html'
+ success_url = '/trading/'
+
+
+class TradeModelFormView(CreateView):
+ model = LuxTrade
+ fields = ['symbol', 'status', 'entry_price', 'stop_price', 'target_price', 'shares', 'is_wanderer']
+ success_url = '/trading/'
+ template_name = 'trading/create_form.html'
+
+
+class LuxOptionsTradeDetailView(UpdateView):
+ model = LuxOptionsTrade
+ fields = [
+ 'symbol',
+ 'status',
+ 'entry_price',
+ 'stop_price',
+ 'target_price',
+ 'call_put',
+ 'expiration_date',
+ 'strike_price',
+ 'contract_price',
+ 'number_contracts',
+ 'delta'
+ ]
+ template_name = 'trading/update_options_form.html'
+ success_url = '/trading/'
+
+
+class OptionsModelFormView(CreateView):
+ model = LuxOptionsTrade
+ fields = [
+ 'symbol',
+ 'status',
+ 'entry_price',
+ 'stop_price',
+ 'target_price',
+ 'call_put',
+ 'expiration_date',
+ 'strike_price',
+ 'contract_price',
+ 'number_contracts',
+ 'delta'
+ ]
+ success_url = '/trading/'
+ template_name = 'trading/create_options_form.html'