1
ध्यान केंद्रित करना
2
समर्थक

क्या आप कृपया इस कोड को PANDAS कोड में परिवर्तित कर सकते हैं?

में बनाया: 2021-06-29 21:03:55, को अपडेट:
comments   1
hits   978

यह एक खुला स्रोत एटीआर फ़ंक्शन है, जिसे समूह के मालिकों द्वारा लिखा गया है, और मैं चाहता हूं कि आप एक PANDAS संस्करण लिखें, जिसमें TALIB फ़ंक्शन का उपयोग नहीं किया गया है।

def ATR(records, period=14): if len(records) == 0: return [] if ‘Close’ not in records[0]: raise “TA.ATR argument must KLine”

    R = Std._zeros(len(records))
    m = 0.0
    n = 0.0
    for i in xrange(0, len(records)):
        TR = 0
        if i == 0:
            TR = records[i]['High'] - records[i]['Low']
        else:
            TR = max(records[i]['High'] - records[i]['Low'], abs(records[i]['High'] - records[i - 1]['Close']), abs(records[i - 1]['Close'] - records[i]['Low']))
        m += TR
        if i < period:
            n = m / (i + 1)
        else:
            n = (((period - 1) * n) + TR) / period
        R[i] = n
    return R