本文整理了Java中org.openimaj.twitter.finance.YahooFinanceData
类的一些代码示例,展示了YahooFinanceData
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YahooFinanceData
类的具体详情如下:
包路径:org.openimaj.twitter.finance.YahooFinanceData
类名称:YahooFinanceData
[英]A class which doesn't belong here, but I need it so here it lives!
[中]一个不属于这里的阶级,但我需要它,所以它就生活在这里!
代码示例来源:origin: openimaj/openimaj
public static void main(String[] args) throws IOException {
YahooFinanceData yd = new YahooFinanceData("AAPL", "10/10/2010", "11/10/2010","dd/MM/YYYY");
yd.results();
}
}
代码示例来源:origin: org.openimaj/twitter
/**
* Interpolated finance results from the beggining time till the end in perscribed delta
* @param delta
* @return a map of stock components to time series
* @throws IOException
*/
public Map<String, DoubleTimeSeries> seriesMapInerp(long delta) throws IOException {
long[] financeTimes = this.timeperiods();
long start = financeTimes[0];
long end = financeTimes[financeTimes.length-1];
long[] times = TimeSpanUtils.getTime(start, end, delta);
return seriesMapInerp(times);
}
代码示例来源:origin: openimaj/openimaj
private void prepare() throws IOException{
if(this.data == null){
String uri = buildURI(product, start, end);
this.data = doCall(uri);
this.loadedFromAPICall = true;
readData();
}
}
代码示例来源:origin: org.openimaj/sandbox
final long learnstart = parser.parseDateTime(learns).getMillis();
final long learnend = parser.parseDateTime(learne).getMillis();
YahooFinanceData data = new YahooFinanceData(stock, start, end, "YYYY-MM-dd");
data = Cache.load(data);
final DoubleTimeSeries highseries = data.seriesMap().get("High");
final DoubleTimeSeries yearFirstHalf = highseries.get(learnstart, learnend);
TimeSeriesCollection dataset = new TimeSeriesCollection();
代码示例来源:origin: openimaj/openimaj
/**
* @param name
* @return stocks time series by name
* @throws IOException
*/
public DoubleTimeSeries seriesByName(String name) throws IOException{
prepare();
if(!this.datavalues.containsKey(name))return null;
return new DoubleTimeSeries(timeperiods(),this.datavalues.get(name));
}
代码示例来源:origin: openimaj/openimaj
YahooFinanceData data = new YahooFinanceData("AAPL", begin, end);
data = Cache.load(data);
coll = new TSCollection();
data.seriesByName("High").process(new MovingAverageProcessor(30 * 24 * 60 * 60 * 1000l)), coll);
timeSeriesToChart(
"AAPL Interpolated",
data.seriesByName("High").process(
new LinearInterpolationProcessor(begin.getMillis(), end.getMillis(), gap)), coll);
timeSeriesToChart("AAPL", data.seriesByName("High"), coll);
displayTimeSeries(coll, "AAPL High", "date", "price");
代码示例来源:origin: org.openimaj.hadoop.tools/HadoopTwitterTokenTool
protected static synchronized void loadOptions(Mapper<Text, BytesWritable, NullWritable, Text>.Context context) throws IOException {
if (finance == null) {
Path financeLoc = new Path(context.getConfiguration().getStrings(CorrelateWordTimeSeries.FINANCE_DATA)[0]);
FileSystem fs = HadoopToolsUtil.getFileSystem(financeLoc);
finance = IOUtils.read(fs.open(financeLoc),YahooFinanceData.class);
financeSeries = finance.seriesMapInerp(SINGLE_DAY);
long[] times = financeSeries.get("High").getTimes();
interp = new IntervalSummationProcessor<WordDFIDF[],WordDFIDF, WordDFIDFTimeSeries>(times);
}
}
代码示例来源:origin: org.openimaj/twitter
/**
* @return obtain the underlying data
* @throws IOException
*/
public String resultsString() throws IOException{
prepare();
return this.data;
}
代码示例来源:origin: openimaj/openimaj
private void readData() throws IOException {
StringReader reader = new StringReader(this.data);
readData(reader);
}
代码示例来源:origin: openimaj/openimaj
tocorr[0] = wts.doubleTimeSeries().getData();
for (String ticker : finance.labels()) {
try{
if(!financeSeries.containsKey(ticker))continue;
代码示例来源:origin: org.openimaj/twitter
private String doCall(String uri) throws IOException {
System.out.println("We're calling the uri");
HttpClient httpClient = new HttpClient();
httpClient.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY);
HttpMethod getMethod = new GetMethod(uri);
try {
int response = httpClient.executeMethod(getMethod);
if (response != 200) {
throw new IOException("HTTP problem, httpcode: "
+ response);
}
InputStream stream = getMethod.getResponseBodyAsStream();
String responseText = responseToString(stream);
return responseText;
} catch (HttpException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
代码示例来源:origin: openimaj/openimaj
final long learnstart = parser.parseDateTime(learns).getMillis();
final long learnend = parser.parseDateTime(learne).getMillis();
YahooFinanceData data = new YahooFinanceData(stock, start, end, "YYYY-MM-dd");
data = Cache.load(data);
final DoubleTimeSeries highseries = data.seriesMap().get("High");
final DoubleTimeSeries yearFirstHalf = highseries.get(learnstart, learnend);
TimeSeriesCollection dataset = new TimeSeriesCollection();
代码示例来源:origin: org.openimaj/twitter
/**
* @param name
* @return stocks time series by name
* @throws IOException
*/
public DoubleTimeSeries seriesByName(String name) throws IOException{
prepare();
if(!this.datavalues.containsKey(name))return null;
return new DoubleTimeSeries(timeperiods(),this.datavalues.get(name));
}
代码示例来源:origin: org.openimaj/sandbox
YahooFinanceData data = new YahooFinanceData("AAPL", begin, end);
data = Cache.load(data);
coll = new TSCollection();
data.seriesByName("High").process(new MovingAverageProcessor(30 * 24 * 60 * 60 * 1000l)), coll);
timeSeriesToChart(
"AAPL Interpolated",
data.seriesByName("High").process(
new LinearInterpolationProcessor(begin.getMillis(), end.getMillis(), gap)), coll);
timeSeriesToChart("AAPL", data.seriesByName("High"), coll);
displayTimeSeries(coll, "AAPL High", "date", "price");
代码示例来源:origin: openimaj/openimaj
protected static synchronized void loadOptions(Mapper<Text, BytesWritable, NullWritable, Text>.Context context) throws IOException {
if (finance == null) {
Path financeLoc = new Path(context.getConfiguration().getStrings(CorrelateWordTimeSeries.FINANCE_DATA)[0]);
FileSystem fs = HadoopToolsUtil.getFileSystem(financeLoc);
finance = IOUtils.read(fs.open(financeLoc),YahooFinanceData.class);
financeSeries = finance.seriesMapInerp(SINGLE_DAY);
long[] times = financeSeries.get("High").getTimes();
interp = new IntervalSummationProcessor<WordDFIDF[],WordDFIDF, WordDFIDFTimeSeries>(times);
}
}
代码示例来源:origin: org.openimaj/twitter
/**
* @return obtain the underlying data
* @throws IOException
*/
public Map<String,double[]> results() throws IOException{
prepare();
return this.datavalues;
}
代码示例来源:origin: org.openimaj/twitter
private void readData() throws IOException {
StringReader reader = new StringReader(this.data);
readData(reader);
}
代码示例来源:origin: org.openimaj.hadoop.tools/HadoopTwitterTokenTool
tocorr[0] = wts.doubleTimeSeries().getData();
for (String ticker : finance.labels()) {
try{
if(!financeSeries.containsKey(ticker))continue;
代码示例来源:origin: openimaj/openimaj
private String doCall(String uri) throws IOException {
System.out.println("We're calling the uri");
HttpClient httpClient = new HttpClient();
httpClient.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY);
HttpMethod getMethod = new GetMethod(uri);
try {
int response = httpClient.executeMethod(getMethod);
if (response != 200) {
throw new IOException("HTTP problem, httpcode: "
+ response);
}
InputStream stream = getMethod.getResponseBodyAsStream();
String responseText = responseToString(stream);
return responseText;
} catch (HttpException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
代码示例来源:origin: org.openimaj/sandbox
public static void main(String[] args) throws IOException {
YahooFinanceData yd = new YahooFinanceData("AAPL", "10/10/2010", "11/10/2010","dd/MM/YYYY");
yd.results();
}
}
内容来源于网络,如有侵权,请联系作者删除!