SlideShare a Scribd company logo
Designing Customized Hash Function For High-
         Frequency Trading Systems




              Jim Wang, PhD, CFA
         Program in Financial Engineering
          Stevens Institute of Technology
            Hoboken, NJ, 07030, USA
Introduction

                                  TC
                 Trading Engine   P     GUI

    UDPx          TC
    5             P
                 Stock Exchange


● TCP messages between U and Exchanges
● UDP messages from all market participants
Source of Latency
● Propagation latency: speed of light 5us/km,
  Mahwah – Weehawken 40km.

● Transmission latency: high speed
  communication link throughput rate 1-10
  Gbps. 1us/1kb to serialize and transport.

● Processing latency. dedicated CPU for
  critical threads, kernel bypass, hardware
  acceleration.
Processing Latency
● Parallel Problem: With 10k symbols, 6
  major exchanges, relatively
  independent, tasks be streamlined.
● Through Software optimization:
  flexibility, take advantage of general
  purpose CPU improvements over time.
● Through Hardware Acceleration:
  specialized hardware, improve
  consistency by reducing jitter.
Software Optimization
● Separation of high speed vs high
  complexity. Latency sensitive task in
  critical path, computation intensive
  tasks offload to separate
  thread/process.
● memory caching: critical decision
  thread pined to a dedicated CPU.
● inline vs function calls: C, C++, Java.
Market Data Processing
● Data using ticker symbol as key
● String of Characters translation into
  integer memory location
● MS Windows and Linux systems
  standard of hash table (associative
  array, or memory map)
● Generic implementation without
  knowledge of input
Data Specificity
● Tickers are not made of equal tick
  event probability
● BAC, ADV of 180M shares
● BAC.PRE, ADV of 18K shares
● Difference of 10K times or more
● Search miss (or Collision) in ticker BAC
  is 10K more costly than that in BAC.
  PRE
Data Specificity
Implementation: Data Structure
#define NUM_SYMBOL 10000 // total symbol universe

struct tSym {                    // define a data structure to for tick events
   char m_pszTicker[12];          // Stock Symbol
   long long key;                // key to symbol
   short nextIndex;              // next search location if there is collision
};

tSym gSym[NUM_SYMBOL];             // allocate memory for symbol universe ticks

#define HASH_TABLE_SIZE 28091 // optimal size by empirical calibration

short keyToIndex[HASH_TABLE_SIZE]; // allocate memory for hash table

inline short symbolToIndex(long long key) { // search function
    short i = keyToIndex[key % HASH_TABLE_SIZE]; // find the key
   while ((i>-1) && (gSym[i].key != key)) i = gSym[i].nextIndex; // next if collision
    return i; // either find the matching key, or symbol unknown (return -1)
}
Implementation: Initialization
Assuming you have loaded g_nSym number of known symbol in descending
order of expected tick activity gSym[j].m_pszTicker, j=0 most active stock

void buildHashTable() // This function will initialize the hash table
{
  int i, j, k; short key;
  memset(keyToIndex, -1, sizeof(short)*HASH_TABLE_SIZE); // init cell to -1
  for (j=0; j<g_nSym; j++) { // first path
      gSym[j].nextIndex = -3; // initialize to resolution unknown
      gSym[j].key = *(long long *)gSym[j].m_pszTicker; // assign key
      key = gSym[j].key % HASH_TABLE_SIZE;                   // collision possible
      if (keyToIndex[key] == -1) { keyToIndex[key] = j; gSym[j].nextIndex = -1; }
  } // terminating, do not resolve collision
  for (j=0; j<g_nSym; j++) if (gSym[j].nextIndex == -3) { // second path
      i = keyToIndex[gSym[j].key % HASH_TABLE_SIZE];
      k = -2; // find an empty slot
      while (gSym[i].nextIndex > -1) { i = gSym[i].nextIndex; k--; }
      gSym[i].nextIndex = j; gSym[j].nextIndex = k; // k number of collisions
  }
}
Implementation: Expansion
Intraday, symbol not in known universe may appear (IPO, or symbol change).

int addSymbol(char *sym)
{
   int j = g_nSym++;
   strcpy(gSym[j].m_pszTicker, sym);
   gSym[j].key = *(long long *)gSym[i].m_pszTicker;

    short key = gSym[j].key % HASH_TABLE_SIZE;
    int i = keyToIndex[key];
    if (i == -1) { keyToIndex[key] = j; gSym[j].nextIndex = -1; }
    else {
        int k = -2; // find an empty slot
        while (gSym[i].nextIndex > -1) { i = gSym[i].nextIndex; k--; }
        gSym[i].nextIndex = j;
        gSym[j].nextIndex = k; // k number of steps, so we know
    }
    return j;
}
Implementation: Example



● HUN active stock, convert to long int, mod 28091, hash table
  location 3462, return symbol location 433, match key, done
  in 1 unit of time.
● RYN medium activity, convert to long int, mod 28091, hash
  table location 3462 (collision), return symbol location 433,
  not match, next location 1811, match key, done in 2 unit of
  time
● AHL.PR low activity, convert to long int, mod 28091, hash
  table location 3462 (collision), return symbol location 433,
  not match, next location 1811, not match, next location 5363,
  match key, done in 3 unit of time.
Optimal HASH_TABLE_SIZE
  Max Collision     Costs
Optimal HASH_TABLE_SIZE
Cost<500,TotalCollision<800,MaxCollision<=4,Minimize Size
Worst HASH_TABLE_SIZE

        ● 24 active Symbols start with "ST"
        ● When convert into long long, mode by
          24576, result the same key 5203 (24
          collisions)
        ● Size divisible by 256 are worst
        ● Byte Order Encoding
           ○ Big-endian
           ○ Little-endian
        ● Padding Convension
           ○ Null padding (ARCA)
           ○ Space padding (NASDAQ)
        ● Need to calibrate own system for best
          performance

More Related Content

What's hot

Design and minimization of reversible programmable logic arrays and its reali...
Design and minimization of reversible programmable logic arrays and its reali...Design and minimization of reversible programmable logic arrays and its reali...
Design and minimization of reversible programmable logic arrays and its reali...
Sajib Mitra
 
NIR on the Mesa i965 backend (FOSDEM 2016)
NIR on the Mesa i965 backend (FOSDEM 2016)NIR on the Mesa i965 backend (FOSDEM 2016)
NIR on the Mesa i965 backend (FOSDEM 2016)
Igalia
 
Good news, everybody! Guile 2.2 performance notes (FOSDEM 2016)
Good news, everybody! Guile 2.2 performance notes (FOSDEM 2016)Good news, everybody! Guile 2.2 performance notes (FOSDEM 2016)
Good news, everybody! Guile 2.2 performance notes (FOSDEM 2016)
Igalia
 
[Paper Reading]Chucky: A Succinct Cuckoo Filter for LSM-Tree
[Paper Reading]Chucky: A Succinct Cuckoo Filter for LSM-Tree[Paper Reading]Chucky: A Succinct Cuckoo Filter for LSM-Tree
[Paper Reading]Chucky: A Succinct Cuckoo Filter for LSM-Tree
PingCAP
 
Aes cryptography algorithm based on intelligent blum blum-shub prn gs publica...
Aes cryptography algorithm based on intelligent blum blum-shub prn gs publica...Aes cryptography algorithm based on intelligent blum blum-shub prn gs publica...
Aes cryptography algorithm based on intelligent blum blum-shub prn gs publica...
zaidinvisible
 
Knit, Chisel, Hack: Building Programs in Guile Scheme (Strange Loop 2016)
Knit, Chisel, Hack: Building Programs in Guile Scheme (Strange Loop 2016)Knit, Chisel, Hack: Building Programs in Guile Scheme (Strange Loop 2016)
Knit, Chisel, Hack: Building Programs in Guile Scheme (Strange Loop 2016)
Igalia
 
Reversible logic gate
Reversible logic gateReversible logic gate
Reversible logic gate
Debraj Maji
 
Optimizing with persistent data structures (LLVM Cauldron 2016)
Optimizing with persistent data structures (LLVM Cauldron 2016)Optimizing with persistent data structures (LLVM Cauldron 2016)
Optimizing with persistent data structures (LLVM Cauldron 2016)
Igalia
 
3.4 deterministic pda
3.4 deterministic pda3.4 deterministic pda
3.4 deterministic pda
Sampath Kumar S
 
Concurrency in Go by Denys Goldiner.pdf
Concurrency in Go by Denys Goldiner.pdfConcurrency in Go by Denys Goldiner.pdf
Concurrency in Go by Denys Goldiner.pdf
Denys Goldiner
 
A NEW DESIGN TECHNIQUE OF REVERSIBLE BCD ADDER BASED ON NMOS WITH PASS TRANSI...
A NEW DESIGN TECHNIQUE OF REVERSIBLE BCD ADDER BASED ON NMOS WITH PASS TRANSI...A NEW DESIGN TECHNIQUE OF REVERSIBLE BCD ADDER BASED ON NMOS WITH PASS TRANSI...
A NEW DESIGN TECHNIQUE OF REVERSIBLE BCD ADDER BASED ON NMOS WITH PASS TRANSI...
VLSICS Design
 
Linear Cryptanalysis Lecture 線形解読法
Linear Cryptanalysis Lecture 線形解読法Linear Cryptanalysis Lecture 線形解読法
Linear Cryptanalysis Lecture 線形解読法
Kai Katsumata
 
Implementation of the Binary Multiplier on CPLD Using Reversible Logic Gates
Implementation of the Binary Multiplier on CPLD Using Reversible Logic GatesImplementation of the Binary Multiplier on CPLD Using Reversible Logic Gates
Implementation of the Binary Multiplier on CPLD Using Reversible Logic Gates
IOSRJECE
 
Code GPU with CUDA - Optimizing memory and control flow
Code GPU with CUDA - Optimizing memory and control flowCode GPU with CUDA - Optimizing memory and control flow
Code GPU with CUDA - Optimizing memory and control flow
Marina Kolpakova
 
Low cost reversible signed comparator
Low cost reversible signed comparatorLow cost reversible signed comparator
Low cost reversible signed comparator
VLSICS Design
 
Implementation and Comparison of Efficient 16-Bit SQRT CSLA Using Parity Pres...
Implementation and Comparison of Efficient 16-Bit SQRT CSLA Using Parity Pres...Implementation and Comparison of Efficient 16-Bit SQRT CSLA Using Parity Pres...
Implementation and Comparison of Efficient 16-Bit SQRT CSLA Using Parity Pres...
IJERA Editor
 
BKK16-503 Undefined Behavior and Compiler Optimizations – Why Your Program St...
BKK16-503 Undefined Behavior and Compiler Optimizations – Why Your Program St...BKK16-503 Undefined Behavior and Compiler Optimizations – Why Your Program St...
BKK16-503 Undefined Behavior and Compiler Optimizations – Why Your Program St...
Linaro
 
Boolean algebra
Boolean algebraBoolean algebra
Boolean algebra
AswiniT3
 
Tpr star tree
Tpr star treeTpr star tree
Tpr star tree
Win Yu
 
GEM - GNU C Compiler Extensions Framework
GEM - GNU C Compiler Extensions FrameworkGEM - GNU C Compiler Extensions Framework
GEM - GNU C Compiler Extensions Framework
Alexey Smirnov
 

What's hot (20)

Design and minimization of reversible programmable logic arrays and its reali...
Design and minimization of reversible programmable logic arrays and its reali...Design and minimization of reversible programmable logic arrays and its reali...
Design and minimization of reversible programmable logic arrays and its reali...
 
NIR on the Mesa i965 backend (FOSDEM 2016)
NIR on the Mesa i965 backend (FOSDEM 2016)NIR on the Mesa i965 backend (FOSDEM 2016)
NIR on the Mesa i965 backend (FOSDEM 2016)
 
Good news, everybody! Guile 2.2 performance notes (FOSDEM 2016)
Good news, everybody! Guile 2.2 performance notes (FOSDEM 2016)Good news, everybody! Guile 2.2 performance notes (FOSDEM 2016)
Good news, everybody! Guile 2.2 performance notes (FOSDEM 2016)
 
[Paper Reading]Chucky: A Succinct Cuckoo Filter for LSM-Tree
[Paper Reading]Chucky: A Succinct Cuckoo Filter for LSM-Tree[Paper Reading]Chucky: A Succinct Cuckoo Filter for LSM-Tree
[Paper Reading]Chucky: A Succinct Cuckoo Filter for LSM-Tree
 
Aes cryptography algorithm based on intelligent blum blum-shub prn gs publica...
Aes cryptography algorithm based on intelligent blum blum-shub prn gs publica...Aes cryptography algorithm based on intelligent blum blum-shub prn gs publica...
Aes cryptography algorithm based on intelligent blum blum-shub prn gs publica...
 
Knit, Chisel, Hack: Building Programs in Guile Scheme (Strange Loop 2016)
Knit, Chisel, Hack: Building Programs in Guile Scheme (Strange Loop 2016)Knit, Chisel, Hack: Building Programs in Guile Scheme (Strange Loop 2016)
Knit, Chisel, Hack: Building Programs in Guile Scheme (Strange Loop 2016)
 
Reversible logic gate
Reversible logic gateReversible logic gate
Reversible logic gate
 
Optimizing with persistent data structures (LLVM Cauldron 2016)
Optimizing with persistent data structures (LLVM Cauldron 2016)Optimizing with persistent data structures (LLVM Cauldron 2016)
Optimizing with persistent data structures (LLVM Cauldron 2016)
 
3.4 deterministic pda
3.4 deterministic pda3.4 deterministic pda
3.4 deterministic pda
 
Concurrency in Go by Denys Goldiner.pdf
Concurrency in Go by Denys Goldiner.pdfConcurrency in Go by Denys Goldiner.pdf
Concurrency in Go by Denys Goldiner.pdf
 
A NEW DESIGN TECHNIQUE OF REVERSIBLE BCD ADDER BASED ON NMOS WITH PASS TRANSI...
A NEW DESIGN TECHNIQUE OF REVERSIBLE BCD ADDER BASED ON NMOS WITH PASS TRANSI...A NEW DESIGN TECHNIQUE OF REVERSIBLE BCD ADDER BASED ON NMOS WITH PASS TRANSI...
A NEW DESIGN TECHNIQUE OF REVERSIBLE BCD ADDER BASED ON NMOS WITH PASS TRANSI...
 
Linear Cryptanalysis Lecture 線形解読法
Linear Cryptanalysis Lecture 線形解読法Linear Cryptanalysis Lecture 線形解読法
Linear Cryptanalysis Lecture 線形解読法
 
Implementation of the Binary Multiplier on CPLD Using Reversible Logic Gates
Implementation of the Binary Multiplier on CPLD Using Reversible Logic GatesImplementation of the Binary Multiplier on CPLD Using Reversible Logic Gates
Implementation of the Binary Multiplier on CPLD Using Reversible Logic Gates
 
Code GPU with CUDA - Optimizing memory and control flow
Code GPU with CUDA - Optimizing memory and control flowCode GPU with CUDA - Optimizing memory and control flow
Code GPU with CUDA - Optimizing memory and control flow
 
Low cost reversible signed comparator
Low cost reversible signed comparatorLow cost reversible signed comparator
Low cost reversible signed comparator
 
Implementation and Comparison of Efficient 16-Bit SQRT CSLA Using Parity Pres...
Implementation and Comparison of Efficient 16-Bit SQRT CSLA Using Parity Pres...Implementation and Comparison of Efficient 16-Bit SQRT CSLA Using Parity Pres...
Implementation and Comparison of Efficient 16-Bit SQRT CSLA Using Parity Pres...
 
BKK16-503 Undefined Behavior and Compiler Optimizations – Why Your Program St...
BKK16-503 Undefined Behavior and Compiler Optimizations – Why Your Program St...BKK16-503 Undefined Behavior and Compiler Optimizations – Why Your Program St...
BKK16-503 Undefined Behavior and Compiler Optimizations – Why Your Program St...
 
Boolean algebra
Boolean algebraBoolean algebra
Boolean algebra
 
Tpr star tree
Tpr star treeTpr star tree
Tpr star tree
 
GEM - GNU C Compiler Extensions Framework
GEM - GNU C Compiler Extensions FrameworkGEM - GNU C Compiler Extensions Framework
GEM - GNU C Compiler Extensions Framework
 

Similar to Stevens 3rd Annual Conference Hfc2011

Js2517181724
Js2517181724Js2517181724
Js2517181724
IJERA Editor
 
Js2517181724
Js2517181724Js2517181724
Js2517181724
IJERA Editor
 
Programar para GPUs
Programar para GPUsProgramar para GPUs
Programar para GPUs
Alcides Fonseca
 
Reduction
ReductionReduction
Reduction
Wei Shen
 
GBM in H2O with Cliff Click: H2O API
GBM in H2O with Cliff Click: H2O APIGBM in H2O with Cliff Click: H2O API
GBM in H2O with Cliff Click: H2O API
Sri Ambati
 
DConf 2016: Keynote by Walter Bright
DConf 2016: Keynote by Walter Bright DConf 2016: Keynote by Walter Bright
DConf 2016: Keynote by Walter Bright
Andrei Alexandrescu
 
lecture16-recap-questions-and-answers.pdf
lecture16-recap-questions-and-answers.pdflecture16-recap-questions-and-answers.pdf
lecture16-recap-questions-and-answers.pdf
AyushKumar93531
 
What’s new in 9.6, by PostgreSQL contributor
What’s new in 9.6, by PostgreSQL contributorWhat’s new in 9.6, by PostgreSQL contributor
What’s new in 9.6, by PostgreSQL contributor
Masahiko Sawada
 
Beyond Breakpoints: A Tour of Dynamic Analysis
Beyond Breakpoints: A Tour of Dynamic AnalysisBeyond Breakpoints: A Tour of Dynamic Analysis
Beyond Breakpoints: A Tour of Dynamic Analysis
Fastly
 
Parallel Implementation of K Means Clustering on CUDA
Parallel Implementation of K Means Clustering on CUDAParallel Implementation of K Means Clustering on CUDA
Parallel Implementation of K Means Clustering on CUDA
prithan
 
Keccak
KeccakKeccak
Keccak
Rajeev Verma
 
Optimizing InfluxDB Performance in the Real World by Dean Sheehan, Senior Dir...
Optimizing InfluxDB Performance in the Real World by Dean Sheehan, Senior Dir...Optimizing InfluxDB Performance in the Real World by Dean Sheehan, Senior Dir...
Optimizing InfluxDB Performance in the Real World by Dean Sheehan, Senior Dir...
InfluxData
 
Exploring Compiler Optimization Opportunities for the OpenMP 4.x Accelerator...
Exploring Compiler Optimization Opportunities for the OpenMP 4.x Accelerator...Exploring Compiler Optimization Opportunities for the OpenMP 4.x Accelerator...
Exploring Compiler Optimization Opportunities for the OpenMP 4.x Accelerator...
Akihiro Hayashi
 
1530-shrivastava
1530-shrivastava1530-shrivastava
1530-shrivastava
Saurabh Shrivastava
 
Introduction to CUDA
Introduction to CUDAIntroduction to CUDA
Introduction to CUDA
Raymond Tay
 
Webinar Slides: Migrating to Galera Cluster
Webinar Slides: Migrating to Galera ClusterWebinar Slides: Migrating to Galera Cluster
Webinar Slides: Migrating to Galera Cluster
Severalnines
 
A taste of GlobalISel
A taste of GlobalISelA taste of GlobalISel
A taste of GlobalISel
Igalia
 
Osol Pgsql
Osol PgsqlOsol Pgsql
Osol Pgsql
Emanuel Calvo
 
Exploring Parallel Merging In GPU Based Systems Using CUDA C.
Exploring Parallel Merging In GPU Based Systems Using CUDA C.Exploring Parallel Merging In GPU Based Systems Using CUDA C.
Exploring Parallel Merging In GPU Based Systems Using CUDA C.
Rakib Hossain
 
LDPC Encoding
LDPC EncodingLDPC Encoding
LDPC Encoding
Bhagwat Singh Rathore
 

Similar to Stevens 3rd Annual Conference Hfc2011 (20)

Js2517181724
Js2517181724Js2517181724
Js2517181724
 
Js2517181724
Js2517181724Js2517181724
Js2517181724
 
Programar para GPUs
Programar para GPUsProgramar para GPUs
Programar para GPUs
 
Reduction
ReductionReduction
Reduction
 
GBM in H2O with Cliff Click: H2O API
GBM in H2O with Cliff Click: H2O APIGBM in H2O with Cliff Click: H2O API
GBM in H2O with Cliff Click: H2O API
 
DConf 2016: Keynote by Walter Bright
DConf 2016: Keynote by Walter Bright DConf 2016: Keynote by Walter Bright
DConf 2016: Keynote by Walter Bright
 
lecture16-recap-questions-and-answers.pdf
lecture16-recap-questions-and-answers.pdflecture16-recap-questions-and-answers.pdf
lecture16-recap-questions-and-answers.pdf
 
What’s new in 9.6, by PostgreSQL contributor
What’s new in 9.6, by PostgreSQL contributorWhat’s new in 9.6, by PostgreSQL contributor
What’s new in 9.6, by PostgreSQL contributor
 
Beyond Breakpoints: A Tour of Dynamic Analysis
Beyond Breakpoints: A Tour of Dynamic AnalysisBeyond Breakpoints: A Tour of Dynamic Analysis
Beyond Breakpoints: A Tour of Dynamic Analysis
 
Parallel Implementation of K Means Clustering on CUDA
Parallel Implementation of K Means Clustering on CUDAParallel Implementation of K Means Clustering on CUDA
Parallel Implementation of K Means Clustering on CUDA
 
Keccak
KeccakKeccak
Keccak
 
Optimizing InfluxDB Performance in the Real World by Dean Sheehan, Senior Dir...
Optimizing InfluxDB Performance in the Real World by Dean Sheehan, Senior Dir...Optimizing InfluxDB Performance in the Real World by Dean Sheehan, Senior Dir...
Optimizing InfluxDB Performance in the Real World by Dean Sheehan, Senior Dir...
 
Exploring Compiler Optimization Opportunities for the OpenMP 4.x Accelerator...
Exploring Compiler Optimization Opportunities for the OpenMP 4.x Accelerator...Exploring Compiler Optimization Opportunities for the OpenMP 4.x Accelerator...
Exploring Compiler Optimization Opportunities for the OpenMP 4.x Accelerator...
 
1530-shrivastava
1530-shrivastava1530-shrivastava
1530-shrivastava
 
Introduction to CUDA
Introduction to CUDAIntroduction to CUDA
Introduction to CUDA
 
Webinar Slides: Migrating to Galera Cluster
Webinar Slides: Migrating to Galera ClusterWebinar Slides: Migrating to Galera Cluster
Webinar Slides: Migrating to Galera Cluster
 
A taste of GlobalISel
A taste of GlobalISelA taste of GlobalISel
A taste of GlobalISel
 
Osol Pgsql
Osol PgsqlOsol Pgsql
Osol Pgsql
 
Exploring Parallel Merging In GPU Based Systems Using CUDA C.
Exploring Parallel Merging In GPU Based Systems Using CUDA C.Exploring Parallel Merging In GPU Based Systems Using CUDA C.
Exploring Parallel Merging In GPU Based Systems Using CUDA C.
 
LDPC Encoding
LDPC EncodingLDPC Encoding
LDPC Encoding
 

Recently uploaded

GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
kumardaparthi1024
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
tolgahangng
 
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Tatiana Kojar
 
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - HiikeSystem Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
Hiike
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
Tomaz Bratanic
 
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptxOcean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
SitimaJohn
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Safe Software
 
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing InstancesEnergy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Alpen-Adria-Universität
 
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
alexjohnson7307
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
DanBrown980551
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
Ivanti
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
Pixlogix Infotech
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
Jakub Marek
 
Recommendation System using RAG Architecture
Recommendation System using RAG ArchitectureRecommendation System using RAG Architecture
Recommendation System using RAG Architecture
fredae14
 
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Jeffrey Haguewood
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
Nunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdf
Nunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdfNunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdf
Nunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdf
flufftailshop
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
Chart Kalyan
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 

Recently uploaded (20)

GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
 
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
 
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - HiikeSystem Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
 
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptxOcean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
 
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing InstancesEnergy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
 
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
 
Recommendation System using RAG Architecture
Recommendation System using RAG ArchitectureRecommendation System using RAG Architecture
Recommendation System using RAG Architecture
 
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
Nunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdf
Nunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdfNunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdf
Nunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdf
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 

Stevens 3rd Annual Conference Hfc2011

  • 1. Designing Customized Hash Function For High- Frequency Trading Systems Jim Wang, PhD, CFA Program in Financial Engineering Stevens Institute of Technology Hoboken, NJ, 07030, USA
  • 2. Introduction TC Trading Engine P GUI UDPx TC 5 P Stock Exchange ● TCP messages between U and Exchanges ● UDP messages from all market participants
  • 3. Source of Latency ● Propagation latency: speed of light 5us/km, Mahwah – Weehawken 40km. ● Transmission latency: high speed communication link throughput rate 1-10 Gbps. 1us/1kb to serialize and transport. ● Processing latency. dedicated CPU for critical threads, kernel bypass, hardware acceleration.
  • 4. Processing Latency ● Parallel Problem: With 10k symbols, 6 major exchanges, relatively independent, tasks be streamlined. ● Through Software optimization: flexibility, take advantage of general purpose CPU improvements over time. ● Through Hardware Acceleration: specialized hardware, improve consistency by reducing jitter.
  • 5. Software Optimization ● Separation of high speed vs high complexity. Latency sensitive task in critical path, computation intensive tasks offload to separate thread/process. ● memory caching: critical decision thread pined to a dedicated CPU. ● inline vs function calls: C, C++, Java.
  • 6. Market Data Processing ● Data using ticker symbol as key ● String of Characters translation into integer memory location ● MS Windows and Linux systems standard of hash table (associative array, or memory map) ● Generic implementation without knowledge of input
  • 7. Data Specificity ● Tickers are not made of equal tick event probability ● BAC, ADV of 180M shares ● BAC.PRE, ADV of 18K shares ● Difference of 10K times or more ● Search miss (or Collision) in ticker BAC is 10K more costly than that in BAC. PRE
  • 9. Implementation: Data Structure #define NUM_SYMBOL 10000 // total symbol universe struct tSym { // define a data structure to for tick events char m_pszTicker[12]; // Stock Symbol long long key; // key to symbol short nextIndex; // next search location if there is collision }; tSym gSym[NUM_SYMBOL]; // allocate memory for symbol universe ticks #define HASH_TABLE_SIZE 28091 // optimal size by empirical calibration short keyToIndex[HASH_TABLE_SIZE]; // allocate memory for hash table inline short symbolToIndex(long long key) { // search function short i = keyToIndex[key % HASH_TABLE_SIZE]; // find the key while ((i>-1) && (gSym[i].key != key)) i = gSym[i].nextIndex; // next if collision return i; // either find the matching key, or symbol unknown (return -1) }
  • 10. Implementation: Initialization Assuming you have loaded g_nSym number of known symbol in descending order of expected tick activity gSym[j].m_pszTicker, j=0 most active stock void buildHashTable() // This function will initialize the hash table { int i, j, k; short key; memset(keyToIndex, -1, sizeof(short)*HASH_TABLE_SIZE); // init cell to -1 for (j=0; j<g_nSym; j++) { // first path gSym[j].nextIndex = -3; // initialize to resolution unknown gSym[j].key = *(long long *)gSym[j].m_pszTicker; // assign key key = gSym[j].key % HASH_TABLE_SIZE; // collision possible if (keyToIndex[key] == -1) { keyToIndex[key] = j; gSym[j].nextIndex = -1; } } // terminating, do not resolve collision for (j=0; j<g_nSym; j++) if (gSym[j].nextIndex == -3) { // second path i = keyToIndex[gSym[j].key % HASH_TABLE_SIZE]; k = -2; // find an empty slot while (gSym[i].nextIndex > -1) { i = gSym[i].nextIndex; k--; } gSym[i].nextIndex = j; gSym[j].nextIndex = k; // k number of collisions } }
  • 11. Implementation: Expansion Intraday, symbol not in known universe may appear (IPO, or symbol change). int addSymbol(char *sym) { int j = g_nSym++; strcpy(gSym[j].m_pszTicker, sym); gSym[j].key = *(long long *)gSym[i].m_pszTicker; short key = gSym[j].key % HASH_TABLE_SIZE; int i = keyToIndex[key]; if (i == -1) { keyToIndex[key] = j; gSym[j].nextIndex = -1; } else { int k = -2; // find an empty slot while (gSym[i].nextIndex > -1) { i = gSym[i].nextIndex; k--; } gSym[i].nextIndex = j; gSym[j].nextIndex = k; // k number of steps, so we know } return j; }
  • 12. Implementation: Example ● HUN active stock, convert to long int, mod 28091, hash table location 3462, return symbol location 433, match key, done in 1 unit of time. ● RYN medium activity, convert to long int, mod 28091, hash table location 3462 (collision), return symbol location 433, not match, next location 1811, match key, done in 2 unit of time ● AHL.PR low activity, convert to long int, mod 28091, hash table location 3462 (collision), return symbol location 433, not match, next location 1811, not match, next location 5363, match key, done in 3 unit of time.
  • 13. Optimal HASH_TABLE_SIZE Max Collision Costs
  • 15. Worst HASH_TABLE_SIZE ● 24 active Symbols start with "ST" ● When convert into long long, mode by 24576, result the same key 5203 (24 collisions) ● Size divisible by 256 are worst ● Byte Order Encoding ○ Big-endian ○ Little-endian ● Padding Convension ○ Null padding (ARCA) ○ Space padding (NASDAQ) ● Need to calibrate own system for best performance