Simulations

Models

class simulations.models.Currency(*args, **kwargs)[source]

Bases: django.db.models.base.Model

A currency, used for display purpose in each views. It has no incidence on the core of the simulation.

Parameters:
  • id (AutoField) – Id
  • code (CharField) – The ISO code of the currency
  • symbol (CharField) – The symbol of the currency
class simulations.models.Simulation(*args, **kwargs)[source]

Bases: django_extensions.db.models.TimeStampedModel

A simulation hold all configuration parameters used to setup and run a simulation.

Parameters:
  • id (AutoField) – Id
  • created (CreationDateTimeField) – Created
  • modified (ModificationDateTimeField) – Modified
  • code (CharField) – The code of the simulation (for the user interface)
  • customer_id (ForeignKey to Customer) – The customer account running this simulation
  • user_id (ForeignKey to User) – The user account running this simulation
  • simulation_type (CharField) – The type of this simulation
  • capital (DecimalField) – Initial capital paid to each team
  • currency_id (ForeignKey to Currency) – The currency symbol displayed in the interface (has no impact on the simulation)
  • state (IntegerField) – The current state of this simulation
class simulations.models.Team(*args, **kwargs)[source]

Bases: django_extensions.db.models.TimeStampedModel

A team participating in a simulation.

Parameters:
  • id (AutoField) – Id
  • created (CreationDateTimeField) – Created
  • modified (ModificationDateTimeField) – Modified
  • customer_id (ForeignKey to Customer) – The organization the team belongs to
  • name (CharField) – A name that can be attributed to the team
  • team_type (CharField) – Indicates if it is a team of players or a liquidity manager
  • locked (BooleanField) – Locked teams can not log in the simulation
  • uuid (CharField) – A unique registration key that is automatically created
simulations.models.create_liquidity_manager(simulation)[source]

Create a new team to host the liquidity manager.

Parameters:simulation – Simulation object in which to add a new team
Returns:Team object created

Tasks

simulations.tasks.initialize_simulation(simulation)[source]

Initialize the simulation (async Celery task).

-Creates stocks -Creates a liquidity manager -Initialize the ticker -Creates opening transactions

Parameters:simulation – Simulation object
Returns:None

Views

class simulations.views.CurrencyViewSet(**kwargs)[source]

Bases: rest_framework.viewsets.ModelViewSet

permission_classes = (<class 'rest_framework.permissions.IsAuthenticatedOrReadOnly'>,)
queryset = [<Currency: CHF>]
serializer_class

alias of CurrencySerializer

suffix = None
class simulations.views.SimulationCreate(**kwargs)[source]

Bases: django.contrib.messages.views.SuccessMessageMixin, django.views.generic.edit.CreateView

fields = ['code', 'simulation_type', 'capital', 'currency']
form_valid(form)[source]
get_context_data(**kwargs)[source]
get_success_message(cleaned_data)[source]
get_success_url()[source]
model

alias of Simulation

success_message = <django.utils.functional.lazy.<locals>.__proxy__ object at 0x2aec9a26e780>
class simulations.views.SimulationDelete(**kwargs)[source]

Bases: django.contrib.messages.views.SuccessMessageMixin, django.views.generic.edit.DeleteView

delete(request, *args, **kwargs)[source]
get_object(queryset=None)[source]
model

alias of Simulation

success_message = <django.utils.functional.lazy.<locals>.__proxy__ object at 0x2aec9a26e978>
success_url = <django.utils.functional.lazy.<locals>.__proxy__ object at 0x2aec9a26e940>
class simulations.views.SimulationDetailView(**kwargs)[source]

Bases: django.views.generic.detail.DetailView

get_context_data(**kwargs)[source]
get_object(queryset=None)[source]
model

alias of Simulation

class simulations.views.SimulationInitializeView(**kwargs)[source]

Bases: django.contrib.messages.views.SuccessMessageMixin, django.views.generic.edit.UpdateView

Update/Create the simulation. It calls initialize_simulation after form validation.

fields = ['nb_companies', 'initial_value', 'fixed_interest_rate']
form_valid(form)[source]
get_context_data(**kwargs)[source]
get_form_class()[source]
get_object(queryset=None)[source]
get_success_message(cleaned_data)[source]
get_success_url()[source]
model

alias of Ticker

simulation = None
success_message = <django.utils.functional.lazy.<locals>.__proxy__ object at 0x2aec9a26ebe0>
class simulations.views.SimulationListView(**kwargs)[source]

Bases: django.views.generic.list.ListView

get_context_data(**kwargs)[source]
get_queryset()[source]
model

alias of Simulation

class simulations.views.SimulationUpdate(**kwargs)[source]

Bases: django.contrib.messages.views.SuccessMessageMixin, django.views.generic.edit.UpdateView

fields = ['code', 'simulation_type', 'capital', 'currency']
get_context_data(**kwargs)[source]
get_object(queryset=None)[source]
get_success_url()[source]
model

alias of Simulation

success_message = <django.utils.functional.lazy.<locals>.__proxy__ object at 0x2aec9a26e860>
class simulations.views.SimulationViewSet(**kwargs)[source]

Bases: rest_framework.viewsets.ModelViewSet

perform_create(serializer)[source]
permission_classes = (<class 'rest_framework.permissions.IsAuthenticatedOrReadOnly'>,)
queryset = [<Simulation: ARC-1>]
serializer_class

alias of SimulationSerializer

suffix = None
class simulations.views.TeamDetailView(**kwargs)[source]

Bases: django.views.generic.detail.DetailView

get_context_data(**kwargs)[source]
get_object(queryset=None)[source]
model

alias of Team

class simulations.views.TeamJoinView(**kwargs)[source]

Bases: django.contrib.messages.views.SuccessMessageMixin, django.views.generic.edit.FormView

form_class

alias of TeamJoinForm

form_valid(form)[source]
get_success_message(cleaned_data)[source]
get_success_url()[source]
success_message = <django.utils.functional.lazy.<locals>.__proxy__ object at 0x2aec9a26ea90>
team_name = ''
template_name = 'simulations/join_team_form.html'
class simulations.views.TeamViewSet(**kwargs)[source]

Bases: rest_framework.viewsets.ModelViewSet

permission_classes = (<class 'rest_framework.permissions.IsAuthenticatedOrReadOnly'>,)
queryset = [<Team: ARC-1>, <Team: ARC-2>, <Team: ARC-3>, <Team: ARC-4>, <Team: ARC-5>, <Team: Liquidity trader ARC-1>]
serializer_class

alias of TeamSerializer

suffix = None
class simulations.views.TeamsSelectionView(**kwargs)[source]

Bases: django.contrib.messages.views.SuccessMessageMixin, django.views.generic.edit.FormView

form_class

alias of TeamsSelectionForm

form_valid(form)[source]
get_context_data(**kwargs)[source]
get_form_kwargs()[source]
get_success_url()[source]
success_message = <django.utils.functional.lazy.<locals>.__proxy__ object at 0x2aec9a26e6a0>
template_name = 'simulations/manage_teams_form.html'
simulations.views.manage_simulation(request, simulation_id, next_state)[source]

Helper to change the current state of the simulation.

Available states are READY -> RUNNING <-> PAUSED -> FINISHED -> ARCHIVED.

Parameters:
  • request
  • simulation_id
  • next_state
Returns:

HttpResponseRedirect

simulations.views.remove_tz_from_date(date)[source]
simulations.views.teams_export_xlsx(request, simulation_id=None, customer_id=None)[source]

Serializers

class simulations.serializers.CurrencySerializer(instance=None, data=None, **kwargs)[source]

Bases: rest_framework.serializers.ModelSerializer

Currency serializer.

class Meta[source]

Bases: builtins.object

fields = ('id', 'code', 'symbol')
model

alias of Currency

class simulations.serializers.SimulationSerializer(instance=None, data=None, **kwargs)[source]

Bases: rest_framework.serializers.ModelSerializer

Simulation serializer.

class Meta[source]

Bases: builtins.object

fields = ('id', 'code', 'customer', 'user', 'simulation_type', 'teams', 'capital', 'currency', 'state', 'stocks')
model

alias of Simulation

class simulations.serializers.TeamSerializer(instance=None, data=None, **kwargs)[source]

Bases: rest_framework.serializers.ModelSerializer

Team serializer.

class Meta[source]

Bases: builtins.object

fields = ('id', 'simulation', 'login', 'password', 'name', 'team_type', 'locked', 'orders')
model

alias of Team

Table Of Contents

This Page