Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
comm034_final
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Suresh, Nayana (PG/T - Comp Sci & Elec Eng)
comm034_final
Commits
060ad453
Commit
060ad453
authored
7 months ago
by
Suresh, Nayana (PG/T - Comp Sci & Elec Eng)
Browse files
Options
Downloads
Patches
Plain Diff
Update montecarlo_ec2
parent
cd0144fb
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
montecarlo_ec2
+7
-4
7 additions, 4 deletions
montecarlo_ec2
with
7 additions
and
4 deletions
montecarlo_ec2
+
7
−
4
View file @
060ad453
...
...
@@ -31,9 +31,7 @@ def calculate_mean_std(close_prices):
return
mean_value
,
std_value
def
process_stock_data
(
event
):
"""
Processing the stock data to identify signals and perform Monte Carlo simulation for each signal.
"""
logging
.
debug
(
f
"
Received event:
{
event
}
"
)
stock_data
=
event
.
get
(
'
stock_data
'
)
h
=
int
(
event
.
get
(
'
h
'
))
d
=
int
(
event
.
get
(
'
d
'
))
...
...
@@ -43,11 +41,14 @@ def process_stock_data(event):
var99_list
=
[]
signal_dates
=
[]
logging
.
debug
(
f
"
Processing
{
len
(
stock_data
)
}
records with h=
{
h
}
, d=
{
d
}
, t=
{
t
}
"
)
for
i
in
range
(
h
,
len
(
stock_data
)):
if
(
t
==
'
buy
'
and
stock_data
[
i
][
'
Buy
'
]
==
1
)
or
(
t
==
'
sell
'
and
stock_data
[
i
][
'
Sell
'
]
==
1
):
close_prices
=
[
entry
[
'
Close
'
]
for
entry
in
stock_data
[
i
-
h
:
i
]]
if
len
(
close_prices
)
<
h
:
logging
.
debug
(
f
"
Skipping index
{
i
}
, insufficient data
"
)
continue
mean_value
,
std_value
=
calculate_mean_std
(
close_prices
)
...
...
@@ -58,13 +59,15 @@ def process_stock_data(event):
signal_dates
.
append
(
stock_data
[
i
][
'
Date
'
])
results
=
{
# 'dates': signal_dates,
'
var95
'
:
var95_list
,
'
var99
'
:
var99_list
}
logging
.
debug
(
f
"
Generated results:
{
results
}
"
)
return
results
def
main
():
try
:
# check and parsing the incoming JSON payload
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment