quantplay 1.2.87__tar.gz → 1.2.91__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.
Files changed (102) hide show
  1. {quantplay-1.2.87 → quantplay-1.2.91}/PKG-INFO +1 -1
  2. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/broker/generics/broker.py +2 -2
  3. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/broker/xts.py +4 -4
  4. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/services/market.py +3 -0
  5. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/services/tradelens.py +120 -16
  6. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay.egg-info/PKG-INFO +1 -1
  7. {quantplay-1.2.87 → quantplay-1.2.91}/setup.py +1 -1
  8. {quantplay-1.2.87 → quantplay-1.2.91}/README.md +0 -0
  9. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/__init__.py +0 -0
  10. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/backtest/__init__.py +0 -0
  11. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/backtest/backtest_trades.py +0 -0
  12. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/broker/__init__.py +0 -0
  13. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/broker/angelone.py +0 -0
  14. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/broker/broker_client.py +0 -0
  15. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/broker/client.py +0 -0
  16. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/broker/finvasia_utils/__init__.py +0 -0
  17. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/broker/finvasia_utils/shoonya.py +0 -0
  18. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/broker/generics/__init__.py +0 -0
  19. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/broker/iifl.py +0 -0
  20. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/broker/iifl_xts.py +0 -0
  21. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/broker/kite_utils.py +0 -0
  22. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/broker/motilal.py +0 -0
  23. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/broker/shoonya.py +0 -0
  24. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/broker/symphony.py +0 -0
  25. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/broker/xts_utils/Connect.py +0 -0
  26. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/broker/xts_utils/Exception.py +0 -0
  27. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/broker/xts_utils/InteractiveSocketClient.py +0 -0
  28. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/broker/xts_utils/MarketDataSocketClient.py +0 -0
  29. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/broker/xts_utils/__init__.py +0 -0
  30. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/broker/zerodha.py +0 -0
  31. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/brokerage/__init__.py +0 -0
  32. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/brokerage/angelone/__init__.py +0 -0
  33. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/brokerage/angelone/angel_broker.py +0 -0
  34. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/brokerage/generics/__init__.py +0 -0
  35. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/brokerage/generics/broker.py +0 -0
  36. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/brokerage/zerodha/ZBroker.py +0 -0
  37. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/brokerage/zerodha/__init__.py +0 -0
  38. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/config/__init__.py +0 -0
  39. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/config/qplay_config.py +0 -0
  40. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/create_sample_data.py +0 -0
  41. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/data_modify_script.py +0 -0
  42. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/date_fix.py +0 -0
  43. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/exception/__init__.py +0 -0
  44. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/exception/exceptions.py +0 -0
  45. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/executor/__init__.py +0 -0
  46. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/executor/strategy_executor.py +0 -0
  47. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/indicators/Indicator.py +0 -0
  48. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/indicators/__init__.py +0 -0
  49. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/indicators/atr.py +0 -0
  50. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/model/__init__.py +0 -0
  51. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/model/exchange/__init__.py +0 -0
  52. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/model/exchange/instrument.py +0 -0
  53. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/model/exchange/order.py +0 -0
  54. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/model/exchange/tick.py +0 -0
  55. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/model/strategy/__init__.py +0 -0
  56. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/model/strategy/strategy_response.py +0 -0
  57. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/oms/__init__.py +0 -0
  58. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/order_execution/__init__.py +0 -0
  59. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/order_execution/execution_algorithm.py +0 -0
  60. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/order_execution/mean_price.py +0 -0
  61. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/reporting/__init__.py +0 -0
  62. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/reporting/strategy_report.py +0 -0
  63. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/reporting/visuals.py +0 -0
  64. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/service.py +0 -0
  65. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/services/__init__.py +0 -0
  66. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/strategies/__init__.py +0 -0
  67. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/strategies/equities/__init__.py +0 -0
  68. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/strategies/equities/intraday/__init__.py +0 -0
  69. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/strategies/equities/overnight/__init__.py +0 -0
  70. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/strategies/futures/__init__.py +0 -0
  71. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/strategies/futures/overnight/__init__.py +0 -0
  72. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/strategies/options/__init__.py +0 -0
  73. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/strategies/options/intraday/__init__.py +0 -0
  74. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/strategies/options/intraday/ladder.py +0 -0
  75. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/strategies/options/intraday/musk.py +0 -0
  76. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/strategies/options/intraday/short_straddle.py +0 -0
  77. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/strategy/__init__.py +0 -0
  78. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/strategy/base.py +0 -0
  79. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/strategy_run.py +0 -0
  80. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/utils/__init__.py +0 -0
  81. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/utils/config_util.py +0 -0
  82. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/utils/constant.py +0 -0
  83. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/utils/data_utils.py +0 -0
  84. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/utils/exchange.py +0 -0
  85. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/utils/number_utils.py +0 -0
  86. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/utils/pickle_utils.py +0 -0
  87. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/utils/selenium_utils.py +0 -0
  88. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay/utils/transaction_utils.py +0 -0
  89. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay.egg-info/SOURCES.txt +0 -0
  90. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay.egg-info/dependency_links.txt +0 -0
  91. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay.egg-info/requires.txt +0 -0
  92. {quantplay-1.2.87 → quantplay-1.2.91}/quantplay.egg-info/top_level.txt +0 -0
  93. {quantplay-1.2.87 → quantplay-1.2.91}/setup.cfg +0 -0
  94. {quantplay-1.2.87 → quantplay-1.2.91}/test/__init__.py +0 -0
  95. {quantplay-1.2.87 → quantplay-1.2.91}/test/broker/__init__.py +0 -0
  96. {quantplay-1.2.87 → quantplay-1.2.91}/test/broker/finvasia.py +0 -0
  97. {quantplay-1.2.87 → quantplay-1.2.91}/test/executor/__init__.py +0 -0
  98. {quantplay-1.2.87 → quantplay-1.2.91}/test/executor/strategy_executor.py +0 -0
  99. {quantplay-1.2.87 → quantplay-1.2.91}/test/strategy/__init__.py +0 -0
  100. {quantplay-1.2.87 → quantplay-1.2.91}/test/strategy/base.py +0 -0
  101. {quantplay-1.2.87 → quantplay-1.2.91}/test/strategy/sample_strategy.py +0 -0
  102. {quantplay-1.2.87 → quantplay-1.2.91}/test/test_motilal.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: quantplay
3
- Version: 1.2.87
3
+ Version: 1.2.91
4
4
  Summary: This python package will be stored in AWS CodeArtifact
5
5
  Home-page:
6
6
  Author:
@@ -342,7 +342,7 @@ class Broker():
342
342
 
343
343
  return option_symbol
344
344
 
345
- def exit_all_trigger_orders(self, tag="ALL", symbol_contains=None, order_timestamp=None):
345
+ def exit_all_trigger_orders(self, tag="ALL", symbol_contains=None, order_timestamp=None, modify_sleep_time=10):
346
346
  stoploss_orders = self.orders()
347
347
  stoploss_orders = stoploss_orders[stoploss_orders.status == "TRIGGER PENDING"]
348
348
 
@@ -382,7 +382,7 @@ class Broker():
382
382
  self.modify_order(stoploss_order)
383
383
  time.sleep(.1)
384
384
 
385
- self.modify_orders_till_complete(orders_to_close)
385
+ self.modify_orders_till_complete(orders_to_close, sleep_time=modify_sleep_time)
386
386
  Constants.logger.info("All order have been closed successfully")
387
387
 
388
388
  def square_off_all(self, dry_run=True, contains=None, sleep_time=0.1):
@@ -504,10 +504,10 @@ class XTS(Broker):
504
504
  elif new_ord["exchange"] == "NSECM":
505
505
  new_ord["exchange"] = "NSE"
506
506
 
507
- if new_ord["exchange"] in ["NFO", "MCX"]:
508
- new_ord["tradingsymbol"] = self.broker_symbol_map[
509
- order["tradingsymbol"]
510
- ]
507
+ # if new_ord["exchange"] in ["NFO", "MCX"]:
508
+ # new_ord["tradingsymbol"] = self.broker_symbol_map[
509
+ # order["tradingsymbol"]
510
+ # ]
511
511
 
512
512
  new_ord["order_type"] = order["OrderType"].upper()
513
513
  new_ord["product"] = order["ProductType"].upper()
@@ -26,12 +26,15 @@ class Market:
26
26
 
27
27
  def __init__(self):
28
28
  config = QuantplayConfig.get_config()
29
+ self.base_path = "{}/.quantplay/".format(expanduser("~"))
29
30
  self.nse_equity_path = "{}/.quantplay/NSE_EQ/".format(expanduser("~"))
30
31
  self.nse_opt_path = "{}/.quantplay/NSE_OPT/".format(expanduser("~"))
31
32
  self.nse_fut_path = "{}/.quantplay/NSE_FUT/".format(expanduser("~"))
32
33
  self.nse_market_data_path = "{}/.quantplay/NSE_MARKET_DATA/".format(expanduser("~"))
33
34
  self.mcx_path = "{}/.quantplay/MCX/".format(expanduser("~"))
34
35
 
36
+ if "DEFAULT" in config and "base_path" in config["DEFAULT"]:
37
+ self.base_path = config["DEFAULT"]["base_path"]
35
38
  if "DEFAULT" in config and "nse_equity_path" in config["DEFAULT"]:
36
39
  self.nse_equity_path = config["DEFAULT"]["nse_equity_path"]
37
40
  if "DEFAULT" in config and "nse_opt_path" in config["DEFAULT"]:
@@ -4,9 +4,12 @@ import pandas as pd
4
4
  from quantplay.reporting.visuals import VisualReport
5
5
  from quantplay.services.market import Market
6
6
  import matplotlib.pyplot as plt
7
+ import inspect
8
+ import typing
7
9
 
8
10
  market = Market()
9
11
 
12
+
10
13
  class TradeLens:
11
14
 
12
15
  @staticmethod
@@ -29,8 +32,10 @@ class TradeLens:
29
32
 
30
33
  for j in range(0, 5):
31
34
  temp_df.loc[:, 'balance'] = temp_df.profit.cumsum()
32
- temp_df.loc[:, 'running_max_balance'] = np.maximum.accumulate(temp_df.balance)
33
- temp_df.loc[:, 'drawdowns'] = temp_df.running_max_balance - temp_df.balance
35
+ temp_df.loc[:, 'running_max_balance'] = np.maximum.accumulate(
36
+ temp_df.balance)
37
+ temp_df.loc[:, 'drawdowns'] = temp_df.running_max_balance - \
38
+ temp_df.balance
34
39
 
35
40
  max_drawdown = np.max(temp_df.drawdowns)
36
41
  end_index = None
@@ -41,7 +46,7 @@ class TradeLens:
41
46
 
42
47
  start_index = end_index
43
48
  while temp_df.iloc[start_index - 1]['running_max_balance'] == temp_df.iloc[start_index][
44
- 'running_max_balance']:
49
+ 'running_max_balance']:
45
50
  start_index = start_index - 1
46
51
 
47
52
  print("Max drawdown {} from {} till {} amount {}".format(j,
@@ -56,7 +61,8 @@ class TradeLens:
56
61
  def analyse(trades, disable_metrics=[]):
57
62
  trades.loc[:, 'date'] = pd.to_datetime(trades.date)
58
63
  exchanges = list(trades.exchange.unique())
59
- trades.loc[:, 'segment'] = np.where("PE" == trades.tradingsymbol.str[-2:], "PE", "CE")
64
+ trades.loc[:, 'segment'] = np.where(
65
+ "PE" == trades.tradingsymbol.str[-2:], "PE", "CE")
60
66
 
61
67
  trades.loc[:, 'hour'] = trades.date.dt.hour
62
68
  trades.loc[:, "day_of_week"] = trades.date.dt.day_name()
@@ -85,18 +91,21 @@ class TradeLens:
85
91
  print("Trade return by time")
86
92
  print(trades.groupby('time').trade_return.mean())
87
93
 
88
- trades.loc[:, 'trade_return'] = trades.close_price / trades.entry_price - 1
94
+ trades.loc[:, 'trade_return'] = trades.close_price / \
95
+ trades.entry_price - 1
89
96
  print("Mean return of trades")
90
97
  print(trades.trade_return.mean())
91
98
 
92
- trades.loc[:, 'week_number'] = (trades.order_timestamp.dt.day / 7).astype(int)
99
+ trades.loc[:, 'week_number'] = (
100
+ trades.order_timestamp.dt.day / 7).astype(int)
93
101
  if "week_number" not in disable_metrics:
94
102
  print("profit by week number")
95
103
  print(trades.groupby('week_number').profit.mean())
96
104
 
97
105
  @staticmethod
98
106
  def show_report(trades):
99
- trades.loc[:, 'order_timestamp'] = pd.to_datetime(trades.order_timestamp)
107
+ trades.loc[:, 'order_timestamp'] = pd.to_datetime(
108
+ trades.order_timestamp)
100
109
  VisualReport.display_profit_report(trades)
101
110
  VisualReport.display_balance_report(trades, 'tt')
102
111
 
@@ -106,7 +115,8 @@ class TradeLens:
106
115
  symbols_by_security_type = {}
107
116
  for security_type in security_types:
108
117
  symbols_by_security_type[security_type] = list(
109
- trades[trades.security_type == security_type].tradingsymbol.unique()
118
+ trades[trades.security_type ==
119
+ security_type].tradingsymbol.unique()
110
120
  )
111
121
 
112
122
  market_data = market.data(
@@ -130,7 +140,8 @@ class TradeLens:
130
140
  testing = pd.concat([testing, t_df])
131
141
  testing = testing.sort_values(["symbol", "date"])
132
142
  testing.loc[:, 'date_only'] = pd.to_datetime(testing.date.dt.date)
133
- testing.loc[:, 'pnl'] = testing.groupby(['symbol', 'date_only']).pnl.ffill()
143
+ testing.loc[:, 'pnl'] = testing.groupby(
144
+ ['symbol', 'date_only']).pnl.ffill()
134
145
 
135
146
  testing = testing.groupby('date').pnl.sum().reset_index()
136
147
 
@@ -138,8 +149,8 @@ class TradeLens:
138
149
  plt.plot(testing.date, testing.pnl)
139
150
  plt.show(block=True)
140
151
  return {
141
- "minimum_pnl" : int(testing.pnl.min()),
142
- "maximum_pnl" : int(testing.pnl.max())
152
+ "minimum_pnl": int(testing.pnl.min()),
153
+ "maximum_pnl": int(testing.pnl.max())
143
154
  }
144
155
 
145
156
  @staticmethod
@@ -163,11 +174,11 @@ class TradeLens:
163
174
  trade_data = trade_data[trade_data.date < trade_data.closing_timestamp]
164
175
  trade_data.loc[:, 'close'] = np.where(
165
176
  ((trade_data.transaction_type == "SELL") & (trade_data.close > trade_data.close_price) & (
166
- trade_data.date >= trade_data.closing_timestamp)),
177
+ trade_data.date >= trade_data.closing_timestamp)),
167
178
  trade_data.close_price, trade_data.close)
168
179
  trade_data.loc[:, 'close'] = np.where(
169
180
  ((trade_data.transaction_type == "BUY") & (trade_data.close < trade_data.close_price) & (
170
- trade_data.date >= trade_data.closing_timestamp)),
181
+ trade_data.date >= trade_data.closing_timestamp)),
171
182
  trade_data.close_price, trade_data.close)
172
183
  trade_data.loc[:, 'pnl'] = np.where(trade_data.transaction_type == "SELL",
173
184
  trade_data.entry_price - trade_data.close,
@@ -180,10 +191,103 @@ class TradeLens:
180
191
  date_only = str(check_date).split("T")[0]
181
192
  response = TradeLens.plot_pnl(trade_data, date_only)
182
193
  trade_analysis.append({
183
- "date_only" : date_only,
184
- "backtesting_pnl" : trades[trades.date_only.astype(str) == date_only].profit.sum(),
185
- "minimum_pnl" : response["minimum_pnl"]
194
+ "date_only": date_only,
195
+ "backtesting_pnl": trades[trades.date_only.astype(str) == date_only].profit.sum(),
196
+ "minimum_pnl": response["minimum_pnl"]
186
197
  })
187
198
 
188
199
  return pd.DataFrame(trade_analysis)
189
200
 
201
+ def alpha_runner(alpha: typing.Callable, day_candles: pd.DataFrame):
202
+ """
203
+ Passes Required Parameters to the alpha function
204
+ """
205
+ return alpha(
206
+ open=day_candles.open,
207
+ low=day_candles.low,
208
+ high=day_candles.high,
209
+ close=day_candles.close,
210
+ volume=day_candles.volume,
211
+ vwap=day_candles.vwap,
212
+ returns=day_candles.returns,
213
+ adv5=day_candles.adv5,
214
+ adv10=day_candles.adv10,
215
+ adv15=day_candles.adv15,
216
+ adv20=day_candles.adv20,
217
+ adv30=day_candles.adv30,
218
+ adv40=day_candles.adv40,
219
+ adv50=day_candles.adv50,
220
+ adv60=day_candles.adv60,
221
+ adv81=day_candles.adv81,
222
+ adv120=day_candles.adv120,
223
+ adv150=day_candles.adv150,
224
+ adv180=day_candles.adv180,
225
+ )
226
+
227
+
228
+ @staticmethod
229
+ def validate_alpha(self, day_candles, alpha, num_buckets=10):
230
+ """Validate alphas by bucketing them into 10 buckets and checking the returns
231
+
232
+ Args:
233
+ day_candles (DataFrame): Dataframe containing day candles
234
+ alpha (Function): function for calculating alpha
235
+ num_buckets (int, optional): No of brackets required. Defaults to 10.
236
+ """
237
+ try:
238
+ alpha_name = alpha.__name__
239
+ alpha_bucket_name = "{}_bucket".format(alpha_name)
240
+
241
+ alpha_candles = day_candles[["date"]]
242
+
243
+ alpha_candles.loc[:, alpha_name] = self.alpha_runner(alpha=alpha, day_candles=day_candles)
244
+
245
+
246
+ alpha_candles.loc[:, f"{alpha_name}_rank"] = alpha_candles.groupby("date")[
247
+ alpha_name
248
+ ].rank(ascending=False)
249
+
250
+ alpha_candles.loc[:, "is_top500"] = np.where(
251
+ (alpha_candles[f"{alpha_name}_rank"] <= 500), True, False
252
+ )
253
+
254
+ alpha_candles.loc[:, "intraday_return"] = (
255
+ day_candles.close / day_candles.open - 1
256
+ )
257
+ alpha_candles.loc[
258
+ :, "next_day_intraday_return"
259
+ ] = alpha_candles.intraday_return.shift(-1)
260
+
261
+ alpha_candles.loc[:, alpha_bucket_name] = 1 + 10 * alpha_candles.groupby(
262
+ ["is_top500", "date"]
263
+ )[alpha_name].rank(method="first", pct=True)
264
+
265
+ alpha_candles.loc[:, alpha_bucket_name] = np.where(
266
+ alpha_candles["is_top500"] == False,
267
+ np.nan,
268
+ alpha_candles[alpha_bucket_name],
269
+ )
270
+
271
+ alpha_candles.loc[:, alpha_bucket_name] = (
272
+ alpha_candles[alpha_bucket_name]
273
+ .replace([np.inf, -np.inf, np.nan], 0)
274
+ .astype(int)
275
+ .replace([0], np.nan)
276
+ .replace([num_buckets + 1], num_buckets)
277
+ )
278
+
279
+ # plotting
280
+ t_df = (
281
+ alpha_candles.groupby(alpha_bucket_name)
282
+ .next_day_intraday_return.mean()
283
+ .reset_index()
284
+ )
285
+
286
+ plt.clf()
287
+ plt.title(alpha_name)
288
+ plt.bar(t_df[alpha_bucket_name], -1 *
289
+ t_df.next_day_intraday_return)
290
+ plt.show()
291
+
292
+ except Exception as e:
293
+ print(alpha, inspect.signature(alpha), e)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: quantplay
3
- Version: 1.2.87
3
+ Version: 1.2.91
4
4
  Summary: This python package will be stored in AWS CodeArtifact
5
5
  Home-page:
6
6
  Author:
@@ -21,7 +21,7 @@ requirements = [
21
21
  setup(
22
22
  name="quantplay",
23
23
  long_description=Path("README.md").read_text(),
24
- version="1.2.87",
24
+ version="1.2.91",
25
25
  setup_requires=["pytest-runner"],
26
26
  install_requires=requirements,
27
27
  tests_require=[],
File without changes
File without changes
File without changes