1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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)
"""
|