while25 0.1.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.
Files changed (50) hide show
  1. while25/__init__.py +341 -0
  2. while25/_costs/brokers/alpaca.json +96 -0
  3. while25/_costs/brokers/binance.json +34 -0
  4. while25/_costs/brokers/coinbase.json +34 -0
  5. while25/_costs/brokers/ibkr.json +39 -0
  6. while25/_costs/brokers/upstox.json +175 -0
  7. while25/_costs/brokers/zerodha.json +175 -0
  8. while25/_costs/crypto_alpaca.json +27 -0
  9. while25/_costs/global_crypto.json +18 -0
  10. while25/_costs/in_nse_equity.json +238 -0
  11. while25/_costs/in_nse_etf.json +352 -0
  12. while25/_costs/in_nse_fo.json +450 -0
  13. while25/_costs/us_crypto.json +18 -0
  14. while25/_costs/us_equity.json +175 -0
  15. while25/_costs/us_options.json +172 -0
  16. while25/_days.py +123 -0
  17. while25/_figures.py +233 -0
  18. while25/_runtime.py +49 -0
  19. while25/_universes/banknifty.json +80 -0
  20. while25/_universes/ndx100.json +520 -0
  21. while25/_universes/nifty50.json +260 -0
  22. while25/_universes/nifty500.json +2505 -0
  23. while25/_universes/sp500.json +2525 -0
  24. while25/assume.py +263 -0
  25. while25/backtest.py +881 -0
  26. while25/barline.py +160 -0
  27. while25/combo_legs.py +238 -0
  28. while25/errors.py +77 -0
  29. while25/fonts/IBMPlexMono-Regular.ttf +0 -0
  30. while25/fonts/IBMPlexMono-SemiBold.ttf +0 -0
  31. while25/fonts/Inter-Bold.ttf +0 -0
  32. while25/fonts/Inter-Regular.ttf +0 -0
  33. while25/fonts/Inter-SemiBold.ttf +0 -0
  34. while25/fonts/OFL-IBMPlexMono.txt +93 -0
  35. while25/fonts/OFL-Inter.txt +93 -0
  36. while25/future_pick.py +77 -0
  37. while25/inputs.py +215 -0
  38. while25/instruments.py +488 -0
  39. while25/modules.py +397 -0
  40. while25/money.py +24 -0
  41. while25/option_pick.py +221 -0
  42. while25/plots.py +147 -0
  43. while25/report.py +644 -0
  44. while25/ui.py +680 -0
  45. while25/universes.py +70 -0
  46. while25-0.1.0.dist-info/METADATA +3194 -0
  47. while25-0.1.0.dist-info/RECORD +50 -0
  48. while25-0.1.0.dist-info/WHEEL +5 -0
  49. while25-0.1.0.dist-info/licenses/LICENSE +201 -0
  50. while25-0.1.0.dist-info/top_level.txt +1 -0
while25/barline.py ADDED
@@ -0,0 +1,160 @@
1
+ """A bar line a module holds, as one object (2026-11-14).
2
+
3
+ class TslaRsi(Strategy):
4
+ id = "tsla_rsi"
5
+ tsla = Bars("EQ:US:TSLA", "5m", keep=100)
6
+
7
+ @on.bar(tsla)
8
+ def on_bar(self, ctx, bar):
9
+ rsi = self.tsla.indicator(MyRsi, length=14)["rsi"]
10
+
11
+ Every strategy that decides on bars did the same four things by hand: fetch
12
+ the history before its first bar, keep a list, add each bar as it closes, and
13
+ cut the list so it does not grow for ever. `Bars` does them. Declared on the
14
+ class, it is the line's subscription; when the module starts, its last `keep`
15
+ finished bars are there before `on_start` runs; each closed bar is added
16
+ before the module's own handlers see it; and no more than `keep` are kept.
17
+
18
+ Declared on the CLASS, held per INSTANCE: `Bars(...)` in the class body is the
19
+ declaration, and `self.tsla` is that module's own line with its own bars.
20
+ """
21
+ from __future__ import annotations
22
+
23
+ from . import _runtime
24
+ from .errors import While25Error
25
+
26
+ #: The most bars one line may keep: what one warm-up may fetch.
27
+ MAX_KEEP = 10_000
28
+
29
+
30
+ def bar_args(symbol: str, interval: str, hours: "str | None" = None) -> dict:
31
+ """One bar line as its subscription carries it: {"symbol", "interval"},
32
+ and "hours": "eth" for the full session. The ONE place the session word is
33
+ judged, for `@on.bar(symbol, interval, hours=)` and `Bars(...)` alike.
34
+
35
+ `hours` is the session the bars come from, in the word an order uses:
36
+ left out = the venue's regular session, for every instrument (futures
37
+ included); "eth" = the full session, pre and post market included. "rth"
38
+ is not a choice: leave hours out for regular hours."""
39
+ args = {"symbol": symbol, "interval": interval}
40
+ if hours:
41
+ text = str(hours).lower()
42
+ if text == "rth":
43
+ raise While25Error(
44
+ "hours='rth' is not a choice — leave hours out for regular "
45
+ "hours, or state 'eth' for extended hours too", "BAD_HOURS")
46
+ if text != "eth":
47
+ raise While25Error(
48
+ f"unknown trading hours: {hours!r} (eth = extended hours "
49
+ f"too; leave it out for regular hours)", "BAD_HOURS")
50
+ # Only when extended: a regular subscription declares exactly what
51
+ # it always has.
52
+ args["hours"] = "eth"
53
+ return args
54
+
55
+
56
+ class BarLine:
57
+ """One module's bars of one line: `self.<name>` for a `Bars` declared on
58
+ its class. A list of bar dicts, oldest first, each as an `@on.bar` handler
59
+ receives it."""
60
+
61
+ def __init__(self, symbol: str, interval: str, hours: "str | None", keep: int) -> None:
62
+ self.symbol = symbol
63
+ self.interval = interval
64
+ self.hours = hours
65
+ self.keep = keep
66
+ #: The bars, oldest first. Read it; the runtime writes it.
67
+ self.rows: list = []
68
+
69
+ # ---- reading ----
70
+
71
+ def __len__(self) -> int:
72
+ return len(self.rows)
73
+
74
+ def __iter__(self):
75
+ return iter(self.rows)
76
+
77
+ def __getitem__(self, index):
78
+ return self.rows[index]
79
+
80
+ @property
81
+ def last(self) -> "dict | None":
82
+ """The newest finished bar, or None before there is one."""
83
+ return self.rows[-1] if self.rows else None
84
+
85
+ @property
86
+ def closes(self) -> list:
87
+ """Every bar's close, oldest first."""
88
+ return [r["close"] for r in self.rows]
89
+
90
+ def indicator(self, cls, *, forming: bool = False, **params) -> dict:
91
+ """Work an indicator out from these bars: what its compute() returns.
92
+ `forming=True` also counts the bar still forming on this line. Every
93
+ other keyword is one of the indicator's inputs."""
94
+ own = {"forming": True} if forming else {}
95
+ return _runtime.current().indicator(cls, bars=self.rows, **own, **params)
96
+
97
+ # ---- written by the runtime ----
98
+
99
+ def _load(self, rows) -> None:
100
+ """The warm-up's bars, as the line starts."""
101
+ self.rows = list(rows)[-self.keep:]
102
+
103
+ def _take(self, bar: dict) -> bool:
104
+ """A bar that has just closed. True when it was added: not when it is
105
+ one the line already holds (the bar reaches this once per handler on
106
+ the line, and a warm-up may have brought it)."""
107
+ t = bar.get("time_ms")
108
+ if self.rows and t is not None and t <= self.rows[-1].get("time_ms", t - 1):
109
+ return False
110
+ self.rows.append(bar)
111
+ del self.rows[:-self.keep]
112
+ return True
113
+
114
+ def __repr__(self) -> str: # pragma: no cover - debugging aid
115
+ return f"<Bars {self.symbol} {self.interval}: {len(self.rows)} of {self.keep}>"
116
+
117
+
118
+ class Bars:
119
+ """Declare a bar line on a module's class.
120
+
121
+ `Bars(symbol, interval, *, hours=None, keep=200)`: the symbol and interval
122
+ as `@on.bar` takes them, `hours="eth"` for the full session, and how many
123
+ finished bars to hold (1 to 10,000). Give it to `@on.bar(...)` to wake a
124
+ handler on each of its bars; without one the line is still subscribed,
125
+ warmed up and kept, for a tick handler to read."""
126
+
127
+ def __init__(self, symbol: str, interval: str, *, hours: "str | None" = None,
128
+ keep: int = 200) -> None:
129
+ if not isinstance(symbol, str) or not symbol.strip():
130
+ raise ValueError("Bars(symbol, interval): the symbol is the instrument's key, "
131
+ "written out")
132
+ if not isinstance(interval, str) or not interval.strip():
133
+ raise ValueError(f"Bars({symbol!r}, interval): the interval is one @on.bar takes, "
134
+ f"such as \"5m\"")
135
+ if isinstance(keep, bool) or not isinstance(keep, int) or not 1 <= keep <= MAX_KEEP:
136
+ raise ValueError(f"Bars(keep=): a whole number from 1 to {MAX_KEEP:,}, not {keep!r}")
137
+ self.symbol = symbol.strip()
138
+ self.interval = interval.strip()
139
+ # Judged here, as the class body is read: a wrong session word is a
140
+ # declaration error, said when the file is saved.
141
+ self.args = bar_args(self.symbol, self.interval, hours)
142
+ self.hours = self.args.get("hours")
143
+ self.keep = keep
144
+ self._name = ""
145
+
146
+ def __set_name__(self, owner, name: str) -> None:
147
+ self._name = name
148
+
149
+ def __get__(self, instance, owner=None):
150
+ if instance is None:
151
+ return self # on the class: the declaration itself
152
+ key = f"_w25_bars_{self._name or id(self)}"
153
+ line = instance.__dict__.get(key)
154
+ if line is None:
155
+ line = instance.__dict__[key] = BarLine(self.symbol, self.interval,
156
+ self.hours, self.keep)
157
+ return line
158
+
159
+ def __repr__(self) -> str: # pragma: no cover - debugging aid
160
+ return f"Bars({self.symbol!r}, {self.interval!r}, keep={self.keep})"
while25/combo_legs.py ADDED
@@ -0,0 +1,238 @@
1
+ """A strategy's combo legs (2026-10-25).
2
+
3
+ The pure half of `while25.combo()`: reading the legs an author wrote, each a
4
+ `while25.leg(...)` or a plain dict, into the one shape the wire carries, and
5
+ refusing in words, before anything is sent, what the engine would refuse
6
+ anyway. Nothing here talks to the terminal, so the rules are tested on their
7
+ own:
8
+
9
+ - A leg is a contract (an option's instrument key, or the dict
10
+ `while25.option()` returned), a side (BUY or SELL, in any capitals), a ratio
11
+ (a whole number of lots of it per lot of the combo, 1 or more) and, on a
12
+ limit combo, its own limit price.
13
+ - A combo is 2 to 10 legs, what the engine's combo placer takes, and names
14
+ each contract once.
15
+ - One order type for every leg, the order ticket's name written exactly so.
16
+ On an "LMT" combo every leg states its own price, above 0; on an "MKT"
17
+ combo none does. Where the broker takes the
18
+ combo as ONE order, its limit is those prices netted by ratio: a leg with no
19
+ price would leave that limit unset, and a price on a market leg would put a
20
+ limit on an order nobody priced.
21
+ - A leg's size is never written: it is the combo's lots x the leg's ratio x
22
+ the contract's own lot size, which the engine reads from its instrument
23
+ list. So a leg dict carrying any key but the four above is refused rather
24
+ than read: a "qty" or "lots" quietly dropped would leave a leg of ratio 1
25
+ that its author believed was sized some other way.
26
+
27
+ Malformed input raises ValueError (the author's mistake: nothing was sent).
28
+ """
29
+ from __future__ import annotations
30
+
31
+ import numbers
32
+ from decimal import Decimal
33
+
34
+ from ._figures import _canon
35
+
36
+ #: How many legs a combo takes: the engine's combo placer (the one Deploy in
37
+ #: Options Execution uses) places 2 to 10.
38
+ MIN_LEGS = 2
39
+ MAX_LEGS = 10
40
+
41
+ #: The largest ratio and lot count the wire carries (CmdPyPlaceCombo: an int32
42
+ #: ratio, int64 lots). A larger one is refused here, because the parent could
43
+ #: build no frame from it and the call would only time out.
44
+ MAX_RATIO = 2 ** 31 - 1
45
+ MAX_LOTS = 2 ** 63 - 1
46
+
47
+ #: The engine's own bounds (BAD_TAG, BAD_NAME): the tag every leg's order
48
+ #: carries, and the name Options Execution, Open orders and the Positions tab
49
+ #: show the combo by.
50
+ MAX_TAG = 20
51
+ MAX_NAME = 64
52
+
53
+ #: Every key a leg dict may hold, in the order a leg is written.
54
+ LEG_KEYS = ("instrument_key", "side", "ratio", "price")
55
+
56
+ ORDER_TYPES = ("MKT", "LMT")
57
+ SIDES = ("BUY", "SELL")
58
+
59
+
60
+ def contract_key(contract) -> str:
61
+ """The instrument key a leg's contract names: the key itself, or the
62
+ "instrument_key" of the dict while25.option() returned ("key" on a
63
+ contract row as a lookup lists it)."""
64
+ key = contract
65
+ if isinstance(contract, dict):
66
+ key = contract.get("instrument_key") or contract.get("key")
67
+ if not key:
68
+ raise ValueError(
69
+ "the contract dict names no instrument_key: pass the dict "
70
+ "while25.option() returned, or the contract's instrument key")
71
+ if not isinstance(key, str) or not key.strip():
72
+ raise ValueError(
73
+ "a leg's contract is an option's instrument key "
74
+ '("OPT:US:SPY:20261120:600.00:C") or the dict while25.option() '
75
+ f"returned, not {contract!r}")
76
+ return key.strip()
77
+
78
+
79
+ def side_word(side, where: str = "a leg") -> str:
80
+ """BUY or SELL, from either in any capitals."""
81
+ word = str(side if side is not None else "").strip().upper()
82
+ if word not in SIDES:
83
+ raise ValueError(f"{where}: side must be BUY or SELL, not {side!r}")
84
+ return word
85
+
86
+
87
+ def whole_count(value, what: str, top: int) -> int:
88
+ """A whole number from 1 to `top`: an int, or a NumPy integer, never a
89
+ bool, a float or text. 1.5 lots, or a ratio of True, is no count of
90
+ anything, and a float that happens to be whole is refused with the rest
91
+ rather than trusted to stay whole."""
92
+ if isinstance(value, bool) or not isinstance(value, numbers.Integral):
93
+ raise ValueError(f"{what} must be a whole number, 1 or more, not {value!r}")
94
+ n = int(value)
95
+ if n < 1:
96
+ raise ValueError(f"{what} must be 1 or more, not {n}")
97
+ if n > top:
98
+ raise ValueError(f"{what} must be at most {top}, not {n}")
99
+ return n
100
+
101
+
102
+ def limit_text(price, where: str = "a leg") -> "str | None":
103
+ """A leg's own limit as wire text, by place()'s rule for every price: None
104
+ when absent; when stated, the canonical text of a figure above 0. A stated
105
+ 0 or less is no price, and is refused rather than sent."""
106
+ if price is None:
107
+ return None
108
+ text = _canon(price, f"{where} price")
109
+ if Decimal(text) <= 0:
110
+ raise ValueError(f"{where}: {text} is not a price")
111
+ return text
112
+
113
+
114
+ def order_type_word(order_type) -> str:
115
+ """"MKT" or "LMT", the order ticket's name written exactly so: every leg's."""
116
+ word = str(order_type if order_type is not None else "")
117
+ if word not in ORDER_TYPES:
118
+ raise ValueError(
119
+ "a combo's order_type is 'MKT' (no leg states a price) or 'LMT' "
120
+ f"(every leg states its own limit), not {order_type!r}")
121
+ return word
122
+
123
+
124
+ def bounded_text(value, what: str, top: int) -> str:
125
+ """`value` as text ("" for None), refused past `top` characters."""
126
+ text = "" if value is None else str(value)
127
+ if len(text) > top:
128
+ raise ValueError(
129
+ f"a combo's {what} is at most {top} characters, not {len(text)} ({text!r})")
130
+ return text
131
+
132
+
133
+ def leg(contract, side, ratio=1, price=None) -> dict:
134
+ """One leg of a combo, for while25.combo():
135
+
136
+ while25.leg(while25.option("SPY", "2026-11-20", "CALL", "ATM+2"), "SELL")
137
+ while25.leg("OPT:US:SPY:20261120:600.00:C", "BUY", ratio=2, price="1.25")
138
+
139
+ `contract`: an option's instrument key, or the dict while25.option()
140
+ returned. `side`: BUY or SELL, in any capitals. `ratio`: how many lots of
141
+ this leg per lot of the combo, a whole number, 1 or more. `price`: this
142
+ leg's own limit, on a combo placed with order_type="LMT" only: the same
143
+ figures every price takes (a Decimal, an int, plain decimal text, or a
144
+ float exact to 9 fraction digits), above 0.
145
+
146
+ Returns {"instrument_key", "side", "ratio", "price"}, the price an exact
147
+ Decimal or None: a plain dict, checked here so that a mistake is named
148
+ on the line that made it. combo() checks every leg again, against the
149
+ combo's order type. ValueError for anything a leg cannot be.
150
+ """
151
+ key = contract_key(contract)
152
+ word = side_word(side)
153
+ count = whole_count(ratio, "a leg's ratio", MAX_RATIO)
154
+ text = limit_text(price)
155
+ return {"instrument_key": key, "side": word, "ratio": count,
156
+ "price": Decimal(text) if text is not None else None}
157
+
158
+
159
+ def _legs_named(nums: list) -> str:
160
+ """"leg 2", "legs 2 and 3", "legs 1, 2 and 4"."""
161
+ if len(nums) == 1:
162
+ return f"leg {nums[0]}"
163
+ return "legs " + ", ".join(str(n) for n in nums[:-1]) + f" and {nums[-1]}"
164
+
165
+
166
+ def wire_legs(legs, order_type) -> list:
167
+ """The combo's legs as CmdPyPlaceCombo carries them, in the order given:
168
+ [{"instrument_key", "side", "ratio", "price"}], `price` the canonical text
169
+ of the leg's own limit on an "LMT" combo, None on an "MKT" one.
170
+
171
+ `legs` is a list (any sequence) of while25.leg() dicts or plain dicts with
172
+ those keys. Refused (ValueError) in words: not a list, not 2 to 10 legs, a
173
+ leg that is no dict or holds another key, a contract named twice, a bad
174
+ side, ratio or price, a limit combo with a leg stating no price and a
175
+ market combo with a leg stating one."""
176
+ kind = order_type_word(order_type)
177
+ if isinstance(legs, (str, bytes, dict)):
178
+ rows = None
179
+ else:
180
+ try:
181
+ rows = list(legs)
182
+ except TypeError:
183
+ rows = None
184
+ if rows is None:
185
+ raise ValueError(
186
+ "combo() takes a list of legs, e.g. [while25.leg(put, 'BUY'), "
187
+ f"while25.leg(call, 'SELL')], not {legs!r}")
188
+ if not MIN_LEGS <= len(rows) <= MAX_LEGS:
189
+ why = f"a combo is {MIN_LEGS} to {MAX_LEGS} legs, not {len(rows)}"
190
+ if len(rows) == 1:
191
+ why += ": one contract is an order of its own (while25.buy / while25.sell)"
192
+ raise ValueError(why)
193
+ out: list = []
194
+ first_at: dict = {}
195
+ for n, raw in enumerate(rows, start=1):
196
+ where = f"leg {n}"
197
+ if not isinstance(raw, dict):
198
+ raise ValueError(
199
+ f"{where} is not a leg: build it with while25.leg(contract, side), or "
200
+ f"write a dict of {', '.join(LEG_KEYS)} (got {raw!r})")
201
+ extra = sorted(repr(k) for k in raw if k not in LEG_KEYS)
202
+ if extra:
203
+ # The dict while25.option() returned, handed over as a leg: it
204
+ # names a contract and no side, so say how to make it one.
205
+ hint = (": it is a contract, not a leg - write while25.leg(contract, 'BUY')"
206
+ if "side" not in raw and "instrument_key" in raw else "")
207
+ raise ValueError(
208
+ f"{where} holds {', '.join(extra)}, which a leg does not take{hint}. A "
209
+ f"leg is {', '.join(LEG_KEYS)}, and its size is the combo's lots x its "
210
+ f"ratio x its contract's lot size")
211
+ try:
212
+ key = contract_key(raw.get("instrument_key"))
213
+ except ValueError as exc:
214
+ raise ValueError(f"{where}: {exc}") from None
215
+ if key in first_at:
216
+ raise ValueError(
217
+ f"{where} names {key} again ({_legs_named([first_at[key]])} has it): "
218
+ f"a combo takes each contract once")
219
+ first_at[key] = n
220
+ out.append({"instrument_key": key,
221
+ "side": side_word(raw.get("side"), where),
222
+ "ratio": whole_count(raw.get("ratio", 1), f"{where} ratio", MAX_RATIO),
223
+ "price": limit_text(raw.get("price"), where)})
224
+ if kind == "LMT":
225
+ unpriced = [n for n, row in enumerate(out, start=1) if row["price"] is None]
226
+ if unpriced:
227
+ raise ValueError(
228
+ f"a limit combo takes every leg's own limit, and {_legs_named(unpriced)} "
229
+ f"{'states' if len(unpriced) == 1 else 'state'} none: give each leg "
230
+ f"price=..., or place the combo with order_type='MKT'")
231
+ else:
232
+ priced = [n for n, row in enumerate(out, start=1) if row["price"] is not None]
233
+ if priced:
234
+ raise ValueError(
235
+ f"a market combo states no prices, and {_legs_named(priced)} "
236
+ f"{'states' if len(priced) == 1 else 'state'} one: leave the prices out, "
237
+ f"or place the combo with order_type='LMT' and every leg's own limit")
238
+ return out
while25/errors.py ADDED
@@ -0,0 +1,77 @@
1
+ """The one exception type engine calls raise.
2
+
3
+ Every ctx.data / ctx.portfolio / ctx.orders call is a round-trip to the engine,
4
+ and the engine answers a refusal with a machine-readable CODE and a
5
+ human-readable message. The code is the part a strategy can act on: NO_SERIES
6
+ means "subscribe it and retry", BAD_ORDER_TYPE means "your input is wrong and
7
+ retrying will not help". Raising a bare RuntimeError threw the code away and
8
+ left authors matching on message substrings, which breaks the moment wording
9
+ changes.
10
+
11
+ Subclasses RuntimeError so existing `except RuntimeError` keeps working.
12
+ """
13
+
14
+
15
+ class While25Error(RuntimeError):
16
+ def __init__(self, message: str, code: str = "", answer: "dict | None" = None) -> None:
17
+ super().__init__(message or code or "the engine refused the call")
18
+ self.code = code
19
+ self.message = message
20
+ # A history span cut short (TOO_WIDE mid-walk, VENDOR_PACING, REFUSED)
21
+ # still brings the bars it got: the whole reply, bars and
22
+ # covered_from/to included, for the script to inspect. It has no id,
23
+ # so a backtest can never be sealed on it. None otherwise.
24
+ self.answer = answer
25
+ # On a TIMEOUT from an order call (2026-10-25): the idempotency key the
26
+ # order went out with, so a retry can carry it and never place the
27
+ # order twice. None on every other error.
28
+ self.idempotency_key: "str | None" = None
29
+
30
+ def __repr__(self) -> str: # pragma: no cover - debugging aid
31
+ return f"While25Error(code={self.code!r}, message={self.message!r})"
32
+
33
+
34
+ class OrderRightsError(While25Error):
35
+ """A module of a kind that may not place orders reached for `ctx.orders`.
36
+
37
+ Only a Strategy — or an App whose file imports a Strategy class — has order
38
+ rights. An Indicator, a Monitor or any other App calling
39
+ buy/sell/place/bracket/cancel/modify gets this — in the worker, before any
40
+ frame leaves for the engine — so the kind boundary is enforced at the call
41
+ site and not only by the engine's grant gate. Subclasses While25Error so an
42
+ existing `except While25Error` keeps catching it; `code` is ORDER_RIGHTS.
43
+ """
44
+
45
+ CODE = "ORDER_RIGHTS"
46
+
47
+ def __init__(self, kind: str) -> None:
48
+ hint = " unless their file imports a Strategy class" if kind == "app" else ""
49
+ super().__init__(f"{kind or 'module'} modules cannot place orders{hint}", self.CODE)
50
+ self.kind = kind
51
+
52
+
53
+ class SubscriptionError(While25Error):
54
+ """The terminal is not subscribed to an instrument this script asked for.
55
+
56
+ A module IS a market-data holder: ctx.subscribe() takes its own reference
57
+ in the engine and returns at once, so this is never raised for a timeout —
58
+ there is nothing to wait for, and a raise inside a handler would halt a
59
+ module that may still need to exit a position.
60
+
61
+ It carries what the runtime refuses at once: NOT_RUNNING (the
62
+ module is stopping or stopped - a subscribe from on_start is fine, the
63
+ module is starting then), BAD_REQUEST (not a key). The engine's own
64
+ refusals - SUB_CAP (over the plan's limit), NO_VENUE (no vendor serves the
65
+ key), BAD_INTERVAL and SERIES_UNAVAILABLE for a bar - arrive after the
66
+ call returned True, as a warning on the module, which keeps running with
67
+ the keys it did get.
68
+ """
69
+
70
+ CODE = "SUB_CAP"
71
+
72
+ def __init__(self, keys, code: str = CODE, message: str = "") -> None:
73
+ self.keys = list(keys)
74
+ super().__init__(
75
+ message or ("the terminal is not subscribed to " + ", ".join(self.keys)
76
+ + " - add them in Market Watch, or confirm the prompt"),
77
+ code or self.CODE)
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,93 @@
1
+ Copyright 2017 IBM Corp. All rights reserved. IBMPlexMono-ThinItalic.ttf: Copyright 2017 IBM Corp. All rights reserved. IBMPlexMono-ExtraLight.ttf: Copyright 2017 IBM Corp. All rights reserved. IBMPlexMono-ExtraLightItalic.ttf: Copyright 2017 IBM Corp. All rights reserved. IBMPlexMono-Light.ttf: Copyright 2017 IBM Corp. All rights reserved. IBMPlexMono-LightItalic.ttf: Copyright 2017 IBM Corp. All rights reserved. IBMPlexMono-Regular.ttf: Copyright 2017 IBM Corp. All rights reserved. IBMPlexMono-Italic.ttf: Copyright 2017 IBM Corp. All rights reserved. IBMPlexMono-Medium.ttf: Copyright 2017 IBM Corp. All rights reserved. IBMPlexMono-MediumItalic.ttf: Copyright 2017 IBM Corp. All rights reserved. IBMPlexMono-SemiBold.ttf: Copyright 2017 IBM Corp. All rights reserved. IBMPlexMono-SemiBoldItalic.ttf: Copyright 2017 IBM Corp. All rights reserved. IBMPlexMono-Bold.ttf: Copyright 2017 IBM Corp. All rights reserved. IBMPlexMono-BoldItalic.ttf: Copyright 2017 IBM Corp. All rights reserved.
2
+
3
+ This Font Software is licensed under the SIL Open Font License, Version 1.1.
4
+ This license is copied below, and is also available with a FAQ at:
5
+ http://scripts.sil.org/OFL
6
+
7
+
8
+ -----------------------------------------------------------
9
+ SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
10
+ -----------------------------------------------------------
11
+
12
+ PREAMBLE
13
+ The goals of the Open Font License (OFL) are to stimulate worldwide
14
+ development of collaborative font projects, to support the font creation
15
+ efforts of academic and linguistic communities, and to provide a free and
16
+ open framework in which fonts may be shared and improved in partnership
17
+ with others.
18
+
19
+ The OFL allows the licensed fonts to be used, studied, modified and
20
+ redistributed freely as long as they are not sold by themselves. The
21
+ fonts, including any derivative works, can be bundled, embedded,
22
+ redistributed and/or sold with any software provided that any reserved
23
+ names are not used by derivative works. The fonts and derivatives,
24
+ however, cannot be released under any other type of license. The
25
+ requirement for fonts to remain under this license does not apply
26
+ to any document created using the fonts or their derivatives.
27
+
28
+ DEFINITIONS
29
+ "Font Software" refers to the set of files released by the Copyright
30
+ Holder(s) under this license and clearly marked as such. This may
31
+ include source files, build scripts and documentation.
32
+
33
+ "Reserved Font Name" refers to any names specified as such after the
34
+ copyright statement(s).
35
+
36
+ "Original Version" refers to the collection of Font Software components as
37
+ distributed by the Copyright Holder(s).
38
+
39
+ "Modified Version" refers to any derivative made by adding to, deleting,
40
+ or substituting -- in part or in whole -- any of the components of the
41
+ Original Version, by changing formats or by porting the Font Software to a
42
+ new environment.
43
+
44
+ "Author" refers to any designer, engineer, programmer, technical
45
+ writer or other person who contributed to the Font Software.
46
+
47
+ PERMISSION & CONDITIONS
48
+ Permission is hereby granted, free of charge, to any person obtaining
49
+ a copy of the Font Software, to use, study, copy, merge, embed, modify,
50
+ redistribute, and sell modified and unmodified copies of the Font
51
+ Software, subject to the following conditions:
52
+
53
+ 1) Neither the Font Software nor any of its individual components,
54
+ in Original or Modified Versions, may be sold by itself.
55
+
56
+ 2) Original or Modified Versions of the Font Software may be bundled,
57
+ redistributed and/or sold with any software, provided that each copy
58
+ contains the above copyright notice and this license. These can be
59
+ included either as stand-alone text files, human-readable headers or
60
+ in the appropriate machine-readable metadata fields within text or
61
+ binary files as long as those fields can be easily viewed by the user.
62
+
63
+ 3) No Modified Version of the Font Software may use the Reserved Font
64
+ Name(s) unless explicit written permission is granted by the corresponding
65
+ Copyright Holder. This restriction only applies to the primary font name as
66
+ presented to the users.
67
+
68
+ 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
69
+ Software shall not be used to promote, endorse or advertise any
70
+ Modified Version, except to acknowledge the contribution(s) of the
71
+ Copyright Holder(s) and the Author(s) or with their explicit written
72
+ permission.
73
+
74
+ 5) The Font Software, modified or unmodified, in part or in whole,
75
+ must be distributed entirely under this license, and must not be
76
+ distributed under any other license. The requirement for fonts to
77
+ remain under this license does not apply to any document created
78
+ using the Font Software.
79
+
80
+ TERMINATION
81
+ This license becomes null and void if any of the above conditions are
82
+ not met.
83
+
84
+ DISCLAIMER
85
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
86
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
87
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
88
+ OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
89
+ COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
90
+ INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
91
+ DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
92
+ FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
93
+ OTHER DEALINGS IN THE FONT SOFTWARE.
@@ -0,0 +1,93 @@
1
+ Copyright 2016 The Inter Project Authors (https://github.com/rsms/inter) Inter-Italic[opsz,wght].ttf: Copyright 2016 The Inter Project Authors (https://github.com/rsms/inter)
2
+
3
+ This Font Software is licensed under the SIL Open Font License, Version 1.1.
4
+ This license is copied below, and is also available with a FAQ at:
5
+ http://scripts.sil.org/OFL
6
+
7
+
8
+ -----------------------------------------------------------
9
+ SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
10
+ -----------------------------------------------------------
11
+
12
+ PREAMBLE
13
+ The goals of the Open Font License (OFL) are to stimulate worldwide
14
+ development of collaborative font projects, to support the font creation
15
+ efforts of academic and linguistic communities, and to provide a free and
16
+ open framework in which fonts may be shared and improved in partnership
17
+ with others.
18
+
19
+ The OFL allows the licensed fonts to be used, studied, modified and
20
+ redistributed freely as long as they are not sold by themselves. The
21
+ fonts, including any derivative works, can be bundled, embedded,
22
+ redistributed and/or sold with any software provided that any reserved
23
+ names are not used by derivative works. The fonts and derivatives,
24
+ however, cannot be released under any other type of license. The
25
+ requirement for fonts to remain under this license does not apply
26
+ to any document created using the fonts or their derivatives.
27
+
28
+ DEFINITIONS
29
+ "Font Software" refers to the set of files released by the Copyright
30
+ Holder(s) under this license and clearly marked as such. This may
31
+ include source files, build scripts and documentation.
32
+
33
+ "Reserved Font Name" refers to any names specified as such after the
34
+ copyright statement(s).
35
+
36
+ "Original Version" refers to the collection of Font Software components as
37
+ distributed by the Copyright Holder(s).
38
+
39
+ "Modified Version" refers to any derivative made by adding to, deleting,
40
+ or substituting -- in part or in whole -- any of the components of the
41
+ Original Version, by changing formats or by porting the Font Software to a
42
+ new environment.
43
+
44
+ "Author" refers to any designer, engineer, programmer, technical
45
+ writer or other person who contributed to the Font Software.
46
+
47
+ PERMISSION & CONDITIONS
48
+ Permission is hereby granted, free of charge, to any person obtaining
49
+ a copy of the Font Software, to use, study, copy, merge, embed, modify,
50
+ redistribute, and sell modified and unmodified copies of the Font
51
+ Software, subject to the following conditions:
52
+
53
+ 1) Neither the Font Software nor any of its individual components,
54
+ in Original or Modified Versions, may be sold by itself.
55
+
56
+ 2) Original or Modified Versions of the Font Software may be bundled,
57
+ redistributed and/or sold with any software, provided that each copy
58
+ contains the above copyright notice and this license. These can be
59
+ included either as stand-alone text files, human-readable headers or
60
+ in the appropriate machine-readable metadata fields within text or
61
+ binary files as long as those fields can be easily viewed by the user.
62
+
63
+ 3) No Modified Version of the Font Software may use the Reserved Font
64
+ Name(s) unless explicit written permission is granted by the corresponding
65
+ Copyright Holder. This restriction only applies to the primary font name as
66
+ presented to the users.
67
+
68
+ 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
69
+ Software shall not be used to promote, endorse or advertise any
70
+ Modified Version, except to acknowledge the contribution(s) of the
71
+ Copyright Holder(s) and the Author(s) or with their explicit written
72
+ permission.
73
+
74
+ 5) The Font Software, modified or unmodified, in part or in whole,
75
+ must be distributed entirely under this license, and must not be
76
+ distributed under any other license. The requirement for fonts to
77
+ remain under this license does not apply to any document created
78
+ using the Font Software.
79
+
80
+ TERMINATION
81
+ This license becomes null and void if any of the above conditions are
82
+ not met.
83
+
84
+ DISCLAIMER
85
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
86
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
87
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
88
+ OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
89
+ COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
90
+ INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
91
+ DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
92
+ FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
93
+ OTHER DEALINGS IN THE FONT SOFTWARE.