def __init__(self): # Create some assets: assetsList = [ Asset('PLF_4.1', 'darwin', 'historical'), Asset('LVS_4.20', 'darwin', 'historical'), Asset('SYO_4.24', 'darwin', 'historical') ] self.R_STUDY = ResearchStudy(assetsList, formOrRead='read_darwin', formerOrNew='former') self.R_STUDY._generateResampledAndFilteredSeries(resampleRule='1D')
def __init__(self): # Create some assets: assetsList = [ Asset('WS30', 'traditional', 'historical'), # Index US Asset('XAUUSD', 'traditional', 'historical'), # CryptoCurrency Asset('GDAXIm', 'traditional', 'historical'), # Index EUR Asset('EURUSD', 'traditional', 'historical'), # Major Asset('GBPJPY', 'traditional', 'historical') ] # Minor # Create the RSTUDY object: self.R_STUDY = ResearchStudy(assetsList, formOrRead='read_features')
class TSDecomposition(BaseModel): def __init__(self): # Create some assets: assetsList = [ Asset('PLF_4.1', 'darwin', 'historical'), Asset('LVS_4.20', 'darwin', 'historical'), Asset('SYO_4.24', 'darwin', 'historical') ] self.R_STUDY = ResearchStudy(assetsList, formOrRead='read_darwin', formerOrNew='former') self.R_STUDY._generateResampledAndFilteredSeries(resampleRule='1D') def executeSeasonalDecompose(self, saveDirectory): # Loop the portfolio dict: for eachAssetName, eachAssetDataFrame in self.R_STUDY.PORTFOLIO._portfolioDict.items( ): # Make the decompose: TS_DECOMPOSED = seasonal_decompose(eachAssetDataFrame['close'], model='aditive', period=20) #TS_DECOMPOSED = seasonal_decompose(eachAssetDataFrame['Returns'], model='multiplicative', period=20) print( f'[executeSeasonalDecompose] - Will plot decomposed series for asset {eachAssetName}' ) # Plot and show it: TS_DECOMPOSED.plot() # In PNG: plt.savefig(saveDirectory + f'/TSDec_DARWIN_{eachAssetName}.png') plt.show()
def __init__(self): # Create some assets: assetsList = [ Asset('WS30', 'traditional', 'historical'), # Index US Asset('XAUUSD', 'traditional', 'historical'), # CryptoCurrency Asset('GDAXIm', 'traditional', 'historical'), # Index EUR Asset('EURUSD', 'traditional', 'historical'), # Major Asset('GBPJPY', 'traditional', 'historical') ] # Minor # Create the RSTUDY object: self.R_STUDY = ResearchStudy(assetsList, formOrRead='read_features') # Print to see if working: print(self.R_STUDY.PORTFOLIO._portfolioDict['WS30'])
assetsList = [ Asset('PLF_4.1', 'darwin', 'historical'), Asset('LVS_4.20', 'darwin', 'historical'), Asset('SYO_4.24', 'darwin', 'historical') ] # Create some path variables > Point them to the specific folder: homeStr = os.path.expanduser("~") plotsSaveDirectory = os.path.expandvars( f'{homeStr}/Desktop/quant-research-env/DARWINStrategyContentSeries/Data') dataframesSaveDirectory = os.path.expandvars( f'{homeStr}/Desktop/quant-research-env/DARWINStrategyContentSeries/Data') #R_STUDY = ResearchStudy(assetsList, formOrRead='form_darwin', saveTheData=True) R_STUDY = ResearchStudy(assetsList, formOrRead='read_darwin', formerOrNew='former') # Apply the reseach study we want: R_STUDY._generateDARWINTickBars(threshold=5000) #R_STUDY._generateDARWINDollarBars(threshold=1000000000) # Plot candles and indicators: R_STUDY._plotCandleAndIndicatorsOtherBars(plotsSaveDirectory, showIt=True) # Generate the plots: R_STUDY._plotReturnsOtherBars(plotsSaveDirectory, showIt=True) R_STUDY._plotDistributionOtherBars(plotsSaveDirectory, showIt=True) #R_STUDY._plotQQPlotOtherBars(plotsSaveDirectory, showIt=True) # Save the generated dataframes:
assetsList = [ Asset('PLF_4.1', 'darwin', 'historical'), Asset('LVS_4.20', 'darwin', 'historical'), Asset('SYO_4.24', 'darwin', 'historical') ] # Create some path variables > Point them to the specific folder: homeStr = os.path.expanduser("~") plotsSaveDirectory = os.path.expandvars( f'{homeStr}/Desktop/quant-research-env/DARWINStrategyContentSeries/Data') dataframesSaveDirectory = os.path.expandvars( f'{homeStr}/Desktop/quant-research-env/DARWINStrategyContentSeries/Data') #R_STUDY = ResearchStudy(assetsList, formOrRead='form_darwin', saveTheData=True) R_STUDY = ResearchStudy(assetsList, formOrRead='read_darwin', formerOrNew='former') # Print it: pprint.pprint(R_STUDY.PORTFOLIO._portfolioDict) ###################### DARWIN SPECIFICS ###################### # Apply the reseach study we want: R_STUDY._generateResampledAndFilteredSeries(resampleRule='1D') #R_STUDY._generateResampledAndFilteredSeries(resampleRule='4H') #R_STUDY._generateResampledAndFilteredSeries(resampleRule='30min') ###################### DARWIN SPECIFICS ###################### # Apply the reseach study we want: #R_STUDY._generateRawReturns() R_STUDY._generateLogReturns()
dataframesSaveDirectory = os.path.expandvars( f'{homeStr}/Desktop/quant-research-env/RegimeAnalysisContentSeries/Data/Data_Others' ) # Create some assets: assetsList = [ Asset('WS30', 'traditional', 'historical'), # Index US Asset('XAUUSD', 'traditional', 'historical'), # CryptoCurrency Asset('GDAXIm', 'traditional', 'historical'), # Index EUR Asset('EURUSD', 'traditional', 'historical'), # Major Asset('GBPJPY', 'traditional', 'historical') ] # Minor # Read it from file: # NOTE: If the data is not in the /Data directory> # we will need to change the path in the AssetClass _readBidAndAskHistoricalData method. R_STUDY = ResearchStudy(assetsList, formOrRead='read', dateHourString='2020-02-04_23') # Apply the reseach study we want: R_STUDY._generateTickBars(endDate='2020-02-04_23', threshold=1522) #R_STUDY._generateDollarBars(endDate='2020-02-04_23', threshold=7000000000) # Generate the plots: #R_STUDY._plotReturnsOtherBars(plotsSaveDirectory, showIt=True) R_STUDY._plotDistributionOtherBars(plotsSaveDirectory, showIt=True) R_STUDY._plotQQPlotOtherBars(plotsSaveDirectory, showIt=True) # Save the generated dataframes: #R_STUDY._saveGeneratedDataFramesOtherBars(dataframesSaveDirectory)
) # Create some assets: assetsList = [ Asset('WS30', 'traditional', 'historical'), # Index US Asset('XAUUSD', 'traditional', 'historical'), # CryptoCurrency Asset('GDAXIm', 'traditional', 'historical'), # Index EUR Asset('EURUSD', 'traditional', 'historical'), # Major Asset('GBPJPY', 'traditional', 'historical') ] # Minor # Create the research study object: # Get the tick data or some time aggregated representation: #R_STUDY = ResearchStudy(assetsList, formOrRead='form', sampleFormat='tick') #R_STUDY = ResearchStudy(assetsList, formOrRead='form', sampleFormat='5T') # Or read it from file: # NOTE: If the data is not in the /Data directory> # we will need to change the path in the AssetClass _readBidAndAskHistoricalData method. R_STUDY = ResearchStudy(assetsList, formOrRead='read', dateHourString='2020-02-04_23') # Let's see the data: pprint.pprint(R_STUDY.PORTFOLIO._portfolioDict['WS30']) # Perform some calculations on the data: R_STUDY._generateRawReturns() # Save the generated dataframes: R_STUDY._saveGeneratedDataFrames(dataframesSaveDirectory)
) # Create some assets: assetsList = [ Asset('WS30', 'traditional', 'historical'), # Index US Asset('XAUUSD', 'traditional', 'historical'), # CryptoCurrency Asset('GDAXIm', 'traditional', 'historical'), # Index EUR Asset('EURUSD', 'traditional', 'historical'), # Major Asset('GBPJPY', 'traditional', 'historical') ] # Minor # Read it from file: # NOTE: If the data is not in the /Data directory> # we will need to change the path in the AssetClass _readBidAndAskHistoricalData method. R_STUDY = ResearchStudy(assetsList, formOrRead='read', dateHourString='2020-02-04_23') # Print the whole dict, some asset or the shape: #pprint.pprint.warning(R_STUDY.PORTFOLIO._portfolioDict) #pprint.pprint.warning(R_STUDY.PORTFOLIO._portfolioDict['WS30']) #pprint.pprint.warning(R_STUDY.PORTFOLIO._portfolioDict['WS30'].shape) # Apply the reseach study we want: R_STUDY._generateRawReturns() #R_STUDY._generateLogReturns() #R_STUDY._generateRollingMean() #R_STUDY._generateRollingMean(rollingWindow=40) # Generate the plots: #R_STUDY._plotReturns(plotsSaveDirectory, showIt=True)
# Create some assets: assetsList = [ Asset('PLF_4.1', 'darwin', 'historical'), Asset('LVS_4.20', 'darwin', 'historical'), Asset('SYO_4.24', 'darwin', 'historical') ] # Create some path variables > Point them to the specific folder: homeStr = os.path.expanduser("~") plotsSaveDirectory = os.path.expandvars( f'{homeStr}/Desktop/quant-research-env/DARWINStrategyContentSeries/Data') dataframesSaveDirectory = os.path.expandvars( f'{homeStr}/Desktop/quant-research-env/DARWINStrategyContentSeries/Data') #R_STUDY = ResearchStudy(assetsList, formOrRead='form_darwin', saveTheData=True) R_STUDY = ResearchStudy(assetsList, formOrRead='read_darwin', formerOrNew='former') # Print it: pprint.pprint(R_STUDY.PORTFOLIO._portfolioDict) # Apply the reseach study we want: R_STUDY._generateResampledAndFilteredSeries(resampleRule='4H') # Print it: pprint.pprint(R_STUDY.PORTFOLIO._portfolioDict) # Save the generated dataframes: R_STUDY._saveDarwinGeneratedDataFrames(dataframesSaveDirectory)