Best JavaScript code snippet using wpt
dac2.py
Source:dac2.py
1# -*-coding:utf-8 -*-2'''3 dacç@indicatorçæ¬4 æä¾æ´ç®åç使ç¨æ¹å¼åå®ç°æ¹å¼5'''67import operator89from collections import (10 deque,11 )1213from base import (14 BaseObject,15 fcustom,16 indicator,17 icache,18 t2order_if,19 )2021from dac import (22 XBASE, #10023 CBASE, #XBASE*XBASE,ç¨äºXATR24 FBASE, #1025 )262728XBASE = 100 #æ´æ°è¿ç®çæ¾å¤§åæ°29CBASE = XBASE * XBASE #XATRåæ°30FBASE = 10 #æ´æ°è¿ç®çæ¾å¤§åæ°23132##########33#ç¼åææ æ¶ï¼è¯·å¡å¿
ç¡®ä¿è¿ä¸ªå¤æä¸çæ è¯å符串åä¸é¢èµå¼çå称çä¸è´æ§ï¼å¦åä¼æ¯æ¬¡é½èµå¼å计ç®ï¼å
åç«é©¬ææ34# if not hasattr(_ts,'ss'):35# _ts.ss = []36#37##########383940###############41# åºæ¬åºåè¿ç®42#43###############4445@indicator46def OPER1(source,oper,_ts=None):47 '''48 ååæ°åºåè¿ç®49 '''50 if not _ts.initialized:51 _ts.initialized = True52 _ts.ss = []5354 for i in range(len(_ts.ss),len(source)):55 #print 'new data:',source[i]56 _ts.ss.append(oper(source[i]))5758 return _ts.ss5960'''61 ä¸åçoperator.xxx, 使OPER1ä¸ç¼åçkeyä¸åï¼ä¸ä¼å¯¼è´æ··æ·62'''63NEG = fcustom(OPER1,oper=operator.neg)64ABS = fcustom(OPER1,oper=operator.abs)65NOT = fcustom(OPER1,oper=operator.not_)6667@indicator68def OPER2(source1,source2,oper,_ts=None):69 '''70 ååæ°åºåè¿ç®71 '''72 assert len(source1) == len(source2),'len(source1) != len(source2)'73 if not _ts.initialized:74 _ts.initialized = True75 #print 'new oper2 ss'76 _ts.ss = []7778 for i in range(len(_ts.ss),len(source1)):79 #print 'new data:',source1[i],source2[i]80 _ts.ss.append(oper(source1[i],source2[i]))8182 return _ts.ss8384ADD = fcustom(OPER2,oper=operator.add)85SUB = fcustom(OPER2,oper=operator.sub)86MUL = fcustom(OPER2,oper=operator.mul)87#AND = fcustom(OPER2,oper=operator.and_) #è¿ä¸ªæ¯ä½æä½88#OR = fcustom(OPER2,oper=operator.or_) #è¿ä¸ªæ¯ä½æä½89#XOR = fcustom(OPER2,oper=operator.xor) #è¿ä¸ªæ¯ä½æä½90LT = fcustom(OPER2,oper=operator.lt) 91LE = fcustom(OPER2,oper=operator.le) 92EQ = fcustom(OPER2,oper=operator.eq) 93GT = fcustom(OPER2,oper=operator.gt) 94GE = fcustom(OPER2,oper=operator.ge) 9596@indicator97def OPER21(source1,vs,oper,_ts=None):98 '''99 ååæ°è¿ç®ï¼ç¬¬ä¸ä¸ªä¸ºåºåï¼ç¬¬äºä¸ªä¸ºæ°å¼100 '''101 if not _ts.initialized:102 _ts.initialized = True103 _ts.ss = []104105 for i in range(len(_ts.ss),len(source1)):106 #print 'new data:',source1[i]107 _ts.ss.append(oper(source1[i],vs))108109 return _ts.ss110111ADD1 = fcustom(OPER21,oper=operator.add)112SUB1 = fcustom(OPER21,oper=operator.sub)113MUL1 = fcustom(OPER21,oper=operator.mul)114#AND1 = fcustom(OPER21,oper=operator.and_) #è¿ä¸ªæ¯ä½æä½115#OR1 = fcustom(OPER21,oper=operator.or_) #è¿ä¸ªæ¯ä½æä½116#XOR1 = fcustom(OPER21,oper=operator.xor) #è¿ä¸ªæ¯ä½æä½117LT1 = fcustom(OPER21,oper=operator.lt) 118LE1 = fcustom(OPER21,oper=operator.le) 119EQ1 = fcustom(OPER21,oper=operator.eq) 120GT1 = fcustom(OPER21,oper=operator.gt) 121GE1 = fcustom(OPER21,oper=operator.ge) 122123@indicator124def AND(source1,source2,_ts=None):125 '''126 ååºååæ°ANDè¿ç®127 '''128 assert len(source1) == len(source2),'len(source1) != len(source2)'129 if not _ts.initialized:130 _ts.initialized = True131 _ts.ss = []132133 for i in range(len(_ts.ss),len(source1)):134 #print 'new data:',source1[i],source2[i]135 _ts.ss.append((source1[i] and source2[i])!=0)136137 return _ts.ss138139140@indicator141def GAND(_ts=None,*args):142 assert len(args)>0,'GAND params number less than 1'143 if not _ts.initialized:144 _ts.initialized = True145 _ts.ga = []146147 for i in range(len(_ts.ga),len(args[0])):148 rv = all([vs[i] for vs in args])149 _ts.ga.append(rv!=0)150 151 return _ts.ga152153@indicator154def GOR(_ts=None,*args):155 assert len(args)>0,'GOR params number less than 1'156 #print 'ts=%s,args=%s' % (_ts,args)157 if not _ts.initialized:158 _ts.initialized = True159 _ts.gor = []160161 for i in range(len(_ts.gor),len(args[0])):162 rv = any([vs[i] for vs in args])163 _ts.gor.append(rv!=0)164 165 return _ts.gor166167#GAND = fcustom(GOPER,oper=all) #æå¯ååæ°æ¶ï¼å°±ä¸è½åæ_tsä¹å¤çåæ°ç¨fcustomæå®é»è®¤å¼168#GOR = fcustom(GOPER,oper=any) #æå¯ååæ°æ¶ï¼å°±ä¸è½åæ_tsä¹å¤çåæ°ç¨fcustomæå®é»è®¤å¼169170171@indicator172def DIV(source1,source2,_ts=None):173 '''174 åºåé¤æ³175 '''176 assert len(source1) == len(source2),'len(source1) != len(source2)'177 if not _ts.initialized:178 _ts.initialized = True179 _ts.ss = []180181 for i in range(len(_ts.ss),len(source1)):182 #print 'new data:',source1[i],source2[i]183 r = (source1[i]+source2[i]/2)/source2[i] if source2[i] != 0 else source1[i]*1000184 _ts.ss.append(r)185186 return _ts.ss187188@indicator189def DIV1(source1,vs,_ts=None):190 '''191 åºåé¤å¸¸æ°192 '''193 assert vs!=0,'divisor vs == 0'194 if not _ts.initialized:195 _ts.initialized = True196 _ts.ss = []197198 for i in range(len(_ts.ss),len(source1)):199 #print 'new data:',source1[i]200 _ts.ss.append((source1[i]+vs/2)/vs)201202 return _ts.ss203204205############206# 常ç¨ææ 207#208############209210211@indicator212def ACCUMULATE(source,_ts=None):213 '''214 ç´¯å 215 '''216 if not _ts.initialized:217 _ts.initialized = True218 _ts.sa = []219220 ss = _ts.sa[-1] if _ts.sa else 0221 for i in range(len(_ts.sa),len(source)):222 ss += source[i]223 _ts.sa.append(ss)224 #print id(_ts),id(source),source,_ts.sa225 return _ts.sa226227NSUM = ACCUMULATE228229@indicator230def MSUM(source,mlen,_ts=None):231 '''232 移å¨æ±å233 '''234 if not _ts.initialized:235 _ts.initialized = True236 _ts.ms = []237238 ss = ACCUMULATE(source)239 for i in range(len(_ts.ms),len(source)):240 v = ss[i] - ss[i-mlen] if i>=mlen else ss[i]241 _ts.ms.append(v)242 return _ts.ms243244245@indicator246def MA(source,mlen,_ts=None):247 '''248 移å¨å¹³å. 使ç¨MSUM249 使ç¨æ¹å¼:250 rev = MA(source,13) #è¿åsourceç13æ移å¨å¹³å251 å½åºåä¸å
ç´ ä¸ªæ°<mlenæ¶ï¼ç»æåºå为å°è¯¥å
ç´ ä¸ºæ¢çææå
ç´ å¼çå¹³å252 '''253 assert mlen>0,u'mlen should > 0'254 if not _ts.initialized:255 _ts.initialized = True256 _ts.ma = []257258 ms = MSUM(source,mlen)259 for i in range(len(_ts.ma),len(source)):260 #å½ç´¯è®¡ä¸ªæ°<nlenæ¶ï¼æ±å
¶å¹³åå¼ï¼èä¸æ¯ç´¯è®¡å¼/mlen261 rlen = mlen if i>=mlen else i+1262 _ts.ma.append((ms[i]+rlen/2)/rlen) 263 return _ts.ma264265266@indicator267def MA_2(source,mlen,_ts=None):268 '''269 移å¨å¹³å. ç´æ¥è®¡270 使ç¨æ¹å¼:271 rev = MA(source,13) #è¿åsourceç13æ移å¨å¹³å272 å½åºåä¸å
ç´ ä¸ªæ°<mlenæ¶ï¼ç»æåºå为å°è¯¥å
ç´ ä¸ºæ¢çææå
ç´ å¼çå¹³å273 '''274 assert mlen>0,u'mlen should > 0'275 if not _ts.initialized:276 _ts.initialized = True277 _ts.sa = [0]*mlen #å¨å
µ278 _ts.ma = []279280 slen = len(_ts.ma)281 ss = _ts.sa[-1]282 for i in range(slen,len(source)):283 ss += source[i]284 _ts.sa.append(ss)285 #print ss,_ts.sa[i-mlen]286 #å½ç´¯è®¡ä¸ªæ°<nlenæ¶ï¼æ±å
¶å¹³åå¼ï¼èä¸æ¯ç´¯è®¡å¼/mlen287 rlen = mlen if mlen < i+1 else i+1288 _ts.ma.append((ss-_ts.sa[-rlen-1]+rlen/2)/rlen) 289 #print _ts.sa290 return _ts.ma291292@indicator293def NMA(source,_ts=None):294 '''295 æ»å¹³å296 使ç¨æ¹å¼:297 rev = MA(source) #è¿åsourceçå½æåä¹åçå¹³åå¼298 '''299 if not _ts.initialized:300 _ts.initialized = True301 _ts.sa = [0] #å¨å
µ302 _ts.nma = []303 #print 'initial NMA'304305 slen = len(_ts.nma)306 ss = _ts.sa[-1]307 for i in range(slen,len(source)):308 ss += source[i]309 _ts.sa.append(ss)310 #print ss,_ts.sa[-1]311 _ts.nma.append((ss+(i+1)/2)/(i+1)) 312 #print _ts.sa313 return _ts.nma314315316@indicator317def CEXPMA(source,mlen,_ts=None):318 assert mlen>0,u'mlen should > 0'319 if len(source) == 0:#ä¸è®¡ç®ç©ºåºåï¼ç´æ¥è¿å320 return []321322 if not _ts.initialized:323 _ts.initialized = True324 #print 'new cexpma ema'325 _ts.ema = [source[0]] #å¨å
µå
ç´ æ¯source[0]ï¼ç¡®ä¿è®¡ç®å¾å°çå¼å¨<mlenå
ç´ çæ
åµä¸ä¹æ£ç¡®326327 cur = _ts.ema[-1]328 for i in range(len(_ts.ema),len(source)):329 cur = (source[i]*2 + cur*(mlen-1) + (mlen+1)/2)/(mlen+1)330 _ts.ema.append(cur)331 return _ts.ema332333EMA = CEXPMA334335@indicator336def MACD(source,ifast=12,islow=26,idiff=9,_ts=None):337 if not _ts.initialized:338 _ts.initialized = True339 _ts.diff = []340 _ts.dea = []341342 src = MUL1(source,FBASE)343 sfast = EMA(src,ifast)344 sslow = EMA(src,islow)345 _ts.diff = SUB(sfast,sslow)346 _ts.dea = EMA(_ts.diff,idiff)347 return _ts348349@indicator350def TR(sclose,shigh,slow,_ts=None):351 if len(sclose) == 0:352 return []353354 if not _ts.initialized:355 _ts.initialized = True356 _ts.tr = [(shigh[0]-slow[0]) * XBASE]357358 for i in range(len(_ts.tr),len(sclose)):359 #c,h,l = sclose[slen-1],shigh[slen],sclose[slen]360 hh = shigh[i] if shigh[i] > sclose[i-1] else sclose[i-1]361 ll = slow[i] if slow[i] < sclose[i-1] else sclose[i-1]362 _ts.tr.append((hh-ll)*XBASE)363 return _ts.tr364365@indicator366def ATR(sclose,shigh,slow,length=20,_ts=None):367 ltr = TR(sclose,shigh,slow)368 return CEXPMA(ltr,length)369370371@indicator372def XATR(sclose,shigh,slow,length=20,_ts=None):373 latr = ATR(sclose,shigh,slow,length)374 return DIV(MUL1(latr,CBASE),sclose)375376377@indicator378def STREND(source,_ts=None):379 ''' ç®å累积è¶å¿2380 ä¸strendç¸æ¯ï¼ä¸åè¿ç¨ä¸ï¼å¹³ä¹å½ä½ä¸,ä¸éä¸å¹³ä½ä¸381 è¥å½åè¶å¿ä¸ºä¸åæ0ï¼trendå¼ä¸ºn>0382 åæ°trendå¼ä¸ºï¼383 n+1 å½åå¼ >= pre384 -1 å½åå¼ < pre385 è¥å½åè¶å¿ä¸ºä¸éï¼trendå¼ä¸ºn(è´æ°)386 åä¸ä¸trendå¼ä¸ºï¼387 n-1 å½åå¼ <= pre388 1 å½åå¼ > pre389 0为åå§è¶å¿(缺å°å¤ææ¶)390 '''391 if len(source) == 0:392 return []393394 if not _ts.initialized:395 _ts.initialized = True396 _ts.sd = [0] #第ä¸ä¸ªæ¯æ è¶å¿397398 slen = len(_ts.sd)399 scur = _ts.sd[-1]400 vpre = source[slen-1]401 for i in range(slen,len(source)):402 vcur = source[i]403 if vcur > vpre:404 scur = scur + 1 if scur > 0 else 1405 elif vcur < vpre:406 scur = scur - 1 if scur < 0 else -1407 else: #curv == pre_v408 scur = scur + 1 if scur >= 0 else scur-1 #æå为0æ¶ï¼ä¹ç®ä¸å409 _ts.sd.append(scur)410 vpre = vcur411 return _ts.sd412 413414#TMAX,TMIN,UCROSS,DCROSS415@indicator416def TMM(source,covered,vmm,fcmp,fgroup,_ts=None):417 ''' 418 vmm: æ¯è¾ç¨çæå¼419 fcmp: æ¯è¾å½æ°420 fgroup:æ´ä½æ¯è¾å½æ°421422 cover=0æ¶ï¼è¿åçæ¯æªæ¢å°å½åå
ç´ çæå¼(cover<0ä¹å¦æ¤)423 '''424 assert covered >=0, 'TMM: cover <0'425 if len(source) == 0:426 return []427428 if not _ts.initialized:429 _ts.initialized = True430 #print 'new tmm'431 _ts.tmm = [] #第ä¸ä¸ªæ¯æ è¶å¿432 _ts.buffer = None433434 slen = len(source)435 pre_len = slen if slen <= covered else covered436 cmm = _ts.tmm[-1] if _ts.tmm else vmm437 for i in range(len(_ts.tmm),pre_len):438 if fcmp(source[i],cmm):439 cmm = source[i]440 _ts.tmm.append(cmm)441 if slen <= covered:442 return _ts.tmm443 tlen = len(_ts.tmm)444 if _ts.buffer:445 buffer = _ts.buffer446 else:447 buffer = _ts.buffer = deque(source[tlen-covered:tlen]) 448 #print 'in tmm:tlen=%s,len(source)=%s' % (tlen,len(source))449 for i in range(tlen,len(source)):450 v = source[i]451 buffer.append(v)452 vquit=buffer.popleft()453 if fcmp(v,cmm):454 cmm = v455 if cmm == vquit and v != cmm: #éåºçæ£å¥½æ¯æ大å¼,计ç®åcovered-1个å
ç´ çæ大å¼, pre=source[i-1]456 #cmm = fgroup(source[i-covered+1:i+1])457 cmm = fgroup(buffer)458 _ts.tmm.append(cmm)459 return _ts.tmm460461TMAX = fcustom(TMM,vmm=-99999999,fcmp=operator.gt,fgroup=max)462TMIN = fcustom(TMM,vmm=99999999,fcmp=operator.lt,fgroup=min)463464@indicator465def NMM(source,vmm,fcmp,_ts=None):466 '''467 ä»index0ç®èµ·çæå¼.468 ç¸å½äºcoveredåæ大å¼æ¶çTMM469 '''470 if len(source) == 0:471 return []472473 if not _ts.initialized:474 _ts.initialized = True475 #print 'new nmm'476 _ts.nmm = [] #第ä¸ä¸ªæ¯æ è¶å¿477478 slen = len(source)479 cmm = _ts.nmm[-1] if _ts.nmm else vmm480 for i in range(len(_ts.nmm),len(source)):481 if fcmp(source[i],cmm):482 cmm = source[i]483 _ts.nmm.append(cmm)484 return _ts.nmm485NMAX = fcustom(NMM,vmm=-99999999,fcmp=operator.gt)486NMIN = fcustom(NMM,vmm=99999999,fcmp=operator.lt)487488489@indicator490def CROSS(source1,source2,rcmp,_ts=None):491 '''492 source2å»äº¤åsource1493 rcmp为å¤æ已交åç¶æçå½æ°494 è¿åå¼ä¸,0为æªÃ,1为Ã495 '''496 if len(source1) == 0:497 return []498499 if not _ts.initialized:500 _ts.initialized = True501 _ts.crs = [1 if rcmp(source2[0],source1[0]) else 0] #第ä¸ä¸ªåå³äºç¶æï¼å¦æ为已Ãï¼å为1502503 ps = _ts.crs[-1]504 for i in range(len(_ts.crs),len(source1)):505 cs = rcmp(source2[i],source1[i])506 _ts.crs.append(1 if not ps and cs else 0)507 ps = cs508 return _ts.crs509510UPCROSS = fcustom(CROSS,rcmp = operator.gt) #追å»-å¹³-å¹³-è¶
è¶ï¼ä»¥åè¶
è¶-å¹³-è¶
è¶åç®Ã511DOWNCROSS = fcustom(CROSS,rcmp = operator.lt) #追å»-å¹³-å¹³-è¶
è¶ï¼ä»¥åè¶
è¶-å¹³-è¶
è¶åç®Ã512513@indicator514def NCROSS(source,target,rcmp,_ts=None):515 '''516 sourceå»äº¤åtarget, target为æ°å517 rcmp为å¤æ已交åç¶æçå½æ°518 è¿åå¼ä¸,0为æªÃ,1为Ã519 '''520 if len(source) == 0:521 return []522523 if not _ts.initialized:524 _ts.initialized = True525 _ts.crs = [1 if rcmp(source[0],target) else 0] #第ä¸ä¸ªåå³äºç¶æï¼å¦æ为已Ãï¼å为1526527 ps = _ts.crs[-1]528 for i in range(len(_ts.crs),len(source)):529 cs = rcmp(source[i],target)530 _ts.crs.append(1 if not ps and cs else 0)531 ps = cs532 return _ts.crs533534NUPCROSS = fcustom(NCROSS,rcmp = operator.gt) #追å»-å¹³-å¹³-è¶
è¶ï¼ä»¥åè¶
è¶-å¹³-è¶
è¶åç®Ã535NDOWNCROSS = fcustom(NCROSS,rcmp = operator.lt) #追å»-å¹³-å¹³-è¶
è¶ï¼ä»¥åè¶
è¶-å¹³-è¶
è¶åç®Ã536537538@indicator539def REF(source,offset=1,_ts=None):540 '''541 åå¾å移为offsetçåºå542 åoffseté¨åç¨ç¬¬ä¸å
ç´ å¡«å
543 å¦æä»
ç¨äºæ¯è¾,ä¸å»ºè®®ç¨è¿ä¸ªå½æ°,èç´æ¥ç¨[-1]ä¸æ æ¯è¾544 åªæå¨å移CROSSæ¶æææä¹545 '''546 if len(source) == 0:547 return []548549 if not _ts.initialized:550 _ts.initialized = True551 _ts.ref = [source[0]]552 #print 'initialize REF'553 554 for i in range(len(_ts.ref),offset if offset <= len(source) else len(source)):555 _ts.ref.append(source[0])556557 for i in range(len(_ts.ref),len(source)):558 _ts.ref.append(source[i-offset])559560 return _ts.ref561562NullMinute = BaseObject(sopen=[],sclose=[],shigh=[],slow=[],svol=[],iorder=[],sholding=[])563564@indicator565def MINUTE(ticks,pre_min1=None,t2order=t2order_if,_ts=None):566 '''567 åéåå568 è¿ä¸ªå®ç°çæ大é®é¢æ¯æªå¤çæåä¸åéçæ¶å°¾569 ä½è¿ç§åºæ¯ä»
ç¨äºä¿åæ°æ®, å¯ä»¥å¨ä½¿ç¨MINUTEä¹å, ç±ç¹å«çè¯å¥å»å¤ææåä¸ä¸ªtick,并æ¶å°¾æåä¸åé570571 pre_min1为é»è®¤æ¶,åªè½ç¨å½æ¥åé572 åä¹å»¶ç»ä¹åçåé573 '''574575 if len(ticks) == 0:576 return NullMinute577578 if not _ts.initialized:579 _ts.initialized = True580 if pre_min1 == None: #ä¸æ¥ç»581 _ts.sopen = []582 _ts.sclose = []583 _ts.shigh = []584 _ts.slow = []585 _ts.svol = []586 _ts.sholding=[]587 _ts.iorder = []588 _ts.min1 = []589 else:590 _ts.sopen = pre_min1.sopen591 _ts.sclose = pre_min1.sclose592 _ts.shigh = pre_min1.shigh593 _ts.slow = pre_min1.slow594 _ts.svol = pre_min1.svol595 _ts.sholding=pre_min1.sholding596 _ts.iorder = pre_min1.iorder597 _ts.min1 = pre_min1.min1598 _ts.cur = BaseObject(vopen = ticks[0].price, 599 vclose = ticks[0].price, 600 vhigh=ticks[0].price, 601 vlow=ticks[0].price, 602 open_dvol=ticks[0].dvolume,#åå¨åå§è¯¯å·®603 close_dvol=ticks[0].dvolume,604 holding = ticks[0].holding,605 min1=ticks[0].min1, #å½æ¥ç¬¬ä¸min1606 iorder=t2order[ticks[0].min1]607 ) #è¿é对dvolçå¤ç,使å¾ä¸ææ¢å¤ä¹å¿
é¡»ä»å½æ¥æå¼å§å¼å§,å¦åææåè¿°æ交é被å½ç»å°ç¬¬ä¸tick608 _ts.ilast = 0609 _ts.modified = False #ä¸å¨æå®ææ å¿610611 scur = _ts.cur612 for i in range(_ts.ilast,len(ticks)):613 tcur = ticks[i]614 #if tcur.min1 != scur.min1: #åæ¢615 if tcur.min1 > scur.min1: #åæ¢, é¿å
ticksæ°æ®é误å¼ååéåºåç´ä¹±,å¦20120905:958:59:500æå
¥å¨20120905:959:00:00ä¹å,è½ç¶é常ç½è§,ä½ä¼å¯¼è´åéåºååºç°958->959->958->959...è¿ä¸ªæ
åµ616 _ts.sopen.append(scur.vopen)617 _ts.sclose.append(scur.vclose)618 _ts.shigh.append(scur.vhigh)619 _ts.slow.append(scur.vlow)620 _ts.svol.append(scur.close_dvol - scur.open_dvol)621 _ts.sholding.append(scur.holding)622 _ts.min1.append(scur.min1)623 _ts.iorder.append(scur.iorder)624 scur.vopen = scur.vclose = scur.vhigh = scur.vlow = tcur.price625 scur.open_dvol = scur.close_dvol626 scur.close_dvol = tcur.dvolume627 scur.dvol = tcur.dvolume628 scur.holding = tcur.holding629 scur.min1 = tcur.min1630 scur.iorder = t2order[tcur.min1]631 _ts.modified = True632 else: #æªåæ¢633 scur.vclose = tcur.price634 scur.close_dvol = tcur.dvolume635 scur.holding = tcur.holding636 #print scur.min1,'close:',scur.vclose637 if tcur.price > scur.vhigh:638 scur.vhigh = tcur.price639 elif tcur.price < scur.vlow:640 scur.vlow = tcur.price641 _ts.modified = False642643 _ts.ilast = len(ticks)644 return _ts645646647##以ä¸ä¸ºç¡®è®¤å¨æç»æçiorderå½æ°648XS3 = lambda x:x%3==0 and x>0 ##914å½å
¥ä¸ä¸å¨æ649XS5 = lambda x: x%5==0 and x>0 650XS10 = lambda x: x%10== 0 and x>0651XS15 = lambda x:x%15 == 0 and x>0652XS30 = lambda x:x%30 == 0 and x>0653XSDAY = lambda x:x == 270654655NullXMinute = BaseObject(sopen=[],sclose=[],shigh=[],slow=[],svol=[],iorder=[],sholding=[])656657@indicator658def XMINUTE(m1,sfunc,_ts=None):659 '''660 1åé以ä¸å¨æ661 sfunc为确认å¨æç»æçç¹662 '''663664 if len(m1.sclose) == 0:665 return NullXMinute666667 if not _ts.initialized:668 _ts.initialized = True669 _ts.sopen = []670 _ts.sclose = []671 _ts.shigh = []672 _ts.slow = []673 _ts.svol = []674 _ts.sholding=[]675 _ts.iorder = []676 _ts.xmin = [] #å¼çåé677 _ts.cur = BaseObject(vopen = 0,678 vclose = 0,679 vhigh=0,680 vlow=99999999,681 xmin =0, 682 svol=0,683 holding=0,684 iorder=0,685 ) 686 _ts.ilast = 0687 _ts.modified = False #ä¸å¨æå®ææ å¿688689 scur = _ts.cur690 for i in range(_ts.ilast,len(m1.sclose)):691 morder = m1.iorder[i]692 if scur.vopen == 0:693 scur.vopen = m1.sopen[i]694 scur.xmin = m1.min1[i]695 scur.vclose = m1.sclose[i]696 scur.svol += m1.svol[i]697 scur.holding = m1.sholding[i]698 if m1.shigh[i] > scur.vhigh:699 scur.vhigh = m1.shigh[i]700 if m1.slow[i] < scur.vlow:701 scur.vlow = m1.slow[i]702 _ts.modified = False703 if sfunc(morder): #åæ¢704 _ts.sopen.append(scur.vopen)705 _ts.sclose.append(scur.vclose)706 _ts.shigh.append(scur.vhigh)707 _ts.slow.append(scur.vlow)708 _ts.svol.append(scur.svol)709 _ts.sholding.append(scur.holding)710 _ts.iorder.append(scur.iorder)711 _ts.xmin.append(scur.xmin)712713 scur.vopen = 0714 scur.vclose = 0715 scur.vhigh = 0716 scur.vlow = 99999999717 scur.svol = 0718 scur.xmin = 0719 scur.holding = 0720 scur.iorder += 1721 _ts.modified = True722723 _ts.ilast = len(m1.sclose)724 return _ts725726MINUTE3 = fcustom(XMINUTE,sfunc=XS3) 727MINUTE5 = fcustom(XMINUTE,sfunc=XS5) 728MINUTE10 = fcustom(XMINUTE,sfunc=XS10) 729MINUTE15 = fcustom(XMINUTE,sfunc=XS15) 730MINUTE30 = fcustom(XMINUTE,sfunc=XS30) 731MINUTED = fcustom(XMINUTE,sfunc=XSDAY)
...
node.d.ts
Source:node.d.ts
...48export declare function isExportDeclaration(node: ts.Node): node is ts.ExportDeclaration;49export declare function isExportSpecifier(node: ts.Node): node is ts.ExportSpecifier;50export declare function isExpression(node: ts.Node): node is ts.Expression;51export declare function isExpressionStatement(node: ts.Node): node is ts.ExpressionStatement;52export declare function isExpressionWithTypeArguments(node: ts.Node): node is ts.ExpressionWithTypeArguments;53export declare function isExternalModuleReference(node: ts.Node): node is ts.ExternalModuleReference;54export declare function isForInStatement(node: ts.Node): node is ts.ForInStatement;55export declare function isForInOrOfStatement(node: ts.Node): node is ts.ForInOrOfStatement;56export declare function isForOfStatement(node: ts.Node): node is ts.ForOfStatement;57export declare function isForStatement(node: ts.Node): node is ts.ForStatement;58export declare function isFunctionDeclaration(node: ts.Node): node is ts.FunctionDeclaration;59export declare function isFunctionExpression(node: ts.Node): node is ts.FunctionExpression;60export declare function isFunctionTypeNode(node: ts.Node): node is ts.FunctionTypeNode;61export declare function isGetAccessorDeclaration(node: ts.Node): node is ts.GetAccessorDeclaration;62export declare function isIdentifier(node: ts.Node): node is ts.Identifier;63export declare function isIfStatement(node: ts.Node): node is ts.IfStatement;64export declare function isImportClause(node: ts.Node): node is ts.ImportClause;65export declare function isImportDeclaration(node: ts.Node): node is ts.ImportDeclaration;66export declare function isImportEqualsDeclaration(node: ts.Node): node is ts.ImportEqualsDeclaration;67export declare function isImportSpecifier(node: ts.Node): node is ts.ImportSpecifier;68export declare function isIndexedAccessTypeNode(node: ts.Node): node is ts.IndexedAccessTypeNode;69export declare function isIndexSignatureDeclaration(node: ts.Node): node is ts.IndexSignatureDeclaration;70export declare function isInferTypeNode(node: ts.Node): node is ts.InferTypeNode;71export declare function isInterfaceDeclaration(node: ts.Node): node is ts.InterfaceDeclaration;72export declare function isIntersectionTypeNode(node: ts.Node): node is ts.IntersectionTypeNode;73export declare function isIterationStatement(node: ts.Node): node is ts.IterationStatement;74export declare function isJsDoc(node: ts.Node): node is ts.JSDoc;75export declare function isJsxAttribute(node: ts.Node): node is ts.JsxAttribute;76export declare function isJsxAttributeLike(node: ts.Node): node is ts.JsxAttributeLike;77export declare function isJsxAttributes(node: ts.Node): node is ts.JsxAttributes;78export declare function isJsxClosingElement(node: ts.Node): node is ts.JsxClosingElement;79export declare function isJsxClosingFragment(node: ts.Node): node is ts.JsxClosingFragment;80export declare function isJsxElement(node: ts.Node): node is ts.JsxElement;81export declare function isJsxExpression(node: ts.Node): node is ts.JsxExpression;82export declare function isJsxFragment(node: ts.Node): node is ts.JsxFragment;83export declare function isJsxOpeningElement(node: ts.Node): node is ts.JsxOpeningElement;84export declare function isJsxOpeningFragment(node: ts.Node): node is ts.JsxOpeningFragment;85export declare function isJsxOpeningLikeElement(node: ts.Node): node is ts.JsxOpeningLikeElement;86export declare function isJsxSelfClosingElement(node: ts.Node): node is ts.JsxSelfClosingElement;87export declare function isJsxSpreadAttribute(node: ts.Node): node is ts.JsxSpreadAttribute;88export declare function isJsxText(node: ts.Node): node is ts.JsxText;89export declare function isLabeledStatement(node: ts.Node): node is ts.LabeledStatement;90export declare function isLiteralExpression(node: ts.Node): node is ts.LiteralExpression;91export declare function isLiteralTypeNode(node: ts.Node): node is ts.LiteralTypeNode;92export declare function isMappedTypeNode(node: ts.Node): node is ts.MappedTypeNode;93export declare function isMetaProperty(node: ts.Node): node is ts.MetaProperty;94export declare function isMethodDeclaration(node: ts.Node): node is ts.MethodDeclaration;95export declare function isMethodSignature(node: ts.Node): node is ts.MethodSignature;96export declare function isModuleBlock(node: ts.Node): node is ts.ModuleBlock;97export declare function isModuleDeclaration(node: ts.Node): node is ts.ModuleDeclaration;98export declare function isNamedExports(node: ts.Node): node is ts.NamedExports;99export declare function isNamedImports(node: ts.Node): node is ts.NamedImports;100export declare function isNamespaceDeclaration(node: ts.Node): node is ts.NamespaceDeclaration;101export declare function isNamespaceImport(node: ts.Node): node is ts.NamespaceImport;102export declare function isNamespaceExportDeclaration(node: ts.Node): node is ts.NamespaceExportDeclaration;103export declare function isNewExpression(node: ts.Node): node is ts.NewExpression;104export declare function isNonNullExpression(node: ts.Node): node is ts.NonNullExpression;105export declare function isNoSubstitutionTemplateLiteral(node: ts.Node): node is ts.NoSubstitutionTemplateLiteral;106export declare function isNullLiteral(node: ts.Node): node is ts.NullLiteral;107export declare function isNumericLiteral(node: ts.Node): node is ts.NumericLiteral;108export declare function isNumericOrStringLikeLiteral(node: ts.Node): node is ts.NumericLiteral | ts.StringLiteral | ts.NoSubstitutionTemplateLiteral;109export declare function isObjectBindingPattern(node: ts.Node): node is ts.ObjectBindingPattern;110export declare function isObjectLiteralExpression(node: ts.Node): node is ts.ObjectLiteralExpression;111export declare function isOmittedExpression(node: ts.Node): node is ts.OmittedExpression;112export declare function isParameterDeclaration(node: ts.Node): node is ts.ParameterDeclaration;113export declare function isParenthesizedExpression(node: ts.Node): node is ts.ParenthesizedExpression;...
typeguard.d.ts
Source:typeguard.d.ts
...41export declare function isExportAssignment(node: ts.Node): node is ts.ExportAssignment;42export declare function isExportDeclaration(node: ts.Node): node is ts.ExportDeclaration;43export declare function isExportSpecifier(node: ts.Node): node is ts.ExportSpecifier;44export declare function isExpressionStatement(node: ts.Node): node is ts.ExpressionStatement;45export declare function isExpressionWithTypeArguments(node: ts.Node): node is ts.ExpressionWithTypeArguments;46export declare function isExternalModuleReference(node: ts.Node): node is ts.ExternalModuleReference;47export declare function isForInStatement(node: ts.Node): node is ts.ForInStatement;48export declare function isForOfStatement(node: ts.Node): node is ts.ForOfStatement;49export declare function isForStatement(node: ts.Node): node is ts.ForStatement;50export declare function isFunctionDeclaration(node: ts.Node): node is ts.FunctionDeclaration;51export declare function isFunctionExpression(node: ts.Node): node is ts.FunctionExpression;52export declare function isFunctionTypeNode(node: ts.Node): node is ts.FunctionTypeNode;53export declare function isGetAccessorDeclaration(node: ts.Node): node is ts.GetAccessorDeclaration;54export declare function isIdentifier(node: ts.Node): node is ts.Identifier;55export declare function isIfStatement(node: ts.Node): node is ts.IfStatement;56export declare function isImportClause(node: ts.Node): node is ts.ImportClause;57export declare function isImportDeclaration(node: ts.Node): node is ts.ImportDeclaration;58export declare function isImportEqualsDeclaration(node: ts.Node): node is ts.ImportEqualsDeclaration;59export declare function isImportSpecifier(node: ts.Node): node is ts.ImportSpecifier;60export declare function isIndexedAccessTypeNode(node: ts.Node): node is ts.IndexedAccessTypeNode;61export declare function isIndexSignatureDeclaration(node: ts.Node): node is ts.IndexSignatureDeclaration;62export declare function isInterfaceDeclaration(node: ts.Node): node is ts.InterfaceDeclaration;63export declare function isIntersectionTypeNode(node: ts.Node): node is ts.IntersectionTypeNode;64export declare function isIterationStatement(node: ts.Node): node is ts.IterationStatement;65export declare function isJsxAttribute(node: ts.Node): node is ts.JsxAttribute;66export declare function isJsxAttributeLike(node: ts.Node): node is ts.JsxAttributeLike;67export declare function isJsxAttributes(node: ts.Node): node is ts.JsxAttributes;68export declare function isJsxClosingElement(node: ts.Node): node is ts.JsxClosingElement;69export declare function isJsxElement(node: ts.Node): node is ts.JsxElement;70export declare function isJsxExpression(node: ts.Node): node is ts.JsxExpression;71export declare function isJsxOpeningElement(node: ts.Node): node is ts.JsxOpeningElement;72export declare function isJsxOpeningLikeElement(node: ts.Node): node is ts.JsxOpeningLikeElement;73export declare function isJsxSelfClosingElement(node: ts.Node): node is ts.JsxSelfClosingElement;74export declare function isJsxSpreadAttribute(node: ts.Node): node is ts.JsxSpreadAttribute;75export declare function isJsxText(node: ts.Node): node is ts.JsxText;76export declare function isLabeledStatement(node: ts.Node): node is ts.LabeledStatement;77export declare function isLiteralExpression(node: ts.Node): node is ts.LiteralExpression;78export declare function isMetaProperty(node: ts.Node): node is ts.MetaProperty;79export declare function isMethodDeclaration(node: ts.Node): node is ts.MethodDeclaration;80export declare function isMethodSignature(node: ts.Node): node is ts.MethodSignature;81export declare function isModuleBlock(node: ts.Node): node is ts.ModuleBlock;82export declare function isModuleDeclaration(node: ts.Node): node is ts.ModuleDeclaration;83export declare function isNamedExports(node: ts.Node): node is ts.NamedExports;84export declare function isNamedImports(node: ts.Node): node is ts.NamedImports;85export declare function isNamespaceDeclaration(node: ts.Node): node is ts.NamespaceDeclaration;86export declare function isNamespaceImport(node: ts.Node): node is ts.NamespaceImport;87export declare function isNamespaceExportDeclaration(node: ts.Node): node is ts.NamespaceExportDeclaration;88export declare function isNewExpression(node: ts.Node): node is ts.NewExpression;89export declare function isNonNullExpression(node: ts.Node): node is ts.NonNullExpression;90export declare function isNoSubstitutionTemplateLiteral(node: ts.Node): node is ts.NoSubstitutionTemplateLiteral;91export declare function isNumericLiteral(node: ts.Node): node is ts.NumericLiteral;92export declare function isNumericliteral(node: ts.Node): node is ts.NumericLiteral;93export declare function isObjectBindingPattern(node: ts.Node): node is ts.ObjectBindingPattern;94export declare function isObjectLiteralExpression(node: ts.Node): node is ts.ObjectLiteralExpression;95export declare function isOmittedExpression(node: ts.Node): node is ts.OmittedExpression;96export declare function isParameterDeclaration(node: ts.Node): node is ts.ParameterDeclaration;97export declare function isParenthesizedExpression(node: ts.Node): node is ts.ParenthesizedExpression;98export declare function isPostfixUnaryExpression(node: ts.Node): node is ts.PostfixUnaryExpression;...
test_structmembers.py
Source:test_structmembers.py
...22 9.99999,# T_FLOAT23 10.1010101010, # T_DOUBLE24 "hi" # T_STRING_INPLACE25 )26class ReadWriteTests(unittest.TestCase):27 def test_bool(self):28 ts.T_BOOL = True29 self.assertEqual(ts.T_BOOL, True)30 ts.T_BOOL = False31 self.assertEqual(ts.T_BOOL, False)32 self.assertRaises(TypeError, setattr, ts, 'T_BOOL', 1)33 def test_byte(self):34 ts.T_BYTE = CHAR_MAX35 self.assertEqual(ts.T_BYTE, CHAR_MAX)36 ts.T_BYTE = CHAR_MIN37 self.assertEqual(ts.T_BYTE, CHAR_MIN)38 ts.T_UBYTE = UCHAR_MAX39 self.assertEqual(ts.T_UBYTE, UCHAR_MAX)40 def test_short(self):41 ts.T_SHORT = SHRT_MAX42 self.assertEqual(ts.T_SHORT, SHRT_MAX)43 ts.T_SHORT = SHRT_MIN44 self.assertEqual(ts.T_SHORT, SHRT_MIN)45 ts.T_USHORT = USHRT_MAX46 self.assertEqual(ts.T_USHORT, USHRT_MAX)47 def test_int(self):48 ts.T_INT = INT_MAX49 self.assertEqual(ts.T_INT, INT_MAX)50 ts.T_INT = INT_MIN51 self.assertEqual(ts.T_INT, INT_MIN)52 ts.T_UINT = UINT_MAX53 self.assertEqual(ts.T_UINT, UINT_MAX)54 def test_long(self):55 ts.T_LONG = LONG_MAX56 self.assertEqual(ts.T_LONG, LONG_MAX)57 ts.T_LONG = LONG_MIN58 self.assertEqual(ts.T_LONG, LONG_MIN)59 ts.T_ULONG = ULONG_MAX60 self.assertEqual(ts.T_ULONG, ULONG_MAX)61 def test_py_ssize_t(self):62 ts.T_PYSSIZET = PY_SSIZE_T_MAX63 self.assertEqual(ts.T_PYSSIZET, PY_SSIZE_T_MAX)64 ts.T_PYSSIZET = PY_SSIZE_T_MIN65 self.assertEqual(ts.T_PYSSIZET, PY_SSIZE_T_MIN)66 @unittest.skipUnless(hasattr(ts, "T_LONGLONG"), "long long not present")67 def test_longlong(self):68 ts.T_LONGLONG = LLONG_MAX69 self.assertEqual(ts.T_LONGLONG, LLONG_MAX)70 ts.T_LONGLONG = LLONG_MIN71 self.assertEqual(ts.T_LONGLONG, LLONG_MIN)72 ts.T_ULONGLONG = ULLONG_MAX73 self.assertEqual(ts.T_ULONGLONG, ULLONG_MAX)74 ## make sure these will accept a plain int as well as a long75 ts.T_LONGLONG = 376 self.assertEqual(ts.T_LONGLONG, 3)77 ts.T_ULONGLONG = 478 self.assertEqual(ts.T_ULONGLONG, 4)79 def test_bad_assignments(self):80 integer_attributes = [81 'T_BOOL',82 'T_BYTE', 'T_UBYTE',83 'T_SHORT', 'T_USHORT',84 'T_INT', 'T_UINT',85 'T_LONG', 'T_ULONG',86 'T_PYSSIZET'87 ]88 if hasattr(ts, 'T_LONGLONG'):89 integer_attributes.extend(['T_LONGLONG', 'T_ULONGLONG'])90 # issue8014: this produced 'bad argument to internal function'91 # internal error92 for nonint in None, 3.2j, "full of eels", {}, []:93 for attr in integer_attributes:...
ts-nodes.d.ts
Source:ts-nodes.d.ts
1import * as ts from 'typescript';2export declare type TSToken = ts.Token<ts.SyntaxKind>;3export declare type TSNode = ts.Node & (ts.Modifier | ts.Identifier | ts.QualifiedName | ts.ComputedPropertyName | ts.Decorator | ts.TypeParameterDeclaration | ts.CallSignatureDeclaration | ts.ConstructSignatureDeclaration | ts.VariableDeclaration | ts.VariableDeclarationList | ts.ParameterDeclaration | ts.BindingElement | ts.PropertySignature | ts.PropertyDeclaration | ts.PropertyAssignment | ts.ShorthandPropertyAssignment | ts.SpreadAssignment | ts.ObjectBindingPattern | ts.ArrayBindingPattern | ts.FunctionDeclaration | ts.MethodSignature | ts.MethodDeclaration | ts.ConstructorDeclaration | ts.SemicolonClassElement | ts.GetAccessorDeclaration | ts.SetAccessorDeclaration | ts.IndexSignatureDeclaration | ts.KeywordTypeNode | ts.ImportTypeNode | ts.ThisTypeNode | ts.ConstructorTypeNode | ts.FunctionTypeNode | ts.TypeReferenceNode | ts.TypePredicateNode | ts.TypeQueryNode | ts.TypeLiteralNode | ts.ArrayTypeNode | ts.TupleTypeNode | ts.OptionalTypeNode | ts.RestTypeNode | ts.UnionTypeNode | ts.IntersectionTypeNode | ts.ConditionalTypeNode | ts.InferTypeNode | ts.ParenthesizedTypeNode | ts.TypeOperatorNode | ts.IndexedAccessTypeNode | ts.MappedTypeNode | ts.LiteralTypeNode | ts.StringLiteral | ts.OmittedExpression | ts.PartiallyEmittedExpression | ts.PrefixUnaryExpression | ts.PostfixUnaryExpression | ts.NullLiteral | ts.BooleanLiteral | ts.ThisExpression | ts.SuperExpression | ts.ImportExpression | ts.DeleteExpression | ts.TypeOfExpression | ts.VoidExpression | ts.AwaitExpression | ts.YieldExpression | ts.SyntheticExpression | ts.BinaryExpression | ts.ConditionalExpression | ts.FunctionExpression | ts.ArrowFunction | ts.RegularExpressionLiteral | ts.NoSubstitutionTemplateLiteral | ts.NumericLiteral | ts.BigIntLiteral | ts.TemplateHead | ts.TemplateMiddle | ts.TemplateTail | ts.TemplateExpression | ts.TemplateSpan | ts.ParenthesizedExpression | ts.ArrayLiteralExpression | ts.SpreadElement | ts.ObjectLiteralExpression | ts.PropertyAccessExpression | ts.ElementAccessExpression | ts.CallExpression | ts.ExpressionWithTypeArguments | ts.NewExpression | ts.TaggedTemplateExpression | ts.AsExpression | ts.TypeAssertion | ts.NonNullExpression | ts.MetaProperty | ts.JsxElement | ts.JsxOpeningElement | ts.JsxSelfClosingElement | ts.JsxFragment | ts.JsxOpeningFragment | ts.JsxClosingFragment | ts.JsxAttribute | ts.JsxSpreadAttribute | ts.JsxClosingElement | ts.JsxExpression | ts.JsxText | ts.NotEmittedStatement | ts.CommaListExpression | ts.EmptyStatement | ts.DebuggerStatement | ts.MissingDeclaration | ts.Block | ts.VariableStatement | ts.ExpressionStatement | ts.IfStatement | ts.DoStatement | ts.WhileStatement | ts.ForStatement | ts.ForInStatement | ts.ForOfStatement | ts.BreakStatement | ts.ContinueStatement | ts.ReturnStatement | ts.WithStatement | ts.SwitchStatement | ts.CaseBlock | ts.CaseClause | ts.DefaultClause | ts.LabeledStatement | ts.ThrowStatement | ts.TryStatement | ts.CatchClause | ts.ClassDeclaration | ts.ClassExpression | ts.InterfaceDeclaration | ts.HeritageClause | ts.TypeAliasDeclaration | ts.EnumMember | ts.EnumDeclaration | ts.ModuleDeclaration | ts.ModuleBlock | ts.ImportEqualsDeclaration | ts.ExternalModuleReference | ts.ImportDeclaration | ts.ImportClause | ts.NamespaceImport | ts.NamespaceExportDeclaration | ts.ExportDeclaration | ts.NamedImports | ts.NamedExports | ts.ImportSpecifier | ts.ExportSpecifier | ts.ExportAssignment | ts.CommentRange | ts.SourceFile | ts.Bundle | ts.InputFiles | ts.UnparsedSource | ts.JsonMinusNumericLiteral | ts.JSDoc | ts.JSDocTypeExpression | ts.JSDocUnknownTag | ts.JSDocAugmentsTag | ts.JSDocClassTag | ts.JSDocEnumTag | ts.JSDocThisTag | ts.JSDocTemplateTag | ts.JSDocReturnTag | ts.JSDocTypeTag | ts.JSDocTypedefTag | ts.JSDocCallbackTag | ts.JSDocSignature | ts.JSDocPropertyTag | ts.JSDocParameterTag | ts.JSDocTypeLiteral | ts.JSDocFunctionType | ts.JSDocAllType | ts.JSDocUnknownType | ts.JSDocNullableType | ts.JSDocNonNullableType | ts.JSDocOptionalType | ts.JSDocVariadicType | ts.JSDocAuthorTag);...
create_compiletime_plot.py
Source:create_compiletime_plot.py
1import pandas as pd2import math3import numpy as np4def getQueryString(string):5 return string.split("_")[0]6data = pd.read_csv("../../results/CompileTimeBenchmark.csv", index_col=False, names=["data", "query", "language", "lazy",7 "ts_1",8 "ts_2"])9data["tp"] = (1000/data["ts_1"])*600121410js = data[data["language"] == "js"]11js["ts"] = js["ts_1"].cumsum()12js["ts_sec"] = (js["ts"] / 1000).apply(np.floor)13mean_js = js.groupby(['ts_sec', 'language']).mean()14mean_js = mean_js[["tp"]].reset_index()15mean_js["ts_sec"] = mean_js["ts_sec"]16mean_js = mean_js.set_index("ts_sec")17mean_js.to_csv('compile_time_js.csv')18data["tp"] = (1000/data["ts_1"])*600121419js = data[data["language"] == "python"]20js["ts"] = js["ts_1"].cumsum()21js["ts_sec"] = (js["ts"] / 1000).apply(np.floor)22mean_js = js.groupby(['ts_sec', 'language']).mean()23mean_js = mean_js[["tp"]].reset_index()24mean_js["ts_sec"] = mean_js["ts_sec"]25mean_js = mean_js.set_index("ts_sec")26mean_js.to_csv('compile_time_python.csv')27data["tp"] = (1000/data["ts_1"])*600121428js = data[data["language"] == "rel"]29js["ts"] = js["ts_1"].cumsum()30js["ts_sec"] = (js["ts"] / 1000).apply(np.floor)31mean_js = js.groupby(['ts_sec', 'language']).mean()32mean_js = mean_js[["tp"]].reset_index()33mean_js["ts_sec"] = mean_js["ts_sec"]34mean_js = mean_js.set_index("ts_sec")35mean_js.to_csv('compile_time_rel.csv')36data["tp"] = (1000/data["ts_1"])*600121437js = data[data["language"] == "java"]38js["ts"] = js["ts_1"].cumsum()39js["ts_sec"] = (js["ts"] / 1000).apply(np.floor)40mean_js = js.groupby(['ts_sec', 'language']).mean()41mean_js = mean_js[["tp"]].reset_index()42mean_js["ts_sec"] = mean_js["ts_sec"]43mean_js = mean_js.set_index("ts_sec")44mean_js.to_csv('compile_time_java.csv')45#java = data[data["language"] == "java"]46#java = java[["ts_2_avg"]].reset_index()47#java = java.rename(columns={"ts_2_avg": "java_ts"})48#python = data[data["language"] == "python"]49#python = python[["ts_2_avg"]].reset_index()50#python = python.rename(columns={"ts_2_avg": "python_ts"})51#typer = pd.read_csv("../hand.out", names=["query", "hand_ts"])52#result = pd.concat([js, java, python, typer], axis=1, sort=False)53#result = result[["query","python_ts", "js_ts", "java_ts", "hand_ts"]]...
Using AI Code Generation
1var wpt = require('webpagetest');2var test = new wpt('www.webpagetest.org');3var options = {4};5test.runTest(options, function(err, data) {6 if (err) {7 console.log(err);8 } else {9 console.log(data);10 }11});12var wpt = require('webpagetest');13var test = new wpt('www.webpagetest.org');14var options = {15};16test.runTest(options, function(err, data) {17 if (err) {18 console.log(err);19 } else {20 console.log(data);21 }22});
Using AI Code Generation
1var wpt = require('webpagetest');2var test = new wpt('www.webpagetest.org', 'A.1234567890abcdef1234567890abcdef');3 if (err) {4 console.error(err);5 } else {6 console.log(data);7 }8});9var wpt = require('webpagetest');10var test = new wpt('www.webpagetest.org', 'A.1234567890abcdef1234567890abcdef');11 if (err) {12 console.error(err);13 } else {14 console.log(data);15 }16});17var wpt = require('webpagetest');18var test = new wpt('www.webpagetest.org', 'A.1234567890abcdef1234567890abcdef');19 if (err) {20 console.error(err);21 } else {22 console.log(data);23 }24});25var wpt = require('webpagetest');26var test = new wpt('www.webpagetest.org', 'A.1234567890abcdef1234567890abcdef');27 if (err) {28 console.error(err);29 } else {30 console.log(data);31 }32});33var wpt = require('webpagetest');34var test = new wpt('www.webpagetest.org', 'A.1234567890abcdef1234567890abcdef');35 if (err) {36 console.error(err);37 } else {38 console.log(data);39 }40});41var wpt = require('webpagetest');42var test = new wpt('www.webpagetest.org', 'A.1234567890abcdef1234567890abcdef');
Using AI Code Generation
1var wptools = require('wptools');2wp.get({page: 'Albert Einstein'}).then(function(page){3 console.log(page);4});5var wptools = require('wptools');6var wp = new wptools();7wp.get({page: 'Albert Einstein'}).then(function(page){8 console.log(page);9});
Using AI Code Generation
1var wpt = require('wpt');2 if(err) console.log(err);3 console.log(data);4});5var wpt = require('wpt');6 if(err) console.log(err);7 console.log(data);8});9var wpt = require('wpt');10 if(err) console.log(err);11 console.log(data);12});13var wpt = require('wpt');14 if(err) console.log(err);15 console.log(data);16});17var wpt = require('wpt');18 if(err) console.log(err);19 console.log(data);20});21var wpt = require('wpt');22 if(err) console.log(err);23 console.log(data);24});25var wpt = require('wpt');26 if(err) console.log(err);27 console.log(data);28});29var wpt = require('wpt');30 if(err) console.log(err);31 console.log(data);32});33var wpt = require('wpt');34 if(err) console.log(err);35 console.log(data);36});
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!