QTradeX 1.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 (45) hide show
  1. qtradex-1.0/PKG-INFO +166 -0
  2. qtradex-1.0/QTradeX.egg-info/PKG-INFO +166 -0
  3. qtradex-1.0/QTradeX.egg-info/SOURCES.txt +43 -0
  4. qtradex-1.0/QTradeX.egg-info/dependency_links.txt +1 -0
  5. qtradex-1.0/QTradeX.egg-info/entry_points.txt +2 -0
  6. qtradex-1.0/QTradeX.egg-info/requires.txt +2 -0
  7. qtradex-1.0/QTradeX.egg-info/top_level.txt +1 -0
  8. qtradex-1.0/README.md +142 -0
  9. qtradex-1.0/qtradex/__init__.py +35 -0
  10. qtradex-1.0/qtradex/common/__init__.py +3 -0
  11. qtradex-1.0/qtradex/common/bitshares_nodes.py +47 -0
  12. qtradex-1.0/qtradex/common/json_ipc.py +112 -0
  13. qtradex-1.0/qtradex/common/utilities.py +578 -0
  14. qtradex-1.0/qtradex/core/__init__.py +4 -0
  15. qtradex-1.0/qtradex/core/backtest.py +167 -0
  16. qtradex-1.0/qtradex/core/base_bot.py +30 -0
  17. qtradex-1.0/qtradex/core/dispatch.py +64 -0
  18. qtradex-1.0/qtradex/core/quant.py +114 -0
  19. qtradex-1.0/qtradex/indicators/__init__.py +3 -0
  20. qtradex-1.0/qtradex/indicators/cache_decorator.py +51 -0
  21. qtradex-1.0/qtradex/indicators/codegen.py +41 -0
  22. qtradex-1.0/qtradex/indicators/fitness.py +427 -0
  23. qtradex-1.0/qtradex/indicators/tulipy_wrapped.py +527 -0
  24. qtradex-1.0/qtradex/indicators/utilities.c +9032 -0
  25. qtradex-1.0/qtradex/indicators/utilities.pyx +151 -0
  26. qtradex-1.0/qtradex/optimizers/__init__.py +2 -0
  27. qtradex-1.0/qtradex/optimizers/qpso.py +405 -0
  28. qtradex-1.0/qtradex/optimizers/utilities.py +138 -0
  29. qtradex-1.0/qtradex/plot/__init__.py +1 -0
  30. qtradex-1.0/qtradex/plot/utilities.py +177 -0
  31. qtradex-1.0/qtradex/private/__init__.py +2 -0
  32. qtradex-1.0/qtradex/private/signals.py +27 -0
  33. qtradex-1.0/qtradex/private/wallet.py +70 -0
  34. qtradex-1.0/qtradex/public/__init__.py +1 -0
  35. qtradex-1.0/qtradex/public/data.py +434 -0
  36. qtradex-1.0/qtradex/public/kibana.py +383 -0
  37. qtradex-1.0/qtradex/public/kibana_queries.py +73 -0
  38. qtradex-1.0/qtradex/public/klines_alphavantage.py +358 -0
  39. qtradex-1.0/qtradex/public/klines_bitshares.py +580 -0
  40. qtradex-1.0/qtradex/public/klines_cryptocompare.py +407 -0
  41. qtradex-1.0/qtradex/public/klines_nomics.py +209 -0
  42. qtradex-1.0/qtradex/public/klines_synthetic.py +159 -0
  43. qtradex-1.0/qtradex/public/rpc.py +369 -0
  44. qtradex-1.0/setup.cfg +4 -0
  45. qtradex-1.0/setup.py +38 -0
qtradex-1.0/PKG-INFO ADDED
@@ -0,0 +1,166 @@
1
+ Metadata-Version: 2.2
2
+ Name: QTradeX
3
+ Version: 1.0
4
+ Home-page: https://github.com/
5
+ Author: squidKid-deluxe, litepresence
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/
8
+ Project-URL: Issues, https://github.com/
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Operating System :: POSIX :: Linux
11
+ Requires-Python: >=3.9
12
+ Description-Content-Type: text/markdown
13
+ Requires-Dist: Cython
14
+ Requires-Dist: setuptools>64
15
+ Dynamic: author
16
+ Dynamic: classifier
17
+ Dynamic: description
18
+ Dynamic: description-content-type
19
+ Dynamic: home-page
20
+ Dynamic: license
21
+ Dynamic: project-url
22
+ Dynamic: requires-dist
23
+ Dynamic: requires-python
24
+
25
+ # QTradeX Core Framework
26
+
27
+ Welcome to **QTradeX**, a powerful and flexible Python framework for designing, backtesting, and deploying algorithmic trading bots. Built with cryptocurrency markets in mind, QTradeX provides high-level abstractions for trading strategies, technical indicators, data handling, and optimization, making it an ideal tool for both novice and experienced algo-traders.
28
+
29
+ This repository contains the core QTradeX framework.
30
+
31
+ For a collection of pre-built trading strategies, check out the companion repository:
32
+
33
+ [QTradeX Algo Trading Strategies](https://github.com/squidKid-deluxe/qtradex-ai-agents).
34
+
35
+ ---
36
+
37
+ ## Overview
38
+
39
+ QTradeX simplifies the development of trading bots by offering a modular architecture and robust tools:
40
+ - **Core Modules**: Build bots, run backtests, and optimize with a QPSO or LSGA.
41
+ - **Data Integration**: Fetch market data from exchanges like BitShares, KuCoin, and others via built-in CCXT integration.
42
+ - **Indicators**: Leverage wrapped traditional fininancial technical indicators from Tulip for strategy logic.
43
+ - **Visualization**: Plot trades and metrics with ease.
44
+ - **Extensibility**: Customize bots and integrate with your preferred exchanges or data sources.
45
+
46
+ Whether you’re experimenting with moving averages or building complex multi-indicator systems, QTradeX provides the foundation to turn your ideas into actionable trading algorithms.
47
+
48
+ ---
49
+
50
+ ## Features
51
+
52
+ - **Bot Development**: Subclass `BaseBot` to define custom strategies, indicators, and fitness metrics.
53
+ - **Backtesting**: Simulate trades with historical data using `qx.core.backtest`, or use the built-in CLI with `qx.core.dispatch`.
54
+ - **Optimization**: Tune parameters automatically with Quantum Particle Swarm Optimization (`qpso.py`) or Local Search Genetic Algorithms (`lsga.py`).
55
+ - **Data Pipeline**: Access candle data from any of over a hundred sources.
56
+ - **Performance Metrics**: Evaluate bots with built-in fitness functions like ROI, Sortino ratio, and Win Rate with our fitness implementations.
57
+ - **DEX and CEX Integration**: Works on both Bitshares Decentralized Exchange and 100+ Centralized Exchanges
58
+
59
+ ## Speed
60
+
61
+ - **Fully Vectorized**: All indicators are calculated once and cached as vectors
62
+ - **Data Cache**: All API candle data from exchanges is collected once and stored on disk
63
+ - **Back Propagation**: Achieve 50+ backtests per second on a Raspberry Pi during parameter optimization
64
+ - **Instant Backtest**: 1000 candles and 10 indicators in less than a 1/10th of second.
65
+
66
+ ---
67
+
68
+ ## Roadmap
69
+
70
+ - **Live Execution**: Finalize and test the live execution pipeline on Centralized Exchange via CCXT SDK and Bitshares Decentralized Exchange
71
+ - **Indicators**: Add additional Technical Indicators from sources other than Tulip
72
+ - **Tradfi**: Create connector for Traditional Retail Finance Brokerage(s); Stocks, Forex, Comex, etc.
73
+
74
+ ## Project Structure
75
+
76
+ ```
77
+ qtradex/
78
+ ├── common/ # Utilities like JSON IPC and BitShares nodes
79
+ ├── core/ # Core bot logic and backtesting
80
+ ├── indicators/ # Technical indicators and fitness metrics
81
+ ├── optimizers/ # Optimization algorithms (QPSO, LSGA)
82
+ ├── plot/ # Visualization tools
83
+ ├── private/ # Wallet and execution logic
84
+ ├── public/ # Data fetching and market utilities
85
+ └── setup.py # Installation script
86
+ ```
87
+
88
+ Key files:
89
+ - `core/base_bot.py`: Base class for creating trading bots.
90
+ - `core/dispatch.py`: Allows for easy management of botscripts and tunes.
91
+ - `public/data.py`: Manages market data retrieval.
92
+ - `indicators/tulipy_wrapped.py`: Wrapped Tulipy indicators for cached speed.
93
+
94
+ ---
95
+
96
+ ## Getting Started
97
+
98
+ ### Installation
99
+
100
+ ```bash
101
+ pip install qtradex
102
+ ```
103
+
104
+ ### Example: Creating a Simple Bot
105
+ Here’s a minimal bot using an EMA crossover strategy:
106
+
107
+ ```python
108
+ import qtradex as qx
109
+ from qtradex.indicators import tulipy as tu
110
+ from qtradex.private.signals import Buy, Sell, Thresholds
111
+
112
+ class EMACrossBot(qx.core.BaseBot):
113
+ def __init__(self):
114
+ self.tune = {"fast_ema": 10, "slow_ema": 50}
115
+
116
+ def indicators(self, data):
117
+ return {
118
+ "fast_ema": tu.ema(data["close"], self.tune["fast_ema"]),
119
+ "slow_ema": tu.ema(data["close"], self.tune["slow_ema"])
120
+ }
121
+
122
+ def strategy(self, tick_info, indicators):
123
+ price = tick_info["close"]
124
+ fast = indicators["fast_ema"][-1]
125
+ slow = indicators["slow_ema"][-1]
126
+ if fast > slow:
127
+ return Buy()
128
+ elif fast < slow:
129
+ return Sell()
130
+ return Thresholds(buying=price, selling=price)
131
+
132
+ # Run the bot
133
+ data = qx.public.Data(exchange="kucoin", asset="BTC", currency="USDT", begin="2023-01-01", end="2023-12-31")
134
+ wallet = qx.private.PaperWallet({"BTC": 1, "USDT": 0})
135
+ bot = EMACrossBot()
136
+ qx.core.dispatch(bot, data, wallet)
137
+ ```
138
+
139
+ For more examples, see the [QTradeX Algo Trading Strategies](https://github.com/squidKid-deluxe/qtradex-ai-agents) repo.
140
+
141
+ ---
142
+
143
+ ## Usage
144
+
145
+ 1. **Build a Bot**: Subclass `BaseBot` and define your `indicators` and `strategy`.
146
+ 2. **Backtest**: Use `qx.core.dispatch` with historical data from `qx.Data`.
147
+ 3. **Optimize**: Run a QPSO of LSGA to fine-tune parameters, which will be stored in `<working directory>/tunes/`.
148
+ 4. **Deploy**: *Work in progress*
149
+
150
+ ---
151
+
152
+ ## Resources
153
+
154
+ - **Strategies Repo**: [QTradeX Algo Trading Strategies](https://github.com/squidKid-deluxe/qtradex-ai-agents)
155
+ - **Tulipy Docs**: [GitHub](https://tulipindicators.org)
156
+ - **CCXT Docs**: [CCXT](https://docs.ccxt.com)
157
+
158
+ ---
159
+
160
+ ## License
161
+
162
+ This project is licensed WTFPL
163
+
164
+ ---
165
+
166
+ Happy coding and trading! Open an issue if you run into problems or have ideas to share.
@@ -0,0 +1,166 @@
1
+ Metadata-Version: 2.2
2
+ Name: QTradeX
3
+ Version: 1.0
4
+ Home-page: https://github.com/
5
+ Author: squidKid-deluxe, litepresence
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/
8
+ Project-URL: Issues, https://github.com/
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Operating System :: POSIX :: Linux
11
+ Requires-Python: >=3.9
12
+ Description-Content-Type: text/markdown
13
+ Requires-Dist: Cython
14
+ Requires-Dist: setuptools>64
15
+ Dynamic: author
16
+ Dynamic: classifier
17
+ Dynamic: description
18
+ Dynamic: description-content-type
19
+ Dynamic: home-page
20
+ Dynamic: license
21
+ Dynamic: project-url
22
+ Dynamic: requires-dist
23
+ Dynamic: requires-python
24
+
25
+ # QTradeX Core Framework
26
+
27
+ Welcome to **QTradeX**, a powerful and flexible Python framework for designing, backtesting, and deploying algorithmic trading bots. Built with cryptocurrency markets in mind, QTradeX provides high-level abstractions for trading strategies, technical indicators, data handling, and optimization, making it an ideal tool for both novice and experienced algo-traders.
28
+
29
+ This repository contains the core QTradeX framework.
30
+
31
+ For a collection of pre-built trading strategies, check out the companion repository:
32
+
33
+ [QTradeX Algo Trading Strategies](https://github.com/squidKid-deluxe/qtradex-ai-agents).
34
+
35
+ ---
36
+
37
+ ## Overview
38
+
39
+ QTradeX simplifies the development of trading bots by offering a modular architecture and robust tools:
40
+ - **Core Modules**: Build bots, run backtests, and optimize with a QPSO or LSGA.
41
+ - **Data Integration**: Fetch market data from exchanges like BitShares, KuCoin, and others via built-in CCXT integration.
42
+ - **Indicators**: Leverage wrapped traditional fininancial technical indicators from Tulip for strategy logic.
43
+ - **Visualization**: Plot trades and metrics with ease.
44
+ - **Extensibility**: Customize bots and integrate with your preferred exchanges or data sources.
45
+
46
+ Whether you’re experimenting with moving averages or building complex multi-indicator systems, QTradeX provides the foundation to turn your ideas into actionable trading algorithms.
47
+
48
+ ---
49
+
50
+ ## Features
51
+
52
+ - **Bot Development**: Subclass `BaseBot` to define custom strategies, indicators, and fitness metrics.
53
+ - **Backtesting**: Simulate trades with historical data using `qx.core.backtest`, or use the built-in CLI with `qx.core.dispatch`.
54
+ - **Optimization**: Tune parameters automatically with Quantum Particle Swarm Optimization (`qpso.py`) or Local Search Genetic Algorithms (`lsga.py`).
55
+ - **Data Pipeline**: Access candle data from any of over a hundred sources.
56
+ - **Performance Metrics**: Evaluate bots with built-in fitness functions like ROI, Sortino ratio, and Win Rate with our fitness implementations.
57
+ - **DEX and CEX Integration**: Works on both Bitshares Decentralized Exchange and 100+ Centralized Exchanges
58
+
59
+ ## Speed
60
+
61
+ - **Fully Vectorized**: All indicators are calculated once and cached as vectors
62
+ - **Data Cache**: All API candle data from exchanges is collected once and stored on disk
63
+ - **Back Propagation**: Achieve 50+ backtests per second on a Raspberry Pi during parameter optimization
64
+ - **Instant Backtest**: 1000 candles and 10 indicators in less than a 1/10th of second.
65
+
66
+ ---
67
+
68
+ ## Roadmap
69
+
70
+ - **Live Execution**: Finalize and test the live execution pipeline on Centralized Exchange via CCXT SDK and Bitshares Decentralized Exchange
71
+ - **Indicators**: Add additional Technical Indicators from sources other than Tulip
72
+ - **Tradfi**: Create connector for Traditional Retail Finance Brokerage(s); Stocks, Forex, Comex, etc.
73
+
74
+ ## Project Structure
75
+
76
+ ```
77
+ qtradex/
78
+ ├── common/ # Utilities like JSON IPC and BitShares nodes
79
+ ├── core/ # Core bot logic and backtesting
80
+ ├── indicators/ # Technical indicators and fitness metrics
81
+ ├── optimizers/ # Optimization algorithms (QPSO, LSGA)
82
+ ├── plot/ # Visualization tools
83
+ ├── private/ # Wallet and execution logic
84
+ ├── public/ # Data fetching and market utilities
85
+ └── setup.py # Installation script
86
+ ```
87
+
88
+ Key files:
89
+ - `core/base_bot.py`: Base class for creating trading bots.
90
+ - `core/dispatch.py`: Allows for easy management of botscripts and tunes.
91
+ - `public/data.py`: Manages market data retrieval.
92
+ - `indicators/tulipy_wrapped.py`: Wrapped Tulipy indicators for cached speed.
93
+
94
+ ---
95
+
96
+ ## Getting Started
97
+
98
+ ### Installation
99
+
100
+ ```bash
101
+ pip install qtradex
102
+ ```
103
+
104
+ ### Example: Creating a Simple Bot
105
+ Here’s a minimal bot using an EMA crossover strategy:
106
+
107
+ ```python
108
+ import qtradex as qx
109
+ from qtradex.indicators import tulipy as tu
110
+ from qtradex.private.signals import Buy, Sell, Thresholds
111
+
112
+ class EMACrossBot(qx.core.BaseBot):
113
+ def __init__(self):
114
+ self.tune = {"fast_ema": 10, "slow_ema": 50}
115
+
116
+ def indicators(self, data):
117
+ return {
118
+ "fast_ema": tu.ema(data["close"], self.tune["fast_ema"]),
119
+ "slow_ema": tu.ema(data["close"], self.tune["slow_ema"])
120
+ }
121
+
122
+ def strategy(self, tick_info, indicators):
123
+ price = tick_info["close"]
124
+ fast = indicators["fast_ema"][-1]
125
+ slow = indicators["slow_ema"][-1]
126
+ if fast > slow:
127
+ return Buy()
128
+ elif fast < slow:
129
+ return Sell()
130
+ return Thresholds(buying=price, selling=price)
131
+
132
+ # Run the bot
133
+ data = qx.public.Data(exchange="kucoin", asset="BTC", currency="USDT", begin="2023-01-01", end="2023-12-31")
134
+ wallet = qx.private.PaperWallet({"BTC": 1, "USDT": 0})
135
+ bot = EMACrossBot()
136
+ qx.core.dispatch(bot, data, wallet)
137
+ ```
138
+
139
+ For more examples, see the [QTradeX Algo Trading Strategies](https://github.com/squidKid-deluxe/qtradex-ai-agents) repo.
140
+
141
+ ---
142
+
143
+ ## Usage
144
+
145
+ 1. **Build a Bot**: Subclass `BaseBot` and define your `indicators` and `strategy`.
146
+ 2. **Backtest**: Use `qx.core.dispatch` with historical data from `qx.Data`.
147
+ 3. **Optimize**: Run a QPSO of LSGA to fine-tune parameters, which will be stored in `<working directory>/tunes/`.
148
+ 4. **Deploy**: *Work in progress*
149
+
150
+ ---
151
+
152
+ ## Resources
153
+
154
+ - **Strategies Repo**: [QTradeX Algo Trading Strategies](https://github.com/squidKid-deluxe/qtradex-ai-agents)
155
+ - **Tulipy Docs**: [GitHub](https://tulipindicators.org)
156
+ - **CCXT Docs**: [CCXT](https://docs.ccxt.com)
157
+
158
+ ---
159
+
160
+ ## License
161
+
162
+ This project is licensed WTFPL
163
+
164
+ ---
165
+
166
+ Happy coding and trading! Open an issue if you run into problems or have ideas to share.
@@ -0,0 +1,43 @@
1
+ README.md
2
+ setup.py
3
+ QTradeX.egg-info/PKG-INFO
4
+ QTradeX.egg-info/SOURCES.txt
5
+ QTradeX.egg-info/dependency_links.txt
6
+ QTradeX.egg-info/entry_points.txt
7
+ QTradeX.egg-info/requires.txt
8
+ QTradeX.egg-info/top_level.txt
9
+ qtradex/__init__.py
10
+ qtradex/common/__init__.py
11
+ qtradex/common/bitshares_nodes.py
12
+ qtradex/common/json_ipc.py
13
+ qtradex/common/utilities.py
14
+ qtradex/core/__init__.py
15
+ qtradex/core/backtest.py
16
+ qtradex/core/base_bot.py
17
+ qtradex/core/dispatch.py
18
+ qtradex/core/quant.py
19
+ qtradex/indicators/__init__.py
20
+ qtradex/indicators/cache_decorator.py
21
+ qtradex/indicators/codegen.py
22
+ qtradex/indicators/fitness.py
23
+ qtradex/indicators/tulipy_wrapped.py
24
+ qtradex/indicators/utilities.c
25
+ qtradex/indicators/utilities.pyx
26
+ qtradex/optimizers/__init__.py
27
+ qtradex/optimizers/qpso.py
28
+ qtradex/optimizers/utilities.py
29
+ qtradex/plot/__init__.py
30
+ qtradex/plot/utilities.py
31
+ qtradex/private/__init__.py
32
+ qtradex/private/signals.py
33
+ qtradex/private/wallet.py
34
+ qtradex/public/__init__.py
35
+ qtradex/public/data.py
36
+ qtradex/public/kibana.py
37
+ qtradex/public/kibana_queries.py
38
+ qtradex/public/klines_alphavantage.py
39
+ qtradex/public/klines_bitshares.py
40
+ qtradex/public/klines_cryptocompare.py
41
+ qtradex/public/klines_nomics.py
42
+ qtradex/public/klines_synthetic.py
43
+ qtradex/public/rpc.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ qtradex-tune-manager = qtradex.core.tune_manager:main
@@ -0,0 +1,2 @@
1
+ Cython
2
+ setuptools>64
@@ -0,0 +1 @@
1
+ qtradex
qtradex-1.0/README.md ADDED
@@ -0,0 +1,142 @@
1
+ # QTradeX Core Framework
2
+
3
+ Welcome to **QTradeX**, a powerful and flexible Python framework for designing, backtesting, and deploying algorithmic trading bots. Built with cryptocurrency markets in mind, QTradeX provides high-level abstractions for trading strategies, technical indicators, data handling, and optimization, making it an ideal tool for both novice and experienced algo-traders.
4
+
5
+ This repository contains the core QTradeX framework.
6
+
7
+ For a collection of pre-built trading strategies, check out the companion repository:
8
+
9
+ [QTradeX Algo Trading Strategies](https://github.com/squidKid-deluxe/qtradex-ai-agents).
10
+
11
+ ---
12
+
13
+ ## Overview
14
+
15
+ QTradeX simplifies the development of trading bots by offering a modular architecture and robust tools:
16
+ - **Core Modules**: Build bots, run backtests, and optimize with a QPSO or LSGA.
17
+ - **Data Integration**: Fetch market data from exchanges like BitShares, KuCoin, and others via built-in CCXT integration.
18
+ - **Indicators**: Leverage wrapped traditional fininancial technical indicators from Tulip for strategy logic.
19
+ - **Visualization**: Plot trades and metrics with ease.
20
+ - **Extensibility**: Customize bots and integrate with your preferred exchanges or data sources.
21
+
22
+ Whether you’re experimenting with moving averages or building complex multi-indicator systems, QTradeX provides the foundation to turn your ideas into actionable trading algorithms.
23
+
24
+ ---
25
+
26
+ ## Features
27
+
28
+ - **Bot Development**: Subclass `BaseBot` to define custom strategies, indicators, and fitness metrics.
29
+ - **Backtesting**: Simulate trades with historical data using `qx.core.backtest`, or use the built-in CLI with `qx.core.dispatch`.
30
+ - **Optimization**: Tune parameters automatically with Quantum Particle Swarm Optimization (`qpso.py`) or Local Search Genetic Algorithms (`lsga.py`).
31
+ - **Data Pipeline**: Access candle data from any of over a hundred sources.
32
+ - **Performance Metrics**: Evaluate bots with built-in fitness functions like ROI, Sortino ratio, and Win Rate with our fitness implementations.
33
+ - **DEX and CEX Integration**: Works on both Bitshares Decentralized Exchange and 100+ Centralized Exchanges
34
+
35
+ ## Speed
36
+
37
+ - **Fully Vectorized**: All indicators are calculated once and cached as vectors
38
+ - **Data Cache**: All API candle data from exchanges is collected once and stored on disk
39
+ - **Back Propagation**: Achieve 50+ backtests per second on a Raspberry Pi during parameter optimization
40
+ - **Instant Backtest**: 1000 candles and 10 indicators in less than a 1/10th of second.
41
+
42
+ ---
43
+
44
+ ## Roadmap
45
+
46
+ - **Live Execution**: Finalize and test the live execution pipeline on Centralized Exchange via CCXT SDK and Bitshares Decentralized Exchange
47
+ - **Indicators**: Add additional Technical Indicators from sources other than Tulip
48
+ - **Tradfi**: Create connector for Traditional Retail Finance Brokerage(s); Stocks, Forex, Comex, etc.
49
+
50
+ ## Project Structure
51
+
52
+ ```
53
+ qtradex/
54
+ ├── common/ # Utilities like JSON IPC and BitShares nodes
55
+ ├── core/ # Core bot logic and backtesting
56
+ ├── indicators/ # Technical indicators and fitness metrics
57
+ ├── optimizers/ # Optimization algorithms (QPSO, LSGA)
58
+ ├── plot/ # Visualization tools
59
+ ├── private/ # Wallet and execution logic
60
+ ├── public/ # Data fetching and market utilities
61
+ └── setup.py # Installation script
62
+ ```
63
+
64
+ Key files:
65
+ - `core/base_bot.py`: Base class for creating trading bots.
66
+ - `core/dispatch.py`: Allows for easy management of botscripts and tunes.
67
+ - `public/data.py`: Manages market data retrieval.
68
+ - `indicators/tulipy_wrapped.py`: Wrapped Tulipy indicators for cached speed.
69
+
70
+ ---
71
+
72
+ ## Getting Started
73
+
74
+ ### Installation
75
+
76
+ ```bash
77
+ pip install qtradex
78
+ ```
79
+
80
+ ### Example: Creating a Simple Bot
81
+ Here’s a minimal bot using an EMA crossover strategy:
82
+
83
+ ```python
84
+ import qtradex as qx
85
+ from qtradex.indicators import tulipy as tu
86
+ from qtradex.private.signals import Buy, Sell, Thresholds
87
+
88
+ class EMACrossBot(qx.core.BaseBot):
89
+ def __init__(self):
90
+ self.tune = {"fast_ema": 10, "slow_ema": 50}
91
+
92
+ def indicators(self, data):
93
+ return {
94
+ "fast_ema": tu.ema(data["close"], self.tune["fast_ema"]),
95
+ "slow_ema": tu.ema(data["close"], self.tune["slow_ema"])
96
+ }
97
+
98
+ def strategy(self, tick_info, indicators):
99
+ price = tick_info["close"]
100
+ fast = indicators["fast_ema"][-1]
101
+ slow = indicators["slow_ema"][-1]
102
+ if fast > slow:
103
+ return Buy()
104
+ elif fast < slow:
105
+ return Sell()
106
+ return Thresholds(buying=price, selling=price)
107
+
108
+ # Run the bot
109
+ data = qx.public.Data(exchange="kucoin", asset="BTC", currency="USDT", begin="2023-01-01", end="2023-12-31")
110
+ wallet = qx.private.PaperWallet({"BTC": 1, "USDT": 0})
111
+ bot = EMACrossBot()
112
+ qx.core.dispatch(bot, data, wallet)
113
+ ```
114
+
115
+ For more examples, see the [QTradeX Algo Trading Strategies](https://github.com/squidKid-deluxe/qtradex-ai-agents) repo.
116
+
117
+ ---
118
+
119
+ ## Usage
120
+
121
+ 1. **Build a Bot**: Subclass `BaseBot` and define your `indicators` and `strategy`.
122
+ 2. **Backtest**: Use `qx.core.dispatch` with historical data from `qx.Data`.
123
+ 3. **Optimize**: Run a QPSO of LSGA to fine-tune parameters, which will be stored in `<working directory>/tunes/`.
124
+ 4. **Deploy**: *Work in progress*
125
+
126
+ ---
127
+
128
+ ## Resources
129
+
130
+ - **Strategies Repo**: [QTradeX Algo Trading Strategies](https://github.com/squidKid-deluxe/qtradex-ai-agents)
131
+ - **Tulipy Docs**: [GitHub](https://tulipindicators.org)
132
+ - **CCXT Docs**: [CCXT](https://docs.ccxt.com)
133
+
134
+ ---
135
+
136
+ ## License
137
+
138
+ This project is licensed WTFPL
139
+
140
+ ---
141
+
142
+ Happy coding and trading! Open an issue if you run into problems or have ideas to share.
@@ -0,0 +1,35 @@
1
+ """
2
+ exposes these methods and classes as the user level qtradex namespace
3
+
4
+ qtradex.expand_bools
5
+ qtradex.rotate
6
+ qtradex.BaseBot
7
+ qtradex.dispatch
8
+ qtradex.load_tune
9
+ qtradex.derivative
10
+ qtradex.fitness
11
+ qtradex.float_period
12
+ qtradex.lag
13
+ qtradex.tu
14
+ qtradex.Buy
15
+ qtradex.Sell
16
+ qtradex.Thresholds
17
+ qtradex.Data
18
+ qtradex.plot
19
+ """
20
+
21
+ import qtradex.common
22
+ import qtradex.core
23
+ import qtradex.indicators
24
+ import qtradex.optimizers
25
+ import qtradex.plot
26
+ import qtradex.public.data
27
+ from qtradex.common.utilities import expand_bools, rotate, truncate
28
+ from qtradex.core import BaseBot, dispatch
29
+ from qtradex.core.tune_manager import load_tune
30
+ from qtradex.indicators import derivative, fitness, float_period, lag
31
+ from qtradex.indicators import tulipy as tu
32
+ from qtradex.plot import plot, plotmotion
33
+ from qtradex.private import PaperWallet, Wallet
34
+ from qtradex.private.signals import Buy, Sell, Thresholds
35
+ from qtradex.public import Data
@@ -0,0 +1,3 @@
1
+ import qtradex.common.bitshares_nodes
2
+ import qtradex.common.json_ipc
3
+ import qtradex.common.utilities
@@ -0,0 +1,47 @@
1
+ """
2
+ ╔═╗─┐ ┬┌┬┐┬┌┐┌┌─┐┌┬┐┬┌─┐┌┐┌╔═╗┬ ┬┌─┐┌┐┌┌┬┐
3
+ ║╣ ┌┴┬┘ │ │││││ │ ││ ││││║╣ └┐┌┘├┤ │││ │
4
+ ╚═╝┴ └─ ┴ ┴┘└┘└─┘ ┴ ┴└─┘┘└┘╚═╝ └┘ └─┘┘└┘ ┴
5
+
6
+ a list of active bitshares nodes
7
+ """
8
+
9
+ bitshares_nodes = [
10
+ "wss://api.bts.mobi/wss",
11
+ # "wss://newyork.bitshares.im/wss",
12
+ # "wss://bts.open.icowallet.net/ws",
13
+ "wss://eu.nodes.bitshares.ws/ws",
14
+ # "wss://cloud.xbts.io/wss",
15
+ "wss://dex.iobanker.com/wss",
16
+ # "wss://bts.mypi.win/wss",
17
+ # "wss://hongkong.bitshares.im/wss",
18
+ "wss://node.xbts.io/wss",
19
+ "wss://public.xbts.io/ws",
20
+ "wss://btsws.roelandp.nl/wss",
21
+ # "wss://singapore.bitshares.im/ws",
22
+ ]
23
+ # "wss://api.bts.mobi/wss",
24
+ # "wss://dex.iobanker.com/ws",
25
+ # ]
26
+ # "wss://api-us.61bts.com/wss",
27
+ # "wss://cloud.xbts.io/ws",
28
+ # "wss://api.dex.trading/wss",
29
+ # "wss://eu.nodes.bitshares.ws/ws",
30
+ # "wss://api.pindd.club/ws",
31
+ # "wss://public.xbts.io/ws",
32
+ # "wss://node.xbts.io/ws",
33
+ # "wss://node.market.rudex.org/ws",
34
+ # "wss://nexus01.co.uk/ws",
35
+ # "wss://api-bts.liondani.com/ws",
36
+ # "wss://api.bitshares.bhuz.info/wss",
37
+ # "wss://btsws.roelandp.nl/ws",
38
+ # "wss://hongkong.bitshares.im/ws",
39
+ # "wss://node1.deex.exchange/wss",
40
+ # "wss://api.cnvote.vip:888/wss",
41
+ # "wss://bts.open.icowallet.net/ws",
42
+ # "wss://api.weaccount.cn/ws",
43
+ # "wss://api.61bts.com",
44
+ # "wss://api.btsgo.net/ws",
45
+ # "wss://bitshares.bts123.cc:15138/wss",
46
+ # "wss://singapore.bitshares.im/wss",
47
+ # ]