trigerr 0.7.1__tar.gz → 0.7.3__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 (239) hide show
  1. {trigerr-0.7.1/trigerr.egg-info → trigerr-0.7.3}/PKG-INFO +17 -13
  2. trigerr-0.7.3/README.md +58 -0
  3. trigerr-0.7.3/tests/test_brokerage.py +152 -0
  4. trigerr-0.7.3/tests/test_bt_orders.py +109 -0
  5. trigerr-0.7.3/tests/test_ledger_contract.py +33 -0
  6. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/__init__.py +1 -1
  7. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/framework/__init__.py +1 -0
  8. trigerr-0.7.3/trigerr/framework/bt_state.py +44 -0
  9. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/framework/compiler.py +8 -0
  10. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/framework/data_feeds.py +7 -23
  11. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/framework/execution_core.py +114 -7
  12. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/framework/point_in_time.py +1 -2
  13. trigerr-0.7.3/trigerr/orders/backtest.py +115 -0
  14. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/utils.py +35 -14
  15. {trigerr-0.7.1 → trigerr-0.7.3/trigerr.egg-info}/PKG-INFO +17 -13
  16. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr.egg-info/SOURCES.txt +4 -0
  17. trigerr-0.7.1/README.md +0 -54
  18. trigerr-0.7.1/trigerr/orders/backtest.py +0 -56
  19. {trigerr-0.7.1 → trigerr-0.7.3}/LICENSE +0 -0
  20. {trigerr-0.7.1 → trigerr-0.7.3}/pyproject.toml +0 -0
  21. {trigerr-0.7.1 → trigerr-0.7.3}/setup.cfg +0 -0
  22. {trigerr-0.7.1 → trigerr-0.7.3}/tests/test_crypto_utils.py +0 -0
  23. {trigerr-0.7.1 → trigerr-0.7.3}/tests/test_data_market.py +0 -0
  24. {trigerr-0.7.1 → trigerr-0.7.3}/tests/test_exit_mutex.py +0 -0
  25. {trigerr-0.7.1 → trigerr-0.7.3}/tests/test_historical_client_config.py +0 -0
  26. {trigerr-0.7.1 → trigerr-0.7.3}/tests/test_live_orders_correlation.py +0 -0
  27. {trigerr-0.7.1 → trigerr-0.7.3}/tests/test_logging_utils.py +0 -0
  28. {trigerr-0.7.1 → trigerr-0.7.3}/tests/test_orders_schema.py +0 -0
  29. {trigerr-0.7.1 → trigerr-0.7.3}/tests/test_package.py +0 -0
  30. {trigerr-0.7.1 → trigerr-0.7.3}/tests/test_reference_symbol_details.py +0 -0
  31. {trigerr-0.7.1 → trigerr-0.7.3}/tests/test_schema_parity.py +0 -0
  32. {trigerr-0.7.1 → trigerr-0.7.3}/tests/test_symbols.py +0 -0
  33. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/config.py +0 -0
  34. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/crypto_utils.py +0 -0
  35. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/custom_indicators.py +0 -0
  36. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/data/__init__.py +0 -0
  37. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/data/historical.py +0 -0
  38. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/data/market.py +0 -0
  39. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/data/reference.py +0 -0
  40. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/framework/candle_transforms.py +0 -0
  41. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/framework/catalog.py +0 -0
  42. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/framework/clock.py +0 -0
  43. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/framework/exit_engine.py +0 -0
  44. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/framework/expressions.py +0 -0
  45. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/framework/instrument.py +0 -0
  46. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/framework/position_sizing.py +0 -0
  47. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/framework/tick_sources.py +0 -0
  48. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/jobs.py +0 -0
  49. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/orders/__init__.py +0 -0
  50. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/orders/live.py +0 -0
  51. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/orders/orders_utils.py +0 -0
  52. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/orders/virtual.py +0 -0
  53. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/symbols.py +0 -0
  54. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/__init__.py +0 -0
  55. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/__main__.py +0 -0
  56. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/_typing.py +0 -0
  57. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/candle/__init__.py +0 -0
  58. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/candle/cdl_doji.py +0 -0
  59. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/candle/cdl_inside.py +0 -0
  60. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/candle/cdl_pattern.py +0 -0
  61. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/candle/cdl_z.py +0 -0
  62. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/candle/ha.py +0 -0
  63. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/core.py +0 -0
  64. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/custom.py +0 -0
  65. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/cycle/__init__.py +0 -0
  66. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/cycle/ebsw.py +0 -0
  67. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/cycle/reflex.py +0 -0
  68. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/ma.py +0 -0
  69. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/maps.py +0 -0
  70. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/momentum/__init__.py +0 -0
  71. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/momentum/ao.py +0 -0
  72. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/momentum/apo.py +0 -0
  73. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/momentum/bias.py +0 -0
  74. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/momentum/bop.py +0 -0
  75. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/momentum/brar.py +0 -0
  76. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/momentum/cci.py +0 -0
  77. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/momentum/cfo.py +0 -0
  78. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/momentum/cg.py +0 -0
  79. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/momentum/cmo.py +0 -0
  80. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/momentum/coppock.py +0 -0
  81. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/momentum/crsi.py +0 -0
  82. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/momentum/cti.py +0 -0
  83. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/momentum/dm.py +0 -0
  84. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/momentum/er.py +0 -0
  85. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/momentum/eri.py +0 -0
  86. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/momentum/exhc.py +0 -0
  87. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/momentum/fisher.py +0 -0
  88. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/momentum/inertia.py +0 -0
  89. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/momentum/kdj.py +0 -0
  90. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/momentum/kst.py +0 -0
  91. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/momentum/macd.py +0 -0
  92. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/momentum/mom.py +0 -0
  93. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/momentum/pgo.py +0 -0
  94. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/momentum/ppo.py +0 -0
  95. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/momentum/psl.py +0 -0
  96. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/momentum/qqe.py +0 -0
  97. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/momentum/roc.py +0 -0
  98. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/momentum/rsi.py +0 -0
  99. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/momentum/rsx.py +0 -0
  100. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/momentum/rvgi.py +0 -0
  101. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/momentum/slope.py +0 -0
  102. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/momentum/smc.py +0 -0
  103. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/momentum/smi.py +0 -0
  104. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/momentum/squeeze.py +0 -0
  105. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/momentum/squeeze_pro.py +0 -0
  106. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/momentum/stc.py +0 -0
  107. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/momentum/stoch.py +0 -0
  108. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/momentum/stochf.py +0 -0
  109. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/momentum/stochrsi.py +0 -0
  110. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/momentum/tmo.py +0 -0
  111. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/momentum/trix.py +0 -0
  112. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/momentum/tsi.py +0 -0
  113. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/momentum/uo.py +0 -0
  114. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/momentum/willr.py +0 -0
  115. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/overlap/__init__.py +0 -0
  116. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/overlap/alligator.py +0 -0
  117. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/overlap/alma.py +0 -0
  118. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/overlap/dema.py +0 -0
  119. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/overlap/ema.py +0 -0
  120. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/overlap/fwma.py +0 -0
  121. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/overlap/hilo.py +0 -0
  122. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/overlap/hl2.py +0 -0
  123. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/overlap/hlc3.py +0 -0
  124. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/overlap/hma.py +0 -0
  125. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/overlap/hwma.py +0 -0
  126. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/overlap/ichimoku.py +0 -0
  127. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/overlap/jma.py +0 -0
  128. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/overlap/kama.py +0 -0
  129. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/overlap/linreg.py +0 -0
  130. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/overlap/mama.py +0 -0
  131. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/overlap/mcgd.py +0 -0
  132. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/overlap/midpoint.py +0 -0
  133. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/overlap/midprice.py +0 -0
  134. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/overlap/ohlc4.py +0 -0
  135. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/overlap/pivots.py +0 -0
  136. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/overlap/pwma.py +0 -0
  137. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/overlap/rma.py +0 -0
  138. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/overlap/sinwma.py +0 -0
  139. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/overlap/sma.py +0 -0
  140. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/overlap/smma.py +0 -0
  141. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/overlap/ssf.py +0 -0
  142. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/overlap/ssf3.py +0 -0
  143. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/overlap/supertrend.py +0 -0
  144. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/overlap/swma.py +0 -0
  145. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/overlap/t3.py +0 -0
  146. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/overlap/tema.py +0 -0
  147. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/overlap/trima.py +0 -0
  148. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/overlap/vidya.py +0 -0
  149. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/overlap/wcp.py +0 -0
  150. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/overlap/wma.py +0 -0
  151. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/overlap/zlma.py +0 -0
  152. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/performance/__init__.py +0 -0
  153. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/performance/drawdown.py +0 -0
  154. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/performance/log_return.py +0 -0
  155. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/performance/percent_return.py +0 -0
  156. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/py.typed +0 -0
  157. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/statistics/__init__.py +0 -0
  158. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/statistics/entropy.py +0 -0
  159. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/statistics/kurtosis.py +0 -0
  160. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/statistics/mad.py +0 -0
  161. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/statistics/median.py +0 -0
  162. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/statistics/quantile.py +0 -0
  163. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/statistics/skew.py +0 -0
  164. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/statistics/stdev.py +0 -0
  165. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/statistics/tos_stdevall.py +0 -0
  166. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/statistics/variance.py +0 -0
  167. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/statistics/zscore.py +0 -0
  168. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/trend/__init__.py +0 -0
  169. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/trend/adx.py +0 -0
  170. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/trend/alphatrend.py +0 -0
  171. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/trend/amat.py +0 -0
  172. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/trend/aroon.py +0 -0
  173. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/trend/chop.py +0 -0
  174. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/trend/cksp.py +0 -0
  175. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/trend/decay.py +0 -0
  176. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/trend/decreasing.py +0 -0
  177. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/trend/dpo.py +0 -0
  178. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/trend/ht_trendline.py +0 -0
  179. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/trend/increasing.py +0 -0
  180. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/trend/long_run.py +0 -0
  181. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/trend/psar.py +0 -0
  182. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/trend/qstick.py +0 -0
  183. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/trend/rwi.py +0 -0
  184. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/trend/short_run.py +0 -0
  185. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/trend/trendflex.py +0 -0
  186. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/trend/ttm_trend.py +0 -0
  187. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/trend/vhf.py +0 -0
  188. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/trend/vortex.py +0 -0
  189. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/trend/zigzag.py +0 -0
  190. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/utils/__init__.py +0 -0
  191. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/utils/_candles.py +0 -0
  192. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/utils/_core.py +0 -0
  193. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/utils/_math.py +0 -0
  194. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/utils/_numba.py +0 -0
  195. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/utils/_signals.py +0 -0
  196. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/utils/_study.py +0 -0
  197. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/utils/_time.py +0 -0
  198. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/utils/_validate.py +0 -0
  199. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/volatility/__init__.py +0 -0
  200. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/volatility/aberration.py +0 -0
  201. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/volatility/accbands.py +0 -0
  202. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/volatility/atr.py +0 -0
  203. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/volatility/atrts.py +0 -0
  204. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/volatility/bbands.py +0 -0
  205. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/volatility/chandelier_exit.py +0 -0
  206. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/volatility/donchian.py +0 -0
  207. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/volatility/hwc.py +0 -0
  208. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/volatility/kc.py +0 -0
  209. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/volatility/massi.py +0 -0
  210. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/volatility/natr.py +0 -0
  211. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/volatility/pdist.py +0 -0
  212. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/volatility/rvi.py +0 -0
  213. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/volatility/thermo.py +0 -0
  214. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/volatility/true_range.py +0 -0
  215. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/volatility/ui.py +0 -0
  216. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/volume/__init__.py +0 -0
  217. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/volume/ad.py +0 -0
  218. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/volume/adosc.py +0 -0
  219. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/volume/aobv.py +0 -0
  220. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/volume/cmf.py +0 -0
  221. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/volume/efi.py +0 -0
  222. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/volume/eom.py +0 -0
  223. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/volume/kvo.py +0 -0
  224. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/volume/mfi.py +0 -0
  225. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/volume/nvi.py +0 -0
  226. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/volume/obv.py +0 -0
  227. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/volume/pvi.py +0 -0
  228. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/volume/pvo.py +0 -0
  229. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/volume/pvol.py +0 -0
  230. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/volume/pvr.py +0 -0
  231. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/volume/pvt.py +0 -0
  232. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/volume/tsv.py +0 -0
  233. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/volume/vhm.py +0 -0
  234. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/volume/vp.py +0 -0
  235. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/volume/vwap.py +0 -0
  236. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr/ta/volume/vwma.py +0 -0
  237. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr.egg-info/dependency_links.txt +0 -0
  238. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr.egg-info/requires.txt +0 -0
  239. {trigerr-0.7.1 → trigerr-0.7.3}/trigerr.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: trigerr
3
- Version: 0.7.1
3
+ Version: 0.7.3
4
4
  Summary: Python tools for quantitative trading research and analysis.
5
5
  Author: Anurag Singh Kushwah
6
6
  License-Expression: MIT
@@ -31,18 +31,19 @@ Dynamic: license-file
31
31
 
32
32
  # Trigerr
33
33
 
34
- Trigerr is a Python package for quantitative trading research and analysis.
35
- It is being developed as an open-source successor to an earlier internal
36
- package, with an initial focus on dependable offline tools: technical
37
- indicators, OHLCV utilities, market-structure analysis, P&L calculations,
38
- reports, and in-memory backtesting.
34
+ Trigerr is a Python package for algorithmic trading — technical indicators,
35
+ OHLCV utilities, market-structure analysis, P&L calculations, reports,
36
+ in-memory backtesting, and network-connected data and order execution
37
+ (historical/live market data, backtest/virtual/live order engines, a
38
+ canonical-AST strategy framework). It is the successor to an earlier internal
39
+ package.
39
40
 
40
41
  ## Status
41
42
 
42
- Trigerr is in its initial migration phase. The import namespace and packaging
43
- are ready; the public API is not yet stable. Network-connected data and order
44
- integrations will be redesigned as optional adapters rather than treated as
45
- part of the core package.
43
+ Trigerr is at v0.7.1 and in production use on the Trigerr white-label trading
44
+ platform (live, virtual and backtest order flow; live market data over Redis
45
+ Streams). The public API is versioned but still evolving — pin a version in
46
+ production and read the changelog before upgrading.
46
47
 
47
48
  Trigerr supports Python 3.10 and newer.
48
49
 
@@ -76,9 +77,12 @@ Do not use real trading credentials in examples, tests, or committed files.
76
77
 
77
78
  ## Roadmap
78
79
 
79
- The near-term focus is stabilizing the offline analysis core (indicators,
80
- utilities, backtesting) and reshaping the network-connected data and order
81
- integrations into optional adapters.
80
+ Near-term work is on the platform side rather than the SDK's own shape:
81
+ onboarding more brokers to live order execution (Dhan, then Upstox), and
82
+ extending the canonical-AST strategy framework (`trigerr.framework`) to more
83
+ strategy families. See `PLATFORM_TARGET_ARCHITECTURE.md` in the
84
+ `trigerr-trading-strategies` repo for the platform-wide plan this SDK
85
+ implements.
82
86
 
83
87
  ## License
84
88
 
@@ -0,0 +1,58 @@
1
+ # Trigerr
2
+
3
+ Trigerr is a Python package for algorithmic trading — technical indicators,
4
+ OHLCV utilities, market-structure analysis, P&L calculations, reports,
5
+ in-memory backtesting, and network-connected data and order execution
6
+ (historical/live market data, backtest/virtual/live order engines, a
7
+ canonical-AST strategy framework). It is the successor to an earlier internal
8
+ package.
9
+
10
+ ## Status
11
+
12
+ Trigerr is at v0.7.1 and in production use on the Trigerr white-label trading
13
+ platform (live, virtual and backtest order flow; live market data over Redis
14
+ Streams). The public API is versioned but still evolving — pin a version in
15
+ production and read the changelog before upgrading.
16
+
17
+ Trigerr supports Python 3.10 and newer.
18
+
19
+ ## Installation
20
+
21
+ ```bash
22
+ pip install trigerr
23
+ ```
24
+
25
+ For local development from a checkout:
26
+
27
+ ```bash
28
+ pip install -e ".[dev]"
29
+ python -m pytest
30
+ ```
31
+
32
+ ## Current configuration API
33
+
34
+ The existing configuration helpers remain available while the integration
35
+ layer is migrated:
36
+
37
+ ```python
38
+ import trigerr
39
+
40
+ trigerr.set_api_key("your-api-key")
41
+ trigerr.set_data_url("https://data.example.com/")
42
+ trigerr.set_orders_url("https://orders.example.com/")
43
+ ```
44
+
45
+ Do not use real trading credentials in examples, tests, or committed files.
46
+
47
+ ## Roadmap
48
+
49
+ Near-term work is on the platform side rather than the SDK's own shape:
50
+ onboarding more brokers to live order execution (Dhan, then Upstox), and
51
+ extending the canonical-AST strategy framework (`trigerr.framework`) to more
52
+ strategy families. See `PLATFORM_TARGET_ARCHITECTURE.md` in the
53
+ `trigerr-trading-strategies` repo for the platform-wide plan this SDK
54
+ implements.
55
+
56
+ ## License
57
+
58
+ Trigerr is released under the [MIT License](LICENSE).
@@ -0,0 +1,152 @@
1
+ """ calculate_brokerage for the Indian market: the charge schedule every number below is worked out from.
2
+
3
+ Statutory charges are the same at every broker; brokerage is the one part that differs. Rates in force from 1 April 2026:
4
+ STT delivery 0.1% buy and sell; intraday equity 0.025% sell; futures 0.05% sell; options 0.15% of the premium, sell
5
+ Exchange (NSE) equity 0.00307%, futures 0.00183%, options 0.03553% of premium (NSE/FA/73061, from 1 March 2026);
6
+ BSE equity 0.00375%, futures nil, options 0.0325%
7
+ SEBI Rs 10 per crore (0.0001%) of turnover
8
+ Stamp duty on the buy side: delivery 0.015%, intraday equity and options 0.003%, futures 0.002%
9
+ GST 18% on brokerage + exchange charges + SEBI fee (+ DP charges on delivery)
10
+ STT and stamp duty on futures/options are rounded to the rupee/paisa as the function does; every total here was added up by
11
+ hand from those components, not read back from the function.
12
+ """
13
+ import pytest
14
+
15
+ from trigerr.utils import calculate_brokerage
16
+
17
+
18
+ def charges(broker="zerodha", **kwargs):
19
+ args = dict(market_type="options", holding_type="intraday", exchange="NFO", market="IN", lot_size=25, order_type="MARKET")
20
+ return calculate_brokerage(broker=broker, **{**args, **kwargs})
21
+
22
+
23
+ # ---- options: 44 lots of 25 bought at 90, sold at 100; flat Rs 20 per executed order
24
+
25
+ def test_nse_options_round_trip():
26
+ # brokerage 40 | SEBI 0.21 (209,000 x 0.0001%) | exchange 74.26 (209,000 x 0.03553%) | STT 165 (110,000 x 0.15%)
27
+ # stamp 2.97 (99,000 x 0.003%) | GST 20.60 (18% of 40 + 0.21 + 74.26) -> total 303.04
28
+ assert charges(buy_price=90, sell_price=100, quantity=1100) == (303.04, 10696.96)
29
+
30
+
31
+ @pytest.mark.parametrize("exchange", ["NSE", "NFO", "XNSE"])
32
+ def test_every_label_for_the_nse_prices_options_at_the_nse_rate(exchange):
33
+ # the strategies place options on "NFO", a plain cash symbol on "NSE": both are NSE
34
+ assert charges(buy_price=90, sell_price=100, quantity=1000, exchange=exchange) == (279.79, 9720.21)
35
+ # brokerage 40 | SEBI 0.19 | exchange 67.51 (190,000 x 0.03553%) | STT 150 | stamp 2.70 | GST 19.39
36
+
37
+
38
+ @pytest.mark.parametrize("exchange", ["BSE", "BFO", "XBSE"])
39
+ def test_bse_options_use_the_bse_rate(exchange):
40
+ # exchange 61.75 (190,000 x 0.0325%) -> GST 18.35 -> total 272.99
41
+ assert charges(buy_price=90, sell_price=100, quantity=1000, exchange=exchange) == (272.99, 9727.01)
42
+
43
+
44
+ def test_a_short_position_has_the_same_charges_and_the_opposite_sign_of_gross_pnl():
45
+ # the charges depend on the two prices, not on which came first; gross is (90 - 100) x 1,100 = -11,000
46
+ assert charges(buy_price=90, sell_price=100, quantity=1100, position_type="SHORT") == (303.04, -11303.04)
47
+
48
+
49
+ # ---- futures: one Nifty lot (75) bought at 22,000, sold at 22,100
50
+
51
+ def test_nse_futures_round_trip():
52
+ # brokerage 40 (the Rs 20 cap; 0.03% of 3,307,500 is 992.25) | SEBI 3.31 | exchange 60.53 (0.00183%) | STT 829 (1,657,500 x 0.05%)
53
+ # stamp 33.00 (1,650,000 x 0.002%) | GST 18.69 (18% of 40 + 3.31 + 60.53) -> total 984.53
54
+ assert charges(market_type="futures", buy_price=22000, sell_price=22100, quantity=75) == (984.53, 6515.47)
55
+
56
+
57
+ def test_bse_futures_pay_no_exchange_charge():
58
+ # brokerage 18 (0.03% of 60,000) | SEBI 0.06 | exchange 0 | STT 15 | stamp 0.60 | GST 3.25 -> 36.91
59
+ assert charges(market_type="futures", exchange="BFO", buy_price=100, sell_price=100, quantity=300) == (36.91, -36.91)
60
+
61
+
62
+ def test_small_futures_trades_pay_the_percentage_not_the_cap():
63
+ # brokerage 18 (0.03% of 60,000) | SEBI 0.06 | exchange 1.10 | STT 15 | stamp 0.60 | GST 3.45 -> 38.21
64
+ assert charges(market_type="futures", buy_price=100, sell_price=100, quantity=300) == (38.21, -38.21)
65
+
66
+
67
+ # ---- equity
68
+
69
+ def test_intraday_equity_round_trip():
70
+ # 100 shares bought at 100, sold at 102. brokerage 6.06 (0.03% of 20,200) | SEBI 0.02 | exchange 0.62 (0.00307%)
71
+ # STT 2.55 (10,200 x 0.025%) | stamp 0.30 | GST 1.21 -> 10.76
72
+ assert charges(market_type="equity", exchange="NSE", buy_price=100, sell_price=102, quantity=100) == (10.76, 189.24)
73
+
74
+
75
+ def test_delivery_equity_round_trip():
76
+ # zero brokerage; the DP charge is 15.34 | SEBI 0.02 | exchange 0.62 | STT 20.20 (0.1% of 10,000 and of 10,200)
77
+ # stamp 1.50 (0.015%) | GST 2.88 -> 40.56
78
+ assert charges(market_type="equity", holding_type="delivery", exchange="NSE", buy_price=100, sell_price=102, quantity=100) == (40.56, 159.44)
79
+
80
+
81
+ def test_spot_is_priced_by_the_callers_as_equity():
82
+ assert charges(market_type="equity", exchange="NSE", buy_price=100, sell_price=102, quantity=100) is not None
83
+
84
+
85
+ # ---- what it still refuses (None, the signal tts_fees.has_fee_model reads)
86
+
87
+ @pytest.mark.parametrize("broker, market", [("zerodha", "US"), ("zerodha", "CRYPTO"), ("someone", "IN"), ("", "IN")])
88
+ def test_a_broker_or_market_with_no_schedule_returns_none(broker, market):
89
+ assert charges(broker=broker, market=market, buy_price=90, sell_price=100, quantity=1000) is None
90
+
91
+
92
+ # ---- Upstox and Dhan: the same statutory charges, a different brokerage
93
+ # Brokerage per executed order (each broker's published schedule, read 2026-10-08):
94
+ # zerodha delivery nil (DP 15.34 on a sell) | intraday equity and futures: the lower of Rs 20 and 0.03% | options Rs 20
95
+ # upstox delivery Rs 20 (+ DP Rs 20 on a sell) | intraday equity: lower of Rs 20 and 0.1% | futures: lower of Rs 20 and 0.05% | options Rs 20
96
+ # dhan delivery nil (DP Rs 12.50) | intraday equity: lower of Rs 20 and 0.03% | futures and options: flat Rs 20
97
+ # GST is charged on the DP fee too, so it sits in the same line as brokerage below.
98
+
99
+ BROKERS = ("zerodha", "upstox", "dhan")
100
+
101
+
102
+ @pytest.mark.parametrize("broker", BROKERS)
103
+ def test_options_cost_the_same_at_every_broker(broker):
104
+ # Rs 20 flat per order everywhere: the options round trip of test_nse_options_round_trip
105
+ assert charges(broker=broker, buy_price=90, sell_price=100, quantity=1100) == (303.04, 10696.96)
106
+
107
+
108
+ @pytest.mark.parametrize("broker", BROKERS)
109
+ def test_a_futures_lot_pays_the_cap_at_every_broker(broker):
110
+ # 0.03% / 0.05% of 3,307,500 is far above Rs 20, so brokerage is the cap of 40: test_nse_futures_round_trip
111
+ assert charges(broker=broker, market_type="futures", buy_price=22000, sell_price=22100, quantity=75) == (984.53, 6515.47)
112
+
113
+
114
+ @pytest.mark.parametrize("broker, expected_total", [
115
+ ("zerodha", 38.21), # brokerage 18.00 (0.03% of 60,000)
116
+ ("upstox", 52.37), # brokerage 30.00 (0.05%): SEBI 0.06 | exchange 1.10 | STT 15 | stamp 0.60 | GST 5.61
117
+ ("dhan", 64.17), # brokerage 40.00 (flat Rs 20 per order): GST 7.41
118
+ ])
119
+ def test_small_futures_trades_show_each_brokers_rule(broker, expected_total):
120
+ assert charges(broker=broker, market_type="futures", buy_price=100, sell_price=100, quantity=300) == (expected_total, -expected_total)
121
+
122
+
123
+ @pytest.mark.parametrize("broker, expected_total", [
124
+ ("zerodha", 10.76), # brokerage 6.06 (0.03% of 20,200): SEBI 0.02 | exchange 0.62 | STT 2.55 | stamp 0.30 | GST 1.21
125
+ ("upstox", 27.44), # brokerage 20.20 (0.1%): GST 3.75
126
+ ("dhan", 10.76), # brokerage 6.06 (0.03%)
127
+ ])
128
+ def test_intraday_equity_shows_each_brokers_percentage(broker, expected_total):
129
+ assert charges(broker=broker, market_type="equity", exchange="NSE", buy_price=100, sell_price=102, quantity=100) == \
130
+ (expected_total, round(200 - expected_total, 2))
131
+
132
+
133
+ @pytest.mark.parametrize("broker, expected_total", [
134
+ ("zerodha", 40.56), # DP 15.34: SEBI 0.02 | exchange 0.62 | STT 20.20 | stamp 1.50 | GST 2.88
135
+ ("upstox", 93.26), # Rs 20 x 2 orders + DP Rs 20 = 60: GST 10.92
136
+ ("dhan", 37.21), # no brokerage, DP 12.50: GST 2.37
137
+ ])
138
+ def test_delivery_shows_each_brokers_fees(broker, expected_total):
139
+ assert charges(broker=broker, market_type="equity", holding_type="delivery", exchange="NSE",
140
+ buy_price=100, sell_price=102, quantity=100) == (expected_total, round(200 - expected_total, 2))
141
+
142
+
143
+ @pytest.mark.parametrize("broker", ["upstox", "dhan"])
144
+ @pytest.mark.parametrize("market", ["US", "CRYPTO", "MCX"])
145
+ def test_the_new_brokers_are_priced_for_the_indian_market_only(broker, market):
146
+ assert charges(broker=broker, market=market, buy_price=90, sell_price=100, quantity=1000) is None
147
+
148
+
149
+ @pytest.mark.parametrize("broker", ["Upstox", "DHAN", "upstox "])
150
+ def test_the_broker_name_is_matched_exactly(broker):
151
+ # callers lower-case it (tts_fees.has_fee_model reads None as "refuse"): an unlisted spelling stays unpriced
152
+ assert charges(broker=broker, buy_price=90, sell_price=100, quantity=1000) is None
@@ -0,0 +1,109 @@
1
+ """ The two pieces a backtest stands on: the in-memory state cursor and the bt order document.
2
+
3
+ A backtest's order must be the vt order — same keys, same stringification, read back through the same
4
+ orders list — because one execution core serves vt, lt and bt. It may differ only where a backtest
5
+ must: stamped from the replayed candle, no database, no alert, no swallowed errors.
6
+ """
7
+ import datetime
8
+ import types
9
+
10
+ import pytest
11
+
12
+ import trigerr.orders.virtual as virtual
13
+ import trigerr.utils as utils
14
+ from trigerr.framework.bt_state import memory_state_cursor
15
+ from trigerr.orders.backtest import place_bt_leg_order
16
+ from trigerr.orders.orders_utils import acquire_exit_mutex, fetch_orders_list, release_exit_mutex, renew_exit_mutex
17
+
18
+ CANDLE = {"symbol": "NIFTY_50", "close": 101.5, "timestamp": datetime.datetime(2025, 6, 2, 9, 31, 7, 500)}
19
+ ORDER = dict(quantity=5, quantity_left=5, position_type="LONG", transaction_type="BUY", trade_action="ENTRY",
20
+ user_id="u1", strategy_id="s1", request_id="r1", market="IN", exchange="NSE", venue="XNSE",
21
+ data_key="UPSTOX:XNSE:NIFTY_50", group_id="r1:2025-06-02:1", leg_key="SPOT", lot_size=1,
22
+ params={"investment": 100000, "sl_price": 70.0})
23
+
24
+
25
+ # ---------------------------------------------------------------- memory_state_cursor
26
+
27
+ def test_memory_cursor_lists_behave_like_redis_lists():
28
+ c = memory_state_cursor()
29
+ assert c.rpush("k", "a") == 1 and c.rpush("k", "b", "c") == 3
30
+ assert c.lrange("k", 0, -1) == ["a", "b", "c"] and c.lrange("k", 1, 1) == ["b"]
31
+ assert c.llen("k") == 3 and c.llen("missing") == 0 and c.lrange("missing", 0, -1) == []
32
+
33
+
34
+ def test_memory_cursor_strings_and_set_nx():
35
+ c = memory_state_cursor()
36
+ assert c.set("m", "t1", nx=True, ex=120) is True
37
+ assert c.set("m", "t2", nx=True, ex=120) is None # already held
38
+ assert c.get("m") == "t1" and c.get("nope") is None
39
+ assert c.delete("m") == 1 and c.delete("m") == 0
40
+
41
+
42
+ def test_memory_cursor_publish_and_expire_are_harmless():
43
+ c = memory_state_cursor()
44
+ c.rpush("k", "x")
45
+ assert c.publish("channel", "msg") == 0 and c.expire("k", 10) is True and c.expire("none", 10) is False
46
+
47
+
48
+ def test_exit_mutex_helpers_work_on_the_memory_cursor():
49
+ c = memory_state_cursor()
50
+ token = acquire_exit_mutex(c, "r1")
51
+ assert token and acquire_exit_mutex(c, "r1", wait_s=0) is None # mutually exclusive
52
+ renew_exit_mutex(c, "r1", token)
53
+ release_exit_mutex(c, "r1", "someone-elses-token") # must not free it
54
+ assert acquire_exit_mutex(c, "r1", wait_s=0) is None
55
+ release_exit_mutex(c, "r1", token)
56
+ assert acquire_exit_mutex(c, "r1", wait_s=0)
57
+
58
+
59
+ # ---------------------------------------------------------------- place_bt_leg_order
60
+
61
+ def _vt_order_keys(monkeypatch):
62
+ monkeypatch.setattr(virtual, "send_order_alert", lambda alert: None)
63
+ db = {"vt_orders": types.SimpleNamespace(insert_one=lambda doc: types.SimpleNamespace(inserted_id="OID1"))}
64
+ cursor = memory_state_cursor()
65
+ orders = virtual.place_vt_order(app_db_cursor=db, redis_cursor=cursor, order_candle=CANDLE, **ORDER)
66
+ return set(orders[-1])
67
+
68
+
69
+ def test_bt_order_has_exactly_the_vt_order_shape(monkeypatch):
70
+ vt_keys = _vt_order_keys(monkeypatch)
71
+ bt = place_bt_leg_order(redis_cursor=memory_state_cursor(), order_candle=CANDLE, **ORDER)[-1]
72
+ assert vt_keys - {"db_order_id"} == set(bt) # the only vt-only field is the database id
73
+
74
+
75
+ def test_bt_order_is_stamped_from_the_candle_and_keeps_its_fields():
76
+ order = place_bt_leg_order(redis_cursor=memory_state_cursor(), order_candle=CANDLE, **ORDER)[-1]
77
+ assert order["date"] == "2025-06-02 00:00:00"
78
+ assert order["order_timestamp"] == "2025-06-02 09:31:07" # microseconds dropped, like vt
79
+ assert order["day"] == "Monday" and order["symbol"] == "NIFTY_50"
80
+ assert order["trigger_price"] == 101.5 # no explicit trigger -> the candle close
81
+ assert order["sl_price"] == 70.0 and order["investment"] == 100000 # params folded in, like vt
82
+ assert order["group_id"] == "r1:2025-06-02:1" and order["leg_key"] == "SPOT" and order["venue"] == "XNSE"
83
+
84
+
85
+ def test_bt_order_accumulates_on_the_request_orders_list():
86
+ c = memory_state_cursor()
87
+ place_bt_leg_order(redis_cursor=c, order_candle=CANDLE, **ORDER)
88
+ second = place_bt_leg_order(redis_cursor=c, order_candle=CANDLE, **{**ORDER, "trade_action": "EXIT", "exit_type": "T1"})
89
+ assert [o["trade_action"] for o in second] == ["ENTRY", "EXIT"]
90
+ assert [o["trade_action"] for o in fetch_orders_list(c, "r1")] == ["ENTRY", "EXIT"]
91
+
92
+
93
+ def test_bt_order_sends_no_alert(monkeypatch):
94
+ monkeypatch.setattr(utils, "send_order_alert", lambda *a, **k: (_ for _ in ()).throw(AssertionError("alert sent")))
95
+ monkeypatch.setattr(virtual, "send_order_alert", lambda *a, **k: (_ for _ in ()).throw(AssertionError("alert sent")))
96
+ place_bt_leg_order(redis_cursor=memory_state_cursor(), order_candle=CANDLE, **ORDER)
97
+
98
+
99
+ def test_bt_order_rejects_a_candle_without_a_datetime_timestamp():
100
+ with pytest.raises(TypeError, match="datetime"):
101
+ place_bt_leg_order(redis_cursor=memory_state_cursor(), order_candle={**CANDLE, "timestamp": "2025-06-02 09:31"},
102
+ **ORDER)
103
+
104
+
105
+ def test_bt_order_raises_when_nothing_was_stored():
106
+ broken = types.SimpleNamespace(rpush=lambda *a: 0, expire=lambda *a: 0, publish=lambda *a: 0,
107
+ lrange=lambda *a: [], llen=lambda k: 0)
108
+ with pytest.raises(RuntimeError, match="not stored"):
109
+ place_bt_leg_order(redis_cursor=broken, order_candle=CANDLE, **ORDER)
@@ -0,0 +1,33 @@
1
+ """ The order ledger must account for every lot, not the last entry per symbol.
2
+
3
+ `check_open_orders` folds an orders list into open positions keyed by SYMBOL, and each ENTRY order overwrites the
4
+ previous one's fields for that symbol (quantity, quantity_left, trigger_price, group_id ...). Two entries in the
5
+ same instrument — pyramiding, a grid, an adjustment that re-opens a strike, two overlapping structures — therefore
6
+ report only the last lot, and a restart rebuilds only that one. No running strategy does this today; the
7
+ families on the roadmap do.
8
+ """
9
+ import pytest
10
+
11
+ from trigerr.orders.orders_utils import check_open_orders
12
+
13
+ SYMBOL = "NIFTY_50_24000_CE_2026-08-27"
14
+
15
+
16
+ def _entry(group, quantity, price, minute):
17
+ return {"symbol": SYMBOL, "trade_action": "ENTRY", "quantity": quantity, "quantity_left": quantity,
18
+ "trigger_price": price, "order_timestamp": f"2025-06-02 09:{minute:02d}:00", "position_type": "LONG",
19
+ "group_id": group, "leg_key": "CE", "data_key": f"UPSTOX:XNSE:{SYMBOL}", "venue": "XNSE", "lot_size": 25}
20
+
21
+
22
+ def test_one_entry_is_one_open_position():
23
+ open_positions = check_open_orders([_entry("r1:2025-06-02:1", 10, 100.0, 16)])
24
+ assert {s: p["quantity_left"] for s, p in open_positions.items()} == {SYMBOL: 10}
25
+
26
+
27
+ @pytest.mark.xfail(strict=True, raises=AssertionError,
28
+ reason="S6: open positions are keyed by symbol and the second ENTRY overwrites the first, so a "
29
+ "second lot in the same instrument hides the first (15 open lots are reported as 5)")
30
+ def test_two_entries_in_the_same_instrument_are_both_open():
31
+ orders = [_entry("r1:2025-06-02:1", 10, 100.0, 16), _entry("r1:2025-06-02:2", 5, 110.0, 30)]
32
+ open_positions = check_open_orders(orders)
33
+ assert sum(p["quantity_left"] for p in open_positions.values()) == 15
@@ -1,6 +1,6 @@
1
1
  from .config import config
2
2
 
3
- __version__ = "0.7.1"
3
+ __version__ = "0.7.3"
4
4
 
5
5
 
6
6
  def set_api_key(key):
@@ -11,6 +11,7 @@ from trigerr.framework.data_feeds import resolve_feeds
11
11
  from trigerr.framework.point_in_time import truncate_feeds_to_moment
12
12
  from trigerr.framework.clock import iterate_clock_bt, evaluate_should_trade_today
13
13
  from trigerr.framework.tick_sources import clock_feed_ticks_live
14
+ from trigerr.framework.bt_state import memory_state_cursor
14
15
  from trigerr.framework.execution_core import (
15
16
  wait_for_entry_signal, monitor_open_position, enter_legs, place_entry_order_for_leg,
16
17
  place_exit_order_for_leg, convert_leg_orders_to_trade, rebuild_legs_from_open_orders,
@@ -0,0 +1,44 @@
1
+ """ The state a backtest runs against: an in-process stand-in for the tenant's state Redis.
2
+
3
+ The execution core keeps a request's orders list, its exit mutex and its pub/sub in
4
+ ctx["state_cursor"]. A live or virtual run hands it the real state Redis; a backtest hands it this
5
+ instead, so a backtest cannot read or write a real Redis key even by mistake — a stray real call
6
+ raises instead of reaching production. It implements only the commands the core and the
7
+ orders_utils helpers actually use, and nothing expires (a run is one process).
8
+
9
+ A plain dict behind closures, not a class, like the rest of the framework. """
10
+
11
+ import types
12
+
13
+
14
+ def memory_state_cursor():
15
+ store = {} # key -> str (strings) or list (lists)
16
+
17
+ def rpush(key, *values):
18
+ store.setdefault(key, []).extend(values)
19
+ return len(store[key])
20
+
21
+ def lrange(key, start, stop):
22
+ items = store.get(key, [])
23
+ return list(items[start:] if stop == -1 else items[start:stop + 1])
24
+
25
+ def llen(key):
26
+ return len(store.get(key, []))
27
+
28
+ def set_(key, value, nx=False, ex=None):
29
+ if nx and key in store:
30
+ return None
31
+ store[key] = value
32
+ return True
33
+
34
+ def get(key):
35
+ value = store.get(key)
36
+ return value if isinstance(value, str) else None
37
+
38
+ def delete(key):
39
+ return 1 if store.pop(key, None) is not None else 0
40
+
41
+ return types.SimpleNamespace(
42
+ rpush=rpush, lrange=lrange, llen=llen, set=set_, get=get, delete=delete,
43
+ expire=lambda key, seconds: key in store,
44
+ publish=lambda channel, message: 0)
@@ -302,6 +302,14 @@ def validate(ast):
302
302
  elif ast["clock"] not in ast["feeds"]:
303
303
  errors.append(f"clock feed '{ast['clock']}' is not declared in feeds")
304
304
 
305
+ from trigerr.framework.data_feeds import DATA_FEED_KINDS # lazy: data_feeds imports this module
306
+ for name, spec in ast["feeds"].items():
307
+ if not isinstance(spec, dict) or "derive" in spec or "kind" not in spec:
308
+ continue
309
+ kind = spec["kind"]
310
+ if kind not in DATA_FEED_KINDS and not (isinstance(kind, str) and kind.startswith("$")):
311
+ errors.append(f"feed '{name}' has unknown kind '{kind}' (known: {', '.join(sorted(DATA_FEED_KINDS))})")
312
+
305
313
  subscriptions = infer_subscriptions(ast)
306
314
  for feed_name in subscriptions:
307
315
  if feed_name not in ast["feeds"]:
@@ -1,15 +1,13 @@
1
1
  """ DATA_FEED_KINDS: one resolver per data source a strategy can declare in
2
2
  its FEEDS block. Each resolver is `fetch_historical(feed_spec, ctx) -> rows`
3
- — a list of dict candles for market-data kinds, or the raw stored value for
4
- collection/model kinds.
3
+ — a list of dict candles.
5
4
 
6
- Candle-kind resolvers call the SDK's own HTTP-based historical fetchers
7
- directly — pure, no Redis/Mongo. `mongo_collection`/`pickled_model` read
8
- whatever the runtime already placed on ctx (`ctx["collections"]`/
9
- `ctx["models"]`) instead of importing pymongo/pickle here — the same pattern
10
- `instrument.py` already uses for broker/symbol metadata, and what keeps this
11
- package infra-free (Decision #8: the SDK is the pure core; live/DB access is
12
- an engine-side adapter).
5
+ Resolvers call the SDK's own HTTP-based historical fetchers directly — pure,
6
+ no Redis/Mongo, which is what keeps this package infra-free (Decision #8: the
7
+ SDK is the pure core; live/DB access is an engine-side adapter). There is
8
+ deliberately no kind that reads a Mongo collection or loads a model file by
9
+ name: market data comes from the Data API, and a new source is added as a
10
+ named kind (one resolver), never as a pass-through to storage.
13
11
 
14
12
  `resolve_feeds` is the entry point: it resolves every declared feed — base
15
13
  feeds via a DATA_FEED_KINDS resolver, derived feeds via a CANDLE_TRANSFORMS
@@ -76,16 +74,6 @@ def _fetch_options(feed_spec, ctx):
76
74
  return _apply_declared_indicators(rows, feed_spec)
77
75
 
78
76
 
79
- def _fetch_mongo_collection(feed_spec, ctx):
80
- return ctx["collections"][feed_spec["name"]]
81
-
82
-
83
- def _fetch_pickled_model(feed_spec, ctx):
84
- """ A model is a single object, not a candle series — a "ref" op can't
85
- read it; a native node's plugin reads ctx["feeds"][name] directly. """
86
- return ctx["models"][feed_spec["path"]]
87
-
88
-
89
77
  DATA_FEED_KINDS = {
90
78
  "eod": {"fetch_historical": _fetch_eod,
91
79
  "spec": {"label": "End-of-day candles", "params": ["symbol", "lookback_days", "exchange"]}},
@@ -97,10 +85,6 @@ DATA_FEED_KINDS = {
97
85
  "options": {"fetch_historical": _fetch_options,
98
86
  "spec": {"label": "Option candles",
99
87
  "params": ["symbol", "option_type", "strike_price", "expiry", "granularity"]}},
100
- "mongo_collection": {"fetch_historical": _fetch_mongo_collection,
101
- "spec": {"label": "Mongo collection (e.g. nse_pre_open)", "params": ["name"]}},
102
- "pickled_model": {"fetch_historical": _fetch_pickled_model,
103
- "spec": {"label": "Pickled ML model", "params": ["path"]}},
104
88
  }
105
89
 
106
90