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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: quantex
3
- Version: 0.2.0
3
+ Version: 0.2.2
4
4
  Summary: A simple quant strategy creation and backtesting package.
5
5
  License: MIT
6
6
  Author: Daniel Green
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "quantex"
3
- version = "0.2.0"
3
+ version = "0.2.2"
4
4
  description = "A simple quant strategy creation and backtesting package."
5
5
  authors = [
6
6
  {name = "Daniel Green",email = "dangreen07@outlook.com"}
@@ -0,0 +1,4 @@
1
+ from .datasource import CSVDataSource as CSVDataSource, ParquetDataSource as ParquetDataSource
2
+ from .strategy import Strategy as Strategy
3
+ from .backtester import SimpleBacktester as SimpleBacktester
4
+ from .enums import CommissionType as CommissionType
@@ -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=0, parse_dates=[0])
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)
@@ -1,4 +0,0 @@
1
- from .datasource import CSVDataSource as CSVDataSource
2
- from .strategy import Strategy as Strategy
3
- from .backtester import SimpleBacktester as SimpleBacktester
4
- from .enums import CommissionType as CommissionType
File without changes
File without changes
File without changes
File without changes
File without changes