Completed

Building a Simple Python Code

def validate_cointegration(ticker_A,ticker_B,window1,window2,start,end):

asset_A=[login to view URL](ticker_A, 'yahoo', start, end)['Adj Close']

asset_B=[login to view URL](ticker_B, 'yahoo', start, end)['Adj Close']

signals=[]

returns=[]

T=end-start

n=int([login to view URL])

print(n)

stationarity_count=0

for i in range(0,n-window1-window2-1):

startdate=start + timedelta(days=(i))

enddate=start + timedelta(days=(window1+i))

constant,slope,logpA,logpB,residuals,stationarity=cointegrate(asset_A,asset_B,startdate,enddate,False)

startdate=start + timedelta(days=(window1+i))

enddate=start + timedelta(days=(window1+i))+timedelta(days=window2)

pnl=out_of_sample_return(slope,asset_A,asset_B,startdate,enddate,False)

if stationarity:

stationarity_count+=1

[login to view URL](residuals[-1],pnl,'*g')

[login to view URL](residuals[-1])

[login to view URL](pnl)

else:

continue

print(stationarity_count)

c=[login to view URL](signals,returns)

correlation=c[0][1]

[login to view URL]('signal')

[login to view URL]('pnl of long-short position')

return signals,returns,correlation

In the above code, I have two lists called signals and returns. I want to add to the function the following logic:

Loop through all signals and check if the current signal is less than one standard deviation from the mean and see what would be the average return at that index.

Skills: Python, Mathematics, Statistics

See more: php code display in browser instead of executing it, in sample and out of sample forecasting in r, in sample vs out of sample backtesting, in sample and out of sample forecasting, in sample vs out of sample error, out of sample forecast example, out of sample regression, in sample and out of sample example, the conversion of a nvarchar data type to a smalldatetime data type resulted in an out-of-range, the conversion of a date data type to a datetime data type resulted in an out-of-range value sql, the conversion of a varchar data type to a datetime data type resulted in an out-of-range value. c#, the conversion of a datetime2 data type to a datetime data type resulted in an out-of-range value., in and out of ketosis, eviews forecast out of sample, stata out of sample prediction example, average turnaround of bidding in freelancing out of five, eviews forecast out-of-sample, out-of-sample forecasting stata, stata predict out-of-sample, php code display in browser instead of executing it xampp

About the Employer:
( 7 reviews ) MADISON, United States

Project ID: #28456323

Awarded to:

pranavjandu3

I can do it right now. I can add the function to this script to check for the signal's standard deviation from the mean and if it's less than 1, get returns at current signal. Let's chat to discuss more. I'm a softwa More

$25 USD in 1 day
(1 Review)
2.2

8 freelancers are bidding on average $18 for this job

rochaksharma7

Hello sir. Your project attracted my attention at first glance, because I've extensive experience in Python, Machine Learning Programming, NLP, AI. I'm really confident about your project, and very eager to join your More

$20 USD in 1 day
(20 Reviews)
3.9
Leongchien0830

Hi, I have Python experience and I have build a web page from scratch with some library by using Python also. If you willing to give me a chance, we can discuss more about this project.

$25 USD in 7 days
(1 Review)
2.5
JaibhanSinghGaur

Hi, I am a python developer with more than 2 years of experience I have done many projects in past. So I think I can help you. Let's discuss more over chat. Please look at my profile once.

$10 USD in 1 day
(3 Reviews)
1.8
Alexeydev1

Hello sir. I am expert on python, I can do this job for 1 hour. It is very easy for python expert. Please come to chat.

$30 USD in 7 days
(0 Reviews)
0.0
seifeleslam1990

Hi, I'm a Senior Python developer at a Canadian company. I'm a Python geek. I'm expert in data analysis(pandas, numpy, ..) and scripting. I have the required skills. I can help you. This my LinkedIn profile: [login to view URL] More

$10 USD in 1 day
(1 Review)
0.2
vishwak1002

Hi sir Iam a newbie but I have sound knowledge in python and programming fundamentals along with statistics .Hence I feel Iam eligible to do your project if given chance. The project is easy and i can do it in 2 hrs s More

$10 USD in 1 day
(0 Reviews)
0.0
jmdeepak143

Hello ,sir I got it what you want to achieve. I'm skilled in python and algorithms . Would love to work for you and thus gaining my first feedback. Can we discuss the things further on chat so that I can provide the s More

$10 USD in 1 day
(0 Reviews)
0.0