roboquant 2.3.2__tar.gz → 2.3.4__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.
- {roboquant-2.3.2 → roboquant-2.3.4}/PKG-INFO +2 -2
- {roboquant-2.3.2 → roboquant-2.3.4}/README.md +1 -1
- {roboquant-2.3.2 → roboquant-2.3.4}/pyproject.toml +1 -1
- {roboquant-2.3.2 → roboquant-2.3.4}/roboquant/ai/features.py +25 -10
- {roboquant-2.3.2 → roboquant-2.3.4}/roboquant/ai/strategies.py +10 -3
- roboquant-2.3.4/roboquant/crypto/__init__.py +4 -0
- {roboquant-2.3.2 → roboquant-2.3.4}/roboquant/signal.py +1 -2
- roboquant-2.3.2/roboquant/crypto/__init__.py +0 -3
- {roboquant-2.3.2 → roboquant-2.3.4}/LICENSE +0 -0
- {roboquant-2.3.2 → roboquant-2.3.4}/roboquant/__init__.py +0 -0
- {roboquant-2.3.2 → roboquant-2.3.4}/roboquant/account.py +0 -0
- {roboquant-2.3.2 → roboquant-2.3.4}/roboquant/ai/__init__.py +0 -0
- {roboquant-2.3.2 → roboquant-2.3.4}/roboquant/ai/rl.py +0 -0
- {roboquant-2.3.2 → roboquant-2.3.4}/roboquant/alpaca/__init__.py +0 -0
- {roboquant-2.3.2 → roboquant-2.3.4}/roboquant/alpaca/broker.py +0 -0
- {roboquant-2.3.2 → roboquant-2.3.4}/roboquant/alpaca/feed.py +0 -0
- {roboquant-2.3.2 → roboquant-2.3.4}/roboquant/asset.py +0 -0
- {roboquant-2.3.2 → roboquant-2.3.4}/roboquant/brokers/__init__.py +0 -0
- {roboquant-2.3.2 → roboquant-2.3.4}/roboquant/brokers/broker.py +0 -0
- {roboquant-2.3.2 → roboquant-2.3.4}/roboquant/brokers/simbroker.py +0 -0
- {roboquant-2.3.2 → roboquant-2.3.4}/roboquant/crypto/cryptobroker.py +0 -0
- {roboquant-2.3.2 → roboquant-2.3.4}/roboquant/crypto/cryptofeed.py +0 -0
- {roboquant-2.3.2 → roboquant-2.3.4}/roboquant/event.py +0 -0
- {roboquant-2.3.2 → roboquant-2.3.4}/roboquant/feeds/__init__.py +0 -0
- {roboquant-2.3.2 → roboquant-2.3.4}/roboquant/feeds/csvfeed.py +0 -0
- {roboquant-2.3.2 → roboquant-2.3.4}/roboquant/feeds/feed.py +0 -0
- {roboquant-2.3.2 → roboquant-2.3.4}/roboquant/feeds/historic.py +0 -0
- {roboquant-2.3.2 → roboquant-2.3.4}/roboquant/feeds/live.py +0 -0
- {roboquant-2.3.2 → roboquant-2.3.4}/roboquant/feeds/parquet.py +0 -0
- {roboquant-2.3.2 → roboquant-2.3.4}/roboquant/feeds/randomwalk.py +0 -0
- {roboquant-2.3.2 → roboquant-2.3.4}/roboquant/feeds/resources/us10.parquet +0 -0
- {roboquant-2.3.2 → roboquant-2.3.4}/roboquant/feeds/sql.py +0 -0
- {roboquant-2.3.2 → roboquant-2.3.4}/roboquant/feeds/util.py +0 -0
- {roboquant-2.3.2 → roboquant-2.3.4}/roboquant/feeds/yahoo.py +0 -0
- {roboquant-2.3.2 → roboquant-2.3.4}/roboquant/ibkr/__init__.py +0 -0
- {roboquant-2.3.2 → roboquant-2.3.4}/roboquant/ibkr/broker.py +0 -0
- {roboquant-2.3.2 → roboquant-2.3.4}/roboquant/ibkr/types.py +0 -0
- {roboquant-2.3.2 → roboquant-2.3.4}/roboquant/journals/__init__.py +0 -0
- {roboquant-2.3.2 → roboquant-2.3.4}/roboquant/journals/alphabeta.py +0 -0
- {roboquant-2.3.2 → roboquant-2.3.4}/roboquant/journals/basicjournal.py +0 -0
- {roboquant-2.3.2 → roboquant-2.3.4}/roboquant/journals/feedmetric.py +0 -0
- {roboquant-2.3.2 → roboquant-2.3.4}/roboquant/journals/journal.py +0 -0
- {roboquant-2.3.2 → roboquant-2.3.4}/roboquant/journals/marketmetric.py +0 -0
- {roboquant-2.3.2 → roboquant-2.3.4}/roboquant/journals/metric.py +0 -0
- {roboquant-2.3.2 → roboquant-2.3.4}/roboquant/journals/metricsjournal.py +0 -0
- {roboquant-2.3.2 → roboquant-2.3.4}/roboquant/journals/pnlmetric.py +0 -0
- {roboquant-2.3.2 → roboquant-2.3.4}/roboquant/journals/pricemetric.py +0 -0
- {roboquant-2.3.2 → roboquant-2.3.4}/roboquant/journals/runmetric.py +0 -0
- {roboquant-2.3.2 → roboquant-2.3.4}/roboquant/journals/scorecard.py +0 -0
- {roboquant-2.3.2 → roboquant-2.3.4}/roboquant/journals/tensorboard.py +0 -0
- {roboquant-2.3.2 → roboquant-2.3.4}/roboquant/monetary.py +0 -0
- {roboquant-2.3.2 → roboquant-2.3.4}/roboquant/order.py +0 -0
- {roboquant-2.3.2 → roboquant-2.3.4}/roboquant/run.py +0 -0
- {roboquant-2.3.2 → roboquant-2.3.4}/roboquant/strategies/__init__.py +0 -0
- {roboquant-2.3.2 → roboquant-2.3.4}/roboquant/strategies/buffer.py +0 -0
- {roboquant-2.3.2 → roboquant-2.3.4}/roboquant/strategies/cachedstrategy.py +0 -0
- {roboquant-2.3.2 → roboquant-2.3.4}/roboquant/strategies/emacrossover.py +0 -0
- {roboquant-2.3.2 → roboquant-2.3.4}/roboquant/strategies/ibsstrategy.py +0 -0
- {roboquant-2.3.2 → roboquant-2.3.4}/roboquant/strategies/multistrategy.py +0 -0
- {roboquant-2.3.2 → roboquant-2.3.4}/roboquant/strategies/strategy.py +0 -0
- {roboquant-2.3.2 → roboquant-2.3.4}/roboquant/strategies/tastrategy.py +0 -0
- {roboquant-2.3.2 → roboquant-2.3.4}/roboquant/ta/__init__.py +0 -0
- {roboquant-2.3.2 → roboquant-2.3.4}/roboquant/timeframe.py +0 -0
- {roboquant-2.3.2 → roboquant-2.3.4}/roboquant/traders/__init__.py +0 -0
- {roboquant-2.3.2 → roboquant-2.3.4}/roboquant/traders/flextrader.py +0 -0
- {roboquant-2.3.2 → roboquant-2.3.4}/roboquant/traders/trader.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: roboquant
|
|
3
|
-
Version: 2.3.
|
|
3
|
+
Version: 2.3.4
|
|
4
4
|
Summary: A fast algorithmic trading platform with support for AI based strategies
|
|
5
5
|
Keywords: algorithmic,trading,machine learning,AI,investment,finance,crypto,stocks,exchange,forex
|
|
6
6
|
Author: roboquant team
|
|
@@ -77,7 +77,7 @@ python3 -m pip install --upgrade roboquant
|
|
|
77
77
|
The core of roboquant limits the number of dependencies. But you can install roboquant including one or more of the optional dependencies if you require certain additional functionality:
|
|
78
78
|
|
|
79
79
|
```shell
|
|
80
|
-
# AI based strategies using
|
|
80
|
+
# AI based strategies using PyTorch and SB3
|
|
81
81
|
python3 -m pip install --upgrade "roboquant[ai]"
|
|
82
82
|
|
|
83
83
|
# Integration with Interactive Brokers
|
|
@@ -35,7 +35,7 @@ python3 -m pip install --upgrade roboquant
|
|
|
35
35
|
The core of roboquant limits the number of dependencies. But you can install roboquant including one or more of the optional dependencies if you require certain additional functionality:
|
|
36
36
|
|
|
37
37
|
```shell
|
|
38
|
-
# AI based strategies using
|
|
38
|
+
# AI based strategies using PyTorch and SB3
|
|
39
39
|
python3 -m pip install --upgrade "roboquant[ai]"
|
|
40
40
|
|
|
41
41
|
# Integration with Interactive Brokers
|
|
@@ -19,7 +19,7 @@ module-name = "roboquant"
|
|
|
19
19
|
|
|
20
20
|
[project]
|
|
21
21
|
name = "roboquant"
|
|
22
|
-
version = "2.3.
|
|
22
|
+
version = "2.3.4"
|
|
23
23
|
authors = [{ name = "roboquant team", email = "info@roboquant.org" }]
|
|
24
24
|
description = "A fast algorithmic trading platform with support for AI based strategies"
|
|
25
25
|
readme = "README.md"
|
|
@@ -16,9 +16,16 @@ FloatArray = NDArray[np.float32]
|
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
class Feature(Generic[T]):
|
|
19
|
-
"""Base class for different types of features.
|
|
19
|
+
"""Base class for different types of features. Features are the data building blocks for
|
|
20
|
+
roboquant machine learning models and can be used to extract relevant information.
|
|
21
|
+
|
|
20
22
|
The ones included by default are either based either an `Event` or an `Account`.
|
|
21
|
-
Typically Event features are used for input and Account features are used for
|
|
23
|
+
Typically Event features are used for input data and Account features are used for
|
|
24
|
+
reward/label/output data.
|
|
25
|
+
|
|
26
|
+
Features can be combined, sliced, nested, normalized and cached to create more
|
|
27
|
+
complex features.
|
|
28
|
+
"""
|
|
22
29
|
|
|
23
30
|
@abstractmethod
|
|
24
31
|
def calc(self, value: T) -> FloatArray:
|
|
@@ -33,7 +40,8 @@ class Feature(Generic[T]):
|
|
|
33
40
|
"""Return the size of this feature"""
|
|
34
41
|
|
|
35
42
|
def reset(self):
|
|
36
|
-
"""Reset the state of the feature
|
|
43
|
+
"""Reset the state of the feature. This is called at the start of a new epoch.
|
|
44
|
+
If the feature has no state, this can be left empty."""
|
|
37
45
|
|
|
38
46
|
def _shape(self):
|
|
39
47
|
"""return the shape of this feature as a tuple"""
|
|
@@ -244,7 +252,7 @@ class ReturnFeature(Feature[T]):
|
|
|
244
252
|
class LongReturnsFeature(Feature[T]):
|
|
245
253
|
def __init__(self, feature: Feature[T], period: int) -> None:
|
|
246
254
|
super().__init__()
|
|
247
|
-
self.history = deque(maxlen=period)
|
|
255
|
+
self.history: deque[FloatArray] = deque(maxlen=period)
|
|
248
256
|
self.feature: Feature = feature
|
|
249
257
|
|
|
250
258
|
def calc(self, value: T) -> FloatArray:
|
|
@@ -275,7 +283,7 @@ class MaxReturnFeature(Feature[T]):
|
|
|
275
283
|
def __init__(self, feature: Feature[T], period: int) -> None:
|
|
276
284
|
super().__init__()
|
|
277
285
|
assert feature.size() == 1
|
|
278
|
-
self.history = deque(maxlen=period)
|
|
286
|
+
self.history: deque[FloatArray] = deque(maxlen=period)
|
|
279
287
|
self.feature: Feature = feature
|
|
280
288
|
|
|
281
289
|
def calc(self, value: T) -> FloatArray:
|
|
@@ -304,7 +312,7 @@ class MinReturnFeature(Feature[T]):
|
|
|
304
312
|
|
|
305
313
|
def __init__(self, feature: Feature[T], period: int) -> None:
|
|
306
314
|
super().__init__()
|
|
307
|
-
self.history = deque(maxlen=period)
|
|
315
|
+
self.history: deque[FloatArray] = deque(maxlen=period)
|
|
308
316
|
self.feature: Feature = feature
|
|
309
317
|
|
|
310
318
|
def calc(self, value: T) -> FloatArray:
|
|
@@ -429,6 +437,7 @@ class DayOfMonthFeature(Feature[Event]):
|
|
|
429
437
|
"""Calculate a day of month where the first day of the month is 0 and the last day is 30.
|
|
430
438
|
Result can be one-hot encoded or not, depending on the `one_hot_encoded` parameter.
|
|
431
439
|
If `one_hot_encoded` is True, the result will be a 30-element array else the result will be a single value.
|
|
440
|
+
|
|
432
441
|
For example, if the event time is the 15th of the month, the result will be:
|
|
433
442
|
- one-hot encoded: [0.0, 0.0, ..., 1.0, 0.0, ..., 0.0] (1.0 at index 14)
|
|
434
443
|
- not one-hot encoded: [14.0]
|
|
@@ -637,11 +646,14 @@ class QuoteFeature(Feature[Event]):
|
|
|
637
646
|
|
|
638
647
|
|
|
639
648
|
class CacheFeature(Feature[Event]):
|
|
640
|
-
"""Cache the results of an event feature from a previous run. This can speed up the learning process
|
|
641
|
-
this requires that:
|
|
649
|
+
"""Cache the results of an event feature from a previous run. This can speed up the learning process
|
|
650
|
+
considerable, but this requires that:
|
|
642
651
|
|
|
643
652
|
- the feed to have always an increasing time value (monotonic)
|
|
644
|
-
- the feature has to produce the same output at a given time
|
|
653
|
+
- the underlying feature has to produce the same output at a given time (deterministic)
|
|
654
|
+
|
|
655
|
+
A reset doesn't clear the cache, but it will reset the underlying feature. If you want to clear
|
|
656
|
+
the cache, use the `clear()` method.
|
|
645
657
|
"""
|
|
646
658
|
|
|
647
659
|
def __init__(self, feature: Feature[Event], validate=False) -> None:
|
|
@@ -678,7 +690,10 @@ class CacheFeature(Feature[Event]):
|
|
|
678
690
|
|
|
679
691
|
|
|
680
692
|
class VolumeFeature(Feature[Event]):
|
|
681
|
-
"""Extract the volume for one or more assets in the event
|
|
693
|
+
"""Extract the trading volume for one or more assets in the event.
|
|
694
|
+
Make sure that the data avaialble in the event contains adjusted volume data (for example for stock splits),
|
|
695
|
+
otherwise the results will be incorrect.
|
|
696
|
+
"""
|
|
682
697
|
|
|
683
698
|
def __init__(self, *assets: Asset, volume_type: str = "DEFAULT") -> None:
|
|
684
699
|
super().__init__()
|
|
@@ -19,7 +19,10 @@ logger = logging.getLogger(__name__)
|
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
class FeatureStrategy(Strategy):
|
|
22
|
-
"""Abstract base class for strategies that use event features as input.
|
|
22
|
+
"""Abstract base class for strategies that use event features as input.
|
|
23
|
+
Typically these features are used to create input data for machine learning models,
|
|
24
|
+
which can then be used to generate signals.
|
|
25
|
+
"""
|
|
23
26
|
|
|
24
27
|
def __init__(self, input_feature: Feature[Event], history: int, dtype="float32"):
|
|
25
28
|
super().__init__()
|
|
@@ -104,9 +107,13 @@ class TimeSeriesStrategy(FeatureStrategy):
|
|
|
104
107
|
"""Strategy using a sequenced neural network to predict future time series values.
|
|
105
108
|
The input and label features are calculated from events.
|
|
106
109
|
The model is expected to be a PyTorch module that takes the input features and outputs predictions.
|
|
110
|
+
An example of a model could be a recurrent neural network (RNN) or a long short-term memory (LSTM) network.
|
|
111
|
+
|
|
107
112
|
The strategy can be used to generate buy/sell signals based on the model's predictions.
|
|
108
113
|
This strategy is suitable for time series forecasting tasks where the model learns from historical data
|
|
109
|
-
to predict future values.
|
|
114
|
+
to predict future values.
|
|
115
|
+
|
|
116
|
+
Right now this class only supports a single asset, but this can be extended.
|
|
110
117
|
"""
|
|
111
118
|
|
|
112
119
|
def __init__(
|
|
@@ -140,7 +147,7 @@ class TimeSeriesStrategy(FeatureStrategy):
|
|
|
140
147
|
else:
|
|
141
148
|
p = output.item()
|
|
142
149
|
|
|
143
|
-
logger.info("Prediction p=%s time=%s", p, dt)
|
|
150
|
+
logger.info("Prediction asset=%s p=%s time=%s", self.asset.symbol, p, dt)
|
|
144
151
|
if p >= self.buy_pct:
|
|
145
152
|
return [Signal.buy(self.asset)]
|
|
146
153
|
if p <= self.sell_pct:
|
|
@@ -22,8 +22,7 @@ class SignalType(Flag):
|
|
|
22
22
|
"""Indicates that this signal can be used for both entering and exiting a position size"""
|
|
23
23
|
|
|
24
24
|
def __repr__(self):
|
|
25
|
-
return self.name.split(".")[-1]
|
|
26
|
-
|
|
25
|
+
return self.name.split(".")[-1] if self.name else super().__repr__()
|
|
27
26
|
|
|
28
27
|
@dataclass(slots=True, frozen=True)
|
|
29
28
|
class Signal:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|