Options orders aren't hidden, but bid/ask quotes are there only because market makers need to post them, and they do try to get the best price for themselves while not getting screwed in case of news/events.
But they continually watch the incoming orders and compete for them. When you submit an order, there is a quick 100-millisecond auction between MMs and if your price is good enough then one of them wins, and may even give you better price than you asked. Otherwise your order becomes the best bid or ask/offer and even skews the mid. At that moment the previous "mid" doesn't matter because your order affects it and you've created a new "mid". At some point someone may simply match your price, or a market maker may fill it when they find another order or a hedge that still makes them a few bucks. Basically your order needs to be useful to someone else to get filled, and this has nothing to do with recent bid & ask. Most orders do get filled near the mid, the only question is how far from the mid.
Thursday, February 23. 2023
Mechanics of Option Trading at the MidPoint
Monday, November 29. 2021
Quantitative Finance
FinRL: Deep Reinforcement Learning Framework to Automate Trading in Quantitative Finance
Deep reinforcement learning (DRL) has been envisioned to have a competitive edge in quantitative finance. However, there is a steep development curve for quantitative traders to obtain an agent that automatically positions to win in the market, namely \textit{to decide where to trade, at what price} and \textit{what quantity}, due to the error-prone programming and arduous debugging. In this paper, we present the first open-source framework \textit{FinRL} as a full pipeline to help quantitative traders overcome the steep learning curve. FinRL is featured with simplicity, applicability and extensibility under the key principles, \textit{full-stack framework, customization, reproducibility} and \textit{hands-on tutoring}.
Embodied as a three-layer architecture with modular structures, FinRL implements fine-tuned state-of-the-art DRL algorithms and common reward functions, while alleviating the debugging workloads. Thus, we help users pipeline the strategy design at a high turnover rate. At multiple levels of time granularity, FinRL simulates various markets as training environments using historical data and live trading APIs. Being highly extensible, FinRL reserves a set of user-import interfaces and incorporates trading constraints such as market friction, market liquidity and investor's risk-aversion. Moreover, serving as practitioners' stepping stones, typical trading tasks are provided as step-by-step tutorials, e.g., stock trading, portfolio allocation, cryptocurrency trading, etc.
Friday, March 5. 2021
SLV & GLD
In fact, where is the Clifford Chance call to investigate the fact that a trading strategy of buying at the New York close silver price and selling at the New York open silver price (New York Overnight Index) would have returned 12,000% since 1970 (or 120 times), whereas a strategy of buying at the New York open and selling at the New York close (New York Intraday Index) would have lost nearly 90% of your investment since 1970.Continue reading "SLV & GLD" »
Sunday, February 28. 2021
[ZeroHedge] Crypto Carnage Continues As 'Whale Wars' Rage
And reduced the size of global negative-yielding debt (reducing the attractiveness of zero-yielding crypto)...
“The move in precious metals prices is most often in direct correlation with the direction of interest rates, particularly on sovereign interest rates, and particularly on U.S. sovereign interest rates. So, any firming in the interest rate is good for the precious metals price. Speculators need to determine whether this move higher in interest rates will continue.” - Historic Washout in Bond Market Clearly Impacts Precious Metals
Wednesday, June 13. 2018
High Frequency Trading
A look behind the scenes on high frequency trading data:
- From 2012: TradingPhysics Historical TotalView-ITCH Files - a one post blog with some examination of a post mortem order book.
- QuantInsti’s Blog on Algo Trading and Quantitative Finance
- No BS Day Trading - training materials
- Idiots Guide to High Frequency Trading - Mark Cuban, some philosophy
Sunday, July 24. 2016
trade-frame: c++ securities trading software development framework
I have been working on some C++ trading code off and on for quite some time to test various trading scenarios and strategies. And to see just how random the market really is... (it is).
Rather than keep it to my self, well probably I'll be the only one to continue to use it, but maybe there are others out there who might be able to use some of this, rather than build everything from scratch, like probably so many others have.
This software knows how to read live execution data (quotes and trades) from DTN IQFeed and from Interactive Brokers. It also knows how to submit orders to Interactive Brokers, and to tally up the results in terms of commissions, spreads, and profit analysis.
I have written a bunch of libraries, and those libraries are in use by my primary application: ComboTrading. This application will allow me to create various options combinations, track them in terms of their composite value (price and volatility wise), and initiate auto entries and exits based upon simple rule sets.
The repository is at Github: trade-frame. I use NetBeans as my IDE for development.
There are a number of libraries on which the code depends. My script, libs-build, also on Github, can be used to download and build the trading library dependencies.
Saturday, August 2. 2014
C++ Augmented Dickey Fuller Test (ADF)
In his book "Algorithmic Trading", E.P. Chan discusses some trading ideas based upon mean reversion and momentum trading styles. As part of the algorithm discussions, he refers to some statistical tests. One of the statistical tests is the Augmented Dickey Fuller Test.
That test seems easy to acquire if one is using Python, R, or many other languages. It just isn't readily available in C++. For those heavy into statistics, it is said to be easy to implement. I was hoping not to spend too much time on the implementation, so sought out some sources. The Wikipedia Entry.
One application package, Stata, has description of their dfuller test. The test statistic from this C++ library matches the Stata library based statistic when using the Box, Jenkins, and Reinsel (2008) Series G data set.
Searching didn't result in much, other than a link to a Wilmott Forum entry called VBA code to perform the Augmented Dickey Fuller? There are some links to a Korean language blog. By running Google Translate on the pages, some useful information becomes available.
The source for a functioning Augmented Dickey Fuller Unit Root Test is found in the blog. The Source refers to a third party matrix operations library called 'newmat', the source of which can be found at Newmat C++ Matrix Library. There are two versions, a v10, and a v11. The ADF code references v10, but I downloaded v11, and was able to link, build and run successfully.
There is a link to a VBA Code and Spreadsheet. The VBA code references the C++ library. But more importantly, the spreadsheet has the test values for verifying the code works. In the code, embedded are results for two lag tests, one with a value of 0, and one with a value of 3. The project matches the tests provided from the original web site.
I have assembled the NewMat library, the ADF subroutine, and the test data into a Microsoft Visual C++ 2012 Project File.
Since NewMat doesn't look to have many recent revisions, it might be wise to convert the matrix operations to maybe uBLAS from the Boost libraries.
To convert the code directly requires matrix inversion. As Boost based uBLAS doesn't offer such a function, an inversion function would have to be conjured up. Fortunately, someone else has created such an animal at C++ matrix inversion (boost::ublas). Here is the original source for the LU Matrix Inversion subroutine.
From the Boost Users List, a few suggestions are provided:
- at the beginning, check that the matrix is square
- in the case of a singular matrix, return a matrix with all values set to infinity
- check if the inverse matrix is different, and if so, resize to match the input matrix
- as a side issue, "matrix inverse to solve a linear system is probably the worst way to solve it", "high performance linear algebra where inversion is a no no"
- side comment: "LU is a factorization of the matrix not a inverse...in real life inverting the matrix is only for small examples"
- insight: "A triangular matrix has zero elements below the diagonal (upper triangular) or above the diagonal (lower triangular). This way a nonsingular triangular matrix can be inverted in straightforward manner. LU decomposition allows to produce two triangular matrices which product is your source matrix. A matrix inversion can be implemented by means of these succeeding operations"
- comment: "LU is a good method for Matrix Inverse (see Numerical Recipes). Been using it for quite a while. You can always calculate the determinant of the inverse and multiply it with the determinant of the original Matrix to determine how good the inversion is"
- comment: "For Kalman filters, ensure that the matrices are stable ie Determinants are not near zero"
- warning: "be aware of floating point limitations on your system, it will impact the max Matrix size and its stability criterion"
When using the Boost uBLAS matrix library, there are some helpful hints at Effective uBLAS. A couple of hints include: a) some typedefs for common matrix types, eg 'ublas::bounded_vector<double, 3>', and b) getting vectors to display cleanly in the Microsoft Visual Studio debugger. Continue reading "C++ Augmented Dickey Fuller Test (ADF)" »
Saturday, January 25. 2014
Portfolio Composition for Long Term Effectiveness
Evergreen/Gavekal publishes a regular newsletter regarding investments. In a recent newsletter, they describe the benefits of an actively management portfolio.
One key point is that a safer portfolio is one that may not catch all the highs of a bull run, nor does it catch all the lows of a bear run. And in the end, this is actually better for portfolio performance. The end appreciation of such a portfolio is actually better than one which follows the equity market directly.
From the newsletter, they suggest the following style of portfolio instruments and activities are considered
—and include when attractively valued—a variety of components, including but not limited to: specialized stock market investments (e.g., actively-managed, high-dividend, covered calls, long/short equity, actively-rebalanced, preferred stocks, etc.), specialized bond investments (e.g., actively-managed, convertible bonds, inflation-protected securities, principal-protected notes, etc.), alternative investments (e.g., master limited partnerships, royalty trusts, REITS, commodity funds/advisors, private equity, hedge funds, timber, etc.) , annuities, variable life, and others.
I would go one further step and explicitly state that obtaining these types of instruments in additional currencies may yield additional stability.
Saturday, December 14. 2013
ARMS Index (TRIN)
Even though High Frequency Trading seems to be all the rage amongst the big players, there still exists slower movements of the markets we smaller guys can play. For example, when trading indexes, there are some indicators available which help in selecting the time and direction of trades. Richard W. Arms, Jr. first codified this in a book called "The Arms Index", an indicator named after him.
Sunday, February 5. 2012
Inconsistent Option Naming For 'Last Trading Day' and For 'Day of Expiry'
The symbol GLD has options available to it. Option naming doesn't appear to be consistent. For example, for a 2012/02/10 expiry for a GLD put at Interactive Brokers is 'GLD 120210P00167000'. 120210 is a Friday. On the other hand, through the API, I had requested options for 20120518, and I receive in response the options I need, but they are dated 120519, which is a Saturday: 'GLD 120519P00109000'.
Is any one able to shed some light on this? Responses can be sent to ray@oneunified.net and I'll update this post with a summary of what I receive.
Friday, September 17. 2010
Percentage of Portfolio in Fixed Income
Here's a handy way to think about it: Keep your age in fixed income. If you're 65 years old, at least 65% of your portfolio ought to be in fixed income.
Keeping money in mutual funds over the last few years has probably been a bad idea for individuals reaching retirement. The better bet is to find income generating securities, for instance, stocks paying dividends. Even though the market value may decrease, income is still derived from dividents payed by the company.
Another example might be short-duration, corporate bonds that are trading at a discount to par. The iShares Corporate Bond Fund (HYG) yields about 9% for people who don't want to hold individual bonds. There are some risks to corporate bonds, but provide one of the few good ways to get a reasonable amount of income.
Saturday, August 21. 2010
The Once Very Valuable ARMS indicator
In 1989, Richard W. ARms, Jr. wrote a book called The ARMS Index (TRIN). In a nutshell, it makes use of various ratios of number of advancing and the number of declining issues. In some cases, it can (or could) be used as a leading indicator of equity market activity.
Oakshire Investment Research's Bourbon and Bayonets newsletter suggested that this may now need to be take with a grain of salt:
It could well be that the 'Hindenberg Omen' is a helpful indicator for those who compute it on a regular basis, but for our part, there are problems associated with it that make it vulnerable to an excessive number of false positives.
It's the same issue, in fact, that plagues the once very valuable ARMS indicator, and some of the McLellan indicators, both of which are reliant on a daily reading of advancing and declining issues in the market.
The problem is this: these systems were designed to work by making a computation of all the market's common stocks, but today there are so many securities that are anything but common stocks that are dressed up and packaged as such . and they comprise an ever increasing number of the total issues trading on exchanges today. That includes bond and money market ETFs, Closed End Funds (CEFs), sector ETFs and preferred shares, not to mention all the reverse ETFs and other derivative products masquerading as common stock.
So to maintain some semblance of usefulness, the calculations will need to be refactored:
In short, both high/low numbers and advance/decline figures are not what they used to be. Certainly, for those who are able to strip out the superfluous aspects and compute the indicators on the basis of common stocks alone, there's something valuable to be had. Otherwise, we wouldn't trust the data as a stand alone indicator.
Sunday, June 27. 2010
The Reformed Broker
Joshua Brown, writes as the The Reformed Broker. He has a number of interesting entries:
- The Periodic Table of Finance Bloggers, which is a list of blogs defined by categories such as Rocket Science, Rogues Gallery, The Establishment, Stock Operators, Peanut Gallery, and Baby Buffets.
Thursday, May 27. 2010
Naked Market Orders and the Market Meltdown
At Security Industry News, Tom Steinert-Threlkeld suggests that naked market orders helped escalate the 'flash crash' and subsequent recovery on May 6. I gather the market-makers, who provide liquidity through limit orders couldn't handle the deluge. And I think that we still don't know what the hair trigger was that set off the deluge of sell orders.
I learned a new lesson today. The best way of submitting market orders, in order to get the trade, is to use limit orders to create 'collars' around the price of a stock to reduce risks in trades. To go along with this, use algorithms that expressly include risk controls.
Speculation is that the naked market orders were used by the less experienced: some smaller high-frequency traders and some semi- professional traders.
Wednesday, May 26. 2010
Value Investing
When it comes time start living off dividends, it will be good to have some good value equities in the portfolio. These equities generate good dividends year and year out.
Good candidates for these types of equities are companies which are what one writer calls 'World Dominators'. These are companies which dominate their industries globally, each is Number One in its industry. They earn consistent high returns on their capital, and generate excellent cash flows year after year, through thick and thin. It is said there is one company which has raised its dividend every year for 54 years, another every year for 36 years.
With the market reaching a low, it might be good to pick up some of these companies. Some are indicated to be trading at less than 10 times free cash flow.
I think I'll generate a query through my DTN IQ live feed and look at the dividend fields and income fields to see what I can see.
As one example, one writer is suggesting NLY as a buy. It's chart may be reaching a bottom. I don't know if it satisfy the other criteria mentioned above, but I'm recording for posterity. It's close today is $16.40.