Best Python code snippet using hypothesis
talib_wrap.py
Source:talib_wrap.py
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:...
core_doc.py
Source:core_doc.py
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: å¾
è½½å
¥çåºååæ件ã...
trade_doc.py
Source:trade_doc.py
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"""...
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!!