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

DTL Quant Contest 3

Rules and regulations

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)
29 views1 page

DTL Quant Contest 3

Rules and regulations

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:43 AM DTL Quant Contest

DTL Quant Code

03:02:16:18 SubmissionsLeaderboardReadme SHUBHAM

Challenge@2024 Editor

36 # Another example
37 simulation.my_data["days_elapsed"] = 0
38
39 ⌄
40 def alphaFn(di, simulation):
Use Run Insample to test the algorithm in insample period and see the score, logs, and PnL curve
41 """Computes alpha vector"""
42 N = simulation.N()
43 # Alpha needs to be
44 # - A Pandas Series
45 # - Have length N
Submission Confirmation
46 # - Have index 0, 1, ... N-1
47 alpha = pd.Series(index=np.arange(N))
48
49 # A 5-day reversal example for reference
50 signal = pd.Series(index=np.arange(N)).fillna(0)
51 ⌄ T = min(di + 1, 5)
52 for dd in range(T):
53 r = simulation.oneDayData("returns", di - dd)
54 signal = signal - r["returns"].fillna(0) / T
55 alpha = signal * 0.4 + simulation.my_data["prev_alpha"] * 0.6
56
57 # Updating saved data
58 simulation.my_data["prev_alpha"] = alpha
59 simulation.my_data["days_elapsed"] += 1
60
61 ⌄ # Can log any inferences (will not be shown Insample Results
in outsample)
62 if simulation.my_data["days_elapsed"] % 63 == 0:
63 print("Quarter ", simulation.my_data["days_elapsed"] // 5)
64 ⌄
65 if simulation.my_data["days_elapsed"] == 10:
66 # Other ways to read data
67 fields = simulation.fields()
68 print("Fields available:", fields)
69 print("Data for stock 10 on day 2:\n", simulation.pointData(fields, 2, 10))
70 print(
71 "Close price for all stocks on day 3:\n",
72 simulation.oneDayData("close", 3).head(5),
73 )
74 print( Logs
75 "Historic returns for stock 1 in last 5 days:\n",
76 You can see the the results of all past submission using the Submissions
simulation.oneStockData("returns", 1, di - 4, tabdi),
77 )
78 print(
79 "Traded volume between days 0 and 2:\n",
80 simulation.fieldData("volume", 0, 2).T.head(5),
81 )
82
83 # You can create your own features
Clicking on any submission will take you to the code of the submission. Here you can see the results and reruse the code for a new
84 df = simulation.oneDayData(["close", "low", "high"], di)
submission by clicking the Reuse This Code button
85 feature = (df["high"] - df["close"]) / (df["close"] - df["low"])
86 print("Feature:\n", feature.head(5))
87
88 ###### DO NOT REMOVE THIS OR WRITE ANY OTHER RETURN STATEMENTS ######
89 return alpha
90 #####################################################################

Notes: Notes for this submission (optional) Submit Outsample Run Insample

You have 10 outsample submission(s) remaining.

Outsample Testing

DTL © 2024toCreated
If you think the results are good, use Submit Outsample test theby DTL
algorithm in outsample period. You can submit a code to
Outsample from the Code Editor or the Submissions page
https://quant-contest.dytechlab.com/quant/contest 1/1

You might also like