nextrade-engine 0.5.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- nextrade/nextrade/__init__.py +277 -0
- nextrade/nextrade/backtest/__init__.py +0 -0
- nextrade/nextrade/backtest/engine.py +249 -0
- nextrade/nextrade/core/__init__.py +0 -0
- nextrade/nextrade/core/brain.py +278 -0
- nextrade/nextrade/core/regime.py +63 -0
- nextrade/nextrade/data/__init__.py +0 -0
- nextrade/nextrade/data/fetcher.py +173 -0
- nextrade/nextrade/indicators/__init__.py +0 -0
- nextrade/nextrade/indicators/adaptive.py +73 -0
- nextrade/nextrade/indicators/confluence.py +61 -0
- nextrade/nextrade/indicators/pattern.py +76 -0
- nextrade/nextrade/utils/__init__.py +0 -0
- nextrade/nextrade/utils/terminal_ui.py +87 -0
- nextrade/setup.py +10 -0
- nextrade_engine-0.5.0.dist-info/METADATA +97 -0
- nextrade_engine-0.5.0.dist-info/RECORD +20 -0
- nextrade_engine-0.5.0.dist-info/WHEEL +5 -0
- nextrade_engine-0.5.0.dist-info/licenses/LICENSE +21 -0
- nextrade_engine-0.5.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"""
|
|
2
|
+
NexTrade — Pattern Scorer
|
|
3
|
+
Beri skor kekuatan pola candlestick, bukan hanya deteksi ya/tidak.
|
|
4
|
+
"""
|
|
5
|
+
import numpy as np
|
|
6
|
+
|
|
7
|
+
def _body(o, c): return abs(c - o)
|
|
8
|
+
def _upper(o, c, h): return h - max(o, c)
|
|
9
|
+
def _lower(o, c, l): return min(o, c) - l
|
|
10
|
+
def _range(h, l): return h - l + 1e-9
|
|
11
|
+
|
|
12
|
+
def hammer_score(open_: float, high: float, low: float, close: float) -> float:
|
|
13
|
+
"""Skor pola hammer / pin bar bawah (0-100)."""
|
|
14
|
+
body = _body(open_, close)
|
|
15
|
+
lower = _lower(open_, close, low)
|
|
16
|
+
upper = _upper(open_, close, high)
|
|
17
|
+
rng = _range(high, low)
|
|
18
|
+
if rng == 0: return 0.0
|
|
19
|
+
lower_ratio = lower / rng
|
|
20
|
+
body_ratio = body / rng
|
|
21
|
+
# Hammer ideal: lower > 60% range, body < 30%, upper < 10%
|
|
22
|
+
score = 0.0
|
|
23
|
+
score += min(lower_ratio / 0.6, 1.0) * 50 # lower shadow besar
|
|
24
|
+
score += max(1 - body_ratio / 0.3, 0) * 30 # body kecil
|
|
25
|
+
score += max(1 - upper / (rng * 0.1 + 1e-9), 0) * 20 # upper shadow kecil
|
|
26
|
+
return round(min(score, 100.0), 2)
|
|
27
|
+
|
|
28
|
+
def engulfing_score(prev_o: float, prev_c: float,
|
|
29
|
+
curr_o: float, curr_c: float) -> tuple:
|
|
30
|
+
"""
|
|
31
|
+
Skor pola engulfing bullish / bearish.
|
|
32
|
+
Returns (score, direction) — direction: 'bull' atau 'bear'
|
|
33
|
+
"""
|
|
34
|
+
prev_body = _body(prev_o, prev_c)
|
|
35
|
+
curr_body = _body(curr_o, curr_c)
|
|
36
|
+
if prev_body == 0: return 0.0, "none"
|
|
37
|
+
|
|
38
|
+
ratio = curr_body / (prev_body + 1e-9)
|
|
39
|
+
is_bull = prev_c < prev_o and curr_c > curr_o and curr_o < prev_c and curr_c > prev_o
|
|
40
|
+
is_bear = prev_c > prev_o and curr_c < curr_o and curr_o > prev_c and curr_c < prev_o
|
|
41
|
+
|
|
42
|
+
if not (is_bull or is_bear): return 0.0, "none"
|
|
43
|
+
score = min(ratio * 60, 80) + 20 # minimum 20 kalau valid
|
|
44
|
+
direction = "bull" if is_bull else "bear"
|
|
45
|
+
return round(min(score, 100.0), 2), direction
|
|
46
|
+
|
|
47
|
+
def pattern_score(opens: np.ndarray, highs: np.ndarray,
|
|
48
|
+
lows: np.ndarray, closes: np.ndarray) -> dict:
|
|
49
|
+
"""
|
|
50
|
+
Gabungan skor semua pola pada candle terbaru.
|
|
51
|
+
Returns dict dengan skor tiap pola dan skor total.
|
|
52
|
+
"""
|
|
53
|
+
if len(closes) < 2:
|
|
54
|
+
return {"total": 50.0, "hammer": 0.0, "engulfing": 0.0, "direction": "neutral"}
|
|
55
|
+
|
|
56
|
+
o, h, l, c = opens[-1], highs[-1], lows[-1], closes[-1]
|
|
57
|
+
po, pc = opens[-2], closes[-2]
|
|
58
|
+
|
|
59
|
+
h_score = hammer_score(o, h, l, c)
|
|
60
|
+
e_score, e_dir = engulfing_score(po, pc, o, c)
|
|
61
|
+
|
|
62
|
+
# Tentukan arah dominan
|
|
63
|
+
if e_dir == "bull" or (h_score > 50 and c > o):
|
|
64
|
+
direction = "bull"
|
|
65
|
+
elif e_dir == "bear" or (h_score > 50 and c < o):
|
|
66
|
+
direction = "bear"
|
|
67
|
+
else:
|
|
68
|
+
direction = "neutral"
|
|
69
|
+
|
|
70
|
+
total = max(h_score, e_score)
|
|
71
|
+
return {
|
|
72
|
+
"total" : total,
|
|
73
|
+
"hammer" : h_score,
|
|
74
|
+
"engulfing" : e_score,
|
|
75
|
+
"direction" : direction,
|
|
76
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"""
|
|
2
|
+
NexTrade — Terminal UI
|
|
3
|
+
Semua tampilan, warna, dan wizard di terminal.
|
|
4
|
+
"""
|
|
5
|
+
import sys
|
|
6
|
+
import time
|
|
7
|
+
|
|
8
|
+
class Color:
|
|
9
|
+
RESET = "\033[0m"
|
|
10
|
+
BOLD = "\033[1m"
|
|
11
|
+
DIM = "\033[2m"
|
|
12
|
+
RED = "\033[31m"
|
|
13
|
+
GREEN = "\033[32m"
|
|
14
|
+
YELLOW = "\033[33m"
|
|
15
|
+
CYAN = "\033[36m"
|
|
16
|
+
WHITE = "\033[37m"
|
|
17
|
+
|
|
18
|
+
C = Color()
|
|
19
|
+
|
|
20
|
+
STRATEGIES = {
|
|
21
|
+
"momentum" : "Ikut tren kuat · cocok market trending",
|
|
22
|
+
"reversal" : "Cari pembalikan arah · counter-trend",
|
|
23
|
+
"scalping" : "Entry cepat · target kecil · frekuensi tinggi",
|
|
24
|
+
"swing" : "Hold beberapa jam/hari · ikut swing besar",
|
|
25
|
+
"adaptive" : "AI pilih strategi otomatis sesuai kondisi pasar",
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
SEP = "─" * 68
|
|
29
|
+
|
|
30
|
+
def print_banner():
|
|
31
|
+
print(f"""
|
|
32
|
+
{C.CYAN}{C.BOLD}
|
|
33
|
+
███╗ ██╗███████╗██╗ ██╗████████╗██████╗ █████╗ ██████╗ ███████╗
|
|
34
|
+
████╗ ██║██╔════╝╚██╗██╔╝╚══██╔══╝██╔══██╗██╔══██╗██╔══██╗██╔════╝
|
|
35
|
+
██╔██╗ ██║█████╗ ╚███╔╝ ██║ ██████╔╝███████║██║ ██║█████╗
|
|
36
|
+
██║╚██╗██║██╔══╝ ██╔██╗ ██║ ██╔══██╗██╔══██║██║ ██║██╔══╝
|
|
37
|
+
██║ ╚████║███████╗██╔╝ ██╗ ██║ ██║ ██║██║ ██║██████╔╝███████╗
|
|
38
|
+
╚═╝ ╚═══╝╚══════╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═════╝ ╚══════╝
|
|
39
|
+
{C.RESET}{C.DIM} AI Trading Engine · Ringan · Multi-Market · Bisa di HP{C.RESET}
|
|
40
|
+
{C.CYAN}{SEP}{C.RESET}""")
|
|
41
|
+
|
|
42
|
+
def print_welcome():
|
|
43
|
+
print_banner()
|
|
44
|
+
print(f"{C.BOLD}{C.WHITE} Selamat datang di NexTrade!{C.RESET}")
|
|
45
|
+
print(f"{C.DIM} Engine AI trading ringan yang bisa jalan di HP sekalipun.{C.RESET}\n")
|
|
46
|
+
print(f"{C.CYAN} ┌─ Strategi tersedia ─────────────────────────────────┐{C.RESET}")
|
|
47
|
+
for i, (name, desc) in enumerate(STRATEGIES.items(), 1):
|
|
48
|
+
print(f"{C.CYAN} │{C.RESET} {C.BOLD}{C.YELLOW}{i}. {name:<12}{C.RESET} {C.DIM}-> {desc}{C.RESET}")
|
|
49
|
+
print(f"{C.CYAN} └─────────────────────────────────────────────────────┘{C.RESET}\n")
|
|
50
|
+
print(f" {C.DIM}Cara mulai:{C.RESET}")
|
|
51
|
+
print(f" {C.GREEN}nextrade.start(\"momentum\"){C.RESET} {C.DIM}# langsung pakai strategi{C.RESET}")
|
|
52
|
+
print(f" {C.GREEN}nextrade.backtest(\"momentum\"){C.RESET} {C.DIM}# test dulu sebelum live{C.RESET}")
|
|
53
|
+
print(f" {C.GREEN}nextrade.info(){C.RESET} {C.DIM}# lihat semua pilihan{C.RESET}\n")
|
|
54
|
+
|
|
55
|
+
def print_loading(text: str, delay: float = 0.03):
|
|
56
|
+
steps = ["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"]
|
|
57
|
+
for i in range(15):
|
|
58
|
+
sys.stdout.write(f"\r {C.CYAN}{steps[i % len(steps)]}{C.RESET} {text}")
|
|
59
|
+
sys.stdout.flush()
|
|
60
|
+
time.sleep(delay)
|
|
61
|
+
sys.stdout.write(f"\r {C.GREEN}v{C.RESET} {text}\n")
|
|
62
|
+
sys.stdout.flush()
|
|
63
|
+
|
|
64
|
+
def print_signal(signal: str, confidence: float, strategy: str, market: str = ""):
|
|
65
|
+
color = C.GREEN if signal == "BUY" else C.RED if signal == "SELL" else C.YELLOW
|
|
66
|
+
bar_len = int(confidence / 5)
|
|
67
|
+
bar = "█" * bar_len + "░" * (20 - bar_len)
|
|
68
|
+
sep2 = "─" * 50
|
|
69
|
+
print(f"\n{C.CYAN}{sep2}{C.RESET}")
|
|
70
|
+
print(f" {C.BOLD}Strategi :{C.RESET} {strategy}")
|
|
71
|
+
if market:
|
|
72
|
+
print(f" {C.BOLD}Market :{C.RESET} {market}")
|
|
73
|
+
print(f" {C.BOLD}Sinyal :{C.RESET} {color}{C.BOLD} {signal} {C.RESET}")
|
|
74
|
+
print(f" {C.BOLD}Confidence:{C.RESET} {color}{bar}{C.RESET} {confidence:.1f}%")
|
|
75
|
+
print(f"{C.CYAN}{sep2}{C.RESET}\n")
|
|
76
|
+
|
|
77
|
+
def print_error(msg: str):
|
|
78
|
+
print(f"\n {C.RED}x Error:{C.RESET} {msg}\n")
|
|
79
|
+
|
|
80
|
+
def print_success(msg: str):
|
|
81
|
+
print(f" {C.GREEN}v{C.RESET} {msg}")
|
|
82
|
+
|
|
83
|
+
def list_strategies():
|
|
84
|
+
print(f"\n{C.BOLD}{C.WHITE} Strategi NexTrade:{C.RESET}\n")
|
|
85
|
+
for name, desc in STRATEGIES.items():
|
|
86
|
+
print(f" {C.YELLOW}{C.BOLD}{name:<14}{C.RESET} {desc}")
|
|
87
|
+
print()
|
nextrade/setup.py
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: nextrade-engine
|
|
3
|
+
Version: 0.5.0
|
|
4
|
+
Summary: AI Trading Engine — Ringan, Multi-Market, Bisa di HP
|
|
5
|
+
Author-email: NexTrade <wafiqrazy035@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/nextrade-ai/nextrade
|
|
8
|
+
Project-URL: Issues, https://github.com/nextrade-ai/nextrade/issues
|
|
9
|
+
Keywords: trading,ai,forex,crypto,backtest,signal
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Intended Audience :: Financial and Insurance Industry
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Topic :: Office/Business :: Financial :: Investment
|
|
21
|
+
Requires-Python: >=3.8
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Requires-Dist: numpy
|
|
25
|
+
Requires-Dist: yfinance
|
|
26
|
+
Dynamic: license-file
|
|
27
|
+
|
|
28
|
+
# NexTrade 🧠
|
|
29
|
+
|
|
30
|
+
**AI Trading Engine — Ringan, Multi-Market, Bisa di HP**
|
|
31
|
+
|
|
32
|
+
NexTrade adalah library Python untuk trading AI yang dirancang seperti cara trader manusia berpikir. Ringan, cepat, dan bisa jalan di HP sekalipun.
|
|
33
|
+
|
|
34
|
+
## Instalasi
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
pip install nextrade
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Cara Pakai
|
|
41
|
+
|
|
42
|
+
```python
|
|
43
|
+
import nextrade
|
|
44
|
+
|
|
45
|
+
# Sinyal trading real time
|
|
46
|
+
nextrade.start("momentum", market="BTCUSD")
|
|
47
|
+
nextrade.start("adaptive", market="EURUSD", timeframe="H4")
|
|
48
|
+
|
|
49
|
+
# Scan banyak market sekaligus
|
|
50
|
+
nextrade.scan(["BTCUSD", "EURUSD", "XAUUSD", "AAPL"])
|
|
51
|
+
|
|
52
|
+
# Backtest strategi
|
|
53
|
+
nextrade.backtest("momentum", market="BTCUSD", timeframe="D1")
|
|
54
|
+
|
|
55
|
+
# Latih AI brain
|
|
56
|
+
nextrade.train("hybrid", market="BTCUSD")
|
|
57
|
+
|
|
58
|
+
# Status otak AI
|
|
59
|
+
nextrade.brain_status()
|
|
60
|
+
|
|
61
|
+
# Set agresivitas sinyal
|
|
62
|
+
nextrade.set_agresivitas(20) # konservatif
|
|
63
|
+
nextrade.set_agresivitas(80) # agresif
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Fitur
|
|
67
|
+
|
|
68
|
+
- **Multi-Market** — Forex, Crypto, Saham, Indeks
|
|
69
|
+
- **AI Brain** — IQ model, neuron aktif, 3 mode learning
|
|
70
|
+
- **Backtest Engine** — test jutaan bar, ringan di HP
|
|
71
|
+
- **Market Scanner** — scan banyak market sekaligus
|
|
72
|
+
- **Adaptive Indicators** — indikator yang menyesuaikan kondisi pasar
|
|
73
|
+
- **Terminal Wizard** — panduan otomatis muncul saat import
|
|
74
|
+
|
|
75
|
+
## Market Tersedia
|
|
76
|
+
|
|
77
|
+
**Forex:** EURUSD, GBPUSD, USDJPY, XAUUSD (Gold), dan lainnya
|
|
78
|
+
|
|
79
|
+
**Crypto:** BTCUSD, ETHUSD, BNBUSD, SOLUSD, dan lainnya
|
|
80
|
+
|
|
81
|
+
**Saham:** AAPL, TSLA, GOOGL, NVDA, BBCA, BBRI, dan lainnya
|
|
82
|
+
|
|
83
|
+
**Indeks:** SPX500, NASDAQ, IHSG, NIKKEI
|
|
84
|
+
|
|
85
|
+
## Timeframe
|
|
86
|
+
|
|
87
|
+
M1 · M5 · M15 · M30 · H1 · H4 · D1 · W1
|
|
88
|
+
|
|
89
|
+
## Requirements
|
|
90
|
+
|
|
91
|
+
- Python 3.8+
|
|
92
|
+
- numpy
|
|
93
|
+
- yfinance
|
|
94
|
+
|
|
95
|
+
## License
|
|
96
|
+
|
|
97
|
+
MIT License
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
nextrade/setup.py,sha256=bCM4bFSvxzWcGVEOUwGxaRBI1RxojfY_KjmoQ35rbIk,261
|
|
2
|
+
nextrade/nextrade/__init__.py,sha256=PixgKcpSe0x1l2Q64uYCIGMn7fNsK-Ozs2RmIGO8Uuc,8719
|
|
3
|
+
nextrade/nextrade/backtest/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
+
nextrade/nextrade/backtest/engine.py,sha256=cEUTaJUK9djLBNkPlESZA1viAR0IoSv0hK5nJ3_C-Q0,9737
|
|
5
|
+
nextrade/nextrade/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
+
nextrade/nextrade/core/brain.py,sha256=zkDHooAJ_C4POlfT3hXQbte4i68cJp8gt2gqwinWjVw,11952
|
|
7
|
+
nextrade/nextrade/core/regime.py,sha256=HXKCBoQQ6rdMmdomv8rpANgg-ppx0hlUJlLQxCXSxvY,2112
|
|
8
|
+
nextrade/nextrade/data/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
9
|
+
nextrade/nextrade/data/fetcher.py,sha256=yl6auEMHsMwFZe5QX5c87b99VlBe3S9ajIu3sB0xpRs,5489
|
|
10
|
+
nextrade/nextrade/indicators/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
11
|
+
nextrade/nextrade/indicators/adaptive.py,sha256=bdDt8So7rsZL95UzK6_m3-TCo0j8JFpjXtgHt3fmOHA,2384
|
|
12
|
+
nextrade/nextrade/indicators/confluence.py,sha256=yACaRaRTUkXTb7p9H25sNFXTzT2d7VRzyv_BIv2Ydes,1824
|
|
13
|
+
nextrade/nextrade/indicators/pattern.py,sha256=nEV1aDZNwSPaULYW6Q1f_0sM4UbzGeyHzih5J5wjsb4,2701
|
|
14
|
+
nextrade/nextrade/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
15
|
+
nextrade/nextrade/utils/terminal_ui.py,sha256=aBeQUDOT0oGiHsJjN2g1SvSwppRQcbj4N9DKAoW6P3M,4393
|
|
16
|
+
nextrade_engine-0.5.0.dist-info/licenses/LICENSE,sha256=wz6Rm4KQqgFAmxWJFcSJYfzL9y7WAJwFT2SKYkxY32M,1065
|
|
17
|
+
nextrade_engine-0.5.0.dist-info/METADATA,sha256=PFFFWEyJQHUBcIMrv95llVRGCgGXCDZzakCAfZK4_HA,2764
|
|
18
|
+
nextrade_engine-0.5.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
19
|
+
nextrade_engine-0.5.0.dist-info/top_level.txt,sha256=tnkn31kWRmuIHvM6OAXo6hEW6mYOc649vd4WzWU3lwM,9
|
|
20
|
+
nextrade_engine-0.5.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 NexTrade
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
nextrade
|