Forgotten commit
parent
ab82f2b2e8
commit
c4047ec400
|
@ -0,0 +1,15 @@
|
|||
from aq.models import *
|
||||
from django.contrib import admin
|
||||
|
||||
class AssetTypeAdmin(admin.ModelAdmin):
|
||||
list_display=['name']
|
||||
|
||||
admin.site.register(Account)
|
||||
admin.site.register(AssetType)
|
||||
admin.site.register(Order)
|
||||
|
||||
class TradingPairAdmin(admin.ModelAdmin):
|
||||
list_display=['Primary', 'Secondary']
|
||||
|
||||
admin.site.register(TradingPair, TradingPairAdmin)
|
||||
admin.site.register(IOTransaction)
|
|
@ -0,0 +1,36 @@
|
|||
from aq import models
|
||||
|
||||
class Transaction():
|
||||
# def __init__(self, **kwargs):
|
||||
# self.__dict__ = **kwargs
|
||||
|
||||
pass
|
||||
|
||||
class DynamicOrder():
|
||||
def __init__(self, o):
|
||||
self.__dict__ = o.__dict__
|
||||
|
||||
|
||||
pass
|
||||
|
||||
class SystemState():
|
||||
|
||||
|
||||
def __init__(self):
|
||||
self.currentOrders = [];
|
||||
self.transactions = [];
|
||||
for o in models.Order.objects.all():
|
||||
do = DynamicOrder(o)
|
||||
self.processOrder(do)
|
||||
# self.currentOrders.append(do)
|
||||
|
||||
def processOrder(self, o):
|
||||
for co in self.currentOrders:
|
||||
if co.pair_id != o.pair_id:
|
||||
continue
|
||||
if o.ordertype == 'S':
|
||||
if co.ordertype == 'B':
|
||||
if co.quantity > o.quantity:
|
||||
|
||||
pass
|
||||
self.currentOrders.append(o)
|
46
aq/models.py
46
aq/models.py
|
@ -1,3 +1,49 @@
|
|||
from django.db import models
|
||||
|
||||
# Create your models here.
|
||||
class AssetType(models.Model):
|
||||
name = models.CharField(max_length=80)
|
||||
def __unicode__(obj):
|
||||
return obj.name
|
||||
|
||||
class TradingPair(models.Model):
|
||||
Primary = models.ForeignKey(AssetType, related_name='pair_primary')
|
||||
Secondary = models.ForeignKey(AssetType, related_name='pair_secondary')
|
||||
""" @todo: Uniqueness is very specific here """
|
||||
|
||||
def __unicode__(obj):
|
||||
return obj.Primary.__unicode__() + "/" + obj.Secondary.__unicode__()
|
||||
|
||||
class Account(models.Model):
|
||||
pass
|
||||
|
||||
class IOTransaction(models.Model):
|
||||
asset = models.ForeignKey(AssetType)
|
||||
volume = models.IntegerField()
|
||||
account = models.ForeignKey(Account)
|
||||
|
||||
class Order(models.Model):
|
||||
TYPECHOICE = (
|
||||
('S', 'Sell'),
|
||||
('B', 'Buy'),
|
||||
)
|
||||
|
||||
STATUSCHOICE = (
|
||||
('A', 'Outstanding'),
|
||||
('C', 'Cancelled'),
|
||||
('S', 'Split'),
|
||||
)
|
||||
|
||||
ordertype = models.CharField(max_length=1, choices=TYPECHOICE)
|
||||
# statustype= models.CharField(max_length=1, choices=STATUSCHOICE)
|
||||
|
||||
pair = models.ForeignKey(TradingPair)
|
||||
|
||||
quantity = models.IntegerField() # Quantity PRIMARY
|
||||
account = models.ForeignKey(Account)
|
||||
price = models.IntegerField() # Price in SECONDARY for UNIT of PRIMARY.
|
||||
|
||||
reference = models.ForeignKey('Order', null=True, blank=True)
|
||||
|
||||
submitted = models.DateTimeField(auto_now_add = True)
|
||||
executed = models.DateTimeField(null=True, blank=True)
|
||||
|
|
|
@ -1 +1,6 @@
|
|||
# Create your views here.
|
||||
from django.shortcuts import render_to_response
|
||||
from aq import control
|
||||
|
||||
def debug(request):
|
||||
ss = control.SystemState()
|
||||
return render_to_response('aq/debug.html', {'ss': ss})
|
||||
|
|
12
settings.py
12
settings.py
|
@ -11,9 +11,9 @@ MANAGERS = ADMINS
|
|||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
|
||||
'NAME': '', # Or path to database file if using sqlite3.
|
||||
'USER': '', # Not used with sqlite3.
|
||||
'ENGINE': 'django.db.backends.postgresql_psycopg2', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
|
||||
'NAME': 'haq', # Or path to database file if using sqlite3.
|
||||
'USER': 'django', # Not used with sqlite3.
|
||||
'PASSWORD': '', # Not used with sqlite3.
|
||||
'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
|
||||
'PORT': '', # Set to empty string for default. Not used with sqlite3.
|
||||
|
@ -116,9 +116,11 @@ INSTALLED_APPS = (
|
|||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
# Uncomment the next line to enable the admin:
|
||||
# 'django.contrib.admin',
|
||||
'django.contrib.admin',
|
||||
# Uncomment the next line to enable admin documentation:
|
||||
# 'django.contrib.admindocs',
|
||||
'django.contrib.admindocs',
|
||||
'south',
|
||||
'aq',
|
||||
)
|
||||
|
||||
# A sample logging configuration. The only tangible logging
|
||||
|
|
7
urls.py
7
urls.py
|
@ -1,17 +1,18 @@
|
|||
from django.conf.urls.defaults import patterns, include, url
|
||||
|
||||
# Uncomment the next two lines to enable the admin:
|
||||
# from django.contrib import admin
|
||||
# admin.autodiscover()
|
||||
from django.contrib import admin
|
||||
admin.autodiscover()
|
||||
|
||||
urlpatterns = patterns('',
|
||||
# Examples:
|
||||
# url(r'^$', 'haq.views.home', name='home'),
|
||||
# url(r'^haq/', include('haq.foo.urls')),
|
||||
url(r'^debug', 'aq.views.debug', name='debug'),
|
||||
|
||||
# Uncomment the admin/doc line below to enable admin documentation:
|
||||
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
|
||||
|
||||
# Uncomment the next line to enable the admin:
|
||||
# url(r'^admin/', include(admin.site.urls)),
|
||||
url(r'^admin/', include(admin.site.urls)),
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue