Qubx 0.6.24__tar.gz → 0.6.26__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.
Potentially problematic release.
This version of Qubx might be problematic. Click here for more details.
- {qubx-0.6.24 → qubx-0.6.26}/PKG-INFO +1 -1
- {qubx-0.6.24 → qubx-0.6.26}/pyproject.toml +1 -1
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/connectors/ccxt/account.py +1 -1
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/connectors/ccxt/exchanges/binance/exchange.py +18 -1
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/connectors/tardis/data.py +1 -1
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/core/interfaces.py +0 -4
- qubx-0.6.26/src/qubx/utils/questdb.py +79 -0
- {qubx-0.6.24 → qubx-0.6.26}/LICENSE +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/README.md +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/build.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/__init__.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/_nb_magic.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/backtester/__init__.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/backtester/account.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/backtester/broker.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/backtester/data.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/backtester/management.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/backtester/ome.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/backtester/optimization.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/backtester/runner.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/backtester/simulated_data.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/backtester/simulated_exchange.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/backtester/simulator.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/backtester/utils.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/cli/__init__.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/cli/commands.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/cli/deploy.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/cli/misc.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/cli/release.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/connectors/ccxt/__init__.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/connectors/ccxt/broker.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/connectors/ccxt/data.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/connectors/ccxt/exceptions.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/connectors/ccxt/exchanges/__init__.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/connectors/ccxt/exchanges/binance/broker.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/connectors/ccxt/exchanges/bitfinex/bitfinex.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/connectors/ccxt/exchanges/kraken/kraken.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/connectors/ccxt/factory.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/connectors/ccxt/reader.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/connectors/ccxt/utils.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/connectors/tardis/utils.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/core/__init__.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/core/account.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/core/basics.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/core/context.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/core/deque.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/core/errors.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/core/exceptions.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/core/helpers.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/core/initializer.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/core/loggers.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/core/lookups.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/core/metrics.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/core/mixins/__init__.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/core/mixins/market.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/core/mixins/processing.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/core/mixins/subscription.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/core/mixins/trading.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/core/mixins/universe.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/core/series.pxd +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/core/series.pyi +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/core/series.pyx +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/core/utils.pyi +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/core/utils.pyx +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/data/__init__.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/data/composite.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/data/helpers.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/data/hft.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/data/readers.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/data/registry.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/data/tardis.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/emitters/__init__.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/emitters/base.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/emitters/composite.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/emitters/csv.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/emitters/prometheus.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/emitters/questdb.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/exporters/__init__.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/exporters/composite.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/exporters/formatters/__init__.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/exporters/formatters/base.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/exporters/formatters/incremental.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/exporters/formatters/slack.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/exporters/redis_streams.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/exporters/slack.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/features/__init__.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/features/core.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/features/orderbook.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/features/price.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/features/trades.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/features/utils.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/gathering/simplest.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/health/__init__.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/health/base.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/math/__init__.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/math/stats.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/notifications/__init__.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/notifications/composite.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/notifications/slack.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/pandaz/__init__.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/pandaz/ta.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/pandaz/utils.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/resources/_build.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/resources/instruments/symbols-binance.cm.json +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/resources/instruments/symbols-binance.json +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/resources/instruments/symbols-binance.um.json +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/resources/instruments/symbols-bitfinex.f.json +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/resources/instruments/symbols-bitfinex.json +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/resources/instruments/symbols-kraken.f.json +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/resources/instruments/symbols-kraken.json +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/restarts/__init__.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/restarts/state_resolvers.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/restarts/time_finders.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/restorers/__init__.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/restorers/balance.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/restorers/factory.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/restorers/interfaces.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/restorers/position.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/restorers/signal.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/restorers/state.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/restorers/utils.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/ta/__init__.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/ta/indicators.pxd +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/ta/indicators.pyi +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/ta/indicators.pyx +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/trackers/__init__.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/trackers/advanced.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/trackers/composite.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/trackers/rebalancers.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/trackers/riskctrl.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/trackers/sizers.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/utils/__init__.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/utils/_pyxreloader.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/utils/charting/lookinglass.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/utils/charting/mpl_helpers.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/utils/collections.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/utils/marketdata/binance.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/utils/marketdata/ccxt.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/utils/marketdata/dukas.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/utils/misc.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/utils/ntp.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/utils/numbers_utils.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/utils/orderbook.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/utils/plotting/__init__.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/utils/plotting/dashboard.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/utils/plotting/data.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/utils/plotting/interfaces.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/utils/plotting/renderers/__init__.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/utils/plotting/renderers/plotly.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/utils/runner/__init__.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/utils/runner/_jupyter_runner.pyt +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/utils/runner/accounts.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/utils/runner/configs.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/utils/runner/factory.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/utils/runner/runner.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/utils/time.py +0 -0
- {qubx-0.6.24 → qubx-0.6.26}/src/qubx/utils/version.py +0 -0
|
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
|
|
|
4
4
|
|
|
5
5
|
[tool.poetry]
|
|
6
6
|
name = "Qubx"
|
|
7
|
-
version = "0.6.
|
|
7
|
+
version = "0.6.26"
|
|
8
8
|
description = "Qubx - Quantitative Trading Framework"
|
|
9
9
|
authors = [ "Dmitry Marienko <dmitry.marienko@xlydian.com>", "Yuriy Arabskyy <yuriy.arabskyy@xlydian.com>",]
|
|
10
10
|
readme = "README.md"
|
|
@@ -170,7 +170,7 @@ class CcxtAccountProcessor(BasicAccountProcessor):
|
|
|
170
170
|
self._instrument_to_last_price[instrument] = (time, extract_price(update))
|
|
171
171
|
super().update_position_price(time, instrument, update)
|
|
172
172
|
|
|
173
|
-
def get_total_capital(self) -> float:
|
|
173
|
+
def get_total_capital(self, exchange: str | None = None) -> float:
|
|
174
174
|
# sum of balances + market value of all positions on non spot/margin
|
|
175
175
|
_currency_to_value = {c: self._get_currency_value(b.total, c) for c, b in self._balances.items()}
|
|
176
176
|
_positions_value = sum([p.market_value_funds for p in self._positions.values() if p.instrument.is_futures()])
|
|
@@ -32,7 +32,8 @@ class BinanceQV(cxp.binance):
|
|
|
32
32
|
"options": {
|
|
33
33
|
"watchTrades": {
|
|
34
34
|
"name": "aggTrade",
|
|
35
|
-
}
|
|
35
|
+
},
|
|
36
|
+
"localOrderBookLimit": 10_000, # set a large limit to avoid cutting off the orderbook
|
|
36
37
|
}
|
|
37
38
|
},
|
|
38
39
|
)
|
|
@@ -210,6 +211,22 @@ class BinanceQV(cxp.binance):
|
|
|
210
211
|
self.trades[symbol] = tradesArray
|
|
211
212
|
client.resolve(tradesArray, messageHash)
|
|
212
213
|
|
|
214
|
+
def handle_order_book_subscription(self, client: Client, message, subscription):
|
|
215
|
+
defaultLimit = self.safe_integer(self.options, "localOrderBookLimit", 4000)
|
|
216
|
+
# messageHash = self.safe_string(subscription, 'messageHash')
|
|
217
|
+
symbolOfSubscription = self.safe_string(subscription, "symbol") # watchOrderBook
|
|
218
|
+
symbols = self.safe_value(subscription, "symbols", [symbolOfSubscription]) # watchOrderBookForSymbols
|
|
219
|
+
limit = self.safe_integer(subscription, "limit", defaultLimit)
|
|
220
|
+
# handle list of symbols
|
|
221
|
+
for i in range(0, len(symbols)):
|
|
222
|
+
symbol = symbols[i]
|
|
223
|
+
if symbol in self.orderbooks:
|
|
224
|
+
del self.orderbooks[symbol]
|
|
225
|
+
self.orderbooks[symbol] = self.order_book({}, limit)
|
|
226
|
+
subscription = self.extend(subscription, {"symbol": symbol})
|
|
227
|
+
# fetch the snapshot in a separate async call
|
|
228
|
+
self.spawn(self.fetch_order_book_snapshot, client, message, subscription)
|
|
229
|
+
|
|
213
230
|
|
|
214
231
|
class BinanceQVUSDM(cxp.binanceusdm, BinanceQV):
|
|
215
232
|
"""
|
|
@@ -687,7 +687,7 @@ class TardisDataProvider(IDataProvider):
|
|
|
687
687
|
elif data_type == DataType.QUOTE:
|
|
688
688
|
return "quote"
|
|
689
689
|
elif data_type == DataType.ORDERBOOK:
|
|
690
|
-
return "
|
|
690
|
+
return "book_snapshot_2000_100ms" # Default depth and interval
|
|
691
691
|
elif data_type == DataType.OHLC:
|
|
692
692
|
return "trade_bar_1m" # Default timeframe
|
|
693
693
|
else:
|
|
@@ -1090,10 +1090,6 @@ class IStrategyContext(
|
|
|
1090
1090
|
"""Check if the strategy context is running."""
|
|
1091
1091
|
return False
|
|
1092
1092
|
|
|
1093
|
-
@property
|
|
1094
|
-
def is_warmup(self) -> bool:
|
|
1095
|
-
return self._strategy_state.is_warmup_in_progress
|
|
1096
|
-
|
|
1097
1093
|
@property
|
|
1098
1094
|
def is_simulation(self) -> bool:
|
|
1099
1095
|
"""Check if the strategy context is running in simulation mode."""
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
from typing import Any, Dict, List, Optional, Union
|
|
2
|
+
|
|
3
|
+
import pandas as pd
|
|
4
|
+
import psycopg as pg
|
|
5
|
+
from psycopg.sql import SQL, Composed
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class QuestDBClient:
|
|
9
|
+
"""
|
|
10
|
+
A helper class for interacting with QuestDB.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
def __init__(
|
|
14
|
+
self,
|
|
15
|
+
host: str = "nebula",
|
|
16
|
+
port: int = 8812,
|
|
17
|
+
user: str = "admin",
|
|
18
|
+
password: str = "quest",
|
|
19
|
+
dbname: Optional[str] = None,
|
|
20
|
+
):
|
|
21
|
+
"""
|
|
22
|
+
Initialize the QuestDB client.
|
|
23
|
+
|
|
24
|
+
Args:
|
|
25
|
+
host: The hostname of the QuestDB server
|
|
26
|
+
port: The port number for QuestDB PostgreSQL interface
|
|
27
|
+
user: The username for authentication
|
|
28
|
+
password: The password for authentication
|
|
29
|
+
dbname: Optional database name
|
|
30
|
+
"""
|
|
31
|
+
conn_str = f"user={user} password={password} host={host} port={port}"
|
|
32
|
+
if dbname:
|
|
33
|
+
conn_str += f" dbname={dbname}"
|
|
34
|
+
|
|
35
|
+
self.conn_str = conn_str
|
|
36
|
+
|
|
37
|
+
def query(self, query: str, params: Optional[Dict[str, Any]] = None) -> pd.DataFrame:
|
|
38
|
+
"""
|
|
39
|
+
Execute a SQL query and return the results as a pandas DataFrame.
|
|
40
|
+
|
|
41
|
+
Args:
|
|
42
|
+
query: The SQL query to execute
|
|
43
|
+
params: Optional parameters for the query
|
|
44
|
+
|
|
45
|
+
Returns:
|
|
46
|
+
A pandas DataFrame containing the query results
|
|
47
|
+
"""
|
|
48
|
+
with pg.connect(self.conn_str) as conn:
|
|
49
|
+
with conn.cursor() as cursor:
|
|
50
|
+
cursor.execute(query, params)
|
|
51
|
+
if cursor.description: # Check if the query returns data
|
|
52
|
+
column_names = [desc.name for desc in cursor.description]
|
|
53
|
+
records = cursor.fetchall()
|
|
54
|
+
return pd.DataFrame(records, columns=column_names)
|
|
55
|
+
return pd.DataFrame()
|
|
56
|
+
|
|
57
|
+
def execute(self, query: str, params: Optional[Dict[str, Any]] = None) -> int:
|
|
58
|
+
"""
|
|
59
|
+
Execute a SQL statement that doesn't return data (INSERT, UPDATE, etc.).
|
|
60
|
+
|
|
61
|
+
Args:
|
|
62
|
+
query: The SQL query to execute
|
|
63
|
+
params: Optional parameters for the query
|
|
64
|
+
|
|
65
|
+
Returns:
|
|
66
|
+
The number of rows affected
|
|
67
|
+
"""
|
|
68
|
+
with pg.connect(self.conn_str) as conn:
|
|
69
|
+
with conn.cursor() as cursor:
|
|
70
|
+
cursor.execute(query, params)
|
|
71
|
+
conn.commit()
|
|
72
|
+
return cursor.rowcount
|
|
73
|
+
|
|
74
|
+
def __enter__(self):
|
|
75
|
+
"""Context manager entry point."""
|
|
76
|
+
return self
|
|
77
|
+
|
|
78
|
+
def __exit__(self, exc_type, exc_val, exc_tb):
|
|
79
|
+
"""Context manager exit point."""
|
|
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
|
|
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
|
|
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
|