Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
wiseplat
GitHub Repository: wiseplat/python-code
Path: blob/master/ invest-robot-contest_tinkoff_trading_contest-main/tinkoff_contest/trading_app/models.py
5929 views
1
from django.db import models
2
from knowledge_base.models import Strategy
3
4
import trading_app.services.choices as choices
5
6
# Create your models here.
7
8
9
class TradingBot(models.Model):
10
11
id = models.AutoField(primary_key=True)
12
process_id = models.CharField(max_length=20)
13
name = models.CharField(max_length=150)
14
strategy = models.ForeignKey(Strategy, on_delete=models.CASCADE)
15
16
17
class Trade(models.Model):
18
19
bot = models.ForeignKey(TradingBot, on_delete=models.CASCADE)
20
stock = models.CharField(max_length=15)
21
timestamp = models.DateTimeField()
22
order_type = models.CharField(max_length=50, choices=choices.ORDER_TYPES,
23
default=choices._ORDER_TYPE_UNSPECIFIED)
24
direction = models.CharField(max_length=50, choices=choices.DIRECTION_TYPES,
25
default=choices._DIRECTION_TYPE_UNSPECIFIED)
26
quantity = models.FloatField()
27
price = models.FloatField()
28
account_id = models.CharField(max_length=20)
29
order_id = models.CharField(max_length=50)
30
31
32
33
34