コード例 #1
0
def printSampleDataFrame(ticker):
    start_date="2009-01-01"
    end_date="2009-01-03"

    options={'qtype':'adjclose',
             'tables':['intStocks','itradingDays']}

    tickerDataRaw=getRawData(ticker,start_date,end_date,options)
    print(tickerDataRaw.head())
    #print("\n Size => " + tickerDataRaw.size)

    for idx, row in tickerDataRaw.iteritems():
        print(idx)
コード例 #2
0
def printFeatureData(ticker):
    options = {'qtype':'adjclose',
               'tables':["intStocks","itradingDays"],
               'freq':0, # The frequency of trading, daily=0, monthly=1,weekly=2
               'offset':1, # The offset if the period > 1day, ie which trading day in the month/week the strategy will be executed
               'pure':0, # from here we have the features , the returns as is
               'cal':1, # Calendar features
               'history':0, # last 3 periods returns
               'momentum':1, # momentum features
               'jump':0, # jump features
               'value':0, # long term reversal features
               'prevWeeks':1,# Now by turning this to 1 we can run a model which includes previous weeks
               'algo':KNeighborsRegressor,
               'algo_params':{'n_neighbors':5}
               }

    supportTickers= None
    # [("BANKNIFTY",{'pure':0,'momentum':1,'jump':0,'prevWeeks':0})]

    trainStart="2006-06-01"
    #testPeriod=["2013-06-01","2016-04-01"]
    testPeriod=["2017-05-01", "2017-05-22",]
    start_date = "2017-05-01"
    end_date = "2017-05-22"

    algo = options['algo']
    algo_params = options['algo_params']

    buffer = 0
    tickerDataRaw = getRawData(ticker, start_date, end_date, options, buffer)
    tickerDataRaw["Return"] = getReturn(tickerDataRaw["Price"])
    print()
    printTickerDataFrame(tickerDataRaw)

    testData = getFeatures(ticker, testPeriod[0], testPeriod[1], options, supportTickers)[0]
    print(testData.head())

    pure = tickerDataRaw["Price"][1:]
    pureIndex = tickerDataRaw.index[0:-1]
    pure.index = pureIndex
    print("pure => " + str(pure.tolist()))
    print("pureIndex => " + str(pureIndex.tolist()))
    print(pure.head(2))
    print(pure.tail(2))
    print("testData count => " + str(len(testData.index)))
    print("Done")
    return testData
コード例 #3
0
import plotly.plotly as py
import plotly.graph_objs as go

import pandas_datareader.data as web
from datetime import datetime
from fetchData import getRawData

#df = web.DataReader("^vix", 'yahoo', datetime(2007, 10, 1), datetime(2009, 4, 1))

ticker, start_date, end_date = "VIX", datetime(2007, 10,
                                               1), datetime(2009, 4, 1)
df = getRawData(ticker, start_date, end_date)
print(df.head())

trace = go.Candlestick(x=df.index,
                       open=df.Open,
                       high=df.High,
                       low=df.Low,
                       close=df.AdjClose)
data = [trace]
py.iplot(data, filename='simple_candlestick')
コード例 #4
0
ticker = "NIFTY"

start_date = "2009-01-01"
end_date = "2010-01-01"

options = {'qtype': 'close', 'tables': ['cm_adjPrice', 'tradingDays']}
from fetchData import getRawData

tickerDataRaw = getRawData(ticker, start_date, end_date, options)

print tickerDataRaw.head()
コード例 #5
0
ファイル: testFunctions.py プロジェクト: himalayas8848/dwang
ticker = "AAPL"
start_date="2015-01-01"
END_date="2017-02-17"

options={
'qtype':'close',
'tables':['adjPrice','tradingdate']
}

from fetchData import getRawData

ticketDataRaw=getRawData(ticker,start_date,end_date,options)

print(ticketDataRaw.head())