Quantitative technologies.jpg Greetings from the StockSharp team! π₯π₯ Our latest article is about the S#.Data program (better known as Hydra). In this article, we will explain (and demonstrate) the completely redesigned functionality of the program - Analytics what made our Hydra like fully quantitative analytics tool. π€ If you\u0027re already a pro at dissecting market data, feel free to watch the video below. https://youtu.be/wp_l0VBfY2o π€ However, if this is still a relatively unfamiliar area, please read this article below. π₯π₯ We\u0027ve long known that Hydra is a program for downloading historical market data from various sources (open or provided for a fee by brokers or exchanges). But now we want to explain how you can work with this data directly, without jumping into developing trading strategies just yet. So, why is this necessary? Primarily, it\u0027s to conduct quick data analysis on large volumes of data and to present the results visually. During trading, it\u0027s not always obvious whether the required conditions existed in the trading data, as historical data might suggest. In short, it\u0027s quantitative analysis tool through the Hydra program. Let\u0027s say a few words about quantitative analysis. π₯π₯ Quantitative analysis (or quantitative financial analytics) in trading is an approach that uses concepts and methods from quantitative mechanics to attempt to predict the future movements of securities and other financial instruments. This approach is mainly applied to high-frequency and short-term trading, where data analysis and decision-making occur on very short timeframes. Here are a few key elements of quantitative analysis in trading: π Securities Modeling: Quantitative traders use mathematical models and algorithms, sometimes based on quantitative mechanics, to describe and predict the behavior of securities. These models can take into account fundamental and technical factors, as well as statistical market patterns. π Big Data Analysis: Quantitative analysis requires extensive data collection and analysis of price, trading volume, and other financial parameters. With the use of powerful computing resources, traders can search for hidden patterns and signals in large volumes of information. π Machine Learning and Artificial Intelligence: Quantitative traders often employ machine learning and artificial intelligence methods to automate the decision-making process and search for optimal trading strategies. π Risk and Portfolio Management: Quantitative traders are also actively involved in risk management, using mathematical methods to assess and manage risks in their investment portfolios. π₯π₯ It\u0027s important to note that quantitative analysis in trading doesn\u0027t always guarantee profitability, and there is a risk of losing funds, just like in any other form of investment. This approach requires a high level of expertise in mathematics, programming, finance, and access to high-speed computing resources for successful strategy implementation. π₯π₯ The Hydra program allows you to work directly with downloaded data through embedded C# code. But don\u0027t be fooled. This is not a primitive script but a full-fledged language - C# - that allows you to work with a variety of mathematical and financial packages (Analytics already uses MathNet.Numerics, but you can connect other packages as well). π₯π₯ All the magic happens thanks to our advanced data access system - Storage API - which is used in all our programs, including Hydra. This provides both speed in obtaining large volumes of data and access to any type of market data (ticks, order books, candles). β‘οΈβ‘οΈ Yes, you can work with data directly through Storage API from Visual Studio. But is it convenient to install a separate program just to write a few queries to test your ideas? That\u0027s why we\u0027ve incorporated all of this into the Hydra program. β‘οΈAll the functions related to data downloading, as well as analytics, are free and available in our free plan. You can use it without any time or capability limitations. π₯π₯ Quantitative analysis in trading is a fascinating field that combines several sciences and areas, including finance, mathematics, computer science, and physics. It\u0027s a modern and innovative way of analyzing and making decisions in financial markets, allowing traders and investors to discover hidden opportunities and better understand complex market behaviors. β‘οΈβ‘οΈ However, like in any field, successfully applying quantitative analysis requires extensive knowledge, skills, and resources. Research and practice in this area can be lengthy and sometimes challenging, but it can lead to potentially high returns and better risk management. π₯π₯ We wish you an enjoyable exploration of this exciting realm of finance, and we hope that the knowledge you gain will help you develop successful trading and investment strategies. Remember that there is always a certain level of risk in the world of finance, so it\u0027s important to apply quantitative methods carefully and thoughtfully. Good luck on your journey into the world of quantitative analysis in trading! 01.png
Today, the concept of futures and options is one of the most frequently uttered in the market. Let\u0027s get acquainted with these financial instruments, give them concepts and consider the mechanism of their use. Futures and options are derivatives, and they are also called derivatives. When buying these financial instruments, the trader does not get the asset itself (stock, bond, etc.), but a contract β an opportunity to perform a purchase and sale operation in the future, at a fixed price. Simply put, a derivative is an insurance that protects the trader from possible adverse fluctuations in the price of the main asset futures-option-trading-system.jpg Little history. Initially, derivatives were created to reduce the possible risks of producers of certain assets in the form of goods. Let\u0027s look at a simple example: Company A produces flour, which is its basic asset. Today, on the conditional market, company A can purchase a contract for the sale of 10,000 tons of flour for $100, with a sales period of 3 months. In fact, after 3 months, company A can sell its flour for a fixed $100, despite the fact that the cost of flour may fall to $80. With this contract, the company predicts and fixes its income, which will be $1,000,000, and the contract is called - futures, a contract \"for the future\". There is a possibility that the cost of flour will increase to $120 per ton, and in this case, company A will receive less than $200,000, since the market value of 10,000 tons of flour will be $1200,000. The buyer of such a contract can be company B, which is engaged in the production of bread, and therefore the market price of flour is also important for it. A private trader needs derivatives in order to get a fixed price of a purchase and sale transaction, such as a stock or currency, as well as an asset that cannot be purchased by a trader, such as oil. financial-furures-contracrt.jpg Let\u0027s talk about which futures and options are the most popular in the world right now. Today, the most\" popular \" are derivatives for currency, stocks, precious metals, and oil. It is worth saying that a little more than 10 years ago, the purchase of a futures contract meant the delivery of a real asset, that is, in our case, the delivery of flour. Today, the lion\u0027s share of derivatives are non-deliverable, and on the day of the end of the contract, counterparties are paid in money. Let\u0027s look at the mechanism in our example. So by the end of the contract, company A must receive a fixed $ 1,000,000 under the terms of the futures contract, which must be paid by company B. Since their derivative is non-deliverable, at the end of the contract period, company A will not supply flour to company B. What\u0027s going on? Company A displays the tonnage of flour on the commodity exchange, with the possibility to sell it to any company, including company B. the tonnage is received at a warehouse accredited by this exchange. At the same time, company B has the opportunity to purchase its 10,000 tons set by futures from another company and receive them at another warehouse accredited by the exchange. futures-trading.jpg The price of flour may change, and may not be equal to the set price in the contract. - Let the price drop to $80 per ton. In this case, company A sells its asset at $80 per ton, receiving $800,000, and the remaining $200,000 is paid to it by company B, so in total, company A will receive $1,000,000. At the same time, company B will buy 10,000 tons of flour for $80 from another supplier, spending $800,000, and with the amount of future compensation paid to company A in the amount of $200,000, its total expense will be $1,000,000, as planned. - If the cost of flour increases to $120, in this case, the difference will be paid by company A to company B. Many novice traders have a question about the possibilities of trading options and futures in various markets, for example, stocks and bonds. The answer is Yes. However, there are restrictions related to the duration of such contracts. In our example β 3 months. If the contract was conditionally concluded in June, it ends in September. The value of a derivative always depends directly on the value of the underlying asset, and the value of both instruments tends to be equal. Because of this dependence, futures and options are called derivatives. Traders earn money using derivatives, for example, on arbitrage transactions, but at the same time derivatives do not cease to play an important role in hedging operations β insurance of transactions. Let\u0027s take a closer look at the features of both financial instruments. Let\u0027s start with futures. Futures a contract that involves the sale of the underlying asset at a fixed price, with a set delay in execution-payment. Futures fix the purchase or sale price of the underlying asset at the expiration of the term, and the market value of the asset may change. If the futures contract is non-deliverable, then only monetary payments between the parties to the contract are made on it. It is worth saying that the delivery of the asset does not necessarily have to be made on time, in other things, as well as the purchase, but in this case there is a probability of price changes, and the risk of loss of profit. Consider the mechanism for concluding a futures contract. The contract is concluded exclusively on the exchange. The seller puts his offer on the exchange with its price, volume, and due date. After a buyer appears who agrees to these terms and conditions. The seller can also choose a ready-made request from the buyer, which has a set price, volume and deadline for execution. This list of applications is always present on the exchange, and applications often differ little. Any of the participants in the transaction sees this list and chooses the most suitable one for them according to the condition. This list is called a glass and is displayed in the program that traders use. The greater the depth of the glass, the more flexible it is possible to enter into contracts, viewing more offers and as a result choosing the most suitable conditions in the case of the buyer, and at the same time more likely to conclude a contract in the case of the seller. Some trading programs allow you to set the depth of order book, for example, Terminal, where you can set your desired depth. The order book in the Terminal program is shown below. trade-terminal-system.png Obligations to execute futures are transferred to the exchange. When the date of execution of the futures contract and the conditions under which the seller will be obliged to pay remuneration (if the price of the asset has fallen), the exchange itself transfers the amount to the seller\u0027s account and withholds this amount from the buyer\u0027s account. If there is a situation that the buyer\u0027s account of the contract does not have the necessary amount, then this will be a problem that will be solved by the exchange, not the seller. The situation is the same in the opposite case if the seller must pay compensation to the buyer. The exchange carries risks, so before entering into contracts, both parties make a cash Deposit calculated according to the exchange\u0027s formula. Most often, its value can be double the size of the fluctuation of the futures price in one day. So if the price fluctuation was 3 %, then the collateral may be 6% of the price of the futures contract. The Deposit is refundable, and is returned to the account of the parties after the execution of the futures. If the participant refuses to fulfill the contract, the Deposit will be deducted from the exchange\u0027s account as compensation. Sometimes there is a need for early termination of the contract, in which case its value will be equal to the value calculated by the exchange on the day of termination. That is, the exchange calculates the price of the contract on a daily basis, while it uses its own rules for calculating the cost, but focuses on the prices that are offered on the market by bidders. As mentioned earlier, the price of the futures is slightly lower than the value of the underlying asset, but the difference is small. Sometimes there is a short-term gap that is associated with market situations, which allows you to earn using an arbitration transaction. You can also make money on futures during the day. So the exchange recalculates the price of the futures, respectively, every day, when its price increases, it charges the difference between the value of the contract and its current value, while the amount of collateral also increases. When the contract execution time comes, the price of the futures becomes equal to the market value of the asset. In General, we can say that a futures contract is a convenient financial instrument that allows you to reduce financial risks. At the same time, speculative operations with this tool are quite complex and, often, it is possible to make money on them using automated tools, such as trading robots. For example, the trading robot \"Edward\". The next financial instrument is an option. This is also a contract, but not for the amount of the sale or purchase, but for the opportunity to buy or sell the underlying asset at a fixed price at a specified time. By type of transaction options are: - Call option β an option to purchase; - Put option β a sell option. option-trade.jpg Option contracts are also traded only on the stock exchange. The participant who bought the option has the right to refuse the transaction at any time if it is not profitable for him, while the seller of the option has no right to refuse it. Thus, if the buyer uses the right of the transaction, the seller is obliged to fulfill it. This condition makes this financial instrument very difficult for an inexperienced user, and allows him to trade confidently using various trading robots or trading systems, coupled with the ability to predict possible market situations. An option can be said to be insurance against possible losses. In case of refusal, the buyer loses an amount equal to the value of the option, which is insignificant in comparison with possible losses. This amount is the seller\u0027s premium. Considered example: Trader A purchased 100 shares of Trend LLC at $10 per share. He plans to sell these shares in 2 months. Trader B offers him an option contract for the sale of 100 shares of the Trehd LLC, with a period of 2 months for the price of $15 per share. The option price is $100. Let\u0027s assume that the transaction took place, let\u0027s consider two possible scenarios: - Let\u0027s assume that the price of the Trend company\u0027s shares fell to $7 per share by the time the option was exercised. In this case, trader A will not only not lose, but also earn. $1500 (optional sale) - $1000 (initial costs) - $100 (seller\u0027s premium) = $400 -profit . - Let\u0027s assume the share price has increased to $17 per share. Thus, the trader had to waste $100 on the purchase of the option. $1700 (optional sale) - $1000 (initial costs) - $100 (seller\u0027s premium) = $600 -profit. And without the option, the profit would have been $700. An option, like a futures contract, is a non-deliverable contract. If the buyer uses the option, the seller will simply pay the difference between the current price of the asset on the market and the option price. Put-option-trading.jpg As mentioned earlier, trading on the stock exchange using options is quite complex, and a market participant needs to be able to predict situations. For call options, you must set a price that will be lower than the expected price after a set period, for a put option, on the contrary, higher than the expected price. Option prices are calculated using statistical data on fluctuations in the asset value. Many users are helped in this by various programs, trading strategies, and trading robots that calculate situations using market data. which for example can be obtained in Hydra. The one who sells the option is exposed to greater risk, its profit is the value of the option, and the loss is unlimited, as it depends on the price fluctuation. Any transactions with derivatives are associated with various risks. The task of the trader is to choose the optimal solution, including the choice of an asset, a trading platform, a strategy, and a trading robot. Manual trading does not bring the necessary income on speculative transactions, so working with trading robots makes the trader\u0027s work profitable if the conditions are chosen correctly.
Unfortunately, insurance companies do not provide traders with insurance in case of adverse price changes in the market. However, the so-called insurance mechanism exists, and is implemented through the futures exchange. This insurance mechanism is called Hedging. Hedging is an option for insuring assets against adverse price changes in the market, in which a trader buys an opportunity to buy and sell an asset (futures) in a subsequent period of time with fixed terms of the transaction. The name originates from the English hedge, which means insurance or protection. hedge.jpg Hedging uses the futures market, which reduces the risks of an adverse trend change in this market, in fact, a futures transaction is a replacement for an upcoming transaction in the cash market, while the futures position has the opposite direction of the position in the cash market, thus reducing the risk. For example: The wheat producer is confident that its future crop will bring it profit in three months. Provided that all farms get a good harvest, the price of wheat will decrease in the market. To reduce the risk β hedging the risk, the wheat producer buys a forward contract (not a standardized contract for the delivery of the underlying asset in the subsequent period, with the fixed price of the underlying asset), under which it will be able to sell 10 000 tons of grain at a price of $200 per ton. Now let\u0027s look at the possible scenarios: - Let the harvest turned out good, respectively, the price on the market sank to $150 per ton. In this case, the manufacturer executes its forward and earns: $200 x 10 000t = $2000000-that is, it remains a winner; - Let the crop was born bad, while the price rose to $250 per ton. The manufacturer performs its forward, while it receives $2000000, and its losses are $500 000. In this scenario, the buyer wins, but the manufacturer has insured itself. To avoid losing more. Hedg-trading-strategy.png When hedging, a fixed-term hedging contract is opened. at the same time, this contract itself is a financial asset, so it can be bought and sold, that is, to carry out normal transactions on the market. The asset that is insured can be any asset from your portfolio and any asset that is only expected to be purchased. The market where the possibility of operations with an asset is implemented is a spot market (transactions in such a market are made immediately, usually within two days at most). We can say that hedging contracts form a fixed-term or future market. Let\u0027s look at another example that examines the possibility of compensating losses from the sale of an asset by selling futures and Vice versa: Let the organization acquire a tanker with oil, having a desire for subsequent resale. In the current period of time, it is not able to sell oil at current market prices, however, the organization sells a futures contract for oil. In the subsequent period, the organization sells oil and buys futures. - Let\u0027s assume that the price of oil fell at the time of sale, respectively, when it is sold, the organization will suffer a loss, but the liquidation of the futures contract will give a profit that will cover the loss from the sale of the real product. - Let\u0027s assume the situation has changed, and the price of oil has started to rise, respectively, the organization will make a profit on the sale, but the purchase of futures will bring a loss, but it should be covered by the profit received. Thus, the loss is compensated in one market at the expense of profit in another, we can say this is comparable to an arbitration operation. Such operations are possible because of the close relationship between the price on the real market and the futures market. Of course, we can not say that the prices in both markets are the same, since there are differences. For this reason, it is impossible to talk about an ideal hedge, in which losses are reduced to zero, but at the same time, the importance and possibilities of hedging are fully justified when trading. Successful hedging depends on the degree of correlation of prices in the cash and futures markets, the higher the correlation, the more successful the hedging. Of course, there is a risk that changes in prices on the cash market will not be compensated by changes in prices on the futures market, which will result in a loss or profit. But this is how hedging protects the underlying risk from the greater risk caused by the insecurity of an open position in the cash market. A market participant who insures their risk is called a hedger, and the counterparty in the hedging contract may be: - hedger\u0027s partner; - other hedger (buyer or seller of the underlying asset, which also insures the risk, but in the opposite direction); - financial speculator. The hedging strategy for participants is based on a unidirectional parallel change: - current price of the underlying asset-spot prices; - a prospective \"futures\" price. Operation of the hedge opens two trades at the same time: - transactions with the underlying asset on the spot market; - transactions on the futures market of the same asset. Hedging can be of various types, let\u0027s look at what types are: By the type of instruments used in hedging: - Exchange-traded instruments (futures, options), while contracts are opened exclusively on exchanges, and transactions have a third party-a Settlement Fee that tracks the performance of obligations. All contracts are independent derivative financial assets and items of purchase/sale operations. It is worth highlighting the following positive aspects of such hedging: - security, - access to auctions, - market liquidity. The disadvantages are standardized assets, strict requirements, and various restrictions on transactions. - Over-the-counter instruments (forwards, options), while contracts are concluded outside the exchange, are one-time, do not have circulation on the market, and are not independently traded assets. Positive aspect: - Large flexibility in the choice of an asset and the terms of the contract. The disadvantages of such hedging are low liquidity with an increased risk of default, and increased transaction costs. The next type is hedging by type of counterparty. It is divided into the following types: - The buyer\u0027s hedge, in this case, the buyer\u0027s risks are insured, which are associated with a prospective increase in prices and deterioration of the transaction conditions. With such hedging, the most common operations are the purchase of forwards, futures, call options, as well as the sale of put options. - The seller\u0027s hedge, in this form, the seller\u0027s risks are insured, which arise when the asset\u0027s value potentially falls and the contract terms deteriorate. This hedging involves selling forwards, futures, and call options, as well as buying put options. Hedge by the amount of risk that must be insured, is divided into the following types: - Full hedging, in which the entire volume of the transaction is insured. - Partial hedging, in which only part of the transaction volume is insured. By the time the underlying transaction is concluded, the hedging is divided into: - Classic hedging, used with the application of a fixed-term transaction, which is concluded after the transaction with the insured asset. - Anticipatory hedging, in which a fixed-term transaction is concluded in advance before the acquisition or sale of the insured asset. Hedging by asset type is divided into: - Net hedging, in which the insurance contract is concluded for the same type of asset. - Cross-hedging, in which the hedging contract is entered into for a different type of asset than the underlying one. Hedging under the terms of the contract is divided into: - One-sided hedging, in which the possible loss from price changes in the market is fully borne by one of the participants in the transaction β the buyer or seller. - Two-way hedging, in which losses are distributed among all participants. It is worth noting that all the types of hedging analyzed allow you to choose the most optimal strategy for the implementation of the trading mechanism. Of course, it is worth saying that this type of operation is quite difficult for a beginner, and sometimes for an experienced user, it causes a large number of problems. Today, the use of this type of operations is facilitated by implementing hedging mechanisms in various trading systems and robots. For example, StockSharp has implemented an \"Hourglass\" trading robot that allows hedging using various methods and trading operations. For Designer users, the \"Hedging\" cube is implemented, which settings allow you to protect against risks in ongoing trading operations. hedge-options-futures.png In this way, building strategies is easier, and is reduced to configuring the cube and input parameters. hedge-trading-spot.png Remember that the types of hedging considered can be fully implemented using our SOFTWARE, including the implementation of these methods is considered in the course of programming training. The most important thing is to remember and not forget about the opportunities to save your profit, and hedging methods will come in handy