CHAPTER 6
Best to Better
Now we have everything ready to squeeze out additional profits from a potential profit strategy. This chapter presents two profit-and-loss reserve algorithms and a program computing the market offer. Forward!
ALGORITHM FOR THE FIRST PROFIT-AND-LOSS RESERVE STRATEGY
The natural input for building the first and second profit-and-loss (P&L) reserve strategies includes vectors of prices P and costs C, initial margin M, maintenance margin Mm, and the initial number of contracts traded U. It is simpler, however, to build both strategies assuming that a potential profit strategy Upps and its initial cash balance A0 are known in advance. The function potential_profit_min_account_alg previously described helps us get both items. Given the vectors P, C, Upps, and values A0, M, and Mm, the following steps represent the first algorithm:
- Scan Upps and find the first buy or sell action. This is the market entry point. The absolute value of this action is U. If the action is found and U ≠ 0, then go to the step 2. If no such action is found, then the first P&L reserve strategy is a “do nothing” strategy. Return the value zero and STOP.
- Depending on the sign of the first action, enter a long or short position with U contracts at the current price. Record this action in a collector, which has been initially filled by zeros, for the first P&L reserve strategy. Reduce the initial cash balance A0 by the current cost times U (the total transaction cost). Go to step 3.
- Continue ...
Get Modeling Maximum Trading Profits with C++ now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.