top of page

Get auto trading tips and tricks from our experts. Join our newsletter now

Thanks for submitting!

Writer's pictureBryan Downing

High Frequency Trading with Pure C: Examining the Viability and Challenges

 

High-frequency trading (HFT) is a fast-paced domain where algorithms execute trades at lightning speed, capitalizing on minuscule market inefficiencies. While C++ reigns supreme in this arena, Bryan Downing's video explores the viability of using C, the granddaddy of many programming languages, for building HFT systems. This article delves into the video's insights, analyzing the pros and cons of C for HFT and exploring the key concepts covered.




hft with pure c

The discussion starts with a viewer's query: does relying solely on C for a statistical arbitrage engine in HFT hinder the use of hardware accelerators like FPGAs? Brian counters by asserting that C, although less popular than C++ in HFT, remains a viable option. He emphasizes C's foundational role, highlighting the fact that C++ itself is built upon C's core principles. To illustrate C's capabilities, Brian embarks on a journey through the well-regarded book "The C Programming Language" by Brian Kernighan and Dennis Ritchie.


The video then dives into the heart of C, introducing fundamental concepts crucial for building HFT applications. These include:


  • Variables and Basic Arithmetic: C provides the groundwork for defining and manipulating data using variables, along with performing basic mathematical operations.

  • For Loops: These loops allow for the efficient execution of a block of code multiple times, a cornerstone of algorithmic trading.

  • Input/Output: While C offers basic input/output functionalities like printf and scanf, Brian acknowledges their limitations, particularly for complex tasks.

  • File Handling: C empowers you to interact with files, enabling features like copying files and performing character, line, and word counts – valuable tools for data manipulation.

  • Functions, Arguments, and Data Types: Functions are the building blocks of modular programming, allowing for code reusability. Arguments passed to functions provide flexibility, while data types ensure data integrity.

  • Control Flow Statements: C offers a rich set of control flow statements like if-else, switch, while, for, and do-while, enabling algorithmic decision making and iteration.

  • Bitwise Operators and Expressions: These operators manipulate data at the bit level, offering fine-grained control for performance-critical sections.

  • Recursion: This powerful technique allows functions to call themselves, potentially leading to concise and elegant code.

  • C Pre-processing: C's pre-processing directives enable tasks like file inclusion, macro substitution (replacing text with values), and conditional compilation (including or excluding code sections based on conditions).

  • Pointers and Memory Management: Pointers are variables that store memory addresses, granting direct access to memory. However, Brian highlights the complexities associated with manual memory management in C, which can lead to memory leaks and security vulnerabilities if not handled meticulously.

  • Structures and Bit Fields: Structures group related variables under a single name, promoting data organization. Bit fields further optimize memory usage by packing data into smaller bit-sized units.


While C offers a robust foundation for building software, Brian acknowledges its limitations. Input/output operations, as mentioned earlier, can be cumbersome in C compared to more modern languages. Mathematical functions are also relatively basic, often requiring programmers to implement them from scratch.


However, C shines in its proximity to the underlying operating system, particularly Unix-based systems like Linux (which was written in C). This closeness translates to efficient utilization of system resources, a significant advantage in the latency-sensitive world of HFT.

In conclusion, the video argues that C remains a viable option for HFT, despite C++'s dominance. C's strengths lie in its low-level control and efficiency. However, programmers must navigate its complexities, particularly around memory management and limited built-in functionalities. The decision between C and C++ ultimately depends on the specific needs of the HFT system and the developer's comfort level with each language.


Additional Considerations:


The video doesn't delve into the specifics of building statistical arbitrage engines using C. Further research into libraries and frameworks specifically designed for HFT in C would be beneficial.


While the video highlights C's efficiency, it's important to remember that modern HFT systems often leverage a combination of languages, potentially including C for performance-critical sections and higher-level languages for development and maintenance.


This article provides a starting point for understanding the potential and challenges of using C for HFT. For those interested in venturing into this domain, a thorough understanding of C programming principles and best practices is essential.

 

 

Video Summary:


This video is about high frequency trading (HFT) using pure C. The speaker, Brian Downing, discusses the pros and cons of using C for HFT and whether it is a good idea to avoid C++.

The video starts with a question from a viewer about whether using pure C and statistical arbitrage engine for HFT will restrict someone from using FPGA or similar hardware accelerators. Brian argues that while C++ is more popular for HFT, C can also be used. He mentions that C is the foundation of many languages, including C++. Then, he dives into the world of C by going through a classic book, "The C Programming Language" by Brian Kernighan and Dennis Ritchie.


Key concepts of C covered in the video include:


  • Variables and basic arithmetic

  • For loops

  • Input and output

  • File copying, character counting, line counting, and word counting

  • Functions, arguments, and data types

  • Control flow (if-else, switch, while, for, do-while)

  • Bitwise operators, assignment, conditional expressions, and order of evaluation

  • Recursion

  • C pre-processing (file inclusion, macro substitution, conditional compilation)

  • Pointers and memory management

  • Structures and bit fields


Brian mentions that C can get limited very quickly, especially for input/output. He covers basic input/output functions like printf and scanf. Mathematical functions are also very basic in C, and a lot of them都需要 (dū xū yao) (need to be) written from scratch.


One advantage of C is that it is very close to the underlying operating system, especially Unix-based systems. Brian mentions that Linux was written in C. This makes C very efficient for utilizing the resources of the operating system.


Overall, the video argues that while C++ is more popular for HFT, C can also be used. However, C can be more challenging to work with due to its limitations in areas like input/output and mathematical functions.





 

31 views0 comments

ความคิดเห็น


bottom of page