math.* 함수 레퍼런스¶
math 네임스페이스는 import 없이 사용할 수 있는 수학 함수를 제공합니다.
함수 목록¶
| 함수 | 시그니처 | 비고 |
|---|---|---|
math.sqrt |
(x) |
제곱근 |
math.log |
(x) |
x <= 0이면 NaN |
math.log10 |
(x) |
x <= 0이면 NaN |
math.exp |
(x) |
e^x |
math.pow |
(x, y) |
거듭제곱 |
math.floor |
(x) |
float 반환 |
math.ceil |
(x) |
float 반환 |
math.pi |
() |
상수 함수 형태 (math.pi()) |
math.isnan |
(x) |
NaN 판별 |
예제¶
c = chart("1D")
atr = ta.atr(c.high, c.low, c.close, 14)
vol_pct = (atr[0] / c.close[0]) * 100
log_vol = math.log(vol_pct + 1)
radius = 10
circ = 2 * math.pi() * radius
if not math.isnan(log_vol):
log("log_vol:", log_vol)
주의사항¶
math.pi는 속성이 아니라 함수입니다.math.pi()로 호출해야 합니다.math.floor,math.ceil은 현재 구현에서int가 아닌float를 반환합니다.