Today I learned
2025/06/05
python else clause
- python else clause can be used alongside loops and try-except statements as well.
elsestatement executes after a loop, if the loop didn’t encounter abreakstatement.- within the
try-except-else-finallyclause, if no exception are raised within the try block, thenelsestatement executes.
python objects and references
- Assignment operator creates/stores a reference to original object. Slicing a list creates a new object.
- during shallow copy, new outer object is created but inner objects are referenced from main object.
- during deep copy, outer object as well as inner objects are newly created.
2025/05/30
portfolio turnover
It essentially means value of your portfolio you have turned over (replaced) in a given time-frame. It is expressed in percentage terms. You replace securities via buying and selling, however while computing turnover, you do not consider both bought and sold value together as it would double count the value replaced. You consider minimum of bought value or sold value to see what value is originally replaced. turnover > 100% tells you that there has been frequent buying and selling of assets in the portfolio (Which is normal for a crypto based or momentum strategy portfolio. turnover < 25% indicates a more buy and hold strategy. High turnover has higher txn costs, which eats into the profits. Higher selling activity leads to high realised gains, which can have tax implications (STCG) Portfolio’s strategy dictates whether high turnover is good or bad, for index funds high turnover is bad but for actively managed funds it is normal.
2025/05/28
git bisect
git bisect is invaluable anytime you have a “before” (good) state and an “after” (bad) state in your commit history and need to find the exact point of transition (when bug occured) efficiently. It saves a tremendous amount of time compared to manually checking out and testing commits one by one.
2025/05/26
Primitives in python are objects, hence they have their own methods
python primitive data types
int,float,bool,strare considered to be objects. Hence they have their own methods. you can do(5).__dir__()to get the methods on int objects.
in order to create a tuple with a single value, you have to add a trailing comma, else it is simply the element.
(5) # => 5 (int)(5,) # => (5) (set)
2025/05/25
car drive-trains speciality
- FWD
- RWD
- 4WD
- AWD
webhooks
you’re waiting for an event A to happen, so that you can execute action B. Instead of sending repeated API request to the service (polling), you set up a callback URL such that when event A happens, the service makes you a HTTP POST request so that you could perform action B. It is like a reverse API, where a service registers your callback address, and sends you a request.
2025/05/24
financial terms
A nifty
bhavcopyis essentially the summary of trades made during a day for a given share. It typically contains OHLCV columns along with turnover, % change, P/E, P/B, Dividend Yield etc.volume: no of shares traded vsturnover: monetary value of those shares.Divident Yield: It is a financial ratio that shows how much a company pays out in dividends each year relative to its current stock price. i.e. If a company’s current price is ₹650 and it has paid out ₹35 in dividends in past 12 months (TTM), then company’s Div Yield would be 35/650 ~ 5.4% or 0.054
- for an index, Dividend Yield is the weighted average of Dividend Yields of Individual Stocks.
block deal: transactions with volume > 500,000 or turnover > ₹ 5 Crore usually done by institutional investors . These are privately negotiated transactions facilitated by the exchange, so that it has minimal impact on the stock’s market price.
- Face Value vs Market Price vs Listing Price of a stock
Face valueis the fixed original price of the stock when it first issued i.e. initial worth of the stock. It doesn’t change with market fluctuations. It changes when company either announces stock splits or consolidation.market priceis the current price at which the stock is being traded on exchange. ‘Issue/IPO price` is price at which company first sells its shares to the public. $Face Value + Share Premium = Issue Price$ Companies declare dividends relative to face value of the stock. i.e. declaring 100% dividend means 100% of face value.
- Nifty 50 Inverse and Leveraged and Leveraged Inverse Indices
these indices exists for hedging purposes.
- If I know the market is going to fall tomorrow, I’ll buy
Nifty 50 1x InverseIndex, so If market falls by 1.5%, Inverse index and I gain 1.5%.- If I have a strong conviction that market is going up tomorrow, I’ll buy
Nifty 50 1x LeverageIndex, so If market goes up by 2%, I gain 4%. and if it falls, my losses double too.- If I have a very strong conviction that market is going see a major fall tomorrow, I could buy
Nifty 50 1x Leveraged InverseIndex, so If market goes down by 1.5%, I gain 3%.
- VIX
- It is a volatility index that measures the Indian stock market’s expectation of volatility in the near term, specifically over the next 30 calendar days.
- It is a forward looking measure.
- It does not use historic volatility data but rather the prices of near term Nifty 50 Options.
2025/05/23
- Investible Weight Factor vs Free Float Factor
Free Float Shares or Public Shares of a stock are shares available to be bought and sold by the public via brokerage companies. Similarly Free Float MCap is the MCap of Free Floating Shares of a company. Free float mcap of a stock is used while determining its weight in an index. The ratio of public-shares/total-shares of a company is called
Investible Weight Factor (IWF)by NSE andFree Float Factorby the BSE Public shareholding details are published by a listed company in its each quarterly reports, under shareholding pattern.
2025/05/20
-
concept of subtyping
-
variance in programming languages
- Covariance
- Contravariance
- Invariance
2025/05/19
- exception handling in python #python
- When an exception occurs for an expression inside try block, the execution of code inside the try block is immediately halted. rest of the code inside it doesn’t gets executed.
- if a matching execpt block is found, code inside it is executed. If it contains a return statement, the execption is considered handled and code execution resumes following the try-execpt-finally clauses. If nothing is returned or if a raise exception statement is found, the exceptions follows up in the stack to the calling function and keep going up untill it is handled, if not handled, then the program abruptly stops.
- if there is a finally block, it will always execute when an exception occurs. If except and finally both blocks have a return statement, finally block’s return is given preference over except block. If finally block doesn’t have its own return statement, then the code inside finally block is executed and then the execution will return to except block which will at last return the value.
- if there’s a return statement present in either except-finally blocks, then it gets executed and any code present after try-catch-finally block will not get executed.
- if there is except-finally block present but neither have any raise or return statement, then the code after try-except-finally block gets executed.
- finally block always gets executed. whether an exception occurs or not.
2025/05/18
- command commenting in shell #terminal
you can add comments/tags to your terminal commands using
#so that It’d be easier to find a specific command into the future by doing a reverse-searchctrl+Rand type the comments or tags.
- get list of keymaps in zsh #terminal
You can type
bindkeyin zsh to get list of all keyboard shortcuts in zsh. where LHS shows key sequence and RHS showszle(zsh line editor).
- get key sequence representation of keyboard keys / combinations in shell
press
ctrl+vfollowed by key or key combination to get the terminal representation of that key.
e.g.ctrl+v ctrl+spacewill show^@meaning spacebar equals@.
frequently used key sequences representation: [LHS: terminal key sequence]: [RHS: keyboard keys]
\M: meta –> (alt/option) key orescapekey.^[–> escape key_: underscore –>/@-> spacebar^[[A–> up arrow key^[[B–> down arrow key^[[C–> right arrow key^[[D–> left arrow key^?–> backspace key^M–> Enter key
- save command output to clipboard in macos #terminal
append
| pbcopyat the end of the command to copy contents to macos keyboard.
bindkey | pbcopy# save output to clipboard.
2024/10/22
- Learnt vs Learned #vocab
While writing the headline I realised I didn’t know what the difference between the two was, so this is the first thing I decided to add here.
Learned is used in American English whereas Learnt is used in British English. Now you know.