This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| EasyLanguage Code To TesT The Predictability Of An Event | |
| Vars: | |
| Event(false), | |
| FuturePrice(0), | |
| I(0), | |
| CG(0), | |
| Denom(0); | |
| Arrays: | |
| PredictBin[100](0); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| } | |
| variables: | |
| Event( false ), | |
| FuturePrice( 0 ), | |
| j( 0 ), | |
| CG( 0 ), | |
| Denom( 0 ) ; | |
| arrays: | |
| PredictBin[100]( 0 ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| INPUT: | |
| MAXFLDUR(15), //Max Flag Duration | |
| FLAGMIN(2.5), // Max Atr in lowest point in flag | |
| PX(23), //Max Pole Duration. | |
| UPT1BARS(70), // Bars for Uptrend leading to flag | |
| POLEMIN(5.5), //Min ATR Height of the pole | |
| LBF(50), // Min distance between flags | |
| ATRmin(5),// Min volatility change | |
| K(1.2), //Profit Target constant | |
| timeexit(100), //Time exit bars |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| from scipy import stats | |
| from statsmodels.distributions.empirical_distribution import ECDF | |
| from scipy.stats import kendalltau, pearsonr, spearmanr | |
| from scipy.optimize import minimize | |
| from scipy.integrate import quad | |
| import sys | |
| from collections import deque | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from sklearn import linear_model | |
| import numpy as np | |
| import pandas as pd | |
| from scipy import stats | |
| from math import floor | |
| from datetime import timedelta | |
| class PairsTradingAlgorithm(QCAlgorithm): | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from pandas import * | |
| from datetime import * | |
| import pdb as pdb | |
| df = DataFrame.from_csv('aapl_1-2012_5min.csv') | |
| dayCount=0 | |
| rangeHigh = -1 | |
| rangeLow = 9999 | |
| openDayRangeDict = {} | |
| getRange = 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class NetCurrentAssetValue(QCAlgorithm): | |
| def Initialize(self): | |
| #rebalancing should occur in July | |
| self.SetStartDate(2007,5,15) #Set Start Date | |
| self.SetEndDate(2018,7,15) #Set End Date | |
| self.SetCash(1000000) #Set Strategy Cash | |
| self.UniverseSettings.Resolution = Resolution.Daily | |
| self.previous_fine = None | |
| self.filtered_fine = None |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def CalculateAccruals(self, current, previous): | |
| accruals = [] | |
| for stock_data in current: | |
| try: | |
| prev_data = None | |
| for x in previous: | |
| if x.Symbol == stock_data.Symbol: | |
| prev_data = x | |
| break | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def CoarseSelectionFunction(self, coarse): | |
| if self.yearly_rebalance: | |
| self.filtered_coarse = [x.Symbol for x in coarse if (x.HasFundamentalData) | |
| and (x.Market == "usa")] | |
| return self.filtered_coarse | |
| else: | |
| return [] | |
| def FineSelectionFunction(self, fine): | |
| if self.yearly_rebalance: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| model = RandomForestRegressor(n_jobs=-1, random_state=42, verbose=2) | |
| grid = {'n_estimators': [10, 13, 18, 25, 33, 45, 60, 81, 110, 148, 200], | |
| 'max_features': [0.05, 0.07, 0.09, 0.11, 0.13, 0.15, 0.17, 0.19, 0.21, 0.23, 0.25], | |
| 'min_samples_split': [2, 3, 5, 8, 13, 20, 32, 50, 80, 126, 200]} | |
| rf_gridsearch = GridSearchCV(estimator=model, param_grid=grid, n_jobs=4, | |
| cv=cv, verbose=2, return_train_score=True) | |
| rf_gridsearch.fit(X1, y1) |
OlderNewer