Selling stocks as LIFO or FIFO
"According to the IRS, you must have written confirmation from your broker ""or other agent"" whenever you sell shares using a method other than FIFO: Specific share identification.   If you adequately identify the shares   you sold, you can use the adjusted basis of those particular shares to   figure your gain or loss. You will adequately identify your mutual fund shares, even if you   bought the shares in different lots at various prices and times, if   you: Specify to your broker or other agent the particular shares to be sold or transferred at the time of the sale or transfer, and Receive confirmation in writing from your broker or other agent within a reasonable time of your specification of the particular   shares sold or transferred. If you don't have a stockbroker, I'm not sure how you even got the shares. If you have an actual stock certificate, then you are selling very specific shares and the purchase date corresponds to the purchase date of those shares represented on the certificate."
You can write industry loss warrants. This is the closest thing I’ve found since I’ve been interested in this side of the ILS trade. Hedge funds and asset managers can do this. From what I understand it’s you selling the risk.   Want to start a fund? 🤔 You have no guarantees. The stock may last have traded at $100 (so, the market price is $100), but is currently in free-fall and nobody else will be willing to buy it for any more than $80. Or heck, maybe nobody will be willing to buy it at all, at any price. Or maybe trading on this stock will be halted. Remember, the market price is just what the stock last traded at. If you put in a 'market order', you are ordering your broker to sell at the best available current price. Assuming someone's willing to buy your stock, that means you'll sell it. But if it last traded at $100, this doesn't guarantee you'll sell at anything close to that. I have heard of this, but then the broker is short the shares if they weren't selling them out of inventory, so they still want to accumulate the shares or a hedge before EOD most likely - In that case it may not be the client themselves, but that demand is hitting the market at some point if there isn't sufficient selling volume.    Whether or not the broker ends up getting all of them below VWAP is a cost of marketing for them, how they expect to reliably get real size below vwap is my question. "As previously answered, the solution is margin. It works like this: You deposit e.g. 1'000 USD at your trading company. They give you a margin of e.g. 1:100, so you are allowed to trade with 100'000 USD.  Let's say you buy 5'000 pieces of a stock at $20 USD (fully using your 100'000 limit), and the price changes to $20.50 . Your profit is 5000* $0.50 = $2'500. Fast money? If you are lucky. Let's say before the price went up to 20.50, it had a slight dip down to $19.80. Your loss was 5000* $0.2 = 1'000$. Wait! You had just 1000 to begin with: You'll find an email saying ""margin call"" or ""termination notice"": Your shares have been sold at $19.80 and you are out of business. The broker willingly gives you this credit, since he can be sure he won't loose a cent. Of course you pay interest for the money you are trading with, but it's only for minutes. So to answer your question: You don't care when you have ""your money"" back, the trading company will always be there to give you more as long as you have deposit left. (I thought no one should get margin explained without the warning why it is a horrible idea to full use the ridiculous high margins some broker offer. 1:10 might or might not be fine, but 1:100 is harakiri.)" As you mentioned in the title, what you're asking about comes down to volatility.  DCA when purchasing stock is one way of dealing with volatility, but it's only profitable if the financial instrument can be sold higher than your sunk costs.  Issues to be concerned with: Let's suppose you're buying a stock listed on the NYSE called FOO (this is a completely fake example).  Over the last six days, the average value of this stock was exactly $1.00Note 1.  Over six trading days you put $100 per day into this stockNote 2: At market close on January 11th, you have 616 shares of FOO.  You paid $596.29 for it, so your average cost (before fees) is: $596.29 / 616 = $0.97 per share Let's look at this including your trading fees: ($596.29 + $30) / 616 = $1.01 per share. When the market opens on January 12th, the quote on FOO could be anything.  Patents, customer wins, wars, politics, lawsuits, press coverage, etc... could cause the value of FOO to fluctuate.  So, let's just roll with the assumption that past performance is consistent: Selling FOO at $0.80 nets: (616 * $0.80 - $5) - ($596.29 + $30) =  $123.49 Loss Selling FOO at $1.20 nets: (616 * $1.20 - $5) - ($596.29 + $30) =  $107.90 Profit Every day that you keep trading FOO, those numbers get bigger (assuming FOO is a constant value).  Also remember, even if FOO never changes its average value and volatility, your recoverable profits shrink with each transaction because you pay $5 in fees for every one. Speaking from experience, it is very easy to paper trade.  It is a lot harder when you're looking at the ticker all day when FOO has been $0.80 - $0.90 for the past four days (and you're $300 under water on a $1000 portfolio).  Now your mind starts playing nasty games with you. If you decide to try this, let me give you some free advice: Unless you have some research (such as support / resistance information) or data on why FOO is a good buy at this price, let's be honest: you're gambling with DCA, not trading. END NOTES: "Edited: Pub 550 says 30 days before or after so the example is ok - but still a gain by average share basis.  On sale your basis is likely defaulted to ""average price"" (in the example 9.67 so there was a gain selling at 10), but can be named shares at your election to your brokerage,  and supported by record keeping. A Pub 550 wash might be buy 2000 @ 10 with basis 20000, sell 1000 @9 (nominally a loss of 1000 for now and remaining basis 10000), buy 1000 @ 8 within 30 days.   Because of the wash sale rule the basis is 10000+8000 paid + 1000 disallowed loss from wash sale with a final position of 2000 shares at 19000 basis.  I think I have the link at the example:  http://www.irs.gov/publications/p550/ch04.html#en_US_2014_publink100010601" "Assuming you are referring to macro corrections and crashes (as opposed to technical crashes like the ""flash crash"") -- It is certainly possible to sell stocks during a market drop -- by definition, the market is dropping not only because there are a larger number of sellers, but more importantly because there are a large number of transactions that are driving prices down. In fact, volumes are strongly correlated with volatility, so volumes are actually higher when the market is going down dramatically -- you can verify this on Yahoo or Google Finance (pick a liquid stock like SPY and look at 2008 vs recent years). That doesn't say anything about the kind of selling that occurs though. With respect to your question ""Whats the best strategy for selling stocks during a drop?"", it really depends on your objective. You can generally always sell at some price. That price will be worse during market crashes. Beyond the obvious fact that prices are declining, spreads in the market will be wider due to heightened volatility. Many people are forced to sell during crashes due to external and / or psychological pressures -- and sometimes selling is the right thing to do -- but the best strategy for long-term investors is often to just hold on." If you can afford the cost and risk of 100 shares of stock, then just sell a put option.  If you can only afford a few shares, you can still use the information the options market is trying to give you -- see below. A standing limit order to buy a stock is essentially a synthetic short put option position. [1]  So deciding on a stock limit order price is the same as valuing an option on that stock. Options (and standing limit orders) are hard to value, and the generally accepted math for doing so -- the Black-Scholes-Merton framework -- is also generally accepted to be wrong, because of black swans. So rather than calculate a stock buy limit price yourself, it's simpler to just sell a put at the put's own midpoint price, accepting the market's best estimate. Options market makers' whole job (and the purpose of the open market) is price discovery, so it's easier to let them fight it out over what price options should really be trading at. The result of that fight is valuable information -- use it. Sell a 1-month ATM put option every month until you get exercised, after which time you'll own 100 shares of stock, purchased at: This will typically give you a much better cost basis (several dollars better) versus buying the stock at spot, and it offloads the valuation math onto the options market.  Meanwhile you get to keep the cash from the options premiums as well. Disclaimer: Markets do make mistakes.  You will lose money when the stock drops more than the option market's own estimate. If you can't afford 100 shares, or for some reason still want to be in the business of creating synthetic options from pure stock limit orders, then you could maybe play around with setting your stock purchase bid price to (approximately): See your statistics book for how to set ndev -- 1 standard deviation gives you a 30% chance of a fill, 2 gives you a 5% chance, etc. Disclaimer: The above math probably has mistakes; do your own work.  It's somewhat invalid anyway, because stock prices don't follow a normal curve, so standard deviations don't really mean a whole lot.  This is where market makers earn their keep (or not). If you still want to create synthetic options using stock limit orders, you might be able to get the options market to do more of the math for you. Try setting your stock limit order bid equal to something like this: Where put_strike is the strike price of a put option for the equity you're trading.  Which option expiration and strike you use for put_strike depends on your desired time horizon and desired fill probability.  To get probability, you can look at the delta for a given option.  The relationship between option delta and equity limit order probability of fill is approximately: Disclaimer: There may be math errors here.  Again, do your own work. Also, while this method assumes option markets provide good estimates, see above disclaimer about the markets making mistakes. "Generally if you are using FIFO (first in, first out) accounting, you will need to match the transactions based on the number of shares. In your example, at the beginning of day 6, you had two lots of shares, 100 @ 50 and 10 @ 52.  On that day you sold 50 shares, and using FIFO, you sold 50 shares of the first lot.  This leaves you with 50 @ 50 and 10 @ 52, and a taxable capital gain on the 50 shares you sold. Note that commissions incurred buying the shares increase your basis, and commissions incurred selling the shares decrease your proceeds.  So if you spent $10 per trade, your basis on the 100 @ 50 lot was $5010, and the proceeds on your 50 @ 60 sale were $2990.  In this example you sold half of the lot, so your basis for the sale was half of $5010 or $2505, so your capital gain is $2990 - 2505 = $485. The sales you describe are also ""wash sales"", in that you sold stock and bought back an equivalent stock within 30 days.  Generally this is only relevant if one of the sales was at a loss but you will need to account for this in your code.  You can look up the definition of wash sale, it starts to get complex. If you are writing code to handle this in any generic situation you will also have to handle stock splits, spin-offs, mergers, etc. which change the number of shares you own and their cost basis.  I have implemented this myself and I have written about 25-30 custom routines, one for each kind of transaction that I've encountered.  The structure of these deals is limited only by the imagination of investment bankers so I think it is impossible to write a single generic algorithm that handles them all, instead I have a framework that I update each quarter as new transactions occur." "Most of the investors who have large holdings in a particular stock have pretty good exit strategies for those positions to ensure they are getting the best price they can by selling gradually into the volume over time. Putting a single large block of stock up for sale is problematic for one simple reason: Let's say you have 100,000 shares of a stock, and for some reason you decide today is the day to sell them, take your profits, and ride off into the sunset.  So you call your broker (or log into your brokerage account) and put them up for sale.  He puts in an order somewhere, the stock is sold, and your account is credited. Seems simple, right?  Well...not so fast. Professionals - I'm keeping this simple, so please don't beat me up for it! The way stocks are bought and sold is through companies known as ""market makers"".  These are entities which sit between the markets and you (and your broker), and when you want to buy or sell a stock, most of the time the order is ultimately handled somewhere along the line by a market maker.  If you work with a large brokerage firm, sometimes they'll buy or sell your shares out of their own accounts, but that's another story. It is normal for there to be many, sometimes hundreds, of market makers who are all trading in the same equity.  The bigger the stock, the more market makers it attracts.  They all compete with each other for business, and they make their money on the spread between what they buy stock from people selling for and what they can get for it selling it to people who want it. Given that there could be hundreds of market makers on a particular stock (Google, Apple, and Microsoft are good examples of having hundreds of market makers trading in their stocks), it is very competitive.  The way the makers compete is on price.  It might surprise you to know that it is the market makers, not the markets, that decide what a stock will buy or sell for. Each market maker sets their own prices for what they'll pay to buy from sellers for, and what they'll sell it to buyers for.  This is called, respectively, the ""bid"" and the ""ask"" prices.  So, if there are hundreds of market makers then there could be hundreds of different bid and ask prices on the same stock.  The prices you see for stocks are what are called the ""best bid and best ask"" prices.  What that means is, you are being shown the highest ""bid"" price (what you can sell your shares for) and the best ""ask"" price (what you can buy those shares for) because that's what is required.  That being said, there are many other market makers on the same stock whose bid prices are lower and ask prices are higher.  Many times there will be a big clump of market makers all at the same bid/ask, or within fractions of a cent of each other, all competing for business.  Trading computers are taught to seek out the best prices and the fastest trade fills they can. The point to this very simplistic lesson is that the market makers set the prices that shares trade at.  They adjust those prices based (among other factors) on how much buying and selling volume they're seeing.  If they see a wave of sell orders coming into the system then they'll start marking down their bid prices.  This keeps them from paying too much for shares they're going to have to find a buyer for eventually, and it can sometimes slow down the pace of selling as investors and automated systems notice the price decline and decide to wait to sell.  Conversely, if market makers see a wave of buy orders coming into the system, they'll start marking their ask prices up to maximize their gains, since they're selling you shares they bought from someone else, presumably at a lower price.  But they typically adjust their prices up or down before they actually fill trades.  (sneaky, eh?) Depending on how much volume there is on the shares of the company you're selling, and depending on whether there are more buyers than sellers at the moment, your share sell order may be filled at market by a market maker with no real consequence to the share's price. If the block is large enough then it's possible it will not all sell to one market maker, or it might not all happen in one transaction or even all at the same price. This is a pretty complex subject, as you can see, and I've cut a LOT of corners and oversimplified much to keep it comprehensible.  But the short answer to your question is -- it depends. Hope this helps. Good luck!" Thanks for your thorough reply.   Basically, I found a case study in one of my old finance workbooks from school and am trying to complete it.   So it's not entirely complicated in the sense of a full LBO or merger model.   That being said, the information that they provide is Year 1 EBITDA for TargetCo and BuyerCo and a Pro-Forma EBITDA for the consolidated company @ Year 1 and Year 4 (expected IPO). I was able to get the Pre-Money and Post-Money values and the Liquidation values (year 4 IPO), as well as the number of shares.   I can use EBITDA to get EPS (ebitda/share in this case) for both consolidated and stand-alone @ Year 1, but can only get EPS for consolidated for all other years. Given the information provided. One of the questions I have is do I do anything with my liquidation values for an accretion/dilution analysis or is it all EPS? "If the price used to be 2.50 but by the time you get in an order it's 2.80, you're going to have to pay 2.80. You can't say, ""I want to buy it at the price from an hour ago"". If you could, everybody would wait for the price to go up, then buy at the old price and have an instant guaranteed profit. Well, except that when you tried to sell, I suppose the buyer could say, ""I want to pay the lower price from last July"". So no, you always buy or sell at the current price. If you submit an order after the markets close, your broker should buy the stock for you as soon as possible the next morning. There's no strict queue. There are thousands of brokers out there, they don't take turns. So if your broker has 1000 orders and you are number 1000 on his list, while some other broker has 2 orders and number 1 is someone else wanting to buy the same stock, then even if you got your order in first, the other guy will probably get the first buy. LIFO and FIFO refer to any sort of list or queue, but don't really make sense here. When the market opens a broker has a list of orders he received overnight, which he might think of as a queue. He presumably works his way down the list. But whether he follows a strict and simple first-in-first-out, or does biggest orders first, or does buys for stocks he expects to go up today and sells for stocks he expects to go down today first, or what, I don't know. Does anybody on this forum know, are there rules that say brokers have to go through the overnight orders FIFO, or what is the common practice?" From 26 CFR 1.1012(c)(1)i): ... if a taxpayer sells or transfers shares of stock in a corporation that the taxpayer purchased or acquired on different dates or at different prices and the taxpayer does not adequately identify the lot from which the stock is sold or transferred, the stock sold or transferred is charged against the earliest lot the taxpayer purchased or acquired to determine the basis and holding period of the stock. From 26 CFR 1.1012(c)(3): (i) Where the stock is left in the custody of a broker or other agent, an adequate identification is made if—   (a) At the time of the sale or transfer, the taxpayer specifies to such broker or other agent having custody of the stock the particular stock to be sold or transferred, and ... So if you don't specify, the first share bought (for $100) is the one sold, and you have a capital gain of $800. But you can specify to the broker if you would rather sell the stock bought later (and thus have a lower gain). This can either be done for the individual sale (no later than the settlement date of the trade), or via standing order: 26 CFR 1.1012(c)(8) ... A standing order or instruction for the specific identification of stock is treated as an adequate identification made at the time of sale, transfer, delivery, or distribution. API wise there's just one at the retail level: Interactive Brokers (India). Brokerage is high though - 3.5 bps for F&O and 5 bps for cash.  I've used Sharekhan (good, can get to 2 bps brokerage, trading client software, no API). Also used multiple other brokerages, and am advising a new one, Zerodha http://www.zerodha.com. API wise the brokers don't provide it easily to retail, though I've worked with direct access APIs at an institutional level. Interactive Brokers provides historical intraday data including Bid, Ask, Last Trade and Volume for the majority of stocks. You can chart the data, download it to Excel or use it in your own application through their API.  EDIT: Compared to other solutions (like FreeStockCharts.com for instance), Interactive Brokers provides not only historic intraday LAST**** trades **but also historic BID and ASK data, which is very useful information if you want to design your own trading system.  I have enclosed a screenshot to the chart parameter window and a link to the API description.