peg

量化投资学习(一)

淺唱寂寞╮ 提交于 2019-12-10 01:43:13
一、双均线策略 通过建立m天移动平均线,n天移动平均线,则两条线必有交点。若m>n,n天平均线上穿越m天均线则为买入点,反之为卖出点。该策略基于不同天数均线的交叉点,抓住股票的强势和弱势时刻,进行交易。 金叉和死叉 由时间短的均线(如上图蓝色的线)在下方向上穿越时间长一点的均线(如上图黄色的线),为“金叉”,反之为“死叉”。 双均线金叉的时候,表明股票很强势,反之很弱势,强势时买入,弱势时卖出。 二、PEG估值法 计算每只股票的PEG值,并排序,取PEG值最小的前n支股票,作为待买股票即可。 1. EPS(Earnings Per Share)表示每股收益(一般按年计算): EPS = 归属于普通股股东的当期净利润 / 当期实际发行在外的普通股加权平均数 2. PE (Price to Earning Ratio)表示市盈率,是当前股价(P)相对每股收益(EPS)的比值: PE = P / EPS EPS按照不同的计算方法取出,可以得出使用范围不同的PE(市盈率): 若每股收益(EPS)取最近四次的季报的每股收益的平均值,计算出“滚动市盈率”(又称市盈率TIM); 若每股收益(EPS)取去年的12个月的每股收益,则计算出“静态市盈率”(又称市盈率LYR); 若每股收益(EPS)取预测下一年的每股收益,则计算出“动态市盈率”。 3. G(Growth Rate of Expected

How to transform a simple grammar into something which works in PEG.js (expected “a” but “a” found)

我怕爱的太早我们不能终老 提交于 2019-12-08 08:59:14
问题 I've just started playing with PEG.js and have a problem with a grammar (vastly simplified for debugging): start = presingle single / preplural plural presingle = "a" / "b" preplural = "b" / "c" single = "d" / "e" plural = "dd" / "ee" I'm using https://pegjs.org/online This grammar fails to parse bdd . Line 1, column 3: Expected "a" but "d" found. Is this something which PEGs cannot do, or can I transform my grammar into something which will parse this? P.S. If I try to parse the (erroneously

parsimonious parser - error trying to parse assignment grammar

混江龙づ霸主 提交于 2019-12-07 04:54:53
问题 I'm using the Python Parsimonious Parser to try to build an interpreter for a simple language I'm designing. I watched this tutorial video which was very helpful, and now I'm slowly modifying the code to match my own rules. I'm stuck on an assignment rule originally defined as: def assignment(self, node, children): 'assignment = lvalue "=" expr' lvalue, _, expr = children self.env[lvalue] = expr return expr I modified the rule slightly with the following grammar: def assignment(self, node,

Ignore whitespace with PEG.js

北城余情 提交于 2019-12-04 15:55:43
问题 I want to ignore whitespaces and new lines with my grammar so they are missing in the PEG.js output. Also, a literal within brackets should be returned in a new array. Grammar start = 'a'? sep+ ('cat'/'dog') sep* '(' sep* stmt_list sep* ')' stmt_list = exp: [a-zA-Z]+ { return new Array(exp.join('')) } sep = [' '\t\r\n] Test case a dog( Harry ) Output [ "a", [ " " ], "dog", [], "(", [ " " ], [ "Harry" ], [ " " ], ")" ] Output I want [ "a", "dog", [ "Harry" ] ] 回答1: You have to break up the

Problems with an ambiguous grammar and PEG.js (no examples found)

六眼飞鱼酱① 提交于 2019-12-04 03:28:08
问题 I want to parse a file with lines of the following content: simple word abbr -8. (012) word, simple phrase, one another phrase - (simply dummy text of the printing; Lorem Ipsum : "Lorem" - has been the industry's standard dummy text, ever since the 1500s!; "It is a long established!"; "Sometimes by accident, sometimes on purpose (injected humour and the like)"; "sometimes on purpose") This is the end of the line so now explaining the parts (not all spaces are described, because of the markup

Performance of parsers: PEG vs LALR(1) or LL(k)

心不动则不痛 提交于 2019-12-03 16:40:49
问题 I've seen some claims that optimized PEG parsers in general cannot be faster than optimized LALR(1) or LL(k) parsers. (Of course, performance of parsing would depend on a particular grammar.) I'd like to know if there are any specific limitations of PEG parsers, either valid in general or for some subsets of PEG grammars that would make them inferior to LALR(1) or LL(k) performance-wise. In particular, I'm interested in parser generators, but assume that their output can be tweaked for

Parse indentation level with PEG.js

雨燕双飞 提交于 2019-12-03 05:16:10
问题 I have essentially the same question as PEG for Python style indentation, but I'd like to get a little more direction regarding this answer. The answer successfully generates an array of strings that are each line of input with 'INDENT' and 'DEDENT' between lines. It seems like he's pretty much used PEG.js to tokenize, but no real parsing is happening. So how can I extend his example to do some actual parsing? As an example, how can I change this grammar: start = obj obj = id:id children:

What are the differences between PEGs and CFGs?

梦想与她 提交于 2019-12-03 02:16:32
问题 From this wikipedia page: The fundamental difference between context-free grammars and parsing expression grammars is that the PEG's choice operator is ordered. If the first alternative succeeds, the second alternative is ignored. Thus ordered choice is not commutative, unlike unordered choice as in context-free grammars and regular expressions. Ordered choice is analogous to soft cut operators available in some logic programming languages. Why does PEG's choice operator short circuits the

What are the differences between PEGs and CFGs?

馋奶兔 提交于 2019-12-02 15:48:31
From this wikipedia page: The fundamental difference between context-free grammars and parsing expression grammars is that the PEG's choice operator is ordered. If the first alternative succeeds, the second alternative is ignored. Thus ordered choice is not commutative, unlike unordered choice as in context-free grammars and regular expressions. Ordered choice is analogous to soft cut operators available in some logic programming languages. Why does PEG's choice operator short circuits the matching? Is it because to minimize memory usage (due to memoization)? I'm not sure what the choice

Problems with an ambiguous grammar and PEG.js (no examples found)

回眸只為那壹抹淺笑 提交于 2019-12-01 17:47:45
I want to parse a file with lines of the following content: simple word abbr -8. (012) word, simple phrase, one another phrase - (simply dummy text of the printing; Lorem Ipsum : "Lorem" - has been the industry's standard dummy text, ever since the 1500s!; "It is a long established!"; "Sometimes by accident, sometimes on purpose (injected humour and the like)"; "sometimes on purpose") This is the end of the line so now explaining the parts (not all spaces are described, because of the markup here): simple word is one or several words (phrase) separated by the whitespace abbr - is a fixed part