내장 함수 레퍼런스
샌드박스에서 허용된 Python builtins 목록입니다.
값과 상수
| 이름 |
설명 |
True |
불리언 참 |
False |
불리언 거짓 |
None |
널 값 |
타입 변환
| 함수 |
시그니처 |
설명 |
int |
int(x) -> int |
정수로 변환. int(3.7) → 3 |
float |
float(x) -> float |
부동소수점으로 변환. float("3.14") → 3.14 |
str |
str(x) -> str |
문자열로 변환. str(42) → "42" |
bool |
bool(x) -> bool |
불리언으로 변환. bool(0) → False |
qty = int(script_params.get("qty", 1))
threshold = float(script_params.get("threshold", "0.02"))
수학/집계
| 함수 |
시그니처 |
설명 |
abs |
abs(x) -> number |
절대값 |
round |
round(x, n?) -> number |
반올림. round(3.456, 2) → 3.46 |
sum |
sum(iterable) -> number |
합계. sum([1, 2, 3]) → 6 |
min |
min(*args) -> value |
최솟값. min(a, b) |
max |
max(*args) -> value |
최댓값. max(a, b) |
len |
len(obj) -> int |
길이. len(values) |
c = chart("1D")
values = [c.close[0], c.close[1], c.close[2]]
avg = sum(values) / len(values)
spread = max(values) - min(values)
논리/검사
| 함수 |
시그니처 |
설명 |
all |
all(iterable) -> bool |
모두 참이면 True. all([True, True, False]) → False |
any |
any(iterable) -> bool |
하나라도 참이면 True. any([False, True]) → True |
isinstance |
isinstance(obj, type) -> bool |
타입 검사. isinstance(42, int) → True |
c = chart("5T")
rsi = ta.rsi(c.close, 14)
conditions = [rsi < 35, c.close > ta.sma(c.close, 20), bar.is_confirmed]
if all(conditions):
buy(tag="all_clear")
컬렉션 생성
| 함수 |
시그니처 |
설명 |
list |
list(iterable?) -> list |
리스트 생성 |
dict |
dict(**kwargs) -> dict |
딕셔너리 생성 |
tuple |
tuple(iterable?) -> tuple |
튜플 생성 |
반복 유틸
| 함수 |
시그니처 |
설명 |
range |
range(stop) / range(start, stop, step?) |
정수 시퀀스 |
enumerate |
enumerate(iterable, start=0) |
인덱스+값 쌍 반복 |
zip |
zip(*iterables) |
병렬 묶기 |
sorted |
sorted(iterable, reverse=False) -> list |
정렬된 리스트 반환 |
c = chart("1D")
periods = [5, 10, 20, 60]
smas = [ta.sma(c.close, p) for p in periods]
# 모든 이평선이 정배열인지 확인
aligned = all(smas[i] > smas[i+1] for i in range(len(smas)-1))
if aligned:
buy(tag="sma_aligned")
출력
| 함수 |
설명 |
print |
DSL에서는 log로 오버라이드됩니다. print("msg") = log("msg") |
금지 호출 예시
아래 호출은 파서 단계에서 차단됩니다.
exec(...), eval(...)
open(...)
getattr(...), setattr(...), delattr(...)
globals(), locals(), compile(...), breakpoint()
관련 문서