Skip to content

Instantly share code, notes, and snippets.

View Jay-Jay-D's full-sized avatar

Juan José D'Ambrosio Jay-Jay-D

  • Entre Ríos, Argentina
View GitHub Profile
# /etc/security/limits.conf
#<domain> <type> <item> <value>
root hard nofile 999999
root soft nofile 999999
root hard core -1
root soft core -1
root hard data -1
root soft data -1
root hard fsize -1
/*
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
using QuantConnect.Data;
using QuantConnect.Data.Market;
using QuantConnect.Indicators;
using QuantConnect.Securities;
using QuantConnect.Securities.Forex;
using System;
using static System.Diagnostics.Debug;
namespace QuantConnect.Algorithm.CSharp
{
/*
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
using MathNet.Numerics;
using MathNet.Numerics.Distributions;
using MathNet.Numerics.Statistics;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Optimization
{
public class DeflatedSharpeRatio
/*
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@Jay-Jay-D
Jay-Jay-D / cointegration_test.py
Created April 5, 2017 13:58
CointegrationTest
def cointegration_test(df_data, start_date=None, end_date=None, verbose=False):
"""This method test for correlation and cointegration all the combinations
of stocks in the period defined by start_date and end_date.
Following the paper "High Frecuency and Dynamic Pairs Trading Based on
Statistical Arbitrage Using a Two-Stage Correlation and Cointegration Approach",
the method first test if the correlation has a pearson coefficient bigger than 0.9.
Then run a simple cointegration test and if the p-values is less than 0.1, then run
an Augmented Dickey–Fuller test.
using QuantConnect.Data;
using QuantConnect.Data.Market;
using QuantConnect.Indicators;
using QuantConnect.Orders;
using QuantConnect.Orders.Fees;
using QuantConnect.Orders.Fills;
using QuantConnect.Securities;
using System;
using System.Collections.Generic;
using System.Linq;
/*
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,