quantjourney-bidask 0.9.3__py3-none-any.whl → 0.9.4__py3-none-any.whl

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,8 +1,7 @@
1
1
  from .edge import edge
2
2
  from .edge_rolling import edge_rolling
3
3
  from .edge_expanding import edge_expanding
4
- from .data_fetcher import fetch_binance_data, fetch_yfinance_data
5
4
  from .websocket_fetcher import LiveSpreadMonitor
6
5
  from ._version import __version__, __author__, __email__, __license__
7
6
 
8
- __all__ = ['edge', 'edge_rolling', 'edge_expanding', 'fetch_binance_data', 'fetch_yfinance_data', 'LiveSpreadMonitor']
7
+ __all__ = ['edge', 'edge_rolling', 'edge_expanding', 'LiveSpreadMonitor']
@@ -1,6 +1,6 @@
1
1
  """Version information for quantjourney_bidask."""
2
2
 
3
- __version__ = "0.9.3"
3
+ __version__ = "0.9.4"
4
4
  __author__ = "Jakub Polec"
5
5
  __email__ = "jakub@quantjourney.pro"
6
6
  __license__ = "MIT"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: quantjourney-bidask
3
- Version: 0.9.3
3
+ Version: 0.9.4
4
4
  Summary: Efficient bid-ask spread estimator from OHLC prices
5
5
  Author-email: Jakub Polec <jakub@quantjourney.pro>
6
6
  License-Expression: MIT
@@ -312,9 +312,9 @@ python examples/spread_estimator.py
312
312
  - `edge_rolling(df, window, min_periods=None)`: Rolling window estimation
313
313
  - `edge_expanding(df, min_periods=3)`: Expanding window estimation
314
314
 
315
- ### Data Fetching (`data/fetch.py`)
315
+ ### Data Fetching (`data/fetch.py`) - Examples & Demos
316
316
 
317
- - `DataFetcher()`: Main data fetcher class
317
+ - `DataFetcher()`: Simplified data fetcher class for examples
318
318
  - `get_stock_data(ticker, period, interval)`: Fetch stock data from Yahoo Finance
319
319
  - `get_crypto_data(symbol, exchange, timeframe, limit)`: Fetch crypto data via CCXT (async)
320
320
  - `stream_btc_data(duration_seconds)`: Stream BTC data via websocket (async)
@@ -0,0 +1,11 @@
1
+ quantjourney_bidask/__init__.py,sha256=ycBwUmX5uZZvnXIygnREyF_VdGQmoXvX-Kkwb0OKegU,298
2
+ quantjourney_bidask/_version.py,sha256=7lbdg1SKFTzau2oIJGxKQ7-_f5qeY69-EB_gg5wGNI8,220
3
+ quantjourney_bidask/edge.py,sha256=YdL8So3i9CKQsDm6lI6mNRe-ODhisRhipksq-sfRmuk,6274
4
+ quantjourney_bidask/edge_expanding.py,sha256=gAdow81VBb2rXtfoEzDur8xvu-rwfo1OQbt3LbUfq4w,2268
5
+ quantjourney_bidask/edge_rolling.py,sha256=z8463emBLaxa0ceUBk9TPfVayFANo8IeDJ_fuDzGcfA,9103
6
+ quantjourney_bidask/websocket_fetcher.py,sha256=xMS_qLbSW9hCS3RbNKvkn5HTK0XGmAO4wpaAl4_Mxb4,10895
7
+ quantjourney_bidask-0.9.4.dist-info/licenses/LICENSE,sha256=m8MEOGnpSBtS6m9z4M9m1JksWWPzu1OK3UgY1wuHf04,1081
8
+ quantjourney_bidask-0.9.4.dist-info/METADATA,sha256=AeWjnxksyf-aXjdLycosfszLWGX4RhE28wV1q6kuUPw,13202
9
+ quantjourney_bidask-0.9.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
10
+ quantjourney_bidask-0.9.4.dist-info/top_level.txt,sha256=rOBM4GxA87iQv-mR8-WZdu3-Yj5ESyggRICpUhJ-4Dg,20
11
+ quantjourney_bidask-0.9.4.dist-info/RECORD,,
@@ -1,160 +0,0 @@
1
- import pandas as pd
2
- import requests
3
- import yfinance as yf
4
- from typing import Optional, List
5
- from datetime import datetime
6
-
7
- def fetch_binance_data(
8
- symbols: List[str],
9
- timeframe: str,
10
- start: str,
11
- end: str,
12
- api_key: str,
13
- api_url: str = "http://localhost:8000"
14
- ) -> pd.DataFrame:
15
- """
16
- Fetch OHLCV data from Binance using the provided FastAPI server.
17
-
18
- Parameters
19
- ----------
20
- symbols : List[str]
21
- List of trading pairs (e.g., ["BTCUSDT", "ETHUSDT"]).
22
- timeframe : str
23
- Data timeframe (e.g., "1m", "1h", "1d").
24
- start : str
25
- Start time in ISO 8601 format (e.g., "2024-01-01T00:00:00Z").
26
- end : str
27
- End time in ISO 8601 format (e.g., "2024-01-02T00:00:00Z").
28
- api_key : str
29
- API key for authentication.
30
- api_url : str, default "http://localhost:8000"
31
- Base URL of the FastAPI server.
32
-
33
- Returns
34
- -------
35
- pd.DataFrame
36
- DataFrame with columns ['open', 'high', 'low', 'close', 'volume', 'timestamp', 'symbol'].
37
-
38
- Raises
39
- ------
40
- ValueError
41
- If the API request fails or returns an error.
42
- """
43
- payload = {
44
- "exchange": "binance",
45
- "symbols": symbols,
46
- "start": start,
47
- "end": end,
48
- "timeframe": timeframe,
49
- "upload_d1": False,
50
- "force": False
51
- }
52
- headers = {"X-API-Key": api_key}
53
-
54
- # Initiate fetch request
55
- response = requests.post(f"{api_url}/fetch", json=payload, headers=headers)
56
- if response.status_code != 200:
57
- raise ValueError(f"Fetch request failed: {response.text}")
58
-
59
- task_id = response.json().get("task_id")
60
- if not task_id:
61
- raise ValueError("No task ID returned from fetch request")
62
-
63
- # Poll task status
64
- while True:
65
- status_response = requests.get(f"{api_url}/tasks/{task_id}")
66
- if status_response.status_code != 200:
67
- raise ValueError(f"Task status check failed: {status_response.text}")
68
-
69
- task = status_response.json().get("task")
70
- if task["status"] in ["completed", "failed"]:
71
- if task["status"] == "failed":
72
- raise ValueError(f"Task failed: {task.get('message')}")
73
- break
74
-
75
- # Query data
76
- data = []
77
- for symbol in symbols:
78
- query_payload = {
79
- "symbol": symbol,
80
- "timeframe": timeframe,
81
- "start": start,
82
- "end": end
83
- }
84
- query_response = requests.post(f"{api_url}/d1/query", json=query_payload)
85
- if query_response.status_code != 200:
86
- raise ValueError(f"Data query failed for {symbol}: {query_response.text}")
87
-
88
- rows = query_response.json().get("data", [])
89
- df = pd.DataFrame(rows)
90
- if not df.empty:
91
- df['symbol'] = symbol
92
- data.append(df)
93
-
94
- if not data:
95
- raise ValueError("No data retrieved for the specified parameters")
96
-
97
- result = pd.concat(data, ignore_index=True)
98
- result['timestamp'] = pd.to_datetime(result['timestamp'])
99
- return result[['timestamp', 'symbol', 'open', 'high', 'low', 'close', 'volume']]
100
-
101
- def fetch_yfinance_data(
102
- tickers: List[str],
103
- period: str = "1mo",
104
- interval: str = "1d",
105
- start: Optional[str] = None,
106
- end: Optional[str] = None
107
- ) -> pd.DataFrame:
108
- """
109
- Fetch OHLCV data from Yahoo Finance using yfinance.
110
-
111
- Parameters
112
- ----------
113
- tickers : List[str]
114
- List of ticker symbols (e.g., ["AAPL", "MSFT"]).
115
- period : str, default "1mo"
116
- Data period (e.g., "1d", "1mo", "1y"). Ignored if start and end are provided.
117
- interval : str, default "1d"
118
- Data interval (e.g., "1m", "1h", "1d").
119
- start : str, optional
120
- Start date (e.g., "2024-01-01"). Overrides period if provided.
121
- end : str, optional
122
- End date (e.g., "2024-01-31"). Overrides period if provided.
123
-
124
- Returns
125
- -------
126
- pd.DataFrame
127
- DataFrame with columns ['open', 'high', 'low', 'close', 'volume', 'timestamp', 'symbol'].
128
-
129
- Raises
130
- ------
131
- ValueError
132
- If no data is retrieved for the specified parameters.
133
- """
134
- data = []
135
- for ticker in tickers:
136
- stock = yf.Ticker(ticker)
137
- if start and end:
138
- df = stock.history(start=start, end=end, interval=interval)
139
- else:
140
- df = stock.history(period=period, interval=interval)
141
-
142
- if df.empty:
143
- continue
144
-
145
- df = df.reset_index()
146
- df['symbol'] = ticker
147
- df = df.rename(columns={
148
- 'Date': 'timestamp',
149
- 'Open': 'open',
150
- 'High': 'high',
151
- 'Low': 'low',
152
- 'Close': 'close',
153
- 'Volume': 'volume'
154
- })
155
- data.append(df[['timestamp', 'symbol', 'open', 'high', 'low', 'close', 'volume']])
156
-
157
- if not data:
158
- raise ValueError("No data retrieved for the specified parameters")
159
-
160
- return pd.concat(data, ignore_index=True)
@@ -1,12 +0,0 @@
1
- quantjourney_bidask/__init__.py,sha256=vumoRDEDOTclYapknfSwKpCZi9IdfJbukdp7S1-kphA,409
2
- quantjourney_bidask/_version.py,sha256=ExaLWHYvdqbI_ddgEgRrj-rvi6RGAjSAg6mmfcNOMEM,220
3
- quantjourney_bidask/data_fetcher.py,sha256=GMVf4wRVwIE2JJ2sYAR_CCo56JQnReNhTWTSrZc0-L0,4931
4
- quantjourney_bidask/edge.py,sha256=YdL8So3i9CKQsDm6lI6mNRe-ODhisRhipksq-sfRmuk,6274
5
- quantjourney_bidask/edge_expanding.py,sha256=gAdow81VBb2rXtfoEzDur8xvu-rwfo1OQbt3LbUfq4w,2268
6
- quantjourney_bidask/edge_rolling.py,sha256=z8463emBLaxa0ceUBk9TPfVayFANo8IeDJ_fuDzGcfA,9103
7
- quantjourney_bidask/websocket_fetcher.py,sha256=xMS_qLbSW9hCS3RbNKvkn5HTK0XGmAO4wpaAl4_Mxb4,10895
8
- quantjourney_bidask-0.9.3.dist-info/licenses/LICENSE,sha256=m8MEOGnpSBtS6m9z4M9m1JksWWPzu1OK3UgY1wuHf04,1081
9
- quantjourney_bidask-0.9.3.dist-info/METADATA,sha256=VLnrW86ALr9MLWT_Ch6yxkb25CUqN3m-RhD7JOO62SA,13164
10
- quantjourney_bidask-0.9.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
11
- quantjourney_bidask-0.9.3.dist-info/top_level.txt,sha256=rOBM4GxA87iQv-mR8-WZdu3-Yj5ESyggRICpUhJ-4Dg,20
12
- quantjourney_bidask-0.9.3.dist-info/RECORD,,