sma
Simple moving average over a window of bars; the bars before the window fills are NaN (a gap in a plot). From gtfinance, checked against TA-Lib.
values(number[]) -- the closes (or any series)period(number) -- bars in the window
Simple moving average over a window of bars; the bars before the window fills are NaN (a gap in a plot). From gtfinance, checked against TA-Lib.
values (number[]) -- the closes (or any series)period (number) -- bars in the windowExponential moving average with the usual 2/(n + 1) smoothing.
values (number[]) -- the closes (or any series)period (number) -- bars in the windowWeighted moving average, the newest bar weighted most.
values (number[]) -- the closes (or any series)period (number) -- bars in the windowHull moving average, a fast smooth average.
values (number[]) -- the closes (or any series)period (number) -- bars in the windowDouble exponential moving average.
values (number[]) -- the closes (or any series)period (number) -- bars in the windowTriple exponential moving average.
values (number[]) -- the closes (or any series)period (number) -- bars in the windowRate of change, the percentage change over the period.
values (number[]) -- the closes (or any series)period (number) -- bars in the windowTRIX, the one-bar rate of change of a triple-smoothed average, in percent.
values (number[]) -- the closes (or any series)period (number) -- bars in the windowRelative strength index (Wilder), 0 to 100; the period is 14 when left out.
values (number[]) -- the closesperiod (number) -- bars, 14 by defaultMACD: a record with the lists line, signal and histogram (12, 26, 9 by default).
values (number[]) -- the closesfast (number) -- fast EMA period, 12slow (number) -- slow EMA period, 26signal (number) -- signal EMA period, 9Bollinger bands: a record with the lists middle, upper and lower (period 20, 2 standard deviations by default).
values (number[]) -- the closesperiod (number) -- bars, 20deviations (number) -- band width in standard deviations, 2Average true range (Wilder) from highs, lows and closes; the period is 14 by default.
highs (number[]) -- the highslows (number[]) -- the lowscloses (number[]) -- the closesperiod (number) -- bars, 14Average directional index, the trend's strength 0 to 100.
highs (number[]) -- the highslows (number[]) -- the lowscloses (number[]) -- the closesperiod (number) -- bars, 14Commodity channel index.
highs (number[]) -- the highslows (number[]) -- the lowscloses (number[]) -- the closesperiod (number) -- bars, 14Williams %R, -100 to 0.
highs (number[]) -- the highslows (number[]) -- the lowscloses (number[]) -- the closesperiod (number) -- bars, 14Money flow index, a volume-weighted RSI, 0 to 100.
highs (number[]) -- the highslows (number[]) -- the lowscloses (number[]) -- the closesvolumes (number[]) -- the volumesperiod (number) -- bars, 14Chaikin money flow, -1 to 1.
highs (number[]) -- the highslows (number[]) -- the lowscloses (number[]) -- the closesvolumes (number[]) -- the volumesperiod (number) -- bars, 20Stochastic oscillator: a record with the lists k and d (14 and 3 by default).
highs (number[]) -- the highslows (number[]) -- the lowscloses (number[]) -- the closeskPeriod (number) -- %K bars, 14dPeriod (number) -- %D smoothing bars, 3Volume-weighted average price, cumulative from the first bar.
highs (number[]) -- the highslows (number[]) -- the lowscloses (number[]) -- the closesvolumes (number[]) -- the volumesOn-balance volume from closes and volumes.
closes (number[]) -- the closesvolumes (number[]) -- the volumesAccumulation/distribution line.
highs (number[]) -- the highslows (number[]) -- the lowscloses (number[]) -- the closesvolumes (number[]) -- the volumesDonchian channel: a record with the lists upper, middle and lower (period 20 by default).
highs (number[]) -- the highslows (number[]) -- the lowscloses (number[]) -- the closesperiod (number) -- bars, 20Keltner channel: a record with the lists upper, middle and lower (period 20, ATR multiplier 2 by default).
highs (number[]) -- the highslows (number[]) -- the lowscloses (number[]) -- the closesperiod (number) -- bars, 20multiplier (number) -- ATR multiples, 2Parabolic SAR stop levels (acceleration 0.02, maximum 0.2 by default).
highs (number[]) -- the highslows (number[]) -- the lowscloses (number[]) -- the closesacceleration (number) -- 0.02maximum (number) -- 0.2Ichimoku cloud: a record with the lists tenkan, kijun, senkouA, senkouB and chikou (9, 26, 52 by default).
highs (number[]) -- the highslows (number[]) -- the lowscloses (number[]) -- the closestenkan (number) -- 9kijun (number) -- 26senkou (number) -- 52Pivot points: with one high, low and close a record of numbers pivot, r1, r2, r3, s1, s2, s3; with lists a record of lists, row by row; pivotPoints(times, highs, lows, closes[, kind]) gives each bar the previous session's levels (sessions read from the times' days), the first session null, so plot() draws the day's pivots on an intraday chart. The kind is "classic" (or "standard"), "fibonacci" or "camarilla".
high (number) -- the session's highlow (number) -- its lowclose (number) -- its closekind (text) -- "classic" (default), "fibonacci" or "camarilla"Fibonacci levels of a move from low to high: a record with retracement (23.6, 38.2, 50, 61.8, 78.6 percent) and extension (127.2, 161.8 percent) lists; up = false mirrors them for a down move.
low (number) -- the move's lowhigh (number) -- its highup (boolean) -- true (default) for a move upParkinson volatility estimate per bar from highs and lows.
highs (number[]) -- the highslows (number[]) -- the lowsGarman-Klass volatility estimate per bar from opens, highs, lows and closes.
opens (number[]) -- the openshighs (number[]) -- the highslows (number[]) -- the lowscloses (number[]) -- the closesHow many standard deviations a move is against a history of at least 30 earlier moves.
history (number[]) -- earlier movesmove (number) -- the move to placeThe yearly rate (actual days over 365, as Excel's XIRR) at which dated cash flows net to zero: money paid in is negative, money received positive. Cash flows are taken to the paisa. An error says so when no rate exists (all flows one sign). From gtfinance, checked against an independent implementation.
dates (number[]) -- day numbers, date(y, m, d)amounts (number[]) -- the cash flows, same lengthA monthly SIP over a NAV series. Each instalment falls on the day of the month (the month's last day when it is shorter) and buys at the first NAV on or after it; the final value is the units times the last NAV on or before the end date. Returns a record: xirr, invested, units, value, instalments, valuationDate. Past returns only; not a forecast or advice.
dates (number[]) -- the NAV dates as day numbers, increasingnavs (number[]) -- the NAV on each date, positiveamount (number) -- each instalmentdayOfMonth (number) -- 1 to 31startDate (number) -- first date to buy on or after (default: the first NAV date)endDate (number) -- the valuation date, on or before (default: the last NAV date)Rolling returns over a NAV series. For every NAV date, the window ends at the last NAV on or before date + windowDays (windows ending more than toleranceDays short of that, or past the last NAV, are left out; when none fits the lists are empty and summary.count is 0). Returns a record: startDate, endDate, absolute and annualised lists (annualised, (end/start)^(365/days used) - 1, only for windows of 365 days or more, else NaN) and summary: count, min, max, mean, median, p10, p90, shareNegative of the annualised returns (the absolute ones for a shorter window). Past returns only; not a forecast or advice.
dates (number[]) -- the NAV dates as day numbers, increasingnavs (number[]) -- the NAV on each date, positivewindowDays (number) -- the window in daystoleranceDays (number) -- how far before the target date the window may end (default 7)How far a NAV series is below its running peak, 1 - NAV/peak at each date, and the worst fall: a record with series, max, peakDate, troughDate, recoveryDate (NaN when the NAV never got back to the peak), underwaterDays (peak to recovery, or to the last date) and current. Past returns only; not a forecast or advice.
dates (number[]) -- the NAV dates as day numbers, increasingnavs (number[]) -- the NAV on each date, positiveValues a set of holdings: each one's value (units times price), cost (units times cost per unit), gain as a fraction of its cost (NaN when the cost is 0) and weight of the total value, as lists, and a total record with value, cost, gain and gainPct. The price is an AMFI NAV or a last traded price. Arithmetic on what is held; not advice.
units (number[]) -- the units held of each holdingprices (number[]) -- the NAV or price of each, the same lengthcosts (number[]) -- the cost paid per unit of eachThe return between two NAVs some days apart: a record with absolute (end over start, less 1) and annualised ((end/start)^(365/days) - 1, NaN for spans under 365 days). Past returns only; not a forecast.
startNav (number) -- the NAV at the start, positiveendNav (number) -- the NAV at the end, positivedays (number) -- the days between themThe same money two ways on past NAVs: the SIP of sipXirr (xirr, invested, units, value, instalments, valuationDate) and its total put in at once at the first NAV on or after the start date and valued on the same day (lumpUnits, lumpValue, lumpXirr, lumpDate). A look back, not a forecast or advice.
dates (number[]) -- the NAV dates as day numbers, increasingnavs (number[]) -- the NAV on each date, positiveamount (number) -- each instalmentdayOfMonth (number) -- 1 to 31startDate (number) -- first date to buy on or after (default: the first NAV date)endDate (number) -- the valuation date, on or before (default: the last NAV date)A systematic withdrawal plan on past NAVs: the corpus buys at the first NAV on or after the start date; on the day of each month after it the withdrawal is sold at the first NAV on or after that day, the last units when fewer remain. A record with xirr (of the corpus out, the withdrawals in and the value left; NaN when none solves), withdrawn, withdrawals, unitsLeft, valueLeft, depletedDate (NaN when the plan outlasts the series) and valuationDate. Past data only; not a forecast or advice.
dates (number[]) -- the NAV dates as day numbers, increasingnavs (number[]) -- the NAV on each date, positivecorpus (number) -- the money put in at the startwithdrawal (number) -- the money taken out each monthdayOfMonth (number) -- 1 to 31startDate (number) -- the corpus buys on or after this date (default: the first NAV date)endDate (number) -- the valuation date, on or before (default: the last NAV date)The monthly instalment, paid at each month end, whose value after the months is the target if money grew at the yearly rate given (an effective rate; the monthly rate is (1 + r)^(1/12) - 1). Arithmetic at an assumed rate, not a forecast or advice.
target (number) -- the sum wantedannualRate (number) -- the assumed yearly growth as a fraction, 0.1 for 10 percentmonths (number) -- the number of instalmentsRisk measures of a NAV series from the simple returns between its dates: a record with returns (their count), periodsPerYear (returns x 365 over the days spanned), meanAnnual, volAnnual (sample standard deviation, annualised), downsideAnnual (deviation below the risk-free rate), sharpe and sortino (NaN when the deviation is 0). The risk-free rate is an effective yearly rate, 0.06 for 6 percent. About the past only; not advice.
dates (number[]) -- the NAV dates as day numbers, increasing, three or morenavs (number[]) -- the NAV on each date, positiveriskFreeRate (number) -- the yearly risk-free rate as a fraction (default 0)A scheme against a reference series (another scheme, an index fund or an ETF) on their common dates: a record with common (the dates shared), periodsPerYear, beta, correlation, rSquared, alphaAnnual (Jensen's alpha, yearly), trackingError, informationRatio, upCapture and downCapture (NaN where a denominator is 0 or no such period exists). About the past only; not advice.
dates (number[]) -- the scheme's NAV dates as day numbers, increasingnavs (number[]) -- its NAV on each date, positiverefDates (number[]) -- the reference series' datesrefNavs (number[]) -- its values, positiveriskFreeRate (number) -- the yearly risk-free rate as a fraction (default 0)What an expense ratio takes: an amount grown for the years at an assumed yearly gross return, at the gross return less expense ratio A and less expense ratio B (a direct and a regular plan, say): a record with grossValue, valueA, valueB, dragA, dragB (each against the gross value) and aMinusB. Arithmetic at assumed rates; not a forecast or advice.
amount (number) -- the money put ingrossRate (number) -- the assumed yearly return before expenses, as a fractionterA (number) -- the first expense ratio, as a fraction a yearterB (number) -- the secondyears (number) -- the years heldThe capital gain on one sale against dated lots, first in first out: a lot is long term when held more than the holding days; a short-term loss is set off against a long-term gain but not the other way; the exemption comes off the long-term gain; tax = rate x taxable gain. A record with proceeds, costSold, stcg, ltcg, taxableStcg, taxableLtcg, tax and lotsTouched. No surcharge, cess or indexation; the rules are inputs, as the law and the kind of fund change them. Arithmetic on the rules given, not tax advice.
lotDates (number[]) -- the purchase dates as day numbers, increasinglotUnits (number[]) -- the units bought in each lotlotCosts (number[]) -- the cost per unit of each lotsaleDate (number) -- the day of the salesaleUnits (number) -- the units sold, no more than heldsalePrice (number) -- the price per unitholdingDays (number) -- held more than this many days is long termstcgRate (number) -- the short-term rate as a fractionltcgRate (number) -- the long-term rate as a fractionltcgExempt (number) -- the long-term gain exempt (default 0)Where a value stands among peer values: a record with percentile (the share below, ties counting half), rank (1 for the highest) and of (the count). Position only; it says nothing about why or what comes next.
values (number[]) -- the peers' valuesx (number) -- the value to placeThe return a policy gives: the XIRR (ACT/365) of the premiums paid (money out) and the benefits received (maturity, survival, surrender or death benefit, money in), merged by date. A record with xirr (NaN when no rate solves the flows), premiums, benefits, net (benefits less premiums) and multiple (benefits over premiums). Arithmetic on the amounts given; nothing here says what to buy.
premiumDates (number[]) -- the premium dates as day numbers, increasingpremiums (number[]) -- the premium paid on each, positivebenefitDates (number[]) -- the benefit dates, increasingbenefits (number[]) -- the benefit received on each (0 allowed)The premium dates for the years at 1, 2, 4 or 12 payments a year from the first date: a list of day numbers, each on the first date's day of the month, clamped to the month's length (31 Jan, 28 Feb, 31 Mar). Premiums fall at the start of each period.
firstDate (number) -- the first premium date, a day numberyears (number) -- the years of payment, 1 to 100perYear (number) -- payments a year: 1, 2, 4 or 12Cover against stated needs: the present value of a yearly need in today's money over the years, at the real rate (1 + return)/(1 + inflation) - 1 as an ordinary annuity, plus liabilities and goals due; against the cover held and the assets set aside. A record with realRate, annuityFactor, incomeValue, need, available, gap (need less available, or 0), surplus (available less need, or 0) and availableToNeed. Arithmetic on the numbers given, not a recommendation of an amount of cover.
annualNeed (number) -- the yearly amount needed, in today's moneyyears (number) -- for how many yearsreturn (number) -- the yearly return assumed on the money, as a fractioninflation (number) -- the yearly rise in the need, as a fractionliabilities (number) -- loans and dues to be clearedgoals (number) -- amounts for future goalscover (number) -- the life cover already heldassets (number) -- the money set asideThe expected range of a session from the log-linear model of gtfinance (quant-rust indicator I1): a record with median, mean, p10 and p90, all in percent of the open. The six coefficients and sigma come from fitRangeModel (or the stored range_model row); r1 is yesterday's high-low range in percent of its open, m5 and m20 its 5- and 20-day means, vixOpen the India VIX at the open, gap the opening gap in percent. A forecast of a range, never of direction.
r1 (number) -- yesterday's range, percent of its openm5 (number) -- the 5-day mean of thatm20 (number) -- the 20-day meanvixOpen (number) -- the India VIX at the opengap (number) -- the opening gap in percent, 0 or morecoef (number[]) -- the six coefficientssigma (number) -- the residual standard deviation of the log rangeThe range so far today, high less low in percent of the open, as a fraction of the expected range: 1 means the session has done what was expected.
high (number) -- the high so farlow (number) -- the low so faropen (number) -- the openexpected (number) -- the expected range in percent of the openThe inputs of expectedRange for session i (0-based, 20 or more) of a daily series, as the fit script builds them: a record with r1, m5, m20, vixOpen and gap.
opens (number[]) -- the sessions' openshighs (number[]) -- highslows (number[]) -- lowscloses (number[]) -- closesvixOpen (number) -- the India VIX at session i's openi (number) -- the session, 0-basedRefits the expected-range model on a daily series (R277, R280): a row for every session from the 21st, its target the session's own high-low range in percent of the open, or with "move" its absolute open-to-close move, so the same expectedRange then forecasts a move. A record with coef (six numbers), sigma, rSquared and sessions. Needs 32 sessions or more; a fit on the past, not a promise about the future.
opens (number[]) -- the sessions' openshighs (number[]) -- highslows (number[]) -- lowscloses (number[]) -- closesvixOpens (number[]) -- the India VIX at each opentarget (text) -- "range" (default) or "move"Implied less realised volatility in volatility points: the implied figure is annualised percent (the India VIX), the realised one a per-bar estimator from parkinson or garmanKlass (a fraction), scaled by the square root of the bars in a year (75 x 252 for 5-minute bars). Positive when options are priced above what the market has done.
impliedPct (number) -- the implied volatility, annualised percentrealisedPerBar (number) -- the per-bar realised volatility, a fractionbarsPerYear (number) -- bars of that size in a yearHow unusual today's move to a minute of the session is (quant-rust indicator I3): from intraday bars with the minute of the session of each (0 at the first bar; a smaller minute than the bar before opens a new session), each session's move is its close at the last bar on or before the minute over its first bar's open, less 1, in percent. Today is the last session; its move is divided by the population standard deviation of the same move on the look-back sessions before it (at least 30). A record with zscore, move, sd and sessions.
minutes (number[]) -- the minute of the session of each baropens (number[]) -- each bar's opencloses (number[]) -- each bar's closeminute (number) -- the minute to read the move atlookback (number) -- earlier sessions to use (default 250)The strikes of the largest call and put open interest of a chain (resistance and support as traders read them, which is only what the chain shows): a record with callWall, callWallOi, putWall, putWallOi, callDistance and putDistance (percent of the spot, positive when the call wall is above and the put wall below) and pcr (put OI over call OI).
strikes (number[]) -- the strikes, increasingcallOi (number[]) -- call open interest at eachputOi (number[]) -- put open interest at eachspot (number) -- the underlying's priceThe change in open interest from one snapshot of a chain to the next, by band: a record with callAbove and callBelow (strikes above the spot, and at or below it), putAbove and putBelow, callTotal, putTotal, pcrBefore and pcrAfter. Calls added above the spot and puts added below it are the usual writing pattern.
strikes (number[]) -- the strikes, increasingcallBefore (number[]) -- call OI in the first snapshotputBefore (number[]) -- put OI in the firstcallAfter (number[]) -- call OI in the secondputAfter (number[]) -- put OI in the secondspot (number) -- the underlying's pricePrice change against open-interest change, as the futures market reads them: "long buildup" (both up), "short buildup" (price down, OI up), "short covering" (price up, OI down), "long unwinding" (both down), "flat" when either is zero.
priceChange (number) -- the price changeoiChange (number) -- the open-interest changeGamma exposure of a chain: for each strike the Black-Scholes gamma times the open interest times the lot times spot squared times 0.01, calls positive and puts negative (dealers taken long the calls and short the puts), so the figure is the dealers' hedging flow in money for a one percent move. A record with perStrike, total, call, put and flip (the first strike at which the running sum from the lowest strike turns non-negative; NaN when none). A model's estimate on stated assumptions.
strikes (number[]) -- the strikes, increasingcallOi (number[]) -- call open interest at eachputOi (number[]) -- put open interest at eachiv (number[]) -- implied volatility at each, a fraction a yearspot (number) -- the underlying's pricedaysToExpiry (number) -- days to expiry, more than 0rate (number) -- the yearly risk-free rate, a fractionlot (number) -- units a contractThe mean implied volatility of the puts below the spot less that of the calls above it, both within a band of the spot: a record with putIv, callIv, skew, puts and calls (the strikes counted; NaN parts when a side has none). The change of skew between two snapshots is the difference of two such figures.
strikes (number[]) -- the strikes, increasingcallIv (number[]) -- call implied volatility at each, a fractionputIv (number[]) -- put implied volatility at eachspot (number) -- the underlying's priceband (number) -- the band as a fraction of the spot (default 0.02)Bars gathered into a longer interval from the bars given, as the chart server's own resampling does: resampleBars(times, opens, highs, lows, closes, volumes, rule[, openMinute]) returns a record of lists times, open, high, low, close, volume. The rule is a count of minutes (buckets counted from the session open, 09:15 for the NSE, so 15 gives 09:15, 09:30, ...; a bucket never crosses a day; a bar before the open is dropped; each bar is stamped at its bucket's start), or "day", "week" (Monday to Sunday) or "month", each stamped at its first bar's time. The open is the first bar's, the high the highest, the low the lowest, the close the last bar's, the volume the sum (give [] for none). The times are dateTimeDays values (or date() days for daily bars) in order; a last bucket still filling is given as it stands. Checked against quant-rust's chartdb on a year of Nifty 5-minute bars.
times (number[]) -- dateTimeDays values, in orderopens (number[]) -- highs (number[]) -- lows (number[]) -- closes (number[]) -- volumes (number[]) -- the same length, or [] for nonerule (number or text) -- minutes, or "day", "week", "month"openMinute (number) -- the session open in minutes from midnight; 555 (09:15) when left outEach value's change from the first value in percent, 100 (x / x0 - 1): two symbols rebased for a compare chart (the chart's own percent scale is yScale(g, "percent")). A null in the list (an indicator's warm-up) stays null.
values (number[]) -- the closes (or any series); the first value must not be zeroThe spread a - b bar by bar, for a pair or a price against its average; a null on either side stays null.
a (number[]) -- the first seriesb (number[]) -- the second, of the same lengthThe ratio a / b bar by bar (a relative-strength line); a null on either side, or a zero divisor, gives null, a gap in the plot.
a (number[]) -- the first seriesb (number[]) -- the second, of the same lengthSupertrend: a record with the lists line, direction (+1 up, -1 down), up and down (the line split by direction, each for a plot() in its colour), upper and lower (the bands in force); hl2 +- multiplier * ATR(period), period 10 and multiplier 3 by default, null through the ATR's warm-up.
highs (number[]) -- the highslows (number[]) -- the lowscloses (number[]) -- the closesperiod (number) -- ATR bars, 10multiplier (number) -- ATR multiples, 3Anchored VWAP: the volume-weighted average of the typical price (H+L+C)/3 from the first bar at or after the anchor time on, null before it; the times in the bars' unit (dateTimeDays).
times (number[]) -- the bars' timeshighs (number[]) -- the highslows (number[]) -- the lowscloses (number[]) -- the closesvolumes (number[]) -- the volumesanchorTime (number) -- the anchor, in the times' unitSession VWAP with sigma bands: a record with the lists vwap, sd (the volume-weighted standard deviation of the typical price this session) and upper1, lower1, upper2, lower2 (one pair a sigma; [1, 2] unless given), the accumulators reset where the times' day changes.
times (number[]) -- the bars' times (dateTimeDays)highs (number[]) -- the highslows (number[]) -- the lowscloses (number[]) -- the closesvolumes (number[]) -- the volumessigmas (number[]) -- the band multiples, [1, 2]Volume profile: the volume traded at each price row between the lowest low and the highest high (each bar's volume spread over the rows its range covers), a record with the lists price (the row's middle), low, high and volume, and the numbers poc (the point of control, the heaviest row's middle), vaHigh and vaLow (the value area holding the share of the volume, 0.7 unless given), total and step; 24 rows unless given. showVolumeProfile(g, volumes) draws it at the right of a chart.
highs (number[]) -- the highslows (number[]) -- the lowscloses (number[]) -- the closesvolumes (number[]) -- the volumesrows (number) -- price rows, 24share (number) -- the value area's share of the volume, 0.7What an option position pays (R316): legs as a list of {"kind": "call" or "put", "side": "buy" or "sell", "strike", "premium", "qty"} (premium 0 and qty 1 unless given; qty is the lots times the lot size; an "iv" of a leg's own, a fraction a year, overrides the position's), spots a list of prices to work the profit at or the spot alone (then 121 prices about the strikes). A record: spots, expiry (the profit at each spot at expiry), today (the Black-Scholes profit now at iv, days to expiry and the rate; the expiry profit when iv and days are left out), breakevens (every spot where the expiry profit crosses zero, exact), maxProfit and maxLoss (the loss as a size; the word "unlimited" when so), netPremium (positive a debit, negative a credit) and netKind ("debit", "credit" or "even"), spot (the one given, else the middle of the list) with value, delta, gamma, theta (a day) and vega of the whole position there, and legs as read. showPayoff(g, record) draws it.
legs (record[]) -- the legs, each a map or record: kind, side, strike, premium, qty, ivspots (number[] | number) -- the spot prices to work at, ascending, or the spot aloneiv (number) -- implied volatility a year as a fraction, for today's curve; with daysdays (number) -- days to expiryrate (number) -- the risk-free rate a year, 0The legs of a named option strategy about the at-the-money strike (the spot rounded to the strike step), premiums 0 until priceLegs or the chain fills them: "long-straddle", "short-straddle" (a call and a put at the money), "long-strangle", "short-strangle" (the put width strikes below, the call width above), "bull-call-spread", "bear-call-spread", "bull-put-spread", "bear-put-spread" (at the money and width strikes away), "iron-condor" (the short put and call width strikes away, the long ones another width out), "butterfly" (calls at width below, at the money twice, width above), "iron-butterfly" (a short straddle with the wings width strikes away). A list of leg records for strategyPayoff.
name (text) -- the strategy's namespot (number) -- the underlying's pricestep (number) -- the strike step, 50 or 100width (number) -- strikes between the legs, a whole number, 1qty (number) -- units a leg, 1Each leg's premium set to its Black-Scholes value (no dividend) at the spot, the implied volatility (a leg's own iv when it has one), the days to expiry and the rate: the legs back with their premiums, for strategyPayoff when no chain gives them.
legs (record[]) -- the legs, as strategyPayoff takes themspot (number) -- the underlying's priceiv (number) -- implied volatility a year as a fractiondays (number) -- days to expiryrate (number) -- the risk-free rate a year, 0The charges of one order leg on an Indian broker (R317), an estimate from one rate table (Dhan's brokerage, STT or CTT, the exchange's transaction charge, the SEBI fee, stamp duty, GST, the DP charge of a delivery sell) kept with the date it was last checked: a record with value (price x qty x multiplier), brokerage, tax (STT or CTT: on the sell leg; delivery shares both legs), exchange, sebi, stamp (the buy leg), gst (on the brokerage, exchange and SEBI charges, never on the taxes), total, and note (the rates' standing in words). The kinds: "equity" (intraday or delivery), "index-futures", "index-options", "stock-futures", "stock-options", "commodity-futures", "commodity-options", or the exchange's FUTIDX, OPTIDX, FUTSTK, OPTSTK, FUTCOM, OPTFUT.
kind (text) -- the kind of contractintraday (boolean) -- true for intraday, false for delivery or carried; or the words "intraday", "delivery"side (text) -- "buy" or "sell"price (number) -- the price (a premium for an option)qty (number) -- units (the lots times the lot size)multiplier (number) -- rupees a point a unit, 1An entry and its exit after charges: a record with entry and exit (each the record tradeCharges gives), gross (the points times the quantity and multiplier, a buy gaining when the exit is higher), charges (both legs), net, perUnit (the charges a point a unit, the break-even move) and note.
kind (text) -- the kind of contract, as tradeChargesintraday (boolean) -- true for intraday, false for delivery or carriedside (text) -- the entry's side, "buy" or "sell"entry (number) -- the entry priceexit (number) -- the exit priceqty (number) -- unitsmultiplier (number) -- rupees a point a unit, 1