xom

等距离股票配对量化交易策略-R语言

元气小坏坏 提交于 2020-02-27 15:54:01
为了分散交易中的风险,我们可以在量化交易中选择市场中性策略。 我们选择具有基本面相关性的股票对,价格趋势具有趋同和趋离,买多强势的股票,卖空弱势的股票,同时交易,控制股市风险。 案例是石油公司埃克森美孚(NYSE:XOM)和石油公司雪佛龙(NYSE:CVX) > 公司简介:埃克森美孚公司于1882年在美国新泽西州成立,公司的分部及附属公司在美国和世界上大多数其他国家经营或买卖产品。公司主要业务为能源,涉及勘探、生产、原油和天然气;生产石油产品;运输和销售原油、天然气和石油产品。公司是石油化工商品的制造商和销售商,包括烯烃、芳烃、聚乙烯和聚丙烯塑料和各种特色产品。此外,公司还拥有发电设施的利益。公司也是全球主要的石化产品生产商和营销商,并参与发电。 >公司简介: 雪佛龙股份有限公司于1926年在美国特拉华州注册成立。公司经营范围包括石油和化学工业的各个方面。上游业务主要包括勘探、开发及生产原油及天然气;加工、液化、运输和液化天然气再气化;主要的国际石油出口管道输送原油;运输、储存和销售天然气;一个天然气合成油项目。下游业务主要包括将原油提炼为石油产品;营销原油及其成品;通过管道、海洋船舶、电机设备和轨道车运送原油和成品油;制造和销售在工业用途、燃料和润滑油添加剂上应用的石化产品、塑料。 回测 # 载入量化和绩效分析库 library(quantmod) library

基于相关性的投资中性交易模型-R语言

不羁的心 提交于 2020-02-25 16:10:29
投资中性模型。可以让我们的投资组合的风险敞口极小。 # 滚动计算相关性 data <- cbind(ret_xom,ret_cvx) correlation <- function(x){ result <- cor(x[,1],x[,2],use = "na.or.complete") return(result) } corr <- rollapply(data,252,correlation,by.column=FALSE) plot(corr) # 滚动计算上下边界 hedge_ratio <- xom / cvx roll_me <- rollapply(hedge_ratio,14,mean,na.rm=TRUE) roll_std <- rollapply(hedge_ratio,14,sd,na.rm=TRUE) # n是关键值 n <-1 roll_ub <- roll_me + n * roll_std roll_lb <- roll_me - n * roll_std # 交易信号 signal <- NULL signal <- ifelse(hedge_ratio > roll_ub,-1, ifelse(hedge_ratio<roll_lb,1,0)) lagsignal <- lag(signal,1) signal ifelse(lagsignal

Java - Difference between for loop terminating expression

痴心易碎 提交于 2020-01-21 11:27:46
问题 I'm just curious: Is there a difference on speed and performance between this two loops implementation? Assume that size() method returns the length of the array,collection, or object that handles a group of elements (actually it's from XOM api). Implementation 1: int size = someArray.size(); for (int i = 0; i < size; i++) { // do stuff here } Implementation 2: for (int i = 0; i < someArray.size(); i++) { // do stuff here } 回答1: From a performance point of view, there is little difference.

XOM getting attribute from Node?

混江龙づ霸主 提交于 2020-01-16 19:23:00
问题 Shouldn't something like this work? Assuming a document formatted as such: <root> <element id = "a"></element> </root> Node node = doc.query("/root/element").get(0); String id = node.getDocument().getRootElement().getAttribute("id"); When I print the value of the root element, it looks as if this should work. What's failing, here? 回答1: Cast your node to an Element, and you're good to go. 回答2: node.getDocument().getRootElement() at this point you have the element which does not have an

Ignoring DTD when parsing XML

守給你的承諾、 提交于 2020-01-11 08:19:31
问题 How can I ignore the DTD declaration when parsing file with XOM xml library. My file has the following line : <?xml version="1.0"?> <!DOCTYPE BlastOutput PUBLIC "-//NCBI//NCBI BlastOutput/EN" "NCBI_BlastOutput.dtd"> //rest of stuff here And when I try to build() my document I get a filenotfound exception for the DTD file. I know I don't have this file and I don't care about it, so how can it be removed when using XOM? Here is a code snippet: public BlastXMLParser(String filePath) { Builder b

Grails XOM linkageerror - SAXParserException

倖福魔咒の 提交于 2019-12-24 16:23:41
问题 Possibly related: Grails - attempting to include HTPPBuilder - Linkage error I'm trying to include XOM in my grails project. How do I know which dependency library I need to exclude? I'm lost here. dependencies { build('xom:xom:1.1') { excludes "xml-apis" } } Error: java.lang.LinkageError: loader constraint violation: loader (instance of <bootloader>) previously initiated loading for a different type with name "org/xml/sax/SAXParseException" at java.lang.Class.getDeclaredMethods0(Native

How to stream XML data using XOM?

Deadly 提交于 2019-12-18 17:11:43
问题 Say I want to output a huge set of search results, as XML, into a PrintWriter or an OutputStream, using XOM. The resulting XML would look like this: <?xml version="1.0" encoding="UTF-8"?> <resultset> <result> [child elements and data] </result> ... ... [1000s of result elements more] </resultset> Because the resulting XML document could be big (hundreds of megabytes, perhaps), I want to output it in a streaming fashion (instead of creating the whole Document in memory and then writing that).

DTD download error while parsing XHTML document in XOM

拈花ヽ惹草 提交于 2019-12-18 04:18:09
问题 I am trying to parse an HTML document with the doctype declared to use the transitional dtd as follows: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> When I do Builder.build on the document, I get the following exception: java.io.IOException: Server returned HTTP response code: 503 for URL: http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd at sun.net.www.protocol.http.HttpURLConnection.getInputStream

Applying xpath on XML where namespaces are with children with XOM

☆樱花仙子☆ 提交于 2019-12-13 07:19:30
问题 I'm using XOM library to parse xmls. I have the following XML <ns4:parent xmlns:ns4="http://sample.xml.com/ns4"> <ns4:child1 xmlns:ns1="http://sample.xml.com/ns1" xmlns:xsi="http://sample.xml.com/xsi"> <ns1:child2>divaStatus</ns1:child2> <xsi:child>something</xsi:child> </ns4:child1> </ns4:parent> And I want to apply a xpath like ns4:parent/ns4:child1/ns1:child2 . So my code is like below Document doc = new Builder().build(inStream); //inStream is containing the xml XPathContext xc =

How to parse (non well-formed) HTML in android?

穿精又带淫゛_ 提交于 2019-12-11 13:48:42
问题 How to parse non well-formed HTML in android ? I tried to use XOM and TagSoup, but i get the following error when creating the Builder: 11-26 20:42:39.294: ERROR/dalvikvm(1298): Could not find method org.apache.xerces.impl.Version.getVersion, referenced from method nu.xom.Builder. Must i install Xerces to use XOM or can i use tagsoup without XOM ? 回答1: You might find JTidy (http://jtidy.sourceforge.net/) - a port of HTMLTidy to be sufficiently lightweight. It outputs XHTML on request 回答2: XOM