quantex 0.2.0__tar.gz → 0.2.2__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.
- {quantex-0.2.0 → quantex-0.2.2}/PKG-INFO +1 -1
- {quantex-0.2.0 → quantex-0.2.2}/pyproject.toml +1 -1
- quantex-0.2.2/src/quantex/__init__.py +4 -0
- {quantex-0.2.0 → quantex-0.2.2}/src/quantex/broker.py +9 -0
- {quantex-0.2.0 → quantex-0.2.2}/src/quantex/datasource.py +7 -2
- quantex-0.2.0/src/quantex/__init__.py +0 -4
- {quantex-0.2.0 → quantex-0.2.2}/LICENSE.md +0 -0
- {quantex-0.2.0 → quantex-0.2.2}/README.md +0 -0
- {quantex-0.2.0 → quantex-0.2.2}/src/quantex/backtester.py +0 -0
- {quantex-0.2.0 → quantex-0.2.2}/src/quantex/enums.py +0 -0
- {quantex-0.2.0 → quantex-0.2.2}/src/quantex/helpers.py +0 -0
- {quantex-0.2.0 → quantex-0.2.2}/src/quantex/strategy.py +0 -0
|
@@ -144,6 +144,15 @@ class Broker:
|
|
|
144
144
|
timestamp=self.source.Index[self._i]
|
|
145
145
|
)
|
|
146
146
|
self.orders.append(order)
|
|
147
|
+
|
|
148
|
+
def is_long(self):
|
|
149
|
+
return self.position > 0
|
|
150
|
+
|
|
151
|
+
def is_short(self):
|
|
152
|
+
return self.position < 0
|
|
153
|
+
|
|
154
|
+
def is_closed(self):
|
|
155
|
+
return self.position == 0
|
|
147
156
|
|
|
148
157
|
def _debit(self, amount: np.float64): ## Give money to the market (buy shares)
|
|
149
158
|
if (self.cash - amount < 0):
|
|
@@ -71,6 +71,11 @@ class DataSource:
|
|
|
71
71
|
return self.volume_data[self.current_index]
|
|
72
72
|
|
|
73
73
|
class CSVDataSource(DataSource):
|
|
74
|
-
def __init__(self, pathname: str, train_test_split: bool = False, mode: str = "train"):
|
|
75
|
-
data = pd.read_csv(pathname, index_col=
|
|
74
|
+
def __init__(self, pathname: str, train_test_split: bool = False, mode: str = "train", index_col: str = '0'):
|
|
75
|
+
data = pd.read_csv(pathname, index_col=index_col, parse_dates=[index_col])
|
|
76
|
+
super().__init__(data, train_test_split, mode)
|
|
77
|
+
|
|
78
|
+
class ParquetDataSource(DataSource):
|
|
79
|
+
def __init__(self, pathname: str, train_test_split: bool = False, mode: str = "train", index_col: str = '0'):
|
|
80
|
+
data = pd.read_parquet(pathname, index_col=index_col, parse_dates=[index_col])
|
|
76
81
|
super().__init__(data, train_test_split, mode)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|