index
int64 0
0
| repo_id
stringclasses 5
values | file_path
stringlengths 29
58
| content
stringlengths 60
665k
| __index_level_0__
int64 0
0
|
|---|---|---|---|---|
0
|
Chart\Chart
|
Chart\Chart\backend\manage.py
|
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys
def main():
"""Run administrative tasks."""
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'lsg.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)
if __name__ == '__main__':
main()
| 0
|
0
|
Chart\Chart\backend\api\management
|
Chart\Chart\backend\api\management\commands\load_stocks.py
|
import random
from datetime import datetime, timedelta
from django.core.management.base import BaseCommand
from django.db import transaction
from django.utils import timezone
from datetime import timezone as dt_timezone
from api.models import Item
class Command(BaseCommand):
help = "Populate Item table with stock data for a fixed symbol at equal time intervals"
def handle(self, *args, **options):
# Define inputs here directly
num_rows = 100000000
start_str = "2005-05-17 09:00:00"
symbol = ["RA","RB","RC","RD","RE","RF","RG","RH"]
n=len(symbol)
naive_start = datetime.strptime(start_str, "%Y-%m-%d %H:%M:%S")
start_time = timezone.make_aware(naive_start, timezone=dt_timezone.utc)
self.stdout.write(
f"Populating {num_rows} rows for symbol '{symbol}' starting from {start_time}"
)
interval_seconds = 1
items_to_create = []
batch_size = 1000000 # large batch size, adjust if needed
count=0
for i in range(num_rows):
current_time = start_time + timedelta(seconds=i * interval_seconds)
price = round(random.uniform(10000000, 500000000), 2)
volume = random.randint(10000, 1000000)
for s in symbol:
item = Item(
symbol=s,
time=current_time,
price=price,
volume=volume,
)
items_to_create.append(item)
if len(items_to_create) >= batch_size:
with transaction.atomic():
Item.objects.bulk_create(items_to_create)
print(f"Inserted batch: {count}")
count+=1
items_to_create = []
# Insert remaining items
if items_to_create:
with transaction.atomic():
Item.objects.bulk_create(items_to_create)
print("Inserted final batch")
self.stdout.write(self.style.SUCCESS(f"Successfully populated {num_rows} rows"))
# Generate the script to populate the database having CSV rows Timestamp(in milliseconds),Symbol,C1,C2,C3,C4,C5,C6(floats)
| 0
|
0
|
Chart\Chart\backend
|
Chart\Chart\backend\lsg\asgi.py
|
"""
ASGI config for lsg project.
It exposes the ASGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/5.2/howto/deployment/asgi/
"""
import os
from django.core.asgi import get_asgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'lsg.settings')
application = get_asgi_application()
| 0
|
0
|
Chart\Chart\backend
|
Chart\Chart\backend\lsg\settings.py
|
"""
Django settings for lsg project.
Generated by 'django-admin startproject' using Django 5.2.1.
For more information on this file, see
https://docs.djangoproject.com/en/5.2/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/5.2/ref/settings/
"""
from pathlib import Path
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/5.2/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-%003))6u_zp+ysytzj_wgh5=1m!#e+-w45^32+d-vl3y6n45o('
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'api',
'corsheaders',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'corsheaders.middleware.CorsMiddleware',
]
ROOT_URLCONF = 'lsg.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
CORS_ALLOWED_ORIGINS = [
"http://localhost:3000",
]
WSGI_APPLICATION = 'lsg.wsgi.application'
# Database
# https://docs.djangoproject.com/en/5.2/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
# DATABASES = {
# 'default': {
# 'ENGINE': 'django.db.backends.postgresql',
# 'NAME': 'django_db', # e.g. 'postgres' or your custom db
# 'USER': 'postgres',
# 'PASSWORD': '1234',
# 'HOST': 'localhost',
# 'PORT': '5432',
# }
# }
# Password validation
# https://docs.djangoproject.com/en/5.2/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/5.2/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/5.2/howto/static-files/
STATIC_URL = 'static/'
# Default primary key field type
# https://docs.djangoproject.com/en/5.2/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
| 0
|
0
|
Chart\Chart\backend
|
Chart\Chart\backend\lsg\urls.py
|
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
path('api/', include('api.urls')),
]
| 0
|
0
|
Chart\Chart\backend
|
Chart\Chart\backend\lsg\wsgi.py
|
"""
WSGI config for lsg project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/5.2/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'lsg.settings')
application = get_wsgi_application()
| 0
|
0
|
Chart\Chart
|
Chart\Chart\frontend\package-lock.json
| "{\n \"name\": \"frontend\",\n \"version\": \"0.1.0\",\n \"lockfileVersion\": 3,\n \"requires\":(...TRUNCATED)
| 0
|
0
|
Chart\Chart
|
Chart\Chart\frontend\package.json
| "{\n \"proxy\": \"http://localhost:8000\",\n \"name\": \"frontend\",\n \"version\": \"0.1.0\",\n (...TRUNCATED)
| 0
|
0
|
Chart\Chart
|
Chart\Chart\frontend\README.md
| "# Getting Started with Create React App\n\nThis project was bootstrapped with [Create React App](ht(...TRUNCATED)
| 0
|
0
|
Chart\Chart\frontend
|
Chart\Chart\frontend\public\index.html
| "<!DOCTYPE html>\n<html lang=\"en\">\n <head>\n <meta charset=\"utf-8\" />\n <link rel=\"icon(...TRUNCATED)
| 0
|
End of preview. Expand
in Data Studio
README.md exists but content is empty.
- Downloads last month
- 8