Repository navigation
Modern Finance MaxDrawdown
Paul Squires edited this page Oct 19, 2026
·
4 revisions
Home › Finance › Finance › MaxDrawdown
Returns the worst fall from a peak to a later low, as a positive fraction.
MaxDrawdown( periodReturns( ) )#import "std/money"
using money
'' The worst peak-to-trough fall, as a POSITIVE magnitude.
dim as float64 r( 0 to 11 ) = { 0.02, -0.01, 0.03, 0.015, -0.025, 0.04, _
0.01, -0.005, 0.02, 0.03, -0.015, 0.025 }
dim as float64 b( 0 to 11 ) = { 0.018, -0.012, 0.025, 0.012, -0.02, 0.035, _
0.008, -0.004, 0.018, 0.028, -0.012, 0.022 }
print MaxDrawdown( r( ) ).Value( ) '' 0.02500000000000009
'' A series that only ever rose returns exactly zero -- and POSITIVE
'' zero, because a drawdown printing as -0 reads as a defect.
dim as float64 up_( 0 to 3 ) = { 0.01, 0.02, 0.01, 0.03 }
print MaxDrawdown( up_( ) ).Value( ) '' 0
'' A monotonic decline draws down to the whole compounded loss.
dim as float64 down_( 0 to 2 ) = { -0.1, -0.1, -0.1 }
print MaxDrawdown( down_( ) ).Value( ) '' 0.2709999999999999Library: Finance
Category: Finance
Documented under: Nothing Becomes A Keyword
Source: pkg/std/money/finport.tiko in the tiko repository.
tiko-lang · Home · Feature Index · Keyword Index · License
FreeBASIC manual pages reproduced under the GNU FDL 1.3.
- Generics
- Interfaces
- For Each
- Iterators
- Tuples
- Array Results
- Defer
- Lambdas
- Block Strings
- String Slices
- Embed
- Typed Variadics
- C Header Import
- Foreign Library Linking
- UString
- Fixed-Width Types
- Nullptr
- String Library
- Format
- Array
- Map
- Set
- LinkedList
- OrderedMap
- OrderedSet
- Sorting
- Optional
- Result
- Smart Pointers
- Date and Time (Chrono)
- Filesystem
- File Streams
- Config (INI and TOML)
- Codec
- Hash
- UUID
- OS
- Process
- Net
- HTTP and TLS
- Math Library
- Finance
- Logging
- Terminal TUI Library
- PsControls
- tkControls
- sys/win
- Goroutines and Channels
- LLVM Backend
- tiko build
- TIKO_COMPILER
- Variable Declarations
- Standard Data Types
- User Defined Types
- Procedures
- Operators
- Control Flow Statements
- Converting Data Types
- Array Functions
- String Functions
- Mathematical Functions
- Bit Manipulation
- Date and Time Functions
- File I/O Functions
- Console Functions
- User Input (Runtime Library)
- User Input Functions (Graphics Library)
- Screen Functions
- 2D Drawing Functions
- Graphics Library Reference
- Graphics Keyword List
- Memory Functions
- Threading Support Functions
- Error Handling Functions
- Operating System Functions
- Preprocessor
- Intrinsic Defines
- Miscellaneous Keywords
- Modularizing