hkjc 0.3.23__py3-none-any.whl → 0.4.0__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.
hkjc/processing.py CHANGED
@@ -113,20 +113,11 @@ def generate_all_qp_trades(date: str, venue_code: str, race_number: int, rebate:
113
113
  candidates = np.arange(1, N+1)
114
114
 
115
115
  if fit_harville:
116
- fit_res = fit_harville_to_odds(
117
- W_obs=odds['WIN'],
118
- Qin_obs=odds['QIN'],
119
- Q_obs=odds['QPL'],
120
- b_obs=odds['PLA']
121
- )
116
+ fit_res = fit_harville_to_odds(odds)
122
117
  if fit_res['success']:
123
- odds['PLA'] = np.nan_to_num(1/fit_res['b_fitted'], posinf=0)
124
- odds['QPL'] = np.nan_to_num(1/fit_res['Q_fitted'], posinf=0)
125
- odds['WIN'] = np.nan_to_num(1/fit_res['W_fitted'], posinf=0)
126
- odds['QIN'] = np.nan_to_num(1/fit_res['Qin_fitted'], posinf=0)
118
+ odds = fit_res['odds_fit']
127
119
  else:
128
- print(
129
- f"[WARNING] Harville model fitting failed: {fit_res.get('message','')}")
120
+ print(f"[WARNING] Harville model fitting failed: {fit_res.get('message','')}")
130
121
 
131
122
  results = [_process_single_qp_trade(banker, covered, odds['PLA'], odds['QPL'], rebate)
132
123
  for banker in tqdm(candidates, desc="Processing bankers")
@@ -148,7 +139,8 @@ def _process_single_pla_trade(covered: List[int], pla_odds: np.ndarray, p_matrix
148
139
 
149
140
 
150
141
  def generate_all_pla_trades(date: str, venue_code: str, race_number: int, rebate: float = 0.1) -> pl.DataFrame:
151
- """Generate all possible place-only tickets for the specified race.
142
+ """Generate all possible place-only tickets for the specified race.
143
+ We try to arbitrage the disagreement between market place odds and filtered odds.
152
144
 
153
145
  Args:
154
146
  date (str): Date in 'YYYY-MM-DD' format.
@@ -167,15 +159,10 @@ def generate_all_pla_trades(date: str, venue_code: str, race_number: int, rebate
167
159
 
168
160
  fit_res = fit_harville_to_odds(odds)
169
161
 
170
- if fit_res['success']:
171
- odds['PLA'] = np.nan_to_num(1/fit_res['b_fitted'], posinf=0)
172
- odds['QPL'] = np.nan_to_num(1/fit_res['Q_fitted'], posinf=0)
173
- odds['WIN'] = np.nan_to_num(1/fit_res['W_fitted'], posinf=0)
174
- odds['QIN'] = np.nan_to_num(1/fit_res['Qin_fitted'], posinf=0)
175
- else:
162
+ if not fit_res['success']:
176
163
  raise RuntimeError(
177
164
  f"[ERROR] Harville model fitting failed: {fit_res.get('message','')}")
178
- p_matrix = fit_res['P_fitted']
165
+ p_matrix = fit_res['prob_fit']['P']
179
166
 
180
167
  results = [_process_single_pla_trade(covered, odds['PLA'], p_matrix, rebate)
181
168
  for covered in _all_subsets(candidates)]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hkjc
3
- Version: 0.3.23
3
+ Version: 0.4.0
4
4
  Summary: Library for scrapping HKJC data and perform basic analysis
5
5
  Requires-Python: >=3.11
6
6
  Requires-Dist: beautifulsoup4>=4.14.2
@@ -12,4 +12,5 @@ Requires-Dist: numpy>=2.3.3
12
12
  Requires-Dist: polars>=1.33.1
13
13
  Requires-Dist: pyarrow>=21.0.0
14
14
  Requires-Dist: requests>=2.32.5
15
+ Requires-Dist: scipy>=1.16.2
15
16
  Requires-Dist: tqdm>=4.67.1
@@ -3,12 +3,12 @@ hkjc/features.py,sha256=LicwtKBpMzpz_dSX9bjoCLLaRUu8oeZo1AloTe7v7sI,298
3
3
  hkjc/harville_model.py,sha256=WSA_1EcNOHKGraP6WVHJ3FXZPGrDrjKhJc_q70KKx80,20188
4
4
  hkjc/historical.py,sha256=88z3DiWuj1L0sJw5EXnEkg4L_xx7-UH6UI6x9duDMvI,8380
5
5
  hkjc/live.py,sha256=DgCjqd-QHdUk2ReSQoxIcUhcChCqtUG60p8r-iHnk-k,10958
6
- hkjc/processing.py,sha256=hQnHxl6HYlFOeSLSOCVsemgTKcwt9_tYUQI-itpvjUg,7188
6
+ hkjc/processing.py,sha256=xOiNW36bKCYV-WY1XKvnG5-xClLBX7sUaAqBON3Qzyc,6594
7
7
  hkjc/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
8
  hkjc/speedpro.py,sha256=Y2Z3GYGeePc4sM-ZnCHXCI1N7L-_j9nrMqS3CC5BBSo,2031
9
9
  hkjc/utils.py,sha256=uAiFmy5NXsADUiD1-MCPgs1hs4N3e7tVYtSREkxwKSQ,6425
10
10
  hkjc/strategy/place_only.py,sha256=lHPjTSj8PzghxncNBg8FI4T4HJigekB9a3bV7l7VtPA,2079
11
11
  hkjc/strategy/qpbanker.py,sha256=MQxjwsfhllKZroKS8w8Q3bi3HMjGc1DAyBIjNZAp3yQ,4805
12
- hkjc-0.3.23.dist-info/METADATA,sha256=_BEaF2r7sXrq2lhdFj-qunHEKL4koB8-vJtbDs0ZeVw,451
13
- hkjc-0.3.23.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
14
- hkjc-0.3.23.dist-info/RECORD,,
12
+ hkjc-0.4.0.dist-info/METADATA,sha256=0IqDjr-M_iktjvE3tYnjELEdWFP4cprR0C8dRv9ZaJ8,479
13
+ hkjc-0.4.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
14
+ hkjc-0.4.0.dist-info/RECORD,,
File without changes