nextrade-engine 0.5.0__tar.gz

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.
Files changed (25) hide show
  1. nextrade_engine-0.5.0/LICENSE +21 -0
  2. nextrade_engine-0.5.0/PKG-INFO +97 -0
  3. nextrade_engine-0.5.0/README.md +70 -0
  4. nextrade_engine-0.5.0/nextrade/nextrade/__init__.py +277 -0
  5. nextrade_engine-0.5.0/nextrade/nextrade/backtest/__init__.py +0 -0
  6. nextrade_engine-0.5.0/nextrade/nextrade/backtest/engine.py +249 -0
  7. nextrade_engine-0.5.0/nextrade/nextrade/core/__init__.py +0 -0
  8. nextrade_engine-0.5.0/nextrade/nextrade/core/brain.py +278 -0
  9. nextrade_engine-0.5.0/nextrade/nextrade/core/regime.py +63 -0
  10. nextrade_engine-0.5.0/nextrade/nextrade/data/__init__.py +0 -0
  11. nextrade_engine-0.5.0/nextrade/nextrade/data/fetcher.py +173 -0
  12. nextrade_engine-0.5.0/nextrade/nextrade/indicators/__init__.py +0 -0
  13. nextrade_engine-0.5.0/nextrade/nextrade/indicators/adaptive.py +73 -0
  14. nextrade_engine-0.5.0/nextrade/nextrade/indicators/confluence.py +61 -0
  15. nextrade_engine-0.5.0/nextrade/nextrade/indicators/pattern.py +76 -0
  16. nextrade_engine-0.5.0/nextrade/nextrade/utils/__init__.py +0 -0
  17. nextrade_engine-0.5.0/nextrade/nextrade/utils/terminal_ui.py +87 -0
  18. nextrade_engine-0.5.0/nextrade/setup.py +10 -0
  19. nextrade_engine-0.5.0/nextrade_engine.egg-info/PKG-INFO +97 -0
  20. nextrade_engine-0.5.0/nextrade_engine.egg-info/SOURCES.txt +23 -0
  21. nextrade_engine-0.5.0/nextrade_engine.egg-info/dependency_links.txt +1 -0
  22. nextrade_engine-0.5.0/nextrade_engine.egg-info/requires.txt +2 -0
  23. nextrade_engine-0.5.0/nextrade_engine.egg-info/top_level.txt +1 -0
  24. nextrade_engine-0.5.0/pyproject.toml +40 -0
  25. nextrade_engine-0.5.0/setup.cfg +4 -0
@@ -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,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,70 @@
1
+ # NexTrade 🧠
2
+
3
+ **AI Trading Engine — Ringan, Multi-Market, Bisa di HP**
4
+
5
+ NexTrade adalah library Python untuk trading AI yang dirancang seperti cara trader manusia berpikir. Ringan, cepat, dan bisa jalan di HP sekalipun.
6
+
7
+ ## Instalasi
8
+
9
+ ```bash
10
+ pip install nextrade
11
+ ```
12
+
13
+ ## Cara Pakai
14
+
15
+ ```python
16
+ import nextrade
17
+
18
+ # Sinyal trading real time
19
+ nextrade.start("momentum", market="BTCUSD")
20
+ nextrade.start("adaptive", market="EURUSD", timeframe="H4")
21
+
22
+ # Scan banyak market sekaligus
23
+ nextrade.scan(["BTCUSD", "EURUSD", "XAUUSD", "AAPL"])
24
+
25
+ # Backtest strategi
26
+ nextrade.backtest("momentum", market="BTCUSD", timeframe="D1")
27
+
28
+ # Latih AI brain
29
+ nextrade.train("hybrid", market="BTCUSD")
30
+
31
+ # Status otak AI
32
+ nextrade.brain_status()
33
+
34
+ # Set agresivitas sinyal
35
+ nextrade.set_agresivitas(20) # konservatif
36
+ nextrade.set_agresivitas(80) # agresif
37
+ ```
38
+
39
+ ## Fitur
40
+
41
+ - **Multi-Market** — Forex, Crypto, Saham, Indeks
42
+ - **AI Brain** — IQ model, neuron aktif, 3 mode learning
43
+ - **Backtest Engine** — test jutaan bar, ringan di HP
44
+ - **Market Scanner** — scan banyak market sekaligus
45
+ - **Adaptive Indicators** — indikator yang menyesuaikan kondisi pasar
46
+ - **Terminal Wizard** — panduan otomatis muncul saat import
47
+
48
+ ## Market Tersedia
49
+
50
+ **Forex:** EURUSD, GBPUSD, USDJPY, XAUUSD (Gold), dan lainnya
51
+
52
+ **Crypto:** BTCUSD, ETHUSD, BNBUSD, SOLUSD, dan lainnya
53
+
54
+ **Saham:** AAPL, TSLA, GOOGL, NVDA, BBCA, BBRI, dan lainnya
55
+
56
+ **Indeks:** SPX500, NASDAQ, IHSG, NIKKEI
57
+
58
+ ## Timeframe
59
+
60
+ M1 · M5 · M15 · M30 · H1 · H4 · D1 · W1
61
+
62
+ ## Requirements
63
+
64
+ - Python 3.8+
65
+ - numpy
66
+ - yfinance
67
+
68
+ ## License
69
+
70
+ MIT License
@@ -0,0 +1,277 @@
1
+ """
2
+ NexTrade — AI Trading Engine
3
+ import nextrade → wizard muncul otomatis di terminal
4
+ """
5
+
6
+ from nextrade.utils.terminal_ui import (
7
+ print_welcome, print_signal, print_error,
8
+ print_loading, print_success, list_strategies, STRATEGIES
9
+ )
10
+ from nextrade.indicators.confluence import confluence_score
11
+ from nextrade.core.regime import detect_regime
12
+ from nextrade.core.brain import Brain
13
+ from nextrade.data.fetcher import fetch, fetch_multi, list_markets
14
+ import numpy as np
15
+
16
+ __version__ = "0.3.0"
17
+ __author__ = "NexTrade"
18
+
19
+ # Tampilkan wizard saat pertama kali import
20
+ print_welcome()
21
+
22
+ # Instance brain global
23
+ _brain = Brain.__new__(Brain)
24
+ _brain.state = None
25
+
26
+ def _get_brain():
27
+ global _brain
28
+ if _brain.state is None:
29
+ _brain = Brain()
30
+ return _brain
31
+
32
+ # ─────────────────────────────────────────
33
+ # PUBLIC API
34
+ # ─────────────────────────────────────────
35
+
36
+ def start(strategy: str = "adaptive",
37
+ market: str = "BTCUSD",
38
+ timeframe: str = "H1",
39
+ data: dict = None):
40
+ """
41
+ Jalankan NexTrade — ambil data real lalu keluarkan sinyal.
42
+
43
+ Contoh:
44
+ nextrade.start("momentum", market="BTCUSD")
45
+ nextrade.start("reversal", market="EURUSD", timeframe="M15")
46
+ nextrade.start("adaptive", market="AAPL")
47
+ """
48
+ strategy = strategy.lower().strip()
49
+
50
+ if strategy not in STRATEGIES:
51
+ print_error(f"Strategi '{strategy}' tidak ditemukan.")
52
+ list_strategies()
53
+ return
54
+
55
+ print_loading(f"Memuat strategi {strategy.upper()}...")
56
+
57
+ # Ambil data real kalau tidak ada data manual
58
+ if data is None:
59
+ data = fetch(market, timeframe, bars=500)
60
+ if data is None:
61
+ print_error("Gagal ambil data market. Cek koneksi internet.")
62
+ return
63
+
64
+ print_loading("Menghitung indikator AI...")
65
+
66
+ # Hitung sinyal pakai confluence score
67
+ result = confluence_score(
68
+ opens = data["open"],
69
+ highs = data["high"],
70
+ lows = data["low"],
71
+ closes = data["close"],
72
+ )
73
+
74
+ # Sesuaikan confidence threshold dengan agresivitas brain
75
+ brain = _get_brain()
76
+ threshold = brain.get_confidence_threshold()
77
+ confidence = result["confidence"]
78
+
79
+ # Adjust sinyal berdasarkan threshold agresivitas
80
+ if confidence >= threshold and result["details"]["pattern"]["direction"] != "bear":
81
+ signal = "BUY"
82
+ elif confidence <= (100 - threshold) or result["details"]["pattern"]["direction"] == "bear":
83
+ signal = "SELL"
84
+ else:
85
+ signal = "HOLD"
86
+
87
+ # Tampilkan sinyal
88
+ print_signal(
89
+ signal = signal,
90
+ confidence = confidence,
91
+ strategy = strategy,
92
+ market = market,
93
+ )
94
+
95
+ # Tampilkan detail tambahan
96
+ regime = result["details"]["regime"]["regime"]
97
+ rsi = result["details"]["rsi"]
98
+ mom = result["details"]["momentum"]
99
+ price = data["price_now"]
100
+
101
+ print(f" \033[2mDetail Analisis:\033[0m")
102
+ print(f" \033[36mHarga Sekarang :\033[0m {price:,.5f}")
103
+ print(f" \033[36mKondisi Pasar :\033[0m {regime}")
104
+ print(f" \033[36mRSI Adaptif :\033[0m {rsi:.1f}")
105
+ print(f" \033[36mMomentum Score :\033[0m {mom:.1f}")
106
+ print(f" \033[36mIQ Model :\033[0m {brain.state['iq']} / 100")
107
+ print(f" \033[36mAgresivitas :\033[0m {brain.state['agresivitas']}%")
108
+ print()
109
+
110
+ return {**result, "signal": signal, "market": market,
111
+ "price": price, "strategy": strategy}
112
+
113
+
114
+ def train(mode: str = "hybrid", market: str = "BTCUSD",
115
+ timeframe: str = "D1", bars: int = 1000):
116
+ """
117
+ Latih brain NexTrade dengan data real market.
118
+
119
+ Contoh:
120
+ nextrade.train("offline", market="BTCUSD", timeframe="D1")
121
+ nextrade.train("hybrid", market="EURUSD", timeframe="H4")
122
+ nextrade.train("online", market="AAPL", timeframe="D1")
123
+ """
124
+ print(f"\n \033[1m\033[37m Training NexTrade Brain\033[0m")
125
+ print(f" \033[36m{'─' * 40}\033[0m")
126
+
127
+ # Ambil data real untuk training
128
+ data = fetch(market, timeframe, bars=bars)
129
+ if data is None:
130
+ print_error("Gagal ambil data untuk training.")
131
+ return
132
+
133
+ brain = _get_brain()
134
+ brain.train(mode=mode, data=data)
135
+
136
+
137
+ def brain_status():
138
+ """Tampilkan status otak NexTrade."""
139
+ _get_brain().status()
140
+
141
+
142
+ def set_agresivitas(pct: int):
143
+ """
144
+ Set seberapa agresif NexTrade dalam mengambil sinyal.
145
+ 0 = sangat selektif (sedikit sinyal tapi akurat)
146
+ 100 = sangat agresif (banyak sinyal)
147
+
148
+ Contoh:
149
+ nextrade.set_agresivitas(20) # konservatif
150
+ nextrade.set_agresivitas(50) # moderat
151
+ nextrade.set_agresivitas(80) # agresif
152
+ """
153
+ _get_brain().set_agresivitas(pct)
154
+
155
+
156
+ def scan(markets: list = None, strategy: str = "adaptive",
157
+ timeframe: str = "H1"):
158
+ """
159
+ Scan banyak market sekaligus — cari peluang trading terbaik.
160
+
161
+ Contoh:
162
+ nextrade.scan(["BTCUSD", "EURUSD", "AAPL"])
163
+ nextrade.scan(["BTCUSD", "ETHUSD", "SOLUSD"], timeframe="H4")
164
+ """
165
+ if markets is None:
166
+ markets = ["BTCUSD", "EURUSD", "XAUUSD", "AAPL", "TSLA"]
167
+
168
+ print(f"\n \033[1m\033[37m NexTrade Market Scanner\033[0m")
169
+ print(f" \033[36m{'─' * 55}\033[0m")
170
+ print(f" \033[2m{'MARKET':<12} {'HARGA':>14} {'SINYAL':>8} {'CONFIDENCE':>12} {'REGIME'}\033[0m")
171
+ print(f" \033[36m{'─' * 55}\033[0m")
172
+
173
+ results = []
174
+ for market in markets:
175
+ data = fetch(market, timeframe, bars=300, silent=True)
176
+ if data is None:
177
+ continue
178
+
179
+ result = confluence_score(
180
+ opens = data["open"],
181
+ highs = data["high"],
182
+ lows = data["low"],
183
+ closes = data["close"],
184
+ )
185
+
186
+ signal = result["signal"]
187
+ confidence = result["confidence"]
188
+ regime = result["details"]["regime"]["regime"]
189
+ price = data["price_now"]
190
+
191
+ # Warna sinyal
192
+ if signal == "BUY":
193
+ sc = "\033[32m"
194
+ elif signal == "SELL":
195
+ sc = "\033[31m"
196
+ else:
197
+ sc = "\033[33m"
198
+
199
+ print(f" {market:<12} {price:>14,.5f} {sc}{signal:>8}\033[0m "
200
+ f"{confidence:>10.1f}% \033[2m{regime}\033[0m")
201
+
202
+ results.append({**result, "market": market, "price": price})
203
+
204
+ print(f" \033[36m{'─' * 55}\033[0m\n")
205
+
206
+ # Highlight sinyal terkuat
207
+ buys = [r for r in results if r["signal"] == "BUY"]
208
+ sells = [r for r in results if r["signal"] == "SELL"]
209
+
210
+ if buys:
211
+ best = max(buys, key=lambda x: x["confidence"])
212
+ print(f" \033[32m★ Peluang BUY terkuat : {best['market']} "
213
+ f"({best['confidence']:.1f}%)\033[0m")
214
+ if sells:
215
+ best = max(sells, key=lambda x: x["confidence"])
216
+ print(f" \033[31m★ Peluang SELL terkuat : {best['market']} "
217
+ f"({best['confidence']:.1f}%)\033[0m")
218
+ print()
219
+ return results
220
+
221
+
222
+ def backtest(strategy: str = "adaptive", market: str = "BTCUSD",
223
+ timeframe: str = "D1"):
224
+ """Jalankan backtest strategi (coming soon v0.4.0)."""
225
+ print_loading("Menyiapkan backtest engine...")
226
+ print_success("Backtest engine hadir di v0.4.0!")
227
+
228
+
229
+ def info():
230
+ """Tampilkan semua strategi dan market yang tersedia."""
231
+ list_strategies()
232
+ list_markets()
233
+
234
+
235
+ def regime(market: str = "BTCUSD", timeframe: str = "H1") -> dict:
236
+ """
237
+ Deteksi kondisi pasar saat ini.
238
+
239
+ Contoh:
240
+ r = nextrade.regime("EURUSD")
241
+ print(r["regime"]) # TRENDING / RANGING / VOLATILE
242
+ """
243
+ data = fetch(market, timeframe, bars=100, silent=True)
244
+ if data is None:
245
+ return {}
246
+ return detect_regime(data["close"])
247
+
248
+
249
+ def backtest(strategy: str = "adaptive",
250
+ market: str = "BTCUSD",
251
+ timeframe: str = "D1",
252
+ bars: int = 500,
253
+ agresivitas: int = 30,
254
+ sl_pct: float = 2.0,
255
+ tp_pct: float = 4.0):
256
+ """
257
+ Backtest strategi NexTrade dengan data real historis.
258
+
259
+ Contoh:
260
+ nextrade.backtest("momentum", market="BTCUSD", timeframe="D1")
261
+ nextrade.backtest("adaptive", market="EURUSD", agresivitas=50)
262
+ nextrade.backtest("reversal", market="AAPL", sl_pct=1.5, tp_pct=3.0)
263
+ """
264
+ from nextrade.backtest.engine import run as _run
265
+
266
+ data = fetch(market, timeframe, bars=bars)
267
+ if data is None:
268
+ print_error("Gagal ambil data untuk backtest.")
269
+ return
270
+
271
+ return _run(
272
+ data = data,
273
+ strategy = strategy,
274
+ agresivitas = agresivitas,
275
+ sl_pct = sl_pct,
276
+ tp_pct = tp_pct,
277
+ )