How to use __doc__ method in hypothesis

Best Python code snippet using hypothesis

talib_wrap.py

Source:talib_wrap.py Github

copy

Full Screen

1#!/usr/bin/python2# -*- coding: utf8 -*-3# cp9364#5# The MIT License (MIT)6#7# Copyright (c) 2017 fasiondog8#9# Permission is hereby granted, free of charge, to any person obtaining a copy10# of this software and associated documentation files (the "Software"), to deal11# in the Software without restriction, including without limitation the rights12# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell13# copies of the Software, and to permit persons to whom the Software is14# furnished to do so, subject to the following conditions:15#16# The above copyright notice and this permission notice shall be included in all17# copies or substantial portions of the Software.18#19# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR20# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,21# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE22# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER23# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,24# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE25# SOFTWARE.26##===============================================================================27# 作者:fasiondog28# 历史:1)20170923, Added by fasiondog29#===============================================================================30from .indicator import Indicator, IndicatorImp31try:32 import talib33 import talib.abstract as ta34 import numpy as np35 36 def tawrap_init(self, tafunc, name, params, result_num=1, prices = None):37 super(self.__class__, self).__init__(name, result_num)38 for k,v in params.items():39 self.setParam(k, v) 40 self._tafunc = tafunc41 self._prices = prices42 43 def tawrap_calculate(self, ind):44 result_num = self.getResultNumber()45 46 if result_num < 1:47 print("error: result_num must be >= 1!")48 return49 50 if not self._prices:51 if self.name == "TA_OBV":52 if ind.getResultNumber() < 2:53 print("error: result_num must be >= 2!")54 return55 inputs = {'close': ind.getResult(0).to_np(),56 'volume': ind.getResult(1).to_np()}57 elif self.name in ("TA_BETA", "TA_CORREL"):58 if ind.getResultNumber() < 2:59 print("error: result_num must be >= 2!")60 return61 inputs = {'high': ind.getResult(0).to_np(),62 'low': ind.getResult(1).to_np()}63 else:64 inputs = {'close': ind.to_np()}65 else:66 if ind.name != 'KDATA':67 print("error: ind must KDATA")68 return69 70 inputs = {71 'open': ind.getResult(0).to_np(),72 'high': ind.getResult(1).to_np(),73 'low' : ind.getResult(2).to_np(),74 'close': ind.getResult(3).to_np(),75 'volume': ind.getResult(5).to_np()76 }77 78 params = self.getParameter()79 param_names = params.getNameList()80 func_params = {}81 for name in param_names:82 func_params[name] = self.getParam(name)83 84 self._tafunc.set_parameters(func_params)85 outputs = self._tafunc(inputs, prices = self._prices) if self._prices else self._tafunc(inputs)86 87 if result_num == 1:88 for i, val in enumerate(outputs):89 if not np.isnan(val):90 self._set(float(val), i)91 self.setDiscard(self._tafunc.lookback)92 93 else:94 for i, out in enumerate(outputs):95 for j, val in enumerate(out):96 if not np.isnan(val):97 self._set(float(val), j, i)98 self.setDiscard(self._tafunc.lookback)99 def check_all_true(self):100 return True101 102 def crtTaIndicatorImp(tafunc, name, params={}, result_num = 1, 103 prices = None, check = check_all_true):104 meta_x = type(name, (IndicatorImp,), {'__init__': tawrap_init, 105 'check': check,106 '_calculate': tawrap_calculate107 })108 return meta_x(tafunc, name, params, result_num, prices)109 110 def TA_AD(ind=None):111 imp = crtTaIndicatorImp(ta.AD, 'TA_AD', 112 prices = ['high', 'low', 'close', 'volume'])113 if ind is not None:114 imp.calculate(ind)115 return Indicator(imp)116 117 TA_AD.__doc__ = talib.AD.__doc__118 def TA_ADOSC(ind=None, fastperiod=3, slowperiod=10):119 imp = crtTaIndicatorImp(ta.ADOSC, 'TA_ADOSC', 120 params={'fastperiod': fastperiod, 121 'slowperiod': slowperiod},122 prices = ['high', 'low', 'close', 'volume'])123 if ind is not None:124 imp.calculate(ind)125 return Indicator(imp)126 127 TA_ADOSC.__doc__ = talib.ADOSC.__doc__128 129 def TA_ADX(ind=None, timeperiod=14):130 imp = crtTaIndicatorImp(ta.ADX, 'TA_ADX', 131 params={'timeperiod': timeperiod},132 prices = ['high', 'low', 'close'])133 if ind is not None:134 imp.calculate(ind)135 return Indicator(imp)136 137 TA_ADX.__doc__ = talib.ADX.__doc__138 def TA_ADXR(ind=None, timeperiod=14):139 imp = crtTaIndicatorImp(ta.ADXR, 'TA_ADXR', 140 params={'timeperiod': timeperiod},141 prices = ['high', 'low', 'close'])142 if ind is not None:143 imp.calculate(ind)144 return Indicator(imp)145 146 TA_ADXR.__doc__ = talib.ADXR.__doc__147 148 def TA_APO(ind=None, fastperiod=12, slowperiod=26, matype=talib.MA_Type.SMA):149 imp = crtTaIndicatorImp(ta.APO, 'TA_APO', 150 params={'fastperiod': fastperiod,151 'slowperiod': slowperiod,152 'matype': matype})153 if ind is not None:154 imp.calculate(ind)155 return Indicator(imp)156 157 TA_APO.__doc__ = talib.APO.__doc__158 159 def TA_AROON(ind=None, timeperiod=14):160 imp = crtTaIndicatorImp(ta.AROON, 'TA_AROON', 161 result_num = 2,162 params={'timeperiod': timeperiod},163 prices = ['high', 'low'])164 if ind is not None:165 imp.calculate(ind)166 return Indicator(imp) 167 168 TA_AROON.__doc__ = talib.AROON.__doc__169 170 def TA_AROONOSC(ind=None, timeperiod=14):171 imp = crtTaIndicatorImp(ta.AROONOSC, 'TA_AROONOSC', 172 result_num = 1,173 params={'timeperiod': timeperiod},174 prices = ['high', 'low'])175 if ind is not None:176 imp.calculate(ind)177 return Indicator(imp)178 179 TA_AROONOSC.__doc__ = talib.AROONOSC.__doc__180 181 def TA_ATR(ind=None, timeperiod=14):182 imp = crtTaIndicatorImp(ta.ATR, 'TA_ATR', 183 result_num = 1,184 params={'timeperiod': timeperiod},185 prices = ['high', 'low', 'close'])186 if ind is not None:187 imp.calculate(ind)188 return Indicator(imp) 189 190 TA_ATR.__doc__ = talib.ATR.__doc__191 192 def TA_AVGPRICE(ind=None, timeperiod=14):193 imp = crtTaIndicatorImp(ta.AVGPRICE, 'TA_AVGPRICE', 194 result_num = 1,195 #params={'timeperiod': timeperiod},196 prices = ['open', 'high', 'low', 'close'])197 if ind is not None:198 imp.calculate(ind)199 return Indicator(imp)200 201 TA_AVGPRICE.__doc__ = talib.AVGPRICE.__doc__202 203 def TA_BBANDS(ind=None, timeperiod=14, nbdevup=2, nbdevdn=2, matype=talib.MA_Type.SMA):204 imp = crtTaIndicatorImp(ta.BBANDS, 'TA_BBANDS', 205 result_num = 3,206 params={'timeperiod': timeperiod,207 'nbdevup': nbdevup,208 'nbdevdn': nbdevdn,209 'matype': matype})210 if ind is not None:211 imp.calculate(ind)212 return Indicator(imp) 213 214 TA_BBANDS.__doc__ = talib.BBANDS.__doc__215 216 def TA_BOP(ind=None):217 imp = crtTaIndicatorImp(ta.BOP, 'TA_BOP', 218 result_num = 1,219 prices = ['open', 'high', 'low', 'close'])220 if ind is not None:221 imp.calculate(ind)222 return Indicator(imp)223 224 TA_BOP.__doc__ = talib.BOP.__doc__ 225 226 def TA_CCI(ind=None, timeperiod=14):227 imp = crtTaIndicatorImp(ta.CCI, 'TA_CCI', 228 result_num = 1,229 params={'timeperiod': timeperiod},230 prices = ['high', 'low', 'close'])231 if ind is not None:232 imp.calculate(ind)233 return Indicator(imp)234 235 TA_CCI.__doc__ = talib.CCI.__doc__236 237 def TA_CMO(ind=None, timeperiod=14):238 imp = crtTaIndicatorImp(ta.CMO, 'TA_CMO', 239 result_num = 1,240 params={'timeperiod': timeperiod})241 if ind is not None:242 imp.calculate(ind)243 return Indicator(imp)244 245 TA_CMO.__doc__ = talib.CMO.__doc__246 247 def TA_DEMA(ind=None, timeperiod=30):248 imp = crtTaIndicatorImp(ta.DEMA, 'TA_DEMA', 249 result_num = 1,250 params={'timeperiod': timeperiod})251 if ind is not None:252 imp.calculate(ind)253 return Indicator(imp)254 255 TA_DEMA.__doc__ = talib.DEMA.__doc__256 257 def TA_DX(ind=None, timeperiod=14):258 imp = crtTaIndicatorImp(ta.DX, 'TA_DX', 259 result_num = 1,260 params={'timeperiod': timeperiod},261 prices = ['high', 'low', 'close'])262 if ind is not None:263 imp.calculate(ind)264 return Indicator(imp)265 266 TA_DX.__doc__ = talib.DX.__doc__267 268 def TA_EMA(ind=None, timeperiod=30):269 imp = crtTaIndicatorImp(ta.EMA, 'TA_EMA', 270 result_num = 1,271 params={'timeperiod': timeperiod})272 if ind is not None:273 imp.calculate(ind)274 return Indicator(imp)275 276 TA_EMA.__doc__ = talib.EMA.__doc__277 278 def TA_HT_DCPERIOD(ind=None):279 imp = crtTaIndicatorImp(ta.HT_DCPERIOD, 'TA_HT_DCPERIOD', 280 result_num = 1)281 if ind is not None:282 imp.calculate(ind)283 return Indicator(imp) 284 285 TA_HT_DCPERIOD.__doc__ = talib.HT_DCPERIOD.__doc__ 286 287 def TA_HT_DCPHASE(ind=None):288 imp = crtTaIndicatorImp(ta.HT_DCPHASE, 'TA_HT_DCPHASE', 289 result_num = 1)290 if ind is not None:291 imp.calculate(ind)292 return Indicator(imp)293 294 TA_HT_DCPHASE.__doc__ = talib.HT_DCPHASE.__doc__295 296 def TA_HT_PHASOR(ind=None):297 imp = crtTaIndicatorImp(ta.HT_PHASOR, 'TA_HT_PHASOR', 298 result_num = 2)299 if ind is not None:300 imp.calculate(ind)301 return Indicator(imp)302 303 TA_HT_PHASOR.__doc__ = talib.HT_PHASOR.__doc__304 305 def TA_HT_SINE(ind=None):306 imp = crtTaIndicatorImp(ta.HT_SINE, 'TA_HT_SINE', 307 result_num = 2)308 if ind is not None:309 imp.calculate(ind)310 return Indicator(imp)311 312 TA_HT_SINE.__doc__ = talib.HT_SINE.__doc__313 314 def TA_HT_TRENDLINE(ind=None):315 imp = crtTaIndicatorImp(ta.HT_TRENDLINE, 'TA_HT_TRENDLINE', 316 result_num = 1)317 if ind is not None:318 imp.calculate(ind)319 return Indicator(imp)320 321 TA_HT_TRENDLINE.__doc__ = talib.HT_TRENDLINE.__doc__322 323 def TA_HT_TRENDMODE(ind=None):324 imp = crtTaIndicatorImp(ta.HT_TRENDMODE, 'TA_HT_TRENDMODE', 325 result_num = 1)326 if ind is not None:327 imp.calculate(ind)328 return Indicator(imp)329 330 TA_HT_TRENDMODE.__doc__ = talib.HT_TRENDMODE.__doc__331 332 def TA_KAMA(ind=None, timeperiod=30):333 imp = crtTaIndicatorImp(ta.KAMA, 'TA_KAMA', 334 result_num = 1,335 params={'timeperiod': timeperiod})336 if ind is not None:337 imp.calculate(ind)338 return Indicator(imp)339 340 TA_KAMA.__doc__ = talib.KAMA.__doc__341 342 def TA_LINEARREG(ind=None, timeperiod=14):343 imp = crtTaIndicatorImp(ta.LINEARREG, 'TA_LINEARREG', 344 result_num = 1,345 params={'timeperiod': timeperiod})346 if ind is not None:347 imp.calculate(ind)348 return Indicator(imp)349 350 TA_LINEARREG.__doc__ = talib.LINEARREG.__doc__351 352 def TA_LINEARREG_ANGLE(ind=None, timeperiod=14):353 imp = crtTaIndicatorImp(ta.LINEARREG_ANGLE, 'TA_LINEARREG_ANGLE', 354 result_num = 1,355 params={'timeperiod': timeperiod})356 if ind is not None:357 imp.calculate(ind)358 return Indicator(imp)359 360 TA_LINEARREG_ANGLE.__doc__ = talib.LINEARREG_ANGLE.__doc__361 362 def TA_LINEARREG_INTERCEPT(ind=None, timeperiod=14):363 imp = crtTaIndicatorImp(ta.LINEARREG_INTERCEPT, 'TA_LINEARREG_INTERCEPT', 364 result_num = 1,365 params={'timeperiod': timeperiod})366 if ind is not None:367 imp.calculate(ind)368 return Indicator(imp)369 370 TA_LINEARREG_INTERCEPT.__doc__ = talib.LINEARREG_INTERCEPT.__doc__ 371 372 def TA_LINEARREG_SLOPE(ind=None, timeperiod=14):373 imp = crtTaIndicatorImp(ta.LINEARREG_SLOPE, 'TA_LINEARREG_SLOPE', 374 result_num = 1,375 params={'timeperiod': timeperiod})376 if ind is not None:377 imp.calculate(ind)378 return Indicator(imp)379 380 TA_LINEARREG_SLOPE.__doc__ = talib.LINEARREG_SLOPE.__doc__381 382 def TA_MA(ind=None, timeperiod=30, matype=talib.MA_Type.SMA):383 imp = crtTaIndicatorImp(ta.MA, 'TA_MA', 384 result_num = 1,385 params={'timeperiod': timeperiod,386 'matype': matype})387 if ind is not None:388 imp.calculate(ind)389 return Indicator(imp)390 391 TA_MA.__doc__ = talib.MA.__doc__392 393 def TA_MACD(ind=None, fastperiod=12, slowperiod=26, signalperiod=9):394 imp = crtTaIndicatorImp(ta.MACD, 'TA_MACD', 395 result_num = 3,396 params={'fastperiod': fastperiod,397 'slowperiod': slowperiod,398 'signalperiod': signalperiod})399 if ind is not None:400 imp.calculate(ind)401 return Indicator(imp)402 403 TA_MACD.__doc__ = talib.MACD.__doc__404 405 def TA_MACDEXT(ind=None, fastperiod=12, fastmatype=talib.MA_Type.SMA, 406 slowperiod=26, slowmatype=talib.MA_Type.SMA, 407 signalperiod=9, signalmatype=talib.MA_Type.SMA):408 imp = crtTaIndicatorImp(ta.MACDEXT, 'TA_MACDEXT', 409 result_num = 3,410 params={'fastperiod': fastperiod,411 'fastmatype': fastmatype,412 'slowperiod': slowperiod,413 'slowmatype': slowmatype,414 'signalperiod': signalperiod,415 'signalmatype': signalmatype})416 if ind is not None:417 imp.calculate(ind)418 return Indicator(imp)419 420 TA_MACDEXT.__doc__ = talib.MACDEXT.__doc__421 422 def TA_MACDFIX(ind=None, signalperiod=9):423 imp = crtTaIndicatorImp(ta.MACDFIX, 'TA_MACDFIX', 424 result_num = 3,425 params={'signalperiod': signalperiod})426 if ind is not None:427 imp.calculate(ind)428 return Indicator(imp)429 430 TA_MACDFIX.__doc__ = talib.MACDFIX.__doc__431 def TA_MAMA(ind=None, fastlimit=0.5, slowlimit=0.05):432 imp = crtTaIndicatorImp(ta.MAMA, 'TA_MAMA', 433 result_num = 2,434 params={'fastlimit': fastlimit,435 'slowlimit': slowlimit})436 if ind is not None:437 imp.calculate(ind)438 return Indicator(imp)439 440 TA_MAMA.__doc__ = talib.MAMA.__doc__441 442 def TA_MAX(ind=None, timeperiod=30):443 imp = crtTaIndicatorImp(ta.MAX, 'TA_MAX', 444 result_num = 1,445 params={'timeperiod': timeperiod})446 if ind is not None:447 imp.calculate(ind)448 return Indicator(imp)449 450 TA_MAX.__doc__ = talib.MAX.__doc__ 451 452 def TA_MAXINDEX(ind=None, timeperiod=30):453 imp = crtTaIndicatorImp(ta.MAXINDEX, 'TA_MAXINDEX', 454 result_num = 1,455 params={'timeperiod': timeperiod})456 if ind is not None:457 imp.calculate(ind)458 return Indicator(imp)459 460 TA_MAXINDEX.__doc__ = talib.MAXINDEX.__doc__461 462 def TA_MEDPRICE(ind=None):463 imp = crtTaIndicatorImp(ta.MEDPRICE, 'TA_MEDPRICE', 464 result_num = 1,465 prices = ['high', 'low'])466 if ind is not None:467 imp.calculate(ind)468 return Indicator(imp)469 470 TA_MEDPRICE.__doc__ = talib.MEDPRICE.__doc__471 472 def TA_MIDPOINT(ind=None, timeperiod=14):473 imp = crtTaIndicatorImp(ta.MIDPOINT, 'TA_MIDPOINT', 474 result_num = 1,475 params={'timeperiod': timeperiod})476 if ind is not None:477 imp.calculate(ind)478 return Indicator(imp)479 480 TA_MIDPOINT.__doc__ = talib.MIDPRICE.__doc__481 482 def TA_MIDPRICE(ind=None, timeperiod=14):483 imp = crtTaIndicatorImp(ta.MIDPRICE, 'TA_MIDPRICE', 484 result_num = 1,485 params={'timeperiod': timeperiod},486 prices = ['high', 'low'])487 if ind is not None:488 imp.calculate(ind)489 return Indicator(imp)490 491 TA_MIDPRICE.__doc__ = talib.MIDPRICE.__doc__ 492 493 def TA_MIN(ind=None, timeperiod=30):494 imp = crtTaIndicatorImp(ta.MIN, 'TA_MIN', 495 result_num = 1,496 params={'timeperiod': timeperiod})497 if ind is not None:498 imp.calculate(ind)499 return Indicator(imp)500 501 TA_MIN.__doc__ = talib.MIN.__doc__502 503 def TA_MININDEX(ind=None, timeperiod=30):504 imp = crtTaIndicatorImp(ta.MININDEX, 'TA_MININDEX', 505 result_num = 1,506 params={'timeperiod': timeperiod})507 if ind is not None:508 imp.calculate(ind)509 return Indicator(imp) 510 511 TA_MININDEX.__doc__ = talib.MININDEX.__doc__ 512 513 def TA_MINMAX(ind=None, timeperiod=30):514 imp = crtTaIndicatorImp(ta.MINMAX, 'TA_MINMAX', 515 result_num = 2,516 params={'timeperiod': timeperiod})517 if ind is not None:518 imp.calculate(ind)519 return Indicator(imp)520 521 TA_MINMAX.__doc__ = talib.MINMAX.__doc__522 523 def TA_MINMAXINDEX(ind=None, timeperiod=30):524 imp = crtTaIndicatorImp(ta.MINMAXINDEX, 'TA_MINMAXINDEX', 525 result_num = 2,526 params={'timeperiod': timeperiod})527 if ind is not None:528 imp.calculate(ind)529 return Indicator(imp)530 531 TA_MINMAXINDEX.__doc__ = talib.MINMAXINDEX.__doc__532 533 def TA_MINUS_DI(ind=None, timeperiod=14):534 imp = crtTaIndicatorImp(ta.MINUS_DI, 'TA_MINUS_DI', 535 result_num = 1,536 params={'timeperiod': timeperiod},537 prices = ['high', 'low', 'close'])538 if ind is not None:539 imp.calculate(ind)540 return Indicator(imp)541 542 TA_MINUS_DI.__doc__ = talib.MINUS_DI.__doc__543 544 def TA_MINUS_DM(ind=None, timeperiod=14):545 imp = crtTaIndicatorImp(ta.MINUS_DM, 'TA_MINUS_DM', 546 result_num = 1,547 params={'timeperiod': timeperiod},548 prices = ['high', 'low'])549 if ind is not None:550 imp.calculate(ind)551 return Indicator(imp)552 553 TA_MINUS_DM.__doc__ = talib.MINUS_DM.__doc__554 555 def TA_MOM(ind=None, timeperiod=10):556 imp = crtTaIndicatorImp(ta.MOM, 'TA_MOM', 557 result_num = 1,558 params={'timeperiod': timeperiod})559 if ind is not None:560 imp.calculate(ind)561 return Indicator(imp)562 563 TA_MOM.__doc__ = talib.MOM.__doc__ 564 def TA_NATR(ind=None, timeperiod=14):565 imp = crtTaIndicatorImp(ta.NATR, 'TA_NATR', 566 result_num = 1,567 params={'timeperiod': timeperiod},568 prices = ['high', 'low', 'close'])569 if ind is not None:570 imp.calculate(ind)571 return Indicator(imp) 572 573 TA_NATR.__doc__ = talib.NATR.__doc__574 575 def TA_PLUS_DI(ind=None, timeperiod=14):576 imp = crtTaIndicatorImp(ta.PLUS_DI, 'TA_PLUS_DI', 577 result_num = 1,578 params={'timeperiod': timeperiod},579 prices = ['high', 'low', 'close'])580 if ind is not None:581 imp.calculate(ind)582 return Indicator(imp)583 584 TA_PLUS_DI.__doc__ = talib.PLUS_DI.__doc__585 586 def TA_PLUS_DM(ind=None, timeperiod=14):587 imp = crtTaIndicatorImp(ta.PLUS_DM, 'TA_PLUS_DM', 588 result_num = 1,589 params={'timeperiod': timeperiod},590 prices = ['high', 'low'])591 if ind is not None:592 imp.calculate(ind)593 return Indicator(imp)594 595 TA_PLUS_DM.__doc__ = talib.PLUS_DM.__doc__596 597 def TA_PPO(ind=None, fastperiod=12, slowperiod=26, matype=talib.MA_Type.SMA):598 imp = crtTaIndicatorImp(ta.PPO, 'TA_PPO', 599 result_num = 1,600 params={'fastperiod': fastperiod,601 'slowperiod': slowperiod,602 'matype': matype})603 if ind is not None:604 imp.calculate(ind)605 return Indicator(imp)606 607 TA_PPO.__doc__ = talib.PPO.__doc__608 609 def TA_ROC(ind=None, timeperiod=10):610 imp = crtTaIndicatorImp(ta.ROC, 'TA_ROC', 611 result_num = 1,612 params={'timeperiod': timeperiod})613 if ind is not None:614 imp.calculate(ind)615 return Indicator(imp)616 617 TA_ROC.__doc__ = talib.ROC.__doc__618 619 def TA_ROCP(ind=None, timeperiod=10):620 imp = crtTaIndicatorImp(ta.ROCP, 'TA_ROCP', 621 result_num = 1,622 params={'timeperiod': timeperiod})623 if ind is not None:624 imp.calculate(ind)625 return Indicator(imp)626 627 TA_ROCP.__doc__ = talib.ROCP.__doc__628 629 def TA_ROCR(ind=None, timeperiod=10):630 imp = crtTaIndicatorImp(ta.ROCR, 'TA_ROCR', 631 result_num = 1,632 params={'timeperiod': timeperiod})633 if ind is not None:634 imp.calculate(ind)635 return Indicator(imp)636 637 TA_ROCR.__doc__ = talib.ROCR.__doc__638 639 def TA_ROCR100(ind=None, timeperiod=10):640 imp = crtTaIndicatorImp(ta.ROCR100, 'TA_ROCR100', 641 result_num = 1,642 params={'timeperiod': timeperiod})643 if ind is not None:644 imp.calculate(ind)645 return Indicator(imp)646 647 TA_ROCR100.__doc__ = talib.ROCR100.__doc__648 649 def TA_RSI(ind=None, timeperiod=14):650 imp = crtTaIndicatorImp(ta.RSI, 'TA_RSI', 651 result_num = 1,652 params={'timeperiod': timeperiod})653 if ind is not None:654 imp.calculate(ind)655 return Indicator(imp)656 657 TA_RSI.__doc__ = talib.RSI.__doc__658 659 def TA_SAR(ind=None, acceleration=0.02, maximum=0.2):660 imp = crtTaIndicatorImp(ta.SAR, 'TA_SAR', 661 result_num = 1,662 params={'acceleration': acceleration,663 'maximum': maximum},664 prices = ['high', 'low'])665 if ind is not None:666 imp.calculate(ind)667 return Indicator(imp)668 669 TA_SAR.__doc__ = talib.SAR.__doc__670 671 def TA_SAREXT(ind=None, startvalue=0, 672 offsetonreverse=0,673 accelerationinitlong=0.02,674 accelerationlong=0.02,675 accelerationmaxlong=0.02,676 accelerationinitshort=0.02,677 accelerationshort=0.02,678 accelerationmaxshort=0.02):679 imp = crtTaIndicatorImp(ta.SAREXT, 'TA_SAREXT', 680 result_num = 1,681 params={'startvalue': startvalue,682 'offsetonreverse': offsetonreverse,683 'accelerationinitlong': accelerationinitlong,684 'accelerationlong': accelerationlong,685 'accelerationmaxlong': accelerationmaxlong,686 'accelerationinitshort': accelerationinitshort,687 'accelerationshort': accelerationshort,688 'accelerationmaxshort': accelerationmaxshort},689 prices = ['high', 'low'])690 if ind is not None:691 imp.calculate(ind)692 return Indicator(imp)693 694 TA_SAREXT.__doc__ = talib.SAREXT.__doc__695 696 def TA_SMA(ind=None, timeperiod=30):697 imp = crtTaIndicatorImp(ta.SMA, 'TA_SMA', 698 result_num = 1,699 params={'timeperiod': timeperiod})700 if ind is not None:701 imp.calculate(ind)702 return Indicator(imp)703 704 TA_SMA.__doc__ = talib.SMA.__doc__705 706 def TA_STDDEV(ind=None, timeperiod=5, nbdev=1):707 imp = crtTaIndicatorImp(ta.STDDEV, 'TA_STDDEV', 708 result_num = 1,709 params={'timeperiod': timeperiod,710 'nbdev': nbdev})711 if ind is not None:712 imp.calculate(ind)713 return Indicator(imp)714 715 TA_STDDEV.__doc__ = talib.STDDEV.__doc__716 717 def TA_STOCH(ind=None, fastk_period=5, 718 slowk_period=3, slowk_matype=talib.MA_Type.SMA,719 slowd_period=3, slowd_matype=talib.MA_Type.SMA):720 imp = crtTaIndicatorImp(ta.STOCH, 'TA_STOCH', 721 result_num = 2,722 params={'fastk_period': fastk_period,723 'slowk_period': slowk_period,724 'slowk_matype': slowk_matype,725 'slowd_period': slowd_period,726 'slowd_matype': slowd_matype},727 prices = ['high', 'low', 'close'])728 if ind is not None:729 imp.calculate(ind)730 return Indicator(imp)731 732 TA_STOCH.__doc__ = talib.STOCH.__doc__733 734 def TA_STOCHF(ind=None, fastk_period=5, fastd_period=3, fastd_matype=talib.MA_Type.SMA):735 imp = crtTaIndicatorImp(ta.STOCHF, 'TA_STOCHF', 736 result_num = 2,737 params={'fastk_period': fastk_period,738 'fastd_period': fastd_period,739 'fastd_matype': fastd_matype740 },741 prices = ['high', 'low', 'close'])742 if ind is not None:743 imp.calculate(ind)744 return Indicator(imp)745 746 TA_STOCHF.__doc__ = talib.STOCHF.__doc__747 748 def TA_STOCHRSI(ind=None, timeperiod=14, fastk_period=5, fastd_period=3, fastd_matype=talib.MA_Type.SMA):749 imp = crtTaIndicatorImp(ta.STOCHRSI, 'TA_STOCHRSI', 750 result_num = 2,751 params={'timeperiod': timeperiod, 752 'fastk_period': fastk_period,753 'fastd_period': fastd_period,754 'fastd_matype': fastd_matype755 })756 if ind is not None:757 imp.calculate(ind)758 return Indicator(imp)759 760 TA_STOCHRSI.__doc__ = talib.STOCHRSI.__doc__761 762 def TA_SUM(ind=None, timeperiod=30):763 imp = crtTaIndicatorImp(ta.SUM, 'TA_SUM', 764 result_num = 1,765 params={'timeperiod': timeperiod})766 if ind is not None:767 imp.calculate(ind)768 return Indicator(imp)769 770 TA_SUM.__doc__ = talib.SUM.__doc__771 772 def TA_T3(ind=None, timeperiod=5, vfactor=0.7):773 imp = crtTaIndicatorImp(ta.T3, 'TA_T3', 774 result_num = 1,775 params={'timeperiod': timeperiod,776 'vfactor': vfactor777 })778 if ind is not None:779 imp.calculate(ind)780 return Indicator(imp)781 782 TA_T3.__doc__ = talib.T3.__doc__783 784 def TA_TEMA(ind=None, timeperiod=30):785 imp = crtTaIndicatorImp(ta.TEMA, 'TA_TEMA', 786 result_num = 1,787 params={'timeperiod': timeperiod})788 if ind is not None:789 imp.calculate(ind)790 return Indicator(imp)791 792 TA_TEMA.__doc__ = talib.TEMA.__doc__793 794 def TA_TRANGE(ind=None):795 imp = crtTaIndicatorImp(ta.TRANGE, 'TA_TRANGE', 796 result_num = 1,797 prices = ['high', 'low', 'close'])798 if ind is not None:799 imp.calculate(ind)800 return Indicator(imp)801 802 TA_TRANGE.__doc__ = talib.TRANGE.__doc__803 804 def TA_TRIMA(ind=None, timeperiod=30):805 imp = crtTaIndicatorImp(ta.TRIMA, 'TA_TRIMA', 806 result_num = 1,807 params={'timeperiod': timeperiod})808 if ind is not None:809 imp.calculate(ind)810 return Indicator(imp)811 812 TA_TRIMA.__doc__ = talib.TRIMA.__doc__813 814 def TA_TRIX(ind=None, timeperiod=30):815 imp = crtTaIndicatorImp(ta.TRIX, 'TA_TRIX', 816 result_num = 1,817 params={'timeperiod': timeperiod})818 if ind is not None:819 imp.calculate(ind)820 return Indicator(imp)821 822 TA_TRIX.__doc__ = talib.TRIX.__doc__823 824 def TA_TSF(ind=None, timeperiod=14):825 imp = crtTaIndicatorImp(ta.TSF, 'TA_TSF', 826 result_num = 1,827 params={'timeperiod': timeperiod})828 if ind is not None:829 imp.calculate(ind)830 return Indicator(imp)831 832 TA_TSF.__doc__ = talib.TSF.__doc__833 834 def TA_TYPPRICE(ind=None, timeperiod=14):835 imp = crtTaIndicatorImp(ta.TYPPRICE, 'TA_TYPPRICE', 836 result_num = 1,837 prices = ['high', 'low', 'close'])838 if ind is not None:839 imp.calculate(ind)840 return Indicator(imp) 841 842 TA_TYPPRICE.__doc__ = talib.TYPPRICE.__doc__843 844 def TA_ULTOSC(ind=None, timeperiod1=7, timeperiod2=14, timeperiod3=28):845 imp = crtTaIndicatorImp(ta.ULTOSC, 'TA_ULTOSC', 846 result_num = 1,847 params={'timeperiod1': timeperiod1,848 'timeperiod2': timeperiod2,849 'timeperiod3': timeperiod3,850 },851 prices = ['high', 'low', 'close'])852 if ind is not None:853 imp.calculate(ind)854 return Indicator(imp) 855 856 TA_ULTOSC.__doc__ = talib.ULTOSC.__doc__857 858 def TA_VAR(ind=None, timeperiod=5, nbdev=1):859 imp = crtTaIndicatorImp(ta.VAR, 'TA_VAR', 860 result_num = 1,861 params={'timeperiod': timeperiod,862 'nbdev': nbdev863 })864 if ind is not None:865 imp.calculate(ind)866 return Indicator(imp)867 868 TA_VAR.__doc__ = talib.VAR.__doc__ 869 870 def TA_WCLPRICE(ind=None):871 imp = crtTaIndicatorImp(ta.WCLPRICE, 'TA_WCLPRICE', 872 result_num = 1,873 prices = ['high', 'low', 'close'])874 if ind is not None:875 imp.calculate(ind)876 return Indicator(imp)877 878 TA_WCLPRICE.__doc__ = talib.WCLPRICE.__doc__879 880 def TA_WILLR(ind=None, timeperiod=14):881 imp = crtTaIndicatorImp(ta.WILLR, 'TA_WILLR', 882 result_num = 1,883 params={'timeperiod': timeperiod},884 prices = ['high', 'low', 'close'])885 if ind is not None:886 imp.calculate(ind)887 return Indicator(imp)888 889 TA_WILLR.__doc__ = talib.WILLR.__doc__890 891 def TA_WMA(ind=None, timeperiod=30):892 imp = crtTaIndicatorImp(ta.WMA, 'TA_WMA', 893 result_num = 1,894 params={'timeperiod': timeperiod})895 if ind is not None:896 imp.calculate(ind)897 return Indicator(imp) 898 899 TA_WMA.__doc__ = talib.WMA.__doc__900 901 def TA_CDL2CROWS(ind=None):902 imp = crtTaIndicatorImp(ta.CDL2CROWS, 'TA_CDL2CROWS', 903 result_num = 1,904 prices = ['open', 'high', 'low', 'close'])905 if ind is not None:906 imp.calculate(ind)907 return Indicator(imp)908 909 TA_CDL2CROWS.__doc__ = talib.CDL2CROWS.__doc__910 911 def TA_CDL3BLACKCROWS(ind=None):912 imp = crtTaIndicatorImp(ta.CDL3BLACKCROWS, 'TA_CDL3BLACKCROWS', 913 result_num = 1,914 prices = ['open', 'high', 'low', 'close'])915 if ind is not None:916 imp.calculate(ind)917 return Indicator(imp)918 919 TA_CDL3BLACKCROWS.__doc__ = talib.CDL3BLACKCROWS.__doc__920 921 def TA_CDL3INSIDE(ind=None):922 imp = crtTaIndicatorImp(ta.CDL3INSIDE, 'TA_CDL3INSIDE', 923 result_num = 1,924 prices = ['open', 'high', 'low', 'close'])925 if ind is not None:926 imp.calculate(ind)927 return Indicator(imp)928 929 TA_CDL3INSIDE.__doc__ = talib.CDL3INSIDE.__doc__ 930 931 def TA_CDL3LINESTRIKE(ind=None):932 imp = crtTaIndicatorImp(ta.CDL3LINESTRIKE, 'TA_CDL3LINESTRIKE', 933 result_num = 1,934 prices = ['open', 'high', 'low', 'close'])935 if ind is not None:936 imp.calculate(ind)937 return Indicator(imp)938 939 TA_CDL3LINESTRIKE.__doc__ = talib.CDL3LINESTRIKE.__doc__940 941 def TA_CDL3OUTSIDE(ind=None):942 imp = crtTaIndicatorImp(ta.CDL3OUTSIDE, 'TA_CDL3OUTSIDE', 943 result_num = 1,944 prices = ['open', 'high', 'low', 'close'])945 if ind is not None:946 imp.calculate(ind)947 return Indicator(imp)948 949 TA_CDL3OUTSIDE.__doc__ = talib.CDL3OUTSIDE.__doc__950 951 def TA_CDL3STARSINSOUTH(ind=None):952 imp = crtTaIndicatorImp(ta.CDL3STARSINSOUTH, 'TA_CDL3STARSINSOUTH', 953 result_num = 1,954 prices = ['open', 'high', 'low', 'close'])955 if ind is not None:956 imp.calculate(ind)957 return Indicator(imp) 958 959 TA_CDL3STARSINSOUTH.__doc__ = talib.CDL3STARSINSOUTH.__doc__ 960 961 def TA_CDL3WHITESOLDIERS(ind=None):962 imp = crtTaIndicatorImp(ta.CDL3WHITESOLDIERS, 'TA_CDL3WHITESOLDIERS', 963 result_num = 1,964 prices = ['open', 'high', 'low', 'close'])965 if ind is not None:966 imp.calculate(ind)967 return Indicator(imp)968 969 TA_CDL3WHITESOLDIERS.__doc__ = talib.CDL3WHITESOLDIERS.__doc__ 970 971 def TA_CDLABANDONEDBABY(ind=None, penetration=0.3):972 imp = crtTaIndicatorImp(ta.CDLABANDONEDBABY, 'TA_CDLABANDONEDBABY', 973 result_num = 1,974 params={'penetration': penetration},975 prices = ['open', 'high', 'low', 'close'])976 if ind is not None:977 imp.calculate(ind)978 return Indicator(imp)979 980 TA_CDLABANDONEDBABY.__doc__ = talib.CDLABANDONEDBABY.__doc__981 982 def TA_CDLADVANCEBLOCK(ind=None):983 imp = crtTaIndicatorImp(ta.CDLADVANCEBLOCK, 'TA_CDLADVANCEBLOCK', 984 result_num = 1,985 prices = ['open', 'high', 'low', 'close'])986 if ind is not None:987 imp.calculate(ind)988 return Indicator(imp)989 990 TA_CDLADVANCEBLOCK = talib.CDLADVANCEBLOCK.__doc__991 992 def TA_CDLBELTHOLD(ind=None):993 imp = crtTaIndicatorImp(ta.CDLBELTHOLD, 'TA_CDLBELTHOLD', 994 result_num = 1,995 prices = ['open', 'high', 'low', 'close'])996 if ind is not None:997 imp.calculate(ind)998 return Indicator(imp) 999 1000 TA_CDLBELTHOLD.__doc__ = talib.CDLBELTHOLD.__doc__1001 1002 def TA_CDLBREAKAWAY(ind=None):1003 imp = crtTaIndicatorImp(ta.CDLBREAKAWAY, 'TA_CDLBREAKAWAY', 1004 result_num = 1,1005 prices = ['open', 'high', 'low', 'close'])1006 if ind is not None:1007 imp.calculate(ind)1008 return Indicator(imp) 1009 1010 TA_CDLBREAKAWAY.__doc__ = talib.CDLBREAKAWAY.__doc__1011 1012 def TA_CDLCLOSINGMARUBOZU(ind=None):1013 imp = crtTaIndicatorImp(ta.CDLCLOSINGMARUBOZU, 'TA_CDLCLOSINGMARUBOZU', 1014 result_num = 1,1015 prices = ['open', 'high', 'low', 'close'])1016 if ind is not None:1017 imp.calculate(ind)1018 return Indicator(imp)1019 1020 TA_CDLCLOSINGMARUBOZU.__doc__ = talib.CDLCLOSINGMARUBOZU.__doc__ 1021 1022 def TA_CDLCONCEALBABYSWALL(ind=None):1023 imp = crtTaIndicatorImp(ta.CDLCONCEALBABYSWALL, 'TA_CDLCONCEALBABYSWALL', 1024 result_num = 1,1025 prices = ['open', 'high', 'low', 'close'])1026 if ind is not None:1027 imp.calculate(ind)1028 return Indicator(imp) 1029 1030 TA_CDLCONCEALBABYSWALL.__doc__ = talib.CDLCONCEALBABYSWALL.__doc__ 1031 1032 def TA_CDLCOUNTERATTACK(ind=None):1033 imp = crtTaIndicatorImp(ta.CDLCOUNTERATTACK, 'TA_CDLCOUNTERATTACK', 1034 result_num = 1,1035 prices = ['open', 'high', 'low', 'close'])1036 if ind is not None:1037 imp.calculate(ind)1038 return Indicator(imp)1039 1040 TA_CDLCOUNTERATTACK.__doc__ = talib.CDLCOUNTERATTACK.__doc__ 1041 1042 def TA_CDLDARKCLOUDCOVER(ind=None, penetration=0.5):1043 imp = crtTaIndicatorImp(ta.CDLDARKCLOUDCOVER, 'TA_CDLDARKCLOUDCOVER', 1044 result_num = 1,1045 params={'penetration': penetration},1046 prices = ['open', 'high', 'low', 'close'])1047 if ind is not None:1048 imp.calculate(ind)1049 return Indicator(imp) 1050 1051 TA_CDLDARKCLOUDCOVER.__doc__ = talib.CDLDARKCLOUDCOVER.__doc__1052 1053 def TA_CDLDOJI(ind=None):1054 imp = crtTaIndicatorImp(ta.CDLDOJI, 'TA_CDLDOJI', 1055 result_num = 1,1056 prices = ['open', 'high', 'low', 'close'])1057 if ind is not None:1058 imp.calculate(ind)1059 return Indicator(imp) 1060 1061 TA_CDLDOJI.__doc__ = talib.CDLDOJI.__doc__1062 1063 def TA_CDLDOJISTAR(ind=None):1064 imp = crtTaIndicatorImp(ta.CDLDOJISTAR, 'TA_CDLDOJISTAR', 1065 result_num = 1,1066 prices = ['open', 'high', 'low', 'close'])1067 if ind is not None:1068 imp.calculate(ind)1069 return Indicator(imp) 1070 1071 TA_CDLDOJISTAR.__doc__ = talib.CDLDOJISTAR.__doc__ 1072 1073 def TA_CDLDRAGONFLYDOJI(ind=None):1074 imp = crtTaIndicatorImp(ta.CDLDRAGONFLYDOJI, 'TA_CDLDRAGONFLYDOJI', 1075 result_num = 1,1076 prices = ['open', 'high', 'low', 'close'])1077 if ind is not None:1078 imp.calculate(ind)1079 return Indicator(imp) 1080 1081 TA_CDLDRAGONFLYDOJI.__doc__ = talib.CDLDRAGONFLYDOJI.__doc__ 1082 1083 def TA_CDLENGULFING(ind=None):1084 imp = crtTaIndicatorImp(ta.CDLENGULFING, 'TA_CDLENGULFING', 1085 result_num = 1,1086 prices = ['open', 'high', 'low', 'close'])1087 if ind is not None:1088 imp.calculate(ind)1089 return Indicator(imp) 1090 1091 TA_CDLENGULFING.__doc__ = talib.CDLENGULFING.__doc__ 1092 1093 def TA_CDLEVENINGDOJISTAR(ind=None, penetration=0.3):1094 imp = crtTaIndicatorImp(ta.CDLEVENINGDOJISTAR, 'TA_CDLEVENINGDOJISTAR', 1095 result_num = 1,1096 params={'penetration': penetration},1097 prices = ['open', 'high', 'low', 'close'])1098 if ind is not None:1099 imp.calculate(ind)1100 return Indicator(imp) 1101 1102 TA_CDLEVENINGDOJISTAR.__doc__ = talib.CDLEVENINGDOJISTAR.__doc__ 1103 1104 def TA_CDLEVENINGSTAR(ind=None, penetration=0.3):1105 imp = crtTaIndicatorImp(ta.CDLEVENINGSTAR, 'TA_CDLEVENINGSTAR', 1106 result_num = 1,1107 params={'penetration': penetration},1108 prices = ['open', 'high', 'low', 'close'])1109 if ind is not None:1110 imp.calculate(ind)1111 return Indicator(imp) 1112 1113 TA_CDLEVENINGSTAR.__doc__ = talib.CDLEVENINGSTAR.__doc__ 1114 1115 def TA_CDLGAPSIDESIDEWHITE(ind=None):1116 imp = crtTaIndicatorImp(ta.CDLGAPSIDESIDEWHITE, 'TA_CDLGAPSIDESIDEWHITE', 1117 result_num = 1,1118 prices = ['open', 'high', 'low', 'close'])1119 if ind is not None:1120 imp.calculate(ind)1121 return Indicator(imp) 1122 1123 TA_CDLGAPSIDESIDEWHITE.__doc__ = talib.CDLGAPSIDESIDEWHITE.__doc__ 1124 1125 def TA_CDLGRAVESTONEDOJI(ind=None):1126 imp = crtTaIndicatorImp(ta.CDLGRAVESTONEDOJI, 'TA_CDLGRAVESTONEDOJI', 1127 result_num = 1,1128 prices = ['open', 'high', 'low', 'close'])1129 if ind is not None:1130 imp.calculate(ind)1131 return Indicator(imp) 1132 1133 TA_CDLGRAVESTONEDOJI.__doc__ = talib.CDLGRAVESTONEDOJI.__doc__ 1134 1135 def TA_CDLHAMMER(ind=None):1136 imp = crtTaIndicatorImp(ta.CDLHAMMER, 'TA_CDLHAMMER', 1137 result_num = 1,1138 prices = ['open', 'high', 'low', 'close'])1139 if ind is not None:1140 imp.calculate(ind)1141 return Indicator(imp) 1142 1143 TA_CDLHAMMER.__doc__ = talib.CDLHAMMER.__doc__1144 1145 def TA_CDLHANGINGMAN(ind=None):1146 imp = crtTaIndicatorImp(ta.CDLHANGINGMAN, 'TA_CDLHANGINGMAN', 1147 result_num = 1,1148 prices = ['open', 'high', 'low', 'close'])1149 if ind is not None:1150 imp.calculate(ind)1151 return Indicator(imp) 1152 1153 TA_CDLHANGINGMAN.__doc__ = talib.CDLHANGINGMAN.__doc__ 1154 1155 def TA_CDLHARAMI(ind=None):1156 imp = crtTaIndicatorImp(ta.CDLHARAMI, 'TA_CDLHARAMI', 1157 result_num = 1,1158 #params={'penetration': penetration},1159 prices = ['open', 'high', 'low', 'close'])1160 if ind is not None:1161 imp.calculate(ind)1162 return Indicator(imp)1163 1164 TA_CDLHARAMI.__doc__ = talib.CDLHARAMI.__doc__1165 1166 def TA_CDLHARAMICROSS(ind=None):1167 imp = crtTaIndicatorImp(ta.CDLHARAMICROSS, 'TA_CDLHARAMICROSS', 1168 result_num = 1,1169 prices = ['open', 'high', 'low', 'close'])1170 if ind is not None:1171 imp.calculate(ind)1172 return Indicator(imp)1173 1174 TA_CDLHARAMICROSS.__doc__ = talib.CDLHARAMICROSS.__doc__1175 1176 def TA_CDLHIGHWAVE(ind=None):1177 imp = crtTaIndicatorImp(ta.CDLHIGHWAVE, 'TA_CDLHIGHWAVE', 1178 result_num = 1,1179 prices = ['open', 'high', 'low', 'close'])1180 if ind is not None:1181 imp.calculate(ind)1182 return Indicator(imp) 1183 1184 TA_CDLHIGHWAVE.__doc__ = talib.CDLHIGHWAVE.__doc__ 1185 1186 def TA_CDLHIKKAKE(ind=None):1187 imp = crtTaIndicatorImp(ta.CDLHIKKAKE, 'TA_CDLHIKKAKE', 1188 result_num = 1,1189 prices = ['open', 'high', 'low', 'close'])1190 if ind is not None:1191 imp.calculate(ind)1192 return Indicator(imp) 1193 1194 TA_CDLHIKKAKE.__doc__ = talib.CDLHIKKAKE.__doc__ 1195 1196 def TA_CDLHIKKAKEMOD(ind=None):1197 imp = crtTaIndicatorImp(ta.CDLHIKKAKEMOD, 'TA_CDLHIKKAKEMOD', 1198 result_num = 1,1199 prices = ['open', 'high', 'low', 'close'])1200 if ind is not None:1201 imp.calculate(ind)1202 return Indicator(imp)1203 1204 TA_CDLHIKKAKEMOD.__doc__ = talib.CDLHIKKAKEMOD.__doc__1205 1206 def TA_CDLHOMINGPIGEON(ind=None):1207 imp = crtTaIndicatorImp(ta.CDLHOMINGPIGEON, 'TA_CDLHOMINGPIGEON', 1208 result_num = 1,1209 prices = ['open', 'high', 'low', 'close'])1210 if ind is not None:1211 imp.calculate(ind)1212 return Indicator(imp) 1213 1214 TA_CDLHOMINGPIGEON.__doc__ = talib.CDLHOMINGPIGEON.__doc__ 1215 1216 def TA_CDLIDENTICAL3CROWS(ind=None):1217 imp = crtTaIndicatorImp(ta.CDLIDENTICAL3CROWS, 'TA_CDLIDENTICAL3CROWS', 1218 result_num = 1,1219 prices = ['open', 'high', 'low', 'close'])1220 if ind is not None:1221 imp.calculate(ind)1222 return Indicator(imp) 1223 1224 TA_CDLIDENTICAL3CROWS.__doc__ = talib.CDLIDENTICAL3CROWS.__doc__1225 1226 def TA_CDLINNECK(ind=None):1227 imp = crtTaIndicatorImp(ta.CDLINNECK, 'TA_CDLINNECK', 1228 result_num = 1,1229 prices = ['open', 'high', 'low', 'close'])1230 if ind is not None:1231 imp.calculate(ind)1232 return Indicator(imp) 1233 1234 TA_CDLINNECK.__doc__ = talib.CDLINNECK.__doc__1235 1236 def TA_CDLINVERTEDHAMMER(ind=None):1237 imp = crtTaIndicatorImp(ta.CDLINVERTEDHAMMER, 'TA_CDLINVERTEDHAMMER', 1238 result_num = 1,1239 prices = ['open', 'high', 'low', 'close'])1240 if ind is not None:1241 imp.calculate(ind)1242 return Indicator(imp) 1243 1244 TA_CDLINVERTEDHAMMER.__doc__ = talib.CDLINVERTEDHAMMER.__doc__1245 1246 def TA_CDLKICKING(ind=None):1247 imp = crtTaIndicatorImp(ta.CDLKICKING, 'TA_CDLKICKING', 1248 result_num = 1,1249 prices = ['open', 'high', 'low', 'close'])1250 if ind is not None:1251 imp.calculate(ind)1252 return Indicator(imp)1253 1254 TA_CDLKICKING.__doc__ = talib.CDLKICKING.__doc__1255 1256 def TA_CDLKICKINGBYLENGTH(ind=None):1257 imp = crtTaIndicatorImp(ta.CDLKICKINGBYLENGTH, 'TA_CDLKICKINGBYLENGTH', 1258 result_num = 1,1259 prices = ['open', 'high', 'low', 'close'])1260 if ind is not None:1261 imp.calculate(ind)1262 return Indicator(imp)1263 1264 TA_CDLKICKINGBYLENGTH.__doc__ = talib.CDLKICKINGBYLENGTH.__doc__1265 1266 def TA_CDLLADDERBOTTOM(ind=None):1267 imp = crtTaIndicatorImp(ta.CDLLADDERBOTTOM, 'TA_CDLLADDERBOTTOM', 1268 result_num = 1,1269 prices = ['open', 'high', 'low', 'close'])1270 if ind is not None:1271 imp.calculate(ind)1272 return Indicator(imp) 1273 1274 TA_CDLLADDERBOTTOM.__doc__ = talib.CDLLADDERBOTTOM.__doc__ 1275 1276 def TA_CDLLONGLEGGEDDOJI(ind=None):1277 imp = crtTaIndicatorImp(ta.CDLLONGLEGGEDDOJI, 'TA_CDLLONGLEGGEDDOJI', 1278 result_num = 1,1279 prices = ['open', 'high', 'low', 'close'])1280 if ind is not None:1281 imp.calculate(ind)1282 return Indicator(imp)1283 1284 TA_CDLLONGLEGGEDDOJI.__doc__ = talib.CDLLONGLEGGEDDOJI.__doc__1285 1286 def TA_CDLLONGLINE(ind=None):1287 imp = crtTaIndicatorImp(ta.CDLLONGLINE, 'TA_CDLLONGLINE', 1288 result_num = 1,1289 prices = ['open', 'high', 'low', 'close'])1290 if ind is not None:1291 imp.calculate(ind)1292 return Indicator(imp)1293 1294 TA_CDLLONGLINE.__doc__ = talib.CDLLONGLINE.__doc__ 1295 1296 def TA_CDLMARUBOZU(ind=None):1297 imp = crtTaIndicatorImp(ta.CDLMARUBOZU, 'TA_CDLMARUBOZU', 1298 result_num = 1,1299 prices = ['open', 'high', 'low', 'close'])1300 if ind is not None:1301 imp.calculate(ind)1302 return Indicator(imp)1303 1304 TA_CDLMARUBOZU.__doc__ = talib.CDLMARUBOZU.__doc__ 1305 1306 def TA_CDLMATCHINGLOW(ind=None):1307 imp = crtTaIndicatorImp(ta.CDLMATCHINGLOW, 'TA_CDLMATCHINGLOW', 1308 result_num = 1,1309 prices = ['open', 'high', 'low', 'close'])1310 if ind is not None:1311 imp.calculate(ind)1312 return Indicator(imp)1313 1314 TA_CDLMATCHINGLOW.__doc__ = talib.CDLMATCHINGLOW.__doc__1315 1316 def TA_CDLMATHOLD(ind=None, penetration=0.5):1317 imp = crtTaIndicatorImp(ta.CDLMATHOLD, 'TA_CDLMATHOLD', 1318 result_num = 1,1319 params={'penetration': penetration},1320 prices = ['open', 'high', 'low', 'close'])1321 if ind is not None:1322 imp.calculate(ind)1323 return Indicator(imp)1324 1325 TA_CDLMATHOLD.__doc__ = talib.CDLMATHOLD.__doc__1326 1327 def TA_CDLMORNINGDOJISTAR(ind=None, penetration=0.3):1328 imp = crtTaIndicatorImp(ta.CDLMORNINGDOJISTAR, 'TA_CDLMORNINGDOJISTAR', 1329 result_num = 1,1330 params={'penetration': penetration},1331 prices = ['open', 'high', 'low', 'close'])1332 if ind is not None:1333 imp.calculate(ind)1334 return Indicator(imp)1335 1336 TA_CDLMORNINGDOJISTAR.__doc__ = talib.CDLMORNINGDOJISTAR.__doc__1337 1338 def TA_CDLMORNINGSTAR(ind=None, penetration=0.3):1339 imp = crtTaIndicatorImp(ta.CDLMORNINGSTAR, 'TA_CDLMORNINGSTAR', 1340 result_num = 1,1341 params={'penetration': penetration},1342 prices = ['open', 'high', 'low', 'close'])1343 if ind is not None:1344 imp.calculate(ind)1345 return Indicator(imp) 1346 1347 TA_CDLMORNINGSTAR.__doc__ = talib.CDLMORNINGSTAR.__doc__1348 1349 def TA_CDLONNECK(ind=None):1350 imp = crtTaIndicatorImp(ta.CDLONNECK, 'TA_CDLONNECK', 1351 result_num = 1,1352 prices = ['open', 'high', 'low', 'close'])1353 if ind is not None:1354 imp.calculate(ind)1355 return Indicator(imp)1356 1357 TA_CDLONNECK.__doc__ = talib.CDLONNECK.__doc__1358 1359 def TA_CDLPIERCING(ind=None):1360 imp = crtTaIndicatorImp(ta.CDLPIERCING, 'TA_CDLPIERCING', 1361 result_num = 1,1362 prices = ['open', 'high', 'low', 'close'])1363 if ind is not None:1364 imp.calculate(ind)1365 return Indicator(imp)1366 1367 TA_CDLPIERCING.__doc__ = talib.CDLPIERCING.__doc__1368 1369 def TA_CDLRICKSHAWMAN(ind=None):1370 imp = crtTaIndicatorImp(ta.CDLRICKSHAWMAN, 'TA_CDLRICKSHAWMAN', 1371 result_num = 1,1372 prices = ['open', 'high', 'low', 'close'])1373 if ind is not None:1374 imp.calculate(ind)1375 return Indicator(imp) 1376 1377 TA_CDLRICKSHAWMAN.__doc__ = talib.CDLRICKSHAWMAN.__doc__1378 1379 def TA_CDLRISEFALL3METHODS(ind=None):1380 imp = crtTaIndicatorImp(ta.CDLRISEFALL3METHODS, 'TA_CDLRISEFALL3METHODS', 1381 result_num = 1,1382 prices = ['open', 'high', 'low', 'close'])1383 if ind is not None:1384 imp.calculate(ind)1385 return Indicator(imp)1386 1387 TA_CDLRISEFALL3METHODS.__doc__ = talib.CDLRISEFALL3METHODS.__doc__1388 1389 def TA_CDLSEPARATINGLINES(ind=None):1390 imp = crtTaIndicatorImp(ta.CDLSEPARATINGLINES, 'TA_CDLSEPARATINGLINES', 1391 result_num = 1,1392 prices = ['open', 'high', 'low', 'close'])1393 if ind is not None:1394 imp.calculate(ind)1395 return Indicator(imp)1396 1397 TA_CDLSEPARATINGLINES.__doc__ = talib.CDLSEPARATINGLINES.__doc__1398 1399 def TA_CDLSHOOTINGSTAR(ind=None):1400 imp = crtTaIndicatorImp(ta.CDLSHOOTINGSTAR, 'TA_CDLSHOOTINGSTAR', 1401 result_num = 1,1402 prices = ['open', 'high', 'low', 'close'])1403 if ind is not None:1404 imp.calculate(ind)1405 return Indicator(imp)1406 1407 TA_CDLSHOOTINGSTAR.__doc__ = talib.CDLSHOOTINGSTAR.__doc__1408 1409 def TA_CDLSHORTLINE(ind=None):1410 imp = crtTaIndicatorImp(ta.CDLSHORTLINE, 'TA_CDLSHORTLINE', 1411 result_num = 1,1412 prices = ['open', 'high', 'low', 'close'])1413 if ind is not None:1414 imp.calculate(ind)1415 return Indicator(imp)1416 1417 TA_CDLSHORTLINE.__doc__ = talib.CDLSHORTLINE.__doc__1418 1419 def TA_CDLSPINNINGTOP(ind=None):1420 imp = crtTaIndicatorImp(ta.CDLSPINNINGTOP, 'TA_CDLSPINNINGTOP', 1421 result_num = 1,1422 prices = ['open', 'high', 'low', 'close'])1423 if ind is not None:1424 imp.calculate(ind)1425 return Indicator(imp)1426 1427 TA_CDLSPINNINGTOP.__doc__ = talib.CDLSPINNINGTOP.__doc__1428 1429 def TA_CDLSTALLEDPATTERN(ind=None):1430 imp = crtTaIndicatorImp(ta.CDLSTALLEDPATTERN, 'TA_CDLSTALLEDPATTERN', 1431 result_num = 1,1432 prices = ['open', 'high', 'low', 'close'])1433 if ind is not None:1434 imp.calculate(ind)1435 return Indicator(imp)1436 1437 TA_CDLSTALLEDPATTERN.__doc__ = talib.CDLSTALLEDPATTERN.__doc__1438 1439 def TA_CDLSTICKSANDWICH(ind=None):1440 imp = crtTaIndicatorImp(ta.CDLSTICKSANDWICH, 'TA_CDLSTICKSANDWICH', 1441 result_num = 1,1442 prices = ['open', 'high', 'low', 'close'])1443 if ind is not None:1444 imp.calculate(ind)1445 return Indicator(imp)1446 1447 TA_CDLSTICKSANDWICH.__doc__ = talib.CDLSTICKSANDWICH.__doc__ 1448 1449 def TA_CDLTAKURI(ind=None):1450 imp = crtTaIndicatorImp(ta.CDLTAKURI, 'TA_CDLTAKURI', 1451 result_num = 1,1452 prices = ['open', 'high', 'low', 'close'])1453 if ind is not None:1454 imp.calculate(ind)1455 return Indicator(imp)1456 1457 TA_CDLTAKURI.__doc__ = talib.CDLTAKURI.__doc__ 1458 1459 def TA_CDLTASUKIGAP(ind=None):1460 imp = crtTaIndicatorImp(ta.CDLTASUKIGAP, 'TA_CDLTASUKIGAP', 1461 result_num = 1,1462 prices = ['open', 'high', 'low', 'close'])1463 if ind is not None:1464 imp.calculate(ind)1465 return Indicator(imp)1466 1467 TA_CDLTASUKIGAP.__doc__ = talib.CDLTASUKIGAP.__doc__ 1468 1469 def TA_CDLTHRUSTING(ind=None):1470 imp = crtTaIndicatorImp(ta.CDLTHRUSTING, 'TA_CDLTHRUSTING', 1471 result_num = 1,1472 prices = ['open', 'high', 'low', 'close'])1473 if ind is not None:1474 imp.calculate(ind)1475 return Indicator(imp)1476 1477 TA_CDLTHRUSTING.__doc__ = talib.CDLTHRUSTING.__doc__1478 1479 def TA_CDLTRISTAR(ind=None):1480 imp = crtTaIndicatorImp(ta.CDLTRISTAR, 'TA_CDLTRISTAR', 1481 result_num = 1,1482 prices = ['open', 'high', 'low', 'close'])1483 if ind is not None:1484 imp.calculate(ind)1485 return Indicator(imp) 1486 1487 TA_CDLTRISTAR.__doc__ = talib.CDLTRISTAR.__doc__1488 1489 def TA_CDLUNIQUE3RIVER(ind=None):1490 imp = crtTaIndicatorImp(ta.CDLUNIQUE3RIVER, 'TA_CDLUNIQUE3RIVER', 1491 result_num = 1,1492 prices = ['open', 'high', 'low', 'close'])1493 if ind is not None:1494 imp.calculate(ind)1495 return Indicator(imp)1496 1497 TA_CDLUNIQUE3RIVER.__doc__ = talib.CDLUNIQUE3RIVER.__doc__1498 1499 def TA_CDLUPSIDEGAP2CROWS(ind=None):1500 imp = crtTaIndicatorImp(ta.CDLUPSIDEGAP2CROWS, 'TA_CDLUPSIDEGAP2CROWS', 1501 result_num = 1,1502 prices = ['open', 'high', 'low', 'close'])1503 if ind is not None:1504 imp.calculate(ind)1505 return Indicator(imp)1506 1507 TA_CDLUPSIDEGAP2CROWS.__doc__ = talib.CDLUPSIDEGAP2CROWS.__doc__1508 1509 def TA_CDLXSIDEGAP3METHODS(ind=None):1510 imp = crtTaIndicatorImp(ta.CDLXSIDEGAP3METHODS, 'TA_CDLXSIDEGAP3METHODS', 1511 result_num = 1,1512 prices = ['open', 'high', 'low', 'close'])1513 if ind is not None:1514 imp.calculate(ind)1515 return Indicator(imp)1516 1517 TA_CDLXSIDEGAP3METHODS.__doc__ = talib.CDLXSIDEGAP3METHODS.__doc__1518 1519 def TA_BETA(ind=None, timeperiod=5):1520 imp = crtTaIndicatorImp(ta.BETA, 'TA_BETA', 1521 result_num = 1,1522 params={'timeperiod': timeperiod})1523 if ind is not None:1524 imp.calculate(ind)1525 return Indicator(imp) 1526 1527 TA_BETA.__doc__ = talib.BETA.__doc__1528 1529 def TA_CORREL(ind=None, timeperiod=30):1530 imp = crtTaIndicatorImp(ta.CORREL, 'TA_CORREL', 1531 result_num = 1,1532 params={'timeperiod': timeperiod})1533 if ind is not None:1534 imp.calculate(ind)1535 return Indicator(imp) 1536 1537 TA_CORREL.__doc__ = talib.CORREL.__doc__1538 1539 def TA_OBV(ind=None):1540 imp = crtTaIndicatorImp(ta.OBV, 'TA_OBV', 1541 result_num = 1)1542 if ind is not None:1543 imp.calculate(ind)1544 return Indicator(imp)1545 1546 TA_OBV.__doc__ = talib.OBV.__doc__ 1547 1548except:...

Full Screen

Full Screen

core_doc.py

Source:core_doc.py Github

copy

Full Screen

1#!/usr/bin/python2# -*- coding: utf8 -*-3# cp9364#5# The MIT License (MIT)6#7# Copyright (c) 2010-2017 fasiondog8#9# Permission is hereby granted, free of charge, to any person obtaining a copy10# of this software and associated documentation files (the "Software"), to deal11# in the Software without restriction, including without limitation the rights12# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell13# copies of the Software, and to permit persons to whom the Software is14# furnished to do so, subject to the following conditions:15#16# The above copyright notice and this permission notice shall be included in all17# copies or substantial portions of the Software.18#19# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR20# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,21# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE22# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER23# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,24# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE25# SOFTWARE.26from hikyuu._hikyuu import *27#------------------------------------------------------------------28# from _DataType.cpp29#------------------------------------------------------------------30DatetimeList.__doc__ = """日期序列,对应C++中的std::vector<Datetime>"""31PriceList.__doc__ ="""价格序列,其中价格使用double表示,对应C++中的std::vector<double>。"""32toPriceList.__doc__ += """\n33将Python的可迭代对象如 list、tuple 转化为 PriceList34 35 :param arg: 待转化的Python序列36 :rtype: PriceList37"""38StringList.__doc__ = """字符串列表,对应C++中的std::vector<String>"""39#------------------------------------------------------------------40# from _Datetime.cpp41#------------------------------------------------------------------42Datetime.__doc__ = """日期时间类,精确到秒"""43Datetime.dayOfWeek.__doc__ = """44dayOfWeek(self)45 46 返回是一周中的第几天,周日为0,周一为147 48 :rtype: int49"""50Datetime.dayOfYear.__doc__ = """51dayOfYear(self)52 53 返回一年中的第几天,1月1日为一年中的第1天54 55 :rtype: int56"""57Datetime.endOfMonth.__doc__ = """58endOfMonth(self)59 60 返回月末最后一天日期61"""62Datetime.nextDay.__doc__ = """63nextDay(self)64 65 返回下一自然日66"""67Datetime.max.__doc__ += """68获取支持的最大日期69"""70Datetime.min.__doc__ += """71获取支持的最小日期"""72Datetime.now.__doc__ += """73获取当前日期时间"""74getDateRange.__doc__ += """\n75获取指定 [start, end) 日期时间范围的自然日日历日期列表,仅支持到日76:param Datetime start: 起始日期77:param Datetime end: 结束日期78:rtype: DatetimeList79"""80#------------------------------------------------------------------81# from _util.cpp82#------------------------------------------------------------------83roundUp.__doc__ = """84roundUp(arg1[, arg2=0])85 向上截取,如10.1截取后为1186 87 :param float arg1: 待处理数据88 :param int arg2: 保留小数位数89 :return: 处理过的数据90"""91roundDown.__doc__ = """92roundDown(arg1[, arg2=0])93 向下截取,如10.1截取后为1094 95 :param float arg1: 待处理数据96 :param int arg2: 保留小数位数97 :return: 处理过的数据98"""99#------------------------------------------------------------------100# from _MarketInfo.cpp101#------------------------------------------------------------------102MarketInfo.__doc__ = """103 市场信息记录104 105 .. py:attribute:: market : 市场简称(如:沪市“SH”, 深市“SZ”)106 .. py:attribute:: name : 市场全称107 .. py:attribute:: description :描述说明108 .. py:attribute:: code : 该市场对应的主要指数,用于获取交易日历109 .. py:attribute:: lastDate : 该市场K线数据最后交易日期110"""111#------------------------------------------------------------------112# from _StockTypeInfo.cpp113#------------------------------------------------------------------114StockTypeInfo.__doc__ = """115 股票类型详情记录116 117 .. py:attribute:: type : 证券类型118 .. py:attribute:: description : 描述信息119 .. py:attribute:: tick : 最小跳动量120 .. py:attribute:: tickValue : 每一个tick价格121 .. py:attribute:: unit : 每最小变动量价格,即单位价格 = tickValue/tick122 .. py:attribute:: precision : 价格精度123 .. py:attribute:: minTradeNumber : 每笔最小交易量124 .. py:attribute:: maxTradeNumber : 每笔最大交易量125"""126#------------------------------------------------------------------127# from _StockWeight.cpp128#------------------------------------------------------------------129StockWeight.__doc__ = """130 权息记录131 132 .. py:attribute:: datetime : 权息日期133 .. py:attribute:: countAsGift : 每10股送X股134 .. py:attribute:: countForSell : 每10股配X股135 .. py:attribute:: priceForSell : 配股价136 .. py:attribute:: bonus : 每10股红利137 .. py:attribute:: increasement : 每10股转增X股138 .. py:attribute:: totalCount : 总股本(万股)139 .. py:attribute:: freeCount : 流通股(万股)140"""141StockWeightList.__doc__ = """std::vector<StockWeight> 包装"""142#------------------------------------------------------------------143# from _StockManager.cpp144#------------------------------------------------------------------145StockManager.__doc__ = """证券信息管理类"""146StockManager.instance.__doc__ = """147instance()148 149 获取StockManager单例实例150"""151StockManager.tmpdir.__doc__ = """152tmpdir()153 获取用于保存零时变量等的临时目录,如未配置则为当前目录 由m_config中的“tmpdir”指定154"""155StockManager.getAllMarket.__doc__ = """156getAllMarket()157 158 获取市场简称列表159 160 :rtype: StringList161"""162StockManager.getMarketInfo.__doc__ = """163getMarketInfo(market)164 165 获取相应的市场信息166 167 :param string market: 指定的市场标识(市场简称)168 :return: 相应的市场信息,如果相应的市场信息不存在,则返回Null<MarketInfo>()169 :rtype: MarketInfo170"""171StockManager.getStockTypeInfo.__doc__ = """172getStockTypeInfo(stk_type)173 获取相应的证券类型详细信息174 175 :param int stk_type: 证券类型,参见: :py:data:`constant`176 :return: 对应的证券类型信息,如果不存在,则返回Null<StockTypeInfo>()177 :rtype: StockTypeInfo178"""179StockManager.size.__doc__ = """\n180size()181 182 获取证券数量183"""184StockManager.__len__.__doc__ = """\n185 获取证券数量186"""187StockManager.getStock.__doc__ = """188getStock(querystr)189 根据"市场简称证券代码"获取对应的证券实例190 191 :param str querystr: 格式:“市场简称证券代码”,如"sh000001"192 :return: 对应的证券实例,如果实例不存在,则Null<Stock>(),不抛出异常193 :rtype: Stock194"""195StockManager.__getitem__.__doc__ = """196同 getStock197"""198StockManager.getBlock.__doc__ = """199getBlock(category, name)200 获取预定义的板块201 202 :param str category: 板块分类203 :param str name: 板块名称204 :return: 板块,如找不到返回空Block205 :rtype: Block206"""207StockManager.getBlockList.__doc__ = """208getBlockList([category])209 获取指定分类的板块列表210 211 :param str category: 板块分类212 :return: 板块列表213 :rtype: BlockList214"""215StockManager.getTradingCalendar.__doc__ = """216getTradingCalendar(query[, market='SH'])217 218 获取指定市场的交易日日历219 220 :param KQuery query: Query查询条件221 :param str market: 市场简称222 :return: 日期列表223 :rtype: DatetimeList224"""225StockManager.addTempCsvStock.__doc__ = """226addTempCsvStock(code, day_filename, min_filename[, tick=0.01, tickValue=0.01, precision=2, minTradeNumber = 1, maxTradeNumber=1000000])227 从CSV文件(K线数据)增加临时的Stock,可用于只有CSV格式的K线数据时,进行临时测试。 228 229 CSV文件第一行为标题,需含有 Datetime(或Date、日期)、OPEN(或开盘价)、HIGH(或最高价)、LOW(或最低价)、CLOSE(或收盘价)、AMOUNT(或成交金额)、VOLUME(或VOL、COUNT、成交量)。230 231 :param str code: 自行编号的证券代码,不能和已有的Stock相同,否则将返回Null<Stock>232 :param str day_filename: 日线CSV文件名233 :param str min_filename: 分钟线CSV文件名234 :param float tick: 最小跳动量,默认0.01235 :param float tickValue: 最小跳动量价值,默认0.01236 :param int precision: 价格精度,默认2237 :param int minTradeNumber: 单笔最小交易量,默认1238 :param int maxTradeNumber: 单笔最大交易量,默认1000000239 :return: 加入的Stock240 :rtype: Stock241"""242StockManager.removeTempCsvStock.__doc__ = """243removeTempCsvStock(code)244 245 移除增加的临时Stock246 247 :param str code: 创建时自定义的编码248"""249#------------------------------------------------------------------250# from _KQuery.cpp251#------------------------------------------------------------------252KQueryByDate.__doc__ = """253KQueryByDate(start, end, kType, recoverType)254 构建按日期 [start, end) 方式获取K线数据条件255 256 :param Datetime start: 起始日期257 :param Datetime end: 结束日期258 :param KQuery.KType kType: K线数据类型(如日线、分钟线等)259 :param KQuery.RecoverType recoverType: 复权类型260 :return: 查询条件261 :rtype: KQuery262"""263KQueryByIndex.__doc__ = """264KQueryByIndex(start, end, kType, recoverType)265 构建按索引 [start, end) 方式获取K线数据条件,等同于直接使用 Query 构造266 267 :param ind start: 起始日期268 :param ind end: 结束日期269 :param KQuery.KType kType: K线数据类型(如日线、分钟线等)270 :param KQuery.RecoverType recoverType: 复权类型271 :return: 查询条件272 :rtype: KQuery273"""274KQuery.__doc__ = """K线数据查询条件,一般在Python中使用 Query 即可,不用指明 KQuery"""275KQuery.getQueryTypeName.__doc__ = """276getQueryTypeName(queryType)277 获取queryType名称,用于显示输出278 279 :param KQuery.QueryType queryType: 查询类型280 :rtype: str281"""282KQuery.getKTypeName.__doc__ = """283getKTypeName(kType)284 285 获取KType名称,用于显示输出286 287 :param KQuery.KType kType: K线类型288 :rtype: str289"""290KQuery.getRecoverTypeName.__doc__ = """291getRecoverTypeName(recoverType)292 293 获取recoverType名称,用于显示输出294 295 :param KQuery.RecoverType recoverType: 复权类型296 :rtype: str297"""298KQuery.getQueryTypeEnum.__doc__ = """299getQueryTypeEnum(queryType)300 301 根据字符串名称获取相应的queryType枚举值302 303 :param str queryType: 字符串名称,如“DATE”304 :rtype: KQuery.QueryType305"""306KQuery.getKTypeEnum.__doc__ = """307getKTypeEnum(ktype)308 309 根据字符串名称,获取相应的枚举值 310 311 :param str ktype: 字符串名称,如“DAY”312 :rtype: KQuery.KType313"""314KQuery.getRecoverTypeEnum.__doc__ = """315getRecoverTypeEnum(recoverType)316 根据字符串名称,获取相应的枚举值317 318 :param str recoverType: 字符串名称,如“NO_RECOVER”319 :rtype: KQuery.RecoverType320"""321KQuery.QueryType.__doc__ = """322- DATE - 按日期方式查询323- INDEX - 按索引方式查询324"""325KQuery.KType.__doc__ = """326K线类型枚举定义327- DAY - 日线类型328- WEEK - 周线类型329- MONTH - 月线类型330- QUARTER - 季线类型 331- HALFYEAR - 半年线类型 332- YEAR - 年线类型 333- MIN - 1分钟线类型334- MIN5 - 5分钟线类型335- MIN15 - 15分钟线类型336- MIN30 - 30分钟线类型337- MIN60 - 60分钟线类型 338"""339KQuery.RecoverType.__doc__ = """340K线复权类别枚举定义341- NO_RECOVER - 不复权342- FORWARD - 前向复权343- BACKWARD - 后向复权344- EQUAL_FORWARD - 等比前向复权345- EQUAL_BACKWARD - 等比后向复权 346"""347KQuery.start.__doc__ = """348起始索引,当按日期查询方式创建时无效,为 constant.null_int64349"""350KQuery.end.__doc__ = """351结束索引,当按日期查询方式创建时无效,为 constant.null_int64352"""353KQuery.startDatetime.__doc__ = """354起始日期,当按索引查询方式创建时无效,为 constant.null_datetime355"""356KQuery.endDatetime.__doc__ = """357结束日期,当按索引查询方式创建时无效,为 constant.null_datetime358"""359KQuery.queryType.__doc__ = """360查询方式361"""362KQuery.kType.__doc__ = """363查询的K线类型364"""365KQuery.recoverType.__doc__ = """366查询的复权类型367"""368#------------------------------------------------------------------369# from _KRecord.cpp370#------------------------------------------------------------------371KRecord.__doc__ = """K线记录,组成K线数据,属性可读写"""372KRecord.datetime.__doc__ = """日期时间"""373KRecord.openPrice.__doc__ = """开盘价"""374KRecord.highPrice.__doc__ = """最高价"""375KRecord.lowPrice.__doc__ = """最低价"""376KRecord.closePrice.__doc__ = """收盘价"""377KRecord.transAmount.__doc__ = """成交金额"""378KRecord.transCount.__doc__ = """成交量"""379KRecordList.__doc__ = """C++ std::vector<KRecord>包装"""380#------------------------------------------------------------------381# from _KData.cpp382#------------------------------------------------------------------383KData.__doc__ = """384通过 Stock.getKData 获取的K线数据,由 KRecord 组成的数组,可象 list 一样进行遍历385"""386KData.startPos.__doc__ = """387获取在原始K线记录中对应的起始位置,如果KData为空返回0388"""389KData.endPos.__doc__ = """390获取在原始K线记录中对应范围的下一条记录的位置,如果为空返回0,其他等于lastPos + 1391"""392KData.lastPos.__doc__ = """393获取在原始K线记录中对应的最后一条记录的位置,如果为空返回0,其他等于endPos - 1394"""395KData.getDatetimeList.__doc__ = """396getDatetimeList()397 398 返回交易日期列表399 :rtype: DatetimeList400"""401KData.getKRecord.__doc__ = """402getKRecord(pos)403 404 获取指定索引位置的K线记录405 406 :param int pos: 位置索引407 :rtype: KRecord408"""409KData.get.__doc__ = """410get(pos)411 同 getKRecord。获取指定索引位置的K线记录412 413 :param int pos: 位置索引414 :rtype: KRecord 415"""416KData.getKRecordByDate.__doc__ = """417getKRecordByDate(datetime)418 获取指定时间的K线记录419 420 :param Datetime datetime: 指定的日期421 :rtype: KRecord422"""423KData.getByDate.__doc__ = """424getByDate(datetime) 425 获取指定时间的K线记录。同 getKRecordByDate。426 427 :param Datetime datetime: 指定的日期428 :rtype: KRecord429"""430KData.size.__doc__ = """431size()432 433 K线记录数量,同 __len__434"""435KData.empty.__doc__ = """436empty()437 438 判断是否为空439 440 :rtype: bool441"""442KData.getQuery.__doc__ = """443getQuery()444 445 获取关联的查询条件446 447 :rtype: KQuery448"""449KData.getStock.__doc__ = """450getStock()451 452 获取关联的Stock453 454 :rtype: Stock455"""456KData.tocsv.__doc__ = """457tocsv(filename)458 459 将数据保存至CSV文件460 461 :param str filename: 指定保存的文件名称462"""463#------------------------------------------------------------------464# from _Stock.cpp465#------------------------------------------------------------------466Stock.market.__doc__ = """获取所属市场简称,市场简称是市场的唯一标识"""467Stock.code.__doc__ = """获取证券代码"""468Stock.market_code.__doc__ = """市场简称+证券代码,如: sh000001"""469Stock.name.__doc__ = """获取证券名称"""470Stock.type.__doc__ = """获取证券类型,参见::py:data:`constant`"""471Stock.valid.__doc__ = """该证券当前是否有效"""472Stock.startDatetime.__doc__ = """证券起始日期"""473Stock.lastDatetime.__doc__ = """证券最后日期"""474Stock.tick.__doc__ = """最小跳动量"""475Stock.tickValue.__doc__ = """最小跳动量价值"""476Stock.unit.__doc__ = """每单位价值 = tickValue / tick"""477Stock.precision.__doc__ = """价格精度"""478Stock.atom.__doc__ = """最小交易数量,同minTradeNumber"""479Stock.minTradeNumber.__doc__ = """最小交易数量"""480Stock.maxTradeNumber.__doc__ = """最大交易数量"""481Stock.isNull.__doc__ = """482isNull()483 484 是否为Null485 486 :rtype: bool487"""488Stock.getKData.__doc__ = """489getKData(query)490 491 获取K线数据492 493 :param Query query: 查询条件494 :return: 满足查询条件的K线数据495 :rtype: KData496"""497Stock.getCount.__doc__ = """498getCount([ktype=Query.DAY])499 500 获取不同类型K线数据量501 502 :param KQuery.KType ktype: K线数据类别503 :return: K线记录数504 :rtype: int505"""506Stock.getMarketValue.__doc__ = """507getMarketValue(datetime, ktype)508 509 获取指定时刻的市值,即小于等于指定时刻的最后一条记录的收盘价510 511 :param Datetime datetime: 指定时刻512 :param KQuery.KType ktype: K线数据类别513 :return: 指定时刻的市值514 :rtype: float515"""516Stock.getKRecord.__doc__ = """517getKRecord(pos[, ktype=Query.DAY])518 519 获取指定索引的K线数据记录,未作越界检查520 521 :param int pos: 指定的索引位置522 :param KQuery.KType ktype: K线数据类别523 :return: K线记录524 :rtype: KRecord525"""526Stock.getKRecordByDate.__doc__ = """527getKRecordByDate(datetime[, ktype=Query.DAY])528 529 根据数据类型(日线/周线等),获取指定时刻的KRecord530 531 :param Datetime datetime: 指定日期时刻532 :param KQuery.KType ktype: K线数据类别533 :return: K线记录534 :rtype: KRecord535"""536Stock.getKRecordList.__doc__ = """537getKRecordList(start, end, ktype)538 539 获取K线记录 [start, end),一般不直接使用,用getKData替代540 541 :param int start: 起始位置542 :param int end: 结束位置543 :param KQuery.KType ktype: K线类别544 :return: K线记录列表545 :rtype: KRecordList546"""547Stock.getDatetimeList.__doc__ = """548getDatetimeList(query)549 550 获取日期列表551 552 :param Query query: 查询条件553 :rtype: DatetimeList554 555getDatetimeList(start, end, ktype)556 557 获取日期列表558 559 :param int start: 起始位置560 :param ind end: 结束位置561 :param KQuery.KType ktype: K线类型562 :rtype: DatetimeList 563"""564Stock.getWeight.__doc__ = """565getWeight([start, end])566 567 获取指定时间段[start,end)内的权息信息。未指定起始、结束时刻时,获取全部权息记录。568 569 :param Datetime start: 起始时刻570 :param Datetime end: 结束时刻571 :rtype: StockWeightList572"""573Stock.realtimeUpdate.__doc__ = """574realtimeUpdate(krecord)575 576 (临时函数)只用于更新缓存中的日线数据577 578 :param KRecord krecord: 新增的实时K线记录579"""580Stock.loadKDataToBuffer.__doc__ = """581loadKDataToBuffer(ktype)582 583 将指定类别的K线数据加载至内存缓存584 585 :param KQuery.KType ktype: K线类型586"""587Stock.releaseKDataBuffer.__doc__ = """588releaseKDataBuffer(ktype)589 590 释放指定类别的内存K线数据591 592 :param KQuery.KType ktype: K线类型593"""594#------------------------------------------------------------------595# from _Block.cpp596#------------------------------------------------------------------597BlockList.__doc__ = """C++ std::vector<Block>包装"""598Block.__doc__ = """板块类,可视为证券的容器"""599Block.category.__doc__ = """板块分类,可读写"""600Block.name.__doc__ = """板块名称,可读写"""601Block.size.__doc__ = """602size()603 604 包含的证券数量605"""606Block.empty.__doc__ = """607empty()608 609 是否为空610"""611Block.add.__doc__ = """612add(stock)613 614 加入指定的证券615 616 :param Stock stock: 待加入的证券617 :return: 是否成功加入618 :rtype: bool619 620add(market_code)621 622 根据"市场简称证券代码"加入指定的证券623 624 :param str market_code: 市场简称证券代码625 :return: 是否成功加入626 :rtype: bool 627"""628Block.remove.__doc__ = """629remove(stock)630 631 移除指定证券632 633 :param Stock stock: 指定的证券634 :return: 是否成功635 :rtype: bool636 637remove(market_code)638 639 移除指定证券640 641 :param str market_code: 市场简称证券代码642 :return: 是否成功643 :rtype: bool 644"""645Block.clear.__doc__ = """移除包含的所有证券"""646Block.__len__.__doc__ = """包含的证券数量"""647#------------------------------------------------------------------648# from _save_load.cpp649#------------------------------------------------------------------650hku_save.__doc__ = """651hku_save(var, filename)652 序列化,将hikyuu内建类型的变量(如Stock、TradeManager等)保存在指定的文件中,格式为XML。653 654 :param var: hikyuu内建类型的变量655 :param str filename: 指定的文件名656"""657hku_load.__doc__ = """658hku_load(var, filename)659 将通过 hku_save 保存的变量,读取到var中。660 661 :param var: 指定的变量662 :param str filename: 待载入的序列化文件。...

Full Screen

Full Screen

trade_doc.py

Source:trade_doc.py Github

copy

Full Screen

1#!/usr/bin/python2# -*- coding: utf8 -*-3# cp9364#5# The MIT License (MIT)6#7# Copyright (c) 2010-2017 fasiondog8#9# Permission is hereby granted, free of charge, to any person obtaining a copy10# of this software and associated documentation files (the "Software"), to deal11# in the Software without restriction, including without limitation the rights12# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell13# copies of the Software, and to permit persons to whom the Software is14# furnished to do so, subject to the following conditions:15#16# The above copyright notice and this permission notice shall be included in all17# copies or substantial portions of the Software.18#19# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR20# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,21# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE22# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER23# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,24# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE25# SOFTWARE.26from .trade import *27from hikyuu.trade_manage._trade_manage import CostRecord, TradeCostBase,\28 PositionRecord, FundsRecord, TradeManager29#------------------------------------------------------------------30# CostRecord31#------------------------------------------------------------------32CostRecord.__doc__ = """交易成本记录"""33CostRecord.commission.__doc__ = """佣金(float)"""34CostRecord.stamptax.__doc__ = """印花税(float)"""35CostRecord.transferfee.__doc__ = """过户费(float)"""36CostRecord.others.__doc__ = """其它费用(float)"""37CostRecord.total.__doc__ = """总成本(float),= 佣金 + 印花税 + 过户费 + 其它费用"""38#------------------------------------------------------------------39# PositionRecord40#------------------------------------------------------------------41PositionRecord.__doc__ = """持仓记录"""42PositionRecord.stock.__doc__ = """交易对象(Stock)"""43PositionRecord.takeDatetime.__doc__ = """初次建仓时刻(Datetime)"""44PositionRecord.cleanDatetime.__doc__ = """平仓日期,当前持仓记录中为 constant.null_datetime"""45PositionRecord.number.__doc__ = """当前持仓数量(int)"""46PositionRecord.stoploss.__doc__ = """当前止损价(float)"""47PositionRecord.goalPrice.__doc__ = """当前的目标价格(float)"""48PositionRecord.totalNumber.__doc__ = """累计持仓数量(int)"""49PositionRecord.buyMoney.__doc__ = """累计买入资金(float)"""50PositionRecord.totalCost.__doc__ = """累计交易总成本(float)"""51PositionRecord.totalRisk.__doc__ = """累计交易风险(float) = 各次 (买入价格-止损)*买入数量, 不包含交易成本"""52PositionRecord.sellMoney.__doc__ = """累计卖出资金(float)"""53PositionRecordList.__doc__ = """持仓记录列表,C++ std::vector<PositionRecord>包装"""54#------------------------------------------------------------------55# TradeCost56#------------------------------------------------------------------57TradeCostBase.__doc__ = """58交易成本算法基类59实现自定义交易成本算法接口:60* :py:meth:`TradeCostBase.getBuyCost` - 【必须】获取买入成本61* :py:meth:`TradeCostBase.getSellCost` - 【必须】获取卖出成本62* :py:meth:`TradeCostBase._clone` - 【必须】子类克隆接口63"""64TradeCostBase.name.__doc__ = """交易算法名称"""65TradeCostBase.getParam.__doc__ = """66getParam(self, name)67 获取指定的参数68 69 :param str name: 参数名称70 :return: 参数值71 :raises out_of_range: 无此参数72"""73TradeCostBase.setParam.__doc__ = """74setParam(self, name, value)75 76 设置参数77 78 :param str name: 参数名称79 :param value: 参数值80 :type value: int | bool | float | string81 :raises logic_error: Unsupported type! 不支持的参数类型82"""83TradeCostBase.clone.__doc__ = """84clone(self)85 86 克隆操作87"""88TradeCostBase.getBuyCost.__doc__ = """89getBuyCost(self, datetime, stock, price, num)90 91 【重载接口】获取买入成本92 93 :param Datetime datetime: 买入时刻94 :param Stock stock: 买入对象95 :param float price: 买入价格96 :param size_t num: 买入数量97 :return: 交易成本记录98 :rtype: CostRecord99"""100TradeCostBase.getSellCost.__doc__ = """101getSellCost(self, datetime, stock, price, num)102 103 【重载接口】获取卖出成本104 105 :param Datetime datetime: 卖出时刻106 :param Stock stock: 卖出对象107 :param float price: 卖出价格108 :param int num: 卖出数量109 :return: 交易成本记录110 :rtype: CostRecord111"""112TradeCostBase._clone.__doc__ = """113_clone(self)114 115 【重载接口】子类克隆接口116"""117#------------------------------------------------------------------118# FundsRecord119#------------------------------------------------------------------120FundsRecord.__doc__ = """当前资产情况记录,由TradeManager.getFunds返回"""121FundsRecord.cash.__doc__ = """当前现金(float)"""122FundsRecord.market_value.__doc__ = """当前多头市值(float)"""123FundsRecord.short_market_value.__doc__ = """当前空头仓位市值(float)"""124FundsRecord.base_cash.__doc__ = """当前投入本金(float)"""125FundsRecord.base_asset.__doc__ = """当前投入的资产价值(float)"""126FundsRecord.borrow_cash.__doc__ = """当前借入的资金(float),即负债"""127FundsRecord.borrow_asset.__doc__ = """当前借入证券资产价值(float)"""128#------------------------------------------------------------------129# OrderBroker130#------------------------------------------------------------------131OrderBrokerBase.__doc__ = """132Python中非必须使用 OrderBrokerBase 来实现自定义的订单代理。只要 Python 的对象133包含 buy、sell方法,其方法参数规则与 :py:class:`OrderBrokerWrap` 中的 _buy、134_sell 方法相同,即可参见前一章节快速创建订单代理实例。135自定义订单代理接口:136* :py:meth:`OrderBrokerBase._buy` - 【必须】执行实际买入操作137* :py:meth:`OrderBrokerBase._sell` - 【必须】执行实际卖出操作138"""139OrderBrokerBase.name.__doc__ = """名称(可读写)"""140OrderBrokerBase.buy.__doc__ = """141buy(self, code, price, num)142 执行买入操作143 144 :param str code: 证券代码145 :param float price: 买入价格146 :param int num: 买入数量147 :return: 买入操作的执行时刻148 :rtype: Datetime149"""150OrderBrokerBase.sell.__doc__ = """151sell(self, code, price, num)152 153 执行买入操作154 155 :param str code: 证券代码156 :param float price: 买入价格157 :param int num: 买入数量158 :return: 卖出操作的执行时刻159 :rtype: Datetime160"""161OrderBrokerBase._buy.__doc__ = """162_buy(self, code, price, num)163 【重载接口】执行实际买入操作164 165 :param str code: 证券代码166 :param float price: 买入价格167 :param int num: 买入数量168"""169OrderBrokerBase._sell.__doc__ = """170_sell(self, code, price, num)171 172 【重载接口】执行实际买入操作173 174 :param str code: 证券代码175 :param float price: 买入价格176 :param int num: 买入数量177"""178#------------------------------------------------------------------179# TradeManager180#------------------------------------------------------------------181TradeManager.__doc__ = """182交易管理类,可理解为一个模拟账户进行模拟交易。一般使用 crtTM 创建交易管理实例。183公共参数:184 reinvest=False (bool) : 红利是否再投资185 precision=2 (int) : 金额计算精度186 support_borrow_cash=False (bool) : 是否自动融资187 support_borrow_stock=False (bool) : 是否自动融券188 save_action=True (bool) : 是否保存Python命令序列189"""190TradeManager.__init__.__doc__ = """191__init__(self, datetime, initcash, costfunc, name)192 193 初始化构造函数194 195 :param Datetime datetime: 账户建立日期196 :param float initCash: 初始资金197 :param TradeCostBase costFunc: 成本算法198 :param str name: 账户名称199"""200TradeManager.name.__doc__ = """名称"""201TradeManager.initCash.__doc__ = """(只读)初始资金"""202TradeManager.initDatetime.__doc__ = """(只读)账户建立日期"""203TradeManager.costFunc.__doc__ = """交易成本算法"""204TradeManager.firstDatetime.__doc__ = """205(只读)第一笔买入交易发生日期,如未发生交易返回 null_datetime206"""207TradeManager.lastDatetime.__doc__ = """208(只读)最后一笔交易日期,注意和交易类型无关,如未发生交易返回账户建立日期209"""210TradeManager.reinvest.__doc__ = """211(只读)红利/股息/送股再投资标志,同公共参数“reinvest”212"""213TradeManager.precision.__doc__ = """214(只读)价格精度,同公共参数“precision”215"""216TradeManager.brokeLastDatetime.__doc__ = """217实际开始订单代理操作的时刻。218 219默认情况下,TradeManager会在执行买入/卖出操作时,调用订单代理执行代理的买入/卖出动作,220但这样在实盘操作时会存在问题。因为系统在计算信号指示时,需要回溯历史数据才能得到最新的221信号,这样TradeManager会在历史时刻就执行买入/卖出操作,此时如果订单代理本身没有对发出222买入/卖出指令的时刻进行控制,会导致代理发送错误的指令。此时,需要指定在某一个时刻之后,223才允许指定订单代理的买入/卖出操作。属性 brokeLastDatetime 即用于指定该时刻。224"""225TradeManager.getParam.__doc__ = """226getParam(self, name)227 获取指定的参数228 229 :param str name: 参数名称230 :return: 参数值231 :raises out_of_range: 无此参数232"""233TradeManager.setParam.__doc__ = """234setParam(self, name, value)235 236 设置参数237 238 :param str name: 参数名称239 :param value: 参数值240 :type value: int | bool | float | string241 :raises logic_error: Unsupported type! 不支持的参数类型242"""243TradeManager.reset.__doc__ = """244reset(self)245 246 复位,清空交易、持仓记录247"""248TradeManager.clone.__doc__ = """249clone(self)250 克隆(深复制)实例251 252 :rtype: TradeManager253"""254TradeManager.regBroker.__doc__ = """255regBroker(self, broker)256 257 注册订单代理。可执行多次该命令注册多个订单代理。258 259 :param OrderBrokerBase broker: 订单代理实例260"""261TradeManager.clearBroker.__doc__ = """262clearBroker(self)263 清空所有已注册订单代理264"""265TradeManager.have.__doc__ = """266have(self, stock)267 268 当前是否持有指定的证券269 270 :param Stock stock: 指定证券271 :rtype: bool272"""273TradeManager.getStockNumber.__doc__ = """274getStockNumber(self)275 276 当前持有的证券种类数量,即当前持有几只股票(非各个股票的持仓数)277 278 :rtype: int279"""280TradeManager.getHoldNumber.__doc__ = """281getHoldNumber(self, datetime, stock)282 获取指定时刻指定证券的持有数量283 284 :param Datetime datetime: 指定时刻285 :param Stock stock: 指定的证券286 :rtype: int287"""288TradeManager.getTradeList.__doc__ = """289getTradeList(self)290getTradeList(self, start, end)291 292 获取交易记录,未指定参数时,获取全部交易记录293 294 :param Datetime start: 起始日期295 :param Datetime end: 结束日期296 :rtype: TradeRecordList297"""298TradeManager.getPositionList.__doc__ = """299getPositionList(self)300 301 获取当前全部持仓记录302 303 :rtype: PositionRecordList304"""305TradeManager.getHistoryPositionList.__doc__ = """306getHistoryPositionList(self)307 308 获取全部历史持仓记录,即已平仓记录309 310 :rtype: PositionRecordList311"""312TradeManager.getPosition.__doc__ = """313getPosition(self, stock)314 获取指定证券的当前持仓记录,如当前未持有该票,返回PositionRecord()315 316 :param Stock stock: 指定的证券317 :rtype: PositionRecord318"""319TradeManager.getBuyCost.__doc__ = """320getBuyCost(self, datetime, stock, price, num)321 322 计算买入成本323 324 :param Datetime datetime: 交易时间325 :param Stock stock: 交易的证券326 :param float price: 买入价格327 :param int num: 买入数量328 :rtype: CostRecord329"""330TradeManager.getSellCost.__doc__ = """331getSellCost(self, datetime, stock, price, num)332 333 计算卖出成本334 :param Datetime datetime: 交易时间335 :param Stock stock: 交易的证券336 :param float price: 卖出价格337 :param int num: 卖出数量338 :rtype: CostRecord 339"""340TradeManager.cash.__doc__ = """341cash(self, datetime[, ktype=KQuery.KType.DAY])342 343 获取指定日期的现金。(注:如果不带日期参数,无法根据权息信息调整持仓。)344 345 :param Datetime datetime: 指定时刻346 :param ktype: K线类型347 :rtype: float348"""349TradeManager.getFunds.__doc__ = """350getFunds(self[,ktype = KQuery.DAY])351 352 获取账户当前时刻的资产详情353 354 :param KQuery.KType ktype: K线类型355 :rtype: FundsRecord356 357getFunds(self, datetime, [ktype = KQuery.DAY])358 359 获取指定时刻的资产市值详情360 361 :param Datetime datetime: 指定时刻362 :param KQuery.KType ktype: K线类型363 :rtype: FundsRecord 364"""365TradeManager.getFundsCurve.__doc__ = """366getFundsCurve(self, dates[, ktype = KQuery.DAY])367 368 获取资产净值曲线369 370 :param DatetimeList dates: 日期列表,根据该日期列表获取其对应的资产净值曲线371 :param KQuery.KType ktype: K线类型,必须与日期列表匹配372 :return: 资产净值列表373 :rtype: PriceList374"""375TradeManager.getProfitCurve.__doc__ = """376getProfitCurve(self, dates[, ktype = KQuery.DAY])377 378 获取收益曲线,即扣除历次存入资金后的资产净值曲线379 380 :param DatetimeList dates: 日期列表,根据该日期列表获取其对应的收益曲线,应为递增顺序381 :param KQuery.KType ktype: K线类型,必须与日期列表匹配382 :return: 收益曲线383 :rtype: PriceList384"""385TradeManager.checkin.__doc__ = """386checkin(self, datetime, cash)387 388 向账户内存入现金389 390 :param Datetime datetime: 交易时间391 :param float cash: 存入的现金量392 :rtype: TradeRecord393"""394TradeManager.checkout.__doc__ = """395checkout(self, datetime, cash)396 397 从账户内取出现金398 399 :param Datetime datetime: 交易时间400 :param float cash: 取出的资金量401 :rtype: TradeRecord402"""403TradeManager.buy.__doc__ = """404buy(self, datetime, stock, realPrice, number[, stoploss=0.0, goalPrice=0.0, planPrice=0.0, part=System.INVALID])405 406 买入操作407 408 :param Datetime datetime: 买入时间409 :param Stock stock: 买入的证券410 :param float realPrice: 实际买入价格411 :param int num: 买入数量412 :param float stoploss: 止损价413 :param float goalPrice: 目标价格414 :param float planPrice: 计划买入价格415 :param SystemPart part: 交易指示来源416 :rtype: TradeRecord417"""418TradeManager.sell.__doc__ = """419sell(self, datetime, stock, realPrice[, number=Constant.null_size, stoploss=0.0, goalPrice=0.0, planPrice=0.0, part=System.INVALID])420 421 卖出操作422 423 :param Datetime datetime: 卖出时间424 :param Stock stock: 卖出的证券425 :param float realPrice: 实际卖出价格426 :param int num: 卖出数量,如果等于Constant.null_size,表示全部卖出427 :param float stoploss: 新的止损价428 :param float goalPrice: 新的目标价格429 :param float planPrice: 原计划卖出价格430 :param SystemPart part: 交易指示来源431 :rtype: TradeRecord432"""433TradeManager.tocsv.__doc__ = """434tocsv(self, path)435 436 以csv格式输出交易记录、未平仓记录、已平仓记录、资产净值曲线437 438 :param string path: 输出文件所在目录439"""440TradeManager.addTradeRecord.__doc__ = """441addTradeRecord(self, tr)442 直接加入交易记录,如果加入初始化账户记录,将清除全部已有交易及持仓记录。443 :param TradeRecord tr: 交易记录444 :return: True(成功) | False(失败)445 :rtype: bool446"""447#------------------------------------------------------------------448# Performance449#------------------------------------------------------------------450Performance.__doc__ = """简单绩效统计"""451Performance.reset.__doc__ = """452reset(self)453 454 复位,清除已计算的结果455"""456Performance.report.__doc__ = """457report(self, tm[, datetime=Datetime.now()])458 459 简单的文本统计报告,用于直接输出打印460 461 :param TradeManager tm: 指定的交易管理实例462 :param Datetime datetime: 统计截止时刻463 :rtype: str464"""465Performance.statistics.__doc__ = """466statistics(self, tm[, datetime=Datetime.now()])467 468 根据交易记录,统计截至某一时刻的系统绩效, datetime必须大于等于lastDatetime469 :param TradeManager tm: 指定的交易管理实例470 :param Datetime datetime: 统计截止时刻471"""472Performance.get.__doc__ = """473get(self, name)474 475 按指标名称获取指标值,必须在运行 statistics 或 report 之后生效476 477 :param str name: 指标名称478 :rtype: float479"""480Performance.__getitem__.__doc__ = """481__getitem__(self, name)482 483 同 get 方法。按指标名称获取指标值,必须在运行 statistics 或 report 之后生效484 485 :param str name: 指标名称486 :rtype: float487"""488#------------------------------------------------------------------489# build_in490#------------------------------------------------------------------491crtTM.__doc__ = """492crtTM([datetime = Datetime(199001010000), initcash = 100000, costfunc = TC_Zero(), name = "SYS"])493 创建交易管理模块,管理帐户的交易记录及资金使用情况494 495 :param Datetime datetime: 账户建立日期496 :param float initcash: 初始资金497 :param TradeCost costfunc: 交易成本算法498 :param string name: 账户名称499 :rtype: TradeManager500"""501TC_TestStub.__doc__ = """502"""503TC_FixedA.__doc__ = """504TC_FixedA([commission=0.0018, lowestCommission=5.0, stamptax=0.001, transferfee=0.001, lowestTransferfee=1.0])505 2015年8月1日之前的A股交易成本算法。上证过户费为交易数量的千分之一,不足1元,按1元计。506 507 计算规则如下::508 1)上证交易所509 买入:佣金+过户费510 卖出:佣金+过户费+印花税511 2)深证交易所:512 买入:佣金513 卖出:佣金+印花税514 其中,佣金最低5元515 :param float commission: 佣金比例516 :param float lowestCommission: 最低佣金值517 :param float stamptax: 印花税518 :param float transferfee: 过户费519 :param float lowestTransferfee: 最低过户费520 :return: :py:class:`TradeCostBase` 子类实例521"""522 523TC_FixedA2015.__doc__ = """524TC_FixedA2015([commission=0.0018, lowestCommission=5.0, stamptax=0.001, transferfee=0.00002])525 2015年8月1日及之后的A股交易成本算法,上证过户费改为成交金额的千分之0.02526 527 计算规则如下::528 1)上证交易所529 买入:佣金+过户费530 卖出:佣金+过户费+印花税531 2)深证交易所:532 买入:佣金533 卖出:佣金+印花税534 其中,佣金最低5元535 :param float commission: 佣金比例536 :param float lowestCommission: 最低佣金值537 :param float stamptax: 印花税538 :param float transferfee: 过户费539 :return: :py:class:`TradeCostBase` 子类实例540"""541TC_Zero.__doc__ = """542TC_Zero()543 创建零成本算法实例544"""...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run hypothesis automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful