如何买卖股票以获得最大收益算法 java算法

获取股票实时交易数据的方法 - New - JavaEye论坛
获取股票实时交易数据的方法 - New - JavaEye论坛
炒股有一段时间了,发现现在的股票行情软件在很多情况下并不是太好用,我炒股的时候喜欢看盘口的实时交易记录,如果同时关注多支股票的话,我用过的行情软件没有找到同时观看多支股票盘口交易数据的功能,另外在工作的时候使用目前的行情软件也不太方便。所以打算自己写个专门的行情软件,但是数据源是个最棘手的问题,经过搜索和不懈的努力,找到了两种方式:
通过webservice调用,该网站提供了免费的和收费的服务,但是免费的限制了每天的请求次数,在此不太实用。
调用sina专门的js服务器来解析数据,这种方式我使用了有很长一段时间,速度还是相当不错的,有时候比专门的行情软件的实时数据还快,下面是获取数据的部分代码:
String&url&=&"/list=sh600151,sz000830,s_sh000001,s_sz399001,s_sz399106"; &&
&&try&{ &&
&&&&&&URL&u&=&new&URL(url); &&
&&&&&&byte[]&b&=&new&byte[<span style="COLOR: #c0]; &&
&&&&&&InputStream&in&=&null; &&
&&&&&&ByteArrayOutputStream&bo&=&new&ByteArrayOutputStream(); &&
&&&&&&while&(true)&{ &&
&&&&&&&&&&try&{ &&
&&&&&&&&&&&&&&in&=&u.openStream(); &&
&&&&&&&&&&&&&&int&i; &&
&&&&&&&&&&&&&&while&((i&=&in.read(b))&!=&-1)&{ &&
&&&&&&&&&&&&&&&&&&bo.write(b,&0,&i); &&
&&&&&&&&&&&&&&} &&
&&&&&&&&&&&&&&String&result&=&bo.toString(); &&
&&&&&&&&&&&&&&String[]&stocks&=&result.split(";"); &&
&&&&&&&&&&&&&&for&(String&stock&:&stocks)&{ &&
&&&&&&&&&&&&&&&&&&String[]&datas&=&stock.split(","); &&
&&&&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&} &&
&&&&&&&&&&&&&&bo.reset(); &&
&&&&&&&&&&}&catch&(Exception&e)&{ &&
&&&&&&&&&&&&&&System.out.println(e.getMessage()); &&
&&&&&&&&&&}&finally&{ &&
&&&&&&&&&&&&&&if&(in&!=&null)&{ &&
&&&&&&&&&&&&&&&&&&in.close(); &&
&&&&&&&&&&&&&&} &&
&&&&&&&&&&} &&
&&&&&&} &&
&&}&catch&(Exception&ex)&{ &&
&&&&&&System.out.println(ex.getMessage()); &&
list后面的参数为相关的股票代码,可以同时附加多个股票代码,其中上证前面加"sh",深证前面加"sz",如果只需获取股票交易的基本数据则在之前加"s_",如下面的s_sh000001,s_sz399001,s_sz399106分别为:上证指数,深证成指 ,深证综指的基本指标数据获取到的数据格式如下:var hq_str_sh600151="航天机电,14.49,14.57,14.37,14.86,14.10,14.37,14.38,0,14.37,,,,,,,,,,,15:05:32";var hq_str_sz000830="鲁西化工,8.82,8.91,8.53,8.88,8.38,8.52,8.53,,.52,,.50,,,.53,,,,,,15:20:51";var hq_str_sh000001="上证指数,0.986,1.295,,0,,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,,15:05:32";var hq_str_s_sz399001="深证成指,,-135.272,-0.86,757";var hq_str_s_sz399106="深证综指,.264,-1.32,,4557752";&
获取数据后,自己根据行情软件来对应数据,然后使用swing做个界面,呵呵,这样就大功告成了,个人使用了2个多月了,一般情况下非常好用的。
发表评论:
TA的最新馆藏&&国之画&&&& &&&&&&
&& &&&&&&&&&&&&&&&&&&&&
鲁ICP备号-4
打开技术之扣,分享程序人生!algo-trader 用java编写的算法交易软件。包括获取股票数据、分析、下单等全部功能。 Finance-Stock software system 金融证券系统 256万源代码下载-
&文件名称: algo-trader& & [
& & & & &&]
&&所属分类:
&&开发工具: Java
&&文件大小: 3197 KB
&&上传时间:
&&下载次数: 128
&&提 供 者:
&详细说明:用java编写的算法交易软件。包括获取股票数据、分析、下单等全部功能。-AlgoTrader is an automated trading system (ATS) that can trade any type of security on any market available through InteractiveBrokers or FIX. All aspects of trading like getting market data, analyzing prices, taking trade decisions, placing orders & tracking executions can be automated.
Employing automated trading strategies, AlgoTrader eliminates all influences from emotion driven human trading and allows a pure systematic trading approach.
Available features of the system&para &#8226 Automate Trading Strategies based on Trading Rules (using Esper EQL)
&#8226 Automated Execution via different Broker Interfaces
&#8226 Simulate and run several strategies in parallel
&#8226 Backtest strategies based on Historical Data
&#8226 Portfolio Tracking & Performance Measurement
&#8226 Different Numerical and Statistical Libraries are available to analyze trend and produce Trading Signals
AlgoTrader is based on the following Frameworks and Methodologies&para &#8226 Java SE 6
文件列表(点击判断是否您需要的文件,如果是垃圾请在下面评价投诉):
&&说明.txt
&[]:纯粹是垃圾&[]:很好,推荐下载&[]:纯粹是垃圾&[]:纯粹是垃圾&[]:纯粹是垃圾&[]:纯粹是垃圾&[]:纯粹是垃圾
&近期下载过的用户:
&&&&&&&&&&&&&&&&&&&&&[]
&相关搜索:
&输入关键字,在本站256万海量源码库中尽情搜索:
&[] - 我自己写的。使用eclipse环境,使用java语言编写的股票交易成本计算器。主要对上证A股,深证A股,封基,权证计算交易成本。
&[] - algorithm trading platform
&[] - captcha trader source code.
library of integrated trading research tools. algo Quant is a lot more than just an application of backtesting. It is an actively developed and ever
&[] - 这是一款基于VC++6.0平台开发出来的股票交易系统,适合广大C++初学者借鉴。
&[] - algorithmic trading strategy backtesting for MATLAB
&[] - 一个画股票曲线的flash+java socket的例子。
&[] - 股票图表,走势图。一般自己再改下就很好用了股票最大收益 Best Time to Buy and Sell Stock II
股票最大收益 Best Time to Buy and Sell Stock II
发布时间: 9:57:51
编辑:www.fx114.net
本篇文章主要介绍了"股票最大收益 Best Time to Buy and Sell Stock II",主要涉及到股票最大收益 Best Time to Buy and Sell Stock II方面的内容,对于股票最大收益 Best Time to Buy and Sell Stock II感兴趣的同学可以参考一下。
题目源自于leetcode。
题目:Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete as many transactions
as you like (ie, buy one and sell one share of the stock multiple times). However, you may not engage in multiple transactions at the same time (ie, you must sell the stock before you buy again).
思路:假设这把这些点连起来看出折现,观察发现,获得最大收益的方法是每次都在极小&#20540;买入,在极大&#20540;卖出。
第一个点:如果一开始就在增长,则第一个点是极小&#20540;。
最后一点:如果最后是在增长,则最后一个点是极大&#20540;。
实际的代码中已经把两端的特殊情况包含在内了。
class Solution {
int maxProfit(vector&int& &prices) {
int num = prices.size();
if(num &= 1)
int sum =0;
while(i & num)
while((i+1&num) && (prices[i] & prices[i+1]))
min = prices[i];
while((i+1&num) && (prices[i] & prices[i+1]))
max = prices[i];
sum += max -
};注意:代码写完后要认真检查,返回&#20540;不能丢,变量初始化不能丢,输入合法性检查不能忘记。
本文标题:
本页链接:10个最常见的Java算法_百度文库
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
10个最常见的Java算法
上传于||文档简介
&&1&#03;个&#8203;最&#8203;常&#8203;见&#8203;的&#8203;J&#8203;a&#8203;v&#8203;a&#8203;算&#8203;法
阅读已结束,如果下载本文需要使用1下载券
想免费下载本文?
定制HR最喜欢的简历
下载文档到电脑,查找使用更方便
还剩14页未读,继续阅读
定制HR最喜欢的简历
你可能喜欢

我要回帖

更多关于 收益率算法 的文章

 

随机推荐