38239-vm/core/migrations/0001_initial.py
2026-02-06 09:23:02 +00:00

72 lines
3.9 KiB
Python

# Generated by Django 5.2.7 on 2026-02-06 06:28
import django.db.models.deletion
import uuid
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.CreateModel(
name='Account',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('uid', models.UUIDField(default=uuid.uuid4, editable=False, unique=True)),
('session_key', models.CharField(blank=True, max_length=100, null=True, unique=True)),
('account_type', models.CharField(choices=[('SIMULATED', 'Simulated'), ('REAL', 'Real')], default='SIMULATED', max_length=20)),
('created_at', models.DateTimeField(auto_now_add=True)),
('user', models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
migrations.CreateModel(
name='Ledger',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('currency', models.CharField(max_length=10)),
('amount', models.DecimalField(decimal_places=8, max_digits=30)),
('balance_before', models.DecimalField(decimal_places=8, max_digits=30)),
('balance_after', models.DecimalField(decimal_places=8, max_digits=30)),
('biz_type', models.CharField(max_length=50)),
('reference_id', models.CharField(blank=True, max_length=100, null=True)),
('created_at', models.DateTimeField(auto_now_add=True)),
('account', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='ledger_entries', to='core.account')),
],
),
migrations.CreateModel(
name='Order',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('symbol', models.CharField(default='BTC-USDT', max_length=20)),
('side', models.CharField(choices=[('BUY', 'Buy'), ('SELL', 'Sell')], max_length=10)),
('order_type', models.CharField(choices=[('LIMIT', 'Limit'), ('MARKET', 'Market')], max_length=10)),
('price', models.DecimalField(blank=True, decimal_places=8, max_digits=30, null=True)),
('amount', models.DecimalField(decimal_places=8, max_digits=30)),
('filled_amount', models.DecimalField(decimal_places=8, default=0, max_digits=30)),
('status', models.CharField(choices=[('LIVE', 'Live'), ('PARTIALLY_FILLED', 'Partially Filled'), ('FILLED', 'Filled'), ('CANCELED', 'Canceled')], default='LIVE', max_length=20)),
('created_at', models.DateTimeField(auto_now_add=True)),
('account', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='orders', to='core.account')),
],
),
migrations.CreateModel(
name='Asset',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('currency', models.CharField(max_length=10)),
('balance', models.DecimalField(decimal_places=8, default=0, max_digits=30)),
('frozen', models.DecimalField(decimal_places=8, default=0, max_digits=30)),
('account', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='assets', to='core.account')),
],
options={
'unique_together': {('account', 'currency')},
},
),
]