from java.io import File
from java.util import *
from org.encog.ml.data.market import MarketMLDataSet,MarketDataDescription,TickerSymbol,MarketDataType
from org.encog.ml.data.market.loader import YahooFinanceLoader
from org.encog.util.simple import EncogUtility
INPUT_WINDOW=10; PREDICT_WINDOW=1
TICKER =TickerSymbol("AAPL")
loader =YahooFinanceLoader()
market =MarketMLDataSet(loader,INPUT_WINDOW, PREDICT_WINDOW)
desc=MarketDataDescription(TICKER, MarketDataType.ADJUSTED_CLOSE, True, True)
market.addDescription(desc)
end = GregorianCalendar(); begin =end.clone()
begin.add(Calendar.DATE, -60) # Gather training data for the last 2 years, stopping 60 days short of today.
end.add(Calendar.DATE, -60) # The 60 days will be used to evaluate prediction.
begin.add(Calendar.YEAR, -2)
market.load(begin.getTime(), end.getTime())
market.generate()
print "Fetched records=",market.getRecordCount()
# print input and ideal output
for p in market.getData():
print p.getInputArray().tolist(), ' ideal=', p.getIdealArray().tolist()
print "--> save data in a current directory"
EncogUtility.saveEGB(File("./","YahooFinance.egb"), market)
Ads help maintain this website.