0% found this document useful (0 votes)
141 views1 page

DTL Quant Contest 1

Rules part 1

Uploaded by

SHUBHAM NAHATA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
141 views1 page

DTL Quant Contest 1

Rules part 1

Uploaded by

SHUBHAM NAHATA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

9/27/24, 8:42 AM DTL Quant Contest

DTL Quant Code

03:02:17:01 SubmissionsLeaderboardReadme SHUBHAM

Challenge@2024 Editor

Hackathon
36
37
README
# Another example
simulation.my_data["days_elapsed"] = 0
38
Objective
39 ⌄
40 def alphaFn(di, simulation):
Click here
41 to collapse/expand
"""Computes section
alpha vector"""
42 N = simulation.N()
The goal of this hackathon is to develop an alpha algorithm that maximises a score. You are provided data from a fictitious stock market which
43 # Alpha needs to be
you can use in your algorithm. Your algorithm is deployed in this fictitious stock market to generate alphas daily over a period. The score is
44 # - A Pandas Series
computed using a number of metrics based on the performance of the alpha like returns, maximum drawdown, sharpe ratio, turnover, etc.
45 # - Have length N
46 # - Have index 0, 1, ... N-1
Alpha 47 alpha = pd.Series(index=np.arange(N))
48
Click here to collapse/expand section
49 # A 5-day reversal example for reference
An alpha is 50a vector signal = pd.Series(index=np.arange(N)).fillna(0)
of stock positions on a given date. Each element of this vector contains the portfolio weights (relative amount of money)
51 ⌄ T = min(di + at
that is invested in a particular stock 1,the
5)given date. These weights can be positive (long positions), negative (short positions), or 0/NAN (no
positions). 52 for dd in range(T):
53 r = simulation.oneDayData("returns", di - dd)
An Alpha 54 Example signal = signal - r["returns"].fillna(0) / T
55 alpha = signal * 0.4 + simulation.my_data["prev_alpha"] * 0.6
In a fictitious
56 market with only 3 stocks - A, B, and C, if alpha on 2024/06/01 is [-5, 3, 2], it means that you have:
57
−5
# Updating saved data
58
∣−5∣+3+2

= −0.5 or 50% of your money in short position
simulation.my_data["prev_alpha"] in A
= alpha
3
59
∣−5∣+3+2
​ = 0.3 or 30% of your money in long position in+=
simulation.my_data["days_elapsed"] B 1
2
60
∣−5∣+3+2
​ = 0.3 or 20% of your money in long position in C
61 ⌄ # Can log any inferences (will not be shown in outsample)
If the price62of A = $250, B = $300, and C = $125 and you had a total%capital
if simulation.my_data["days_elapsed"] 63 ==of0:
$1M, then according to this alpha:
63 print("Quarter ", simulation.my_data["days_elapsed"] // 5)
50%×1M
You64owe
⌄ (short) 250
= 2000 shares of A

30%×1M
You65own (long) = 1000 shares of B
if simulation.my_data["days_elapsed"]
300

== 10:
You66own (long) 20%×1M
#
125
=
Other
​ 1600
ways shares of Cdata
to read
67 fields = simulation.fields()
Properties 68 of Alpha print("Fields available:", fields)
69 print("Data for stock 10 on day 2:\n", simulation.pointData(fields, 2, 10))
You can notice
70 two properties of the example alpha:
print(
71 "Close price for all stocks on day 3:\n",
1. The scale of the alpha does not matter. [-50, 30, 20] and [-5, 3, 2] are the same alpha. Thus the alpha is scale independent
72 simulation.oneDayData("close", 3).head(5),
2. The sum of the alpha positions is zero. Even if your algorithm does ensure this, we will always subtract the mean from the alpha to make
73 )
its sum as zero. If your alpha is [12, -3, -6], we will treat it as [(12-1),(-3-1),(-6-1)]=[11,-4,-7]. Thus the alpha is shift
74 print(
independent
75 "Historic returns for stock 1 in last 5 days:\n",
76 simulation.oneStockData("returns", 1, di - 4, di),
Simulation 77 )
78 print(
Click here to collapse/expand section
79 "Traded volume between days 0 and 2:\n",
80 simulation.fieldData("volume",
During the simulation, your algorithm 0,to2).T.head(5),
is executed repeatedly everyday generate an alpha on each day. Based on your alpha values, the
simulator 81 will trade stocks) and track the performance.
82
A Trading 83 Example # You can create your own features
84 df = simulation.oneDayData(["close", "low", "high"], di)
Continuing 85from the alpha example,= let
feature us assume that
(df["high"] on the next day /2024/06/02
- df["close"]) the price
(df["close"] of A = $250, B = $400, and C = $100. If your
- df["low"])
algorithm86 sets alpha as [-6,3,3], this means you feature.head(5))
print("Feature:\n", are now short 2000 shares of A, long 625 shares of B, and long 2500 shares of C. The
simulation: 87
88 ###### DO NOT REMOVE THIS OR WRITE ANY OTHER RETURN STATEMENTS ######
Will not trade A (no change is number of shares)
89 return alpha
Will sell 375 shares of B (has 1000 yesterday, need it be 625 today) at $400 get $0.15M
90 #####################################################################
Will buy 900 shares of C (2500 - 1600) at $100 and lose $0.09M

On this day your PnL will be 0.15M-0.09M = 0.06M . Note that the total money ($1M in this example) is fixed for all days. We ignore any cost
incurred Notes:
due to taxes,
Notesstamp duties,
for this brokerage,
submission exchange fees, slippage, or market impact.
(optional) Submit Outsample Run Insample

The Fictitious Market You have 10 outsample submission(s) remaining.

The fictitious market has 200 stocks indexed from 0 to 199 and 2713 days indexed from 0 to 2712. This is split into 3 evaluation periods:

insample: The first 1235 days (5 years) of the market. You can run your algorithm any number of times in this period and can also see the logs.
This score is only for your judgement and will not be used in evaluation
DTL © 2024 Created by DTL
outsample: The next 739 days (3 years) of the market You can only run your algorithm 10 times in this period and cannot see the logs This
https://quant-contest.dytechlab.com/quant/contest 1/1

You might also like