Exemple #1
0
"""'
.. module:: downloadStocks

An example of retrieving empirical equities data using cleaner

.. moduleauthor:: Christopher Phillippi <*****@*****.**>
"""

import afp.keywords as keywords
import afp.settings as settings
import cleaner.store as store
import datetime
import os

if __name__ == "__main__":
    tickerList = keywords.getTickerList(os.path.join(settings.KEYWORDS_DIR, "splist.csv"))
    fromDate = datetime.date(2011, 1, 3)
    toDate = datetime.date(2013, 11, 27)
    store.adjustedClose(tickerList, fromDate, toDate, filename="spDaily.csv")
Exemple #2
0
import afp.keywords as keywords
import afp.count as count
import afp.matrices as matrices
import afp.sentiment as sentiment
import afp.settings as settings
import afp.strategies as strats
import cleaner.retrieve as retrieve
import numpy as np
import pandas as pd
import datetime
import os

if __name__ == '__main__':
    begin = datetime.date( 2011, 1, 3 )
    end = datetime.date( 2013, 11, 27 )
    tickerList = keywords.getTickerList()
    keywordsMap = keywords.getKeywordToIndexMap()
    sentCounter = count.SentimentWordCounter( keywordsMap, sentiment.classifier() )
    mentionCounter = count.WordCounter( keywordsMap )
    empiricalDf = matrices.getEmpiricalDataFrame( tickerList, begin, end )
    constrained = False
    minVarBenchmark = { True : 'minvarConstrained.csv', False : 'minvarAnalytical.csv' }
    maxDivBenchmark = { True : 'maxDivConstrained.csv', False : 'maxDivAnalytical.csv' }
    minvarBenchmarkDf = matrices.getEmpiricalDataFrame( [ strats.MinimumVariance().getName() ], begin, end, retrieve.adjustedClosesFilepath( filename = minVarBenchmark[ constrained ] ) )  
    maxDivBenchmarkDf = matrices.getEmpiricalDataFrame( [ strats.MaximumDiversification().getName() ], begin, end, retrieve.adjustedClosesFilepath( filename = maxDivBenchmark[ constrained ] ) )
    riskParityDf = matrices.getEmpiricalDataFrame( [ strats.RiskParity().getName() ], begin, end, retrieve.adjustedClosesFilepath( filename = 'riskParity.csv' ) )   
    benchmarkDf = matrices.getEmpiricalDataFrame( [ 'OEF', 'SPY' ], begin, end, retrieve.benchmarkFilepath() )
    summedSentDf = matrices.getCountDataFrame( tickerList, sentCounter, empiricalDf.index, aggregator = np.sum )
    articleSentDf = matrices.getCountDataFrame( tickerList, sentCounter, empiricalDf.index )
    summedMentionDf = matrices.getCountDataFrame( tickerList, mentionCounter, empiricalDf.index, aggregator = np.sum )
    articleMentionDf = matrices.getCountDataFrame( tickerList, mentionCounter, empiricalDf.index )