SlideShare uma empresa Scribd logo
1 de 34
Solutions from
OneTick and R
  Portfolio & Risk Analytics
  Business Cases


  Maria Belianina, Ph.D.
  Director, Pre-Sales Engineering Support
Contents
 Data Management & Requirements
 for Portfolio & Risk Analytics
 R and OneTick: Addressing the challenges
   What is OneTick
   R ↔ OneTick integration: Two available methods
 Examples
   Option pricing with OneTick and R RQuantLib functions
   OneTick Value-At-Risk calculations      back to R
   OneTick Portfolio Pricing   back to R
Portfolio & Risk Analytics

Data Requirements & Challenges:
 Increasing data granularity        Increasing data volumes
  Daily to continuous intraday      Reference data (corporate
  Milli → Micro → Nano →             actions, name
   Picoseconds…                       changes, continuous
                                      contracts, etc)
 Data cleansing challenges
                                     Access to both High
 Complexity of data and              (e.g., Price) and Low
  data consolidation                  (e.g., Volatility) frequency
  Consolidation across product       data
   types                             Security master
  Access to complex calculations     maintenance
                                 Database schema changes
        … vs Consolidated Risk and Portfolio Analysis
R AND ONETICK:
ADDRESSING THE CHALLENGES
What is OneTick: Business Cases

Our clients:                  Business Cases:

 Hedge Funds & Proprietary    Backtesting & Quantitative
  Trading Firms                 Research

 Large Asset Managers         High frequency trading signal
                                generation
 Banks / Brokers              Pre- & Post- Trade TCA
 Marketplaces                 Backbone for
 Technology & Information      Charting / Time and Sales
  Providers                    Compliance & Regulatory
                                Reporting
                               Risk & Portfolio Analytics
What is OneTick: Overview
                                                          About data model:
                                                          -   Time series with customizable &
                                                              flexible schema for any asset type
    Real-Time              OneTick Servers
     Feeds                                                -   High and Low frequency
                           -   Data collectors
-     Consolidated         -   In-memory intraday
                                                          -   Reference data support (corp
      (Reuters, Bloom                                         actions, continuous contracts,
                               tick database[s]
      berg, etc)                                              symbology, calendars, etc.)
-     Exchanges            -   Historical archives
-     Custom feeds             (file                      About analytics:
                               based, unlimited, dist     -   Time series generic functions:
    Historical                 ributed)                       Aggregation, filtering, signal
      Data                 -   Analytical Engine              generation, calculated fields, etc.
                               for                        -   Time sensitive Joins & Merges
                               Historical, Intraday           across symbols, databases and
-     Ascii
                               and CEP real-time              tick types
-     Proprietary binary
-     ODBC source              queries. Extendable        -   Finance functions (order book
-     3rd party (NYSE          via:                           snapshots and consolidation,
      TAQ, CME, etc)           R, C++, C#, Java, Pe           statistics, pricing, portfolios)
                               rl & Python
         Real-time Out-of-box           Batch Out-of-box or
         or custom API                  custom API
What is OneTick: Client Side
                                                              End Users & Client Apps:
                                                                 OneTick GUI
    Real-Time              OneTick Servers                       Design & debug
     Feeds                 -   Data collectors                   queries, view results, tune
-     Consolidated                                               performance
                           -   In-memory intraday
      (Reuters, Bloom
                               tick database[s]
      berg, etc)                                                 OneTick API
-     Exchanges            -   Historical archives               C++, C#, Java, Perl, Pyt
-     Custom feeds             (file                             hon
                               based, unlimited, dist
    Historical                 ributed)                          R
      Data                 -   Analytical Engine
                               for                               MatLab
-     Ascii                    Historical, Intraday
                               and CEP real-time                  Excel
-     Proprietary binary
-     ODBC source              queries. Extendable                ODBC clients
-     3rd party (NYSE          via:
      TAQ, CME, etc)           R, C++, C#, Java, Pe               Command Line Utility
                               rl & Python
         Real-time Out-of-box           Batch Out-of-box or           TCP/IP Real-time
         or custom API                  custom API                    or on-demand
What is OneTick: GUI Analytics
Query Example:
Bollinger Bands
Buy/Sell Signals

                                    A “Nested
                                    query” for
                                     Bollinger
                                       Bands
                                    calculations




                   NOTE: One of the nodes can
                   be an R Event Processor
                   calling R functions
What is OneTick:
 Analytics + Financial Reference Data
Reference data can be* mixed with analytics:
  Symbol Name History
                                      * Note:
   Name changes
   Continuous contracts              Market data is stored
                                              “as is”
   Symbology Mapping
    across databases                  Reference data is stored
    (e.g., CUSIP to SEDOL)            separately and
  Corporate Actions                  can be applied as needed
   Splits, dividends, etc
  Continuous Contracts
   E.g. query “ES**” futures as one contract: “ES”
  Currency Conversion
   With monthly, daily or intraday exchange rates
  Market, Exchange & Symbol Calendars
What is OneTick: GUI Analytics + R
Query
Example:
using R
functions




                       Create running (a.k.a. sliding)
                        aggregation of 32 ticks
                       Call R function acf(…)
                        for each sliding group
                       Pass values of MID and LAG
                        from tick fields or query parameters




                             Process the results of
                              R function output
System Integration: OneTick and R
                 OneTick allows to:                          R allows to:
If YOU    Store compressed fast access data       Retrieve OneTick query output
work in   Pre-process data:                        in R code via ODBC/OneTick SQL:
R:         Normalize and clean                    • Call tested OneTick query
           Apply reference data                   • Pass parameters
           Aggregate, intervalize, filter         • Process results in R as usual
           JOIN/MERGE trades vs order             TIP: Limit amount of data
            books, news, weather reports, etc.     processed within ODBC and R
           Set query parameters                   aggregating & filtering data in
                                                   OneTick query
If YOU     [Above] + Call any number of          Map OneTick fields to R input
work in   OneTick or R functions                     • R scalar types or matrices
OneTick  Call separate R functions for a         Load required R libraries
GUI:      bucket entry or exit events             Specify R code to apply
         Run historical or CEP queries           Specify OneTick aggregation
         View query results via GUI or API        parameters
                                                  Map R output back to OneTick
                                                   fields for further OneTick processing


              TIP: Take full advantage of both packages.
Example 1:
OPTION PRICING IN ONETICK
WITH OR WITHOUT R FUNCTIONS
Example: Option Pricing in OneTick/R

                           Sample Business Case
I.      Input:
       a.   OneTick archive or real-time market data for
            American equity options and underlying equities (optional)
       b.   Additional calculation parameters (e.g., underlyer volatility and
            interest rates) can be pre-calculated, pre-loaded from external
            sources or passed as query parameters
II.     OneTick Query must produce
       a.   Option Values at a specified time interval
            (depends on the frequency of the available data)
       b.   Optional: Greeks
       c.   Optional: Apply corporate actions to the underlyers’ prices
III.    Results
       a.   View in OneTick GUI in on-demand or continuous CEP mode
       b.   Bring back to R on demand for plotting and further processing
Example: Option Pricing in OneTick/R

                           Sample Business Case
I.      Input:
       a.   OneTick archive or real-time market data for
            American equity options and underlying equities (optional)
       b.   Additional calculation parameters (e.g., underlyer volatility and
            interest rates) can be pre-calculated, pre-loaded from external
                                     2 sample out-of-box solutions
            sources or passed as query parameters
                                    within OneTick query design:
II.     OneTick Query must produce
       a.   Option Values at a specified time OneTick OPTION_PRICE
                                    1. Using interval
            (depends on the frequency of the available data)
                                       function
       b.   Optional: Greeks
       c.                           2. Using OneTick R function to
            Optional: Apply corporate actions to the underlyers’ prices call
                                        RQuantLib library, function
III.    Results
                                        AmericanOption
       a.   View in OneTick GUI in on-demand or continuous CEP mode
       b.   Bring back to R on demand for plotting and further processing
Example: Option Pricing in OneTick/R

OneTick Prep Steps Include:
1. Retrieve a list of underlying equities
      (csv, ODBC, OneTick archive or via GUI, other)
2.    Retrieve, calculate or pass equity volatility as a
      parameter
3.    Retrieve a list of options for the above
      Optional: Filter by the specified maturity and other parameters
4.    Make sure each tick contains all the required attributes
5.    Call OneTick R function (a.k.a. Event Processor)
     1.   Initialize RQuantLib library
     2.   Call AmericanOption function
6.    Process R output
OneTick Sample Query Graph Design
                           Retrieve corresponding option
  Retrieve equity prices       master data and prices
                                                                         OT Archive or
                                                                          CEP Engine




                                                                                Tick Processing
                                         •       JOIN equity and option data
                                                 for each equity symbol


                                      Call R code with R Event Processor
                                      • to calculate each
                                         option value
                                      • for the specified
                                         bucket interval

                                             •   Calculate statistics based on
                                                 R_OPTION_VALUEs
                                             •   In “running” mode, re-calculating
                                                 on each R output tick
OneTick Sample Query: Calling R functions




                               Bucket interval
                               aggregation for
                               passing ticks to R




                       R call parameters:
                       mapping fields, R code
                       and special instructions
R Functions in OneTick: Parameters
        2 subsets of parameters that work together:

OneTick aggregation                 R function specifications
BUCKET_INTERVAL, UNITS and          R_INITIALIZER to specify one time
optional GROUP_BY                   only initial command
to aggregate ticks into buckets     R_MACRO_PREFIX for naming
OUTPUT_INTERVAL and UNITS           INPUT, OUTPUT, R_CALCULATOR to
to define frequency of output for   map tick fields to R variables and specify
running calculations                R command.
                                    Note: A combination of
                                    BUCKET_INTERVAL and INPUT can be
                                    used to pass matrices into R
IS_RUNNING = true/false             R_ENTERING/LEAVING_
for running (a.k.a. sliding)        TICK_HANDLER to call different
calculations                        functions for BUCKET_INTERVAL entry
                                    and exit events in RUNNING
                                    aggregations
Other parameters for additional
flexibility with aggregation
OneTick Sample Query: GUI Output
                            Query parameters
                 (passed from GUI or any calling application):

                                                      •   Standard




•   Custom for each query




    View results in OneTick GUI grid, debugger, profiler or chart:
An alternative: OneTick OPTION_PRICE function

Description:
For each
bucket, computes
call/put option
price and related
Greeks based on               Bucket interval
the Black-Scholes             aggregation for
option pricing                passing ticks to R
model.
An alternative: OneTick OPTION_PRICE function

DESIGN STEPS:
• Retrieve option
  info
• Retrieve
  underlyer PRICE
• Use
  OPTION_PRICE
  event processor




  View results in OneTick GUI grid, debugger, profiler or chart:
Example 2:
- VALUE-AT-RISK IN ONETICK
- RESULTS   BACK TO R
Example : Historical VAR in OneTick

                         Sample Business Case

I.     Input:
      a.   Equity portfolio composition (from csv, ODBC or OneTick)
      b.   Historical daily prices for all portfolio constituents
           for the specified number of days (preferably 500+)
II.    OneTick Query must produce
       For the past X days and Percent P
      a.   Historical Value-At-Risk 1-day values
      b.   Historical Value-At-Risk N-day values
III. Results           Back to R on demand
       for plotting and further processing
OneTick Sample Query Graph Design
                                                                Prep Steps – Query 1:
                                                                • Get portfolio & calculate
                                                                   estimated volatility
                                                                •   This query is executed
                                                                    as an input to the main
                                                                    query


Notes:
We’re using definition of the daily volatility described by J.C.Hall in
“Options, Futures and Other Derivatives”:
      Daily Volatility = Standard Deviation ( Price Percentage Change in 1 Day )


Using OneTick:
•   Price Percentage Change in 1 day:
    PERC_CHANGE = (CLOSE-CLOSE[-1])/CLOSE[-1]
    where LAST is the closing PRICE for the trading day,
    and [-1] refers to the previous CLOSE tick
•   ESTIMATED_VOLATILITY = STDDEV(PERC_CHANGE)
    over a period of time specified as
    STDDEV aggregation function bucket interval
OneTick Sample Query Graph Design
                                        Prep Steps – Query 1:
                                        • Get portfolio & calculate
                                           estimated volatility
                                                    Query 2
                    For each security from the list above
                    • Retrieve daily or high frequency data
                    • Calculate significant number of loss
                       scenarios



                    •   MERGE all calculated timeseries
                        for all securities into 1 for further
                        portfolio level calculations



                    •   Calculate and rank portfolio
                        LOSSES across scenarios
                    •   Calculate Value-At-Risk and
                        Expected Shortfall
OneTick Sample Query: Nesting and Ranking
         Nested Query: Use of aggregation and ranking
                                        Prep Steps – Query 1:
                                                •   Get portfolio & calculate
                                                    estimated volatility

                                                 • Aggregate to 2
                                                             Query
                             For each security from the list above
                                                     get PORTFOLIO
                             • Retrieve daily or high frequency data
                                                     VALUE and
                             • Calculate significant INVESTMENT
                                                     number of loss
                                scenarios

                                                    •   Calculate LOSS

                             •   MERGE all calculated timeseries
                                 for all securities into 1 for further
                                 portfolio level calculations ticks by
                                                     • Rank
                                                        LOSS




                         …
OneTick Sample Query Graph Output in GUI
                                         Prep Steps – Query 1:
                                         • Get portfolio & calculate
                                            estimated volatility
                                                    Query 2
                     For each security from the list above
                     • Retrieve market data
                     • Calculate $NO_OF_SCENARIOS scenarios
                     • Can use daily or high frequency data as a
                        start

                     •   MERGE all calculated timeseries
                         for all securities into 1 for further
                         portfolio level calculations



                     •   Calculate and rank portfolio
                         LOSSES across scenarios
                     •   Calculate Value-At-Risk and
                         Expected Shortfall
                     •   Results: Summary and Detail

                    OneTick GUI Grid Output
OneTick Historical VaR Results Back to R
library(RODBC)
                                                          Sample Code: R 2.10.1
# Define function to create
# OneTick SQL string
                                                           Load RODBC library
omdBuildSQLQuery <- function(otq, start_time, end_time, tz, ...){ an R function similar to
                                                   Create
start_time_tz <- paste(start_time, tz)
end_time_tz <- paste(end_time, tz)                   omdBuildSQLQuery to build
                                                              OneTick SQL string with parameters
sql <- paste("SELECT * FROM OMD.OTQ_FILES."", otq, "" otq ", sep="")
sql <- paste(sql, "WHERE ", sep="")                    Connect to OneTick                 & pass SQL
sql <- paste(sql, "(otq.TIMESTAMP>='", start_time_tz, "') ", sep="")
                                                       Get query results
sql <- paste(sql, "AND (otq.TIMESTAMP<'", end_time_tz, "') ", sep="")
                                                           Process as usual
parms<-list(...)
for(n in attributes(parms)$names) {
               sql <- paste(sql, "AND (param_assign('", n, "','", parms[[n]], "')=1) ", sep="")
               }

# Open ODBC channel to connect to OneTick server[s]
channel <- odbcConnect("OMD_LOCAL_DSN")

# Call OneTick query VaR_Historical_ saved in the query file var_model_running.otq:
sql<-omdBuildSQLQuery("var_model_running::VaR_Historical_",
             "2009-01-01 09:30:00",
             "2011-01-01 09:30:00",
             "EST5EDT"
); sql
results<-sqlQuery(channel, sql); results
OneTick Historical VaR Results Back to R
…..
# Open ODBC channel to connect to OneTick server[s]
channel <- odbcConnect("OMD_LOCAL_DSN")
# Call OneTick query VaR_Historical_ saved in the query file var_model_running.otq:
sql<-omdBuildSQLQuery("var_model_running::VaR_Historical_",
             "2009-01-01 09:30:00",
             "2011-01-01 09:30:00",
             "EST5EDT"
); sql
results<-sqlQuery(channel, sql); results

# Plot the results:
plot(results[, c("PERCENT","VAR_1_DAY")])
title(main="Portfolio Historical 1 Day VaR and Expected Shortfall", col.main="blue", font.main=3)
lines(results[, c("PERCENT","ES")], type="o", pch=22, lty=2, col="red")
Example 3:
- PORTFOLIO PRICING IN ONETICK
- RESULTS  BACK TO R
Portfolio Pricing in OneTick

                       Sample Business Case
I.     Input:
      a.   Portfolio or Portfolio of Portfolios composition
           source (CSV, ODBC source or OneTick database); can
           include weight, side and any other attributes
      b.   Market data
II.    OneTick Query must produce Portfolio Prices:
      a.   Long, Short and Total side by side
      b.   At a specified interval
      c.   Optional: With corporate actions applied to prices
      d.   Optional: In specified currency
III.   Results      Back to R on demand
       for plotting and further processing
Portfolio Pricing in OneTick: Sample Input

#SYMBOL_NAME,WEIGHT
A,400
CSCO,-500
GS,600
IBM,-700
MSFT,-900
Portfolio Pricing in OneTick: Design

OneTick portfolio related aggregation event processors:
      PORTFOLIO_PRICE and MULTI_PORTFOLIO_PRICE
OneTick Query Design Steps:

1. Specify portfolio
2. Retrieve prices
3. Apply CORP_ACTIONS event processor
   (make sure the corresponding reference data is loaded)
4. Use PORTFOLIO_PRICE event processor
   or
   Use COMPUTE “meta-aggregation” event processor to compute
   side by side:
    • LONG PORTFOLIO_PRICE
    • SHORT PORTFOLIO_PRICE
    • 2-SIDED PORTFOLIO_PRICE
5. Bring results back to R
THANK YOU



Information:
info@onetick.com
www.onetick.com

Mais conteúdo relacionado

Semelhante a OneTick and the R mathematical language, a presentation from R in Finance

Ronan Corkery, kdb+ developer at Kx Systems: “Kdb+: How Wall Street Tech can ...
Ronan Corkery, kdb+ developer at Kx Systems: “Kdb+: How Wall Street Tech can ...Ronan Corkery, kdb+ developer at Kx Systems: “Kdb+: How Wall Street Tech can ...
Ronan Corkery, kdb+ developer at Kx Systems: “Kdb+: How Wall Street Tech can ...Maya Lumbroso
 
Ronan Corkery, kdb+ developer at Kx Systems: “Kdb+: How Wall Street Tech can ...
Ronan Corkery, kdb+ developer at Kx Systems: “Kdb+: How Wall Street Tech can ...Ronan Corkery, kdb+ developer at Kx Systems: “Kdb+: How Wall Street Tech can ...
Ronan Corkery, kdb+ developer at Kx Systems: “Kdb+: How Wall Street Tech can ...Dataconomy Media
 
Millions quotes per second in pure java
Millions quotes per second in pure javaMillions quotes per second in pure java
Millions quotes per second in pure javaRoman Elizarov
 
brock_delong_all_your_database_final.pptx
brock_delong_all_your_database_final.pptxbrock_delong_all_your_database_final.pptx
brock_delong_all_your_database_final.pptxAWS Chicago
 
Using Spark and Riak for IoT Apps—Patterns and Anti-Patterns: Spark Summit Ea...
Using Spark and Riak for IoT Apps—Patterns and Anti-Patterns: Spark Summit Ea...Using Spark and Riak for IoT Apps—Patterns and Anti-Patterns: Spark Summit Ea...
Using Spark and Riak for IoT Apps—Patterns and Anti-Patterns: Spark Summit Ea...Spark Summit
 
Cloud Connect 2012, Big Data @ Netflix
Cloud Connect 2012, Big Data @ NetflixCloud Connect 2012, Big Data @ Netflix
Cloud Connect 2012, Big Data @ NetflixJerome Boulon
 
Webinar: How Banks Use MongoDB as a Tick Database
Webinar: How Banks Use MongoDB as a Tick DatabaseWebinar: How Banks Use MongoDB as a Tick Database
Webinar: How Banks Use MongoDB as a Tick DatabaseMongoDB
 
Kognitio overview jan 2013
Kognitio overview jan 2013Kognitio overview jan 2013
Kognitio overview jan 2013Michael Hiskey
 
Kognitio overview jan 2013
Kognitio overview jan 2013Kognitio overview jan 2013
Kognitio overview jan 2013Kognitio
 
Stephen Cantrell, kdb+ Developer at Kx Systems “Kdb+: How Wall Street Tech c...
Stephen Cantrell, kdb+ Developer at Kx Systems  “Kdb+: How Wall Street Tech c...Stephen Cantrell, kdb+ Developer at Kx Systems  “Kdb+: How Wall Street Tech c...
Stephen Cantrell, kdb+ Developer at Kx Systems “Kdb+: How Wall Street Tech c...Dataconomy Media
 
Delta Lake OSS: Create reliable and performant Data Lake by Quentin Ambard
Delta Lake OSS: Create reliable and performant Data Lake by Quentin AmbardDelta Lake OSS: Create reliable and performant Data Lake by Quentin Ambard
Delta Lake OSS: Create reliable and performant Data Lake by Quentin AmbardParis Data Engineers !
 
Overcoming the Top Four Challenges to Real‐Time Performance in Large‐Scale, D...
Overcoming the Top Four Challenges to Real‐Time Performance in Large‐Scale, D...Overcoming the Top Four Challenges to Real‐Time Performance in Large‐Scale, D...
Overcoming the Top Four Challenges to Real‐Time Performance in Large‐Scale, D...SL Corporation
 
SnappyData @ Seattle Spark Meetup
SnappyData @ Seattle Spark MeetupSnappyData @ Seattle Spark Meetup
SnappyData @ Seattle Spark MeetupSnappyData
 
Solving Cybersecurity at Scale
Solving Cybersecurity at ScaleSolving Cybersecurity at Scale
Solving Cybersecurity at ScaleDataWorks Summit
 
Big Data Analytics Platforms by KTH and RISE SICS
Big Data Analytics Platforms by KTH and RISE SICSBig Data Analytics Platforms by KTH and RISE SICS
Big Data Analytics Platforms by KTH and RISE SICSBig Data Value Association
 
Continuous Intelligence - Intersecting Event-Based Business Logic and ML
Continuous Intelligence - Intersecting Event-Based Business Logic and MLContinuous Intelligence - Intersecting Event-Based Business Logic and ML
Continuous Intelligence - Intersecting Event-Based Business Logic and MLParis Carbone
 
Unify Analytics: Combine Strengths of Data Lake and Data Warehouse
Unify Analytics: Combine Strengths of Data Lake and Data WarehouseUnify Analytics: Combine Strengths of Data Lake and Data Warehouse
Unify Analytics: Combine Strengths of Data Lake and Data WarehousePaige_Roberts
 
Aerospike Hybrid Memory Architecture
Aerospike Hybrid Memory ArchitectureAerospike Hybrid Memory Architecture
Aerospike Hybrid Memory ArchitectureAerospike, Inc.
 

Semelhante a OneTick and the R mathematical language, a presentation from R in Finance (20)

Ronan Corkery, kdb+ developer at Kx Systems: “Kdb+: How Wall Street Tech can ...
Ronan Corkery, kdb+ developer at Kx Systems: “Kdb+: How Wall Street Tech can ...Ronan Corkery, kdb+ developer at Kx Systems: “Kdb+: How Wall Street Tech can ...
Ronan Corkery, kdb+ developer at Kx Systems: “Kdb+: How Wall Street Tech can ...
 
Ronan Corkery, kdb+ developer at Kx Systems: “Kdb+: How Wall Street Tech can ...
Ronan Corkery, kdb+ developer at Kx Systems: “Kdb+: How Wall Street Tech can ...Ronan Corkery, kdb+ developer at Kx Systems: “Kdb+: How Wall Street Tech can ...
Ronan Corkery, kdb+ developer at Kx Systems: “Kdb+: How Wall Street Tech can ...
 
Millions quotes per second in pure java
Millions quotes per second in pure javaMillions quotes per second in pure java
Millions quotes per second in pure java
 
brock_delong_all_your_database_final.pptx
brock_delong_all_your_database_final.pptxbrock_delong_all_your_database_final.pptx
brock_delong_all_your_database_final.pptx
 
Using Spark and Riak for IoT Apps—Patterns and Anti-Patterns: Spark Summit Ea...
Using Spark and Riak for IoT Apps—Patterns and Anti-Patterns: Spark Summit Ea...Using Spark and Riak for IoT Apps—Patterns and Anti-Patterns: Spark Summit Ea...
Using Spark and Riak for IoT Apps—Patterns and Anti-Patterns: Spark Summit Ea...
 
Cloud Connect 2012, Big Data @ Netflix
Cloud Connect 2012, Big Data @ NetflixCloud Connect 2012, Big Data @ Netflix
Cloud Connect 2012, Big Data @ Netflix
 
Webinar: How Banks Use MongoDB as a Tick Database
Webinar: How Banks Use MongoDB as a Tick DatabaseWebinar: How Banks Use MongoDB as a Tick Database
Webinar: How Banks Use MongoDB as a Tick Database
 
Kognitio overview jan 2013
Kognitio overview jan 2013Kognitio overview jan 2013
Kognitio overview jan 2013
 
Kognitio overview jan 2013
Kognitio overview jan 2013Kognitio overview jan 2013
Kognitio overview jan 2013
 
Stephen Cantrell, kdb+ Developer at Kx Systems “Kdb+: How Wall Street Tech c...
Stephen Cantrell, kdb+ Developer at Kx Systems  “Kdb+: How Wall Street Tech c...Stephen Cantrell, kdb+ Developer at Kx Systems  “Kdb+: How Wall Street Tech c...
Stephen Cantrell, kdb+ Developer at Kx Systems “Kdb+: How Wall Street Tech c...
 
Delta Lake OSS: Create reliable and performant Data Lake by Quentin Ambard
Delta Lake OSS: Create reliable and performant Data Lake by Quentin AmbardDelta Lake OSS: Create reliable and performant Data Lake by Quentin Ambard
Delta Lake OSS: Create reliable and performant Data Lake by Quentin Ambard
 
Analytics&IoT
Analytics&IoTAnalytics&IoT
Analytics&IoT
 
Overcoming the Top Four Challenges to Real‐Time Performance in Large‐Scale, D...
Overcoming the Top Four Challenges to Real‐Time Performance in Large‐Scale, D...Overcoming the Top Four Challenges to Real‐Time Performance in Large‐Scale, D...
Overcoming the Top Four Challenges to Real‐Time Performance in Large‐Scale, D...
 
SnappyData @ Seattle Spark Meetup
SnappyData @ Seattle Spark MeetupSnappyData @ Seattle Spark Meetup
SnappyData @ Seattle Spark Meetup
 
Solving Cybersecurity at Scale
Solving Cybersecurity at ScaleSolving Cybersecurity at Scale
Solving Cybersecurity at Scale
 
eXtremeDB FE
eXtremeDB FEeXtremeDB FE
eXtremeDB FE
 
Big Data Analytics Platforms by KTH and RISE SICS
Big Data Analytics Platforms by KTH and RISE SICSBig Data Analytics Platforms by KTH and RISE SICS
Big Data Analytics Platforms by KTH and RISE SICS
 
Continuous Intelligence - Intersecting Event-Based Business Logic and ML
Continuous Intelligence - Intersecting Event-Based Business Logic and MLContinuous Intelligence - Intersecting Event-Based Business Logic and ML
Continuous Intelligence - Intersecting Event-Based Business Logic and ML
 
Unify Analytics: Combine Strengths of Data Lake and Data Warehouse
Unify Analytics: Combine Strengths of Data Lake and Data WarehouseUnify Analytics: Combine Strengths of Data Lake and Data Warehouse
Unify Analytics: Combine Strengths of Data Lake and Data Warehouse
 
Aerospike Hybrid Memory Architecture
Aerospike Hybrid Memory ArchitectureAerospike Hybrid Memory Architecture
Aerospike Hybrid Memory Architecture
 

Último

Tenets of Physiocracy History of Economic
Tenets of Physiocracy History of EconomicTenets of Physiocracy History of Economic
Tenets of Physiocracy History of Economiccinemoviesu
 
Overview of Inkel Unlisted Shares Price.
Overview of Inkel Unlisted Shares Price.Overview of Inkel Unlisted Shares Price.
Overview of Inkel Unlisted Shares Price.Precize Formely Leadoff
 
Market Morning Updates for 16th April 2024
Market Morning Updates for 16th April 2024Market Morning Updates for 16th April 2024
Market Morning Updates for 16th April 2024Devarsh Vakil
 
Economic Risk Factor Update: April 2024 [SlideShare]
Economic Risk Factor Update: April 2024 [SlideShare]Economic Risk Factor Update: April 2024 [SlideShare]
Economic Risk Factor Update: April 2024 [SlideShare]Commonwealth
 
原版1:1复刻温哥华岛大学毕业证Vancouver毕业证留信学历认证
原版1:1复刻温哥华岛大学毕业证Vancouver毕业证留信学历认证原版1:1复刻温哥华岛大学毕业证Vancouver毕业证留信学历认证
原版1:1复刻温哥华岛大学毕业证Vancouver毕业证留信学历认证rjrjkk
 
magnetic-pensions-a-new-blueprint-for-the-dc-landscape.pdf
magnetic-pensions-a-new-blueprint-for-the-dc-landscape.pdfmagnetic-pensions-a-new-blueprint-for-the-dc-landscape.pdf
magnetic-pensions-a-new-blueprint-for-the-dc-landscape.pdfHenry Tapper
 
(中央兰开夏大学毕业证学位证成绩单-案例)
(中央兰开夏大学毕业证学位证成绩单-案例)(中央兰开夏大学毕业证学位证成绩单-案例)
(中央兰开夏大学毕业证学位证成绩单-案例)twfkn8xj
 
GOODSANDSERVICETAX IN INDIAN ECONOMY IMPACT
GOODSANDSERVICETAX IN INDIAN ECONOMY IMPACTGOODSANDSERVICETAX IN INDIAN ECONOMY IMPACT
GOODSANDSERVICETAX IN INDIAN ECONOMY IMPACTharshitverma1762
 
The AES Investment Code - the go-to counsel for the most well-informed, wise...
The AES Investment Code -  the go-to counsel for the most well-informed, wise...The AES Investment Code -  the go-to counsel for the most well-informed, wise...
The AES Investment Code - the go-to counsel for the most well-informed, wise...AES International
 
SBP-Market-Operations and market managment
SBP-Market-Operations and market managmentSBP-Market-Operations and market managment
SBP-Market-Operations and market managmentfactical
 
The Core Functions of the Bangko Sentral ng Pilipinas
The Core Functions of the Bangko Sentral ng PilipinasThe Core Functions of the Bangko Sentral ng Pilipinas
The Core Functions of the Bangko Sentral ng PilipinasCherylouCamus
 
Call Girls Near Golden Tulip Essential Hotel, New Delhi 9873777170
Call Girls Near Golden Tulip Essential Hotel, New Delhi 9873777170Call Girls Near Golden Tulip Essential Hotel, New Delhi 9873777170
Call Girls Near Golden Tulip Essential Hotel, New Delhi 9873777170Sonam Pathan
 
Managing Finances in a Small Business (yes).pdf
Managing Finances  in a Small Business (yes).pdfManaging Finances  in a Small Business (yes).pdf
Managing Finances in a Small Business (yes).pdfmar yame
 
Unveiling Business Expansion Trends in 2024
Unveiling Business Expansion Trends in 2024Unveiling Business Expansion Trends in 2024
Unveiling Business Expansion Trends in 2024Champak Jhagmag
 
《加拿大本地办假证-寻找办理Dalhousie毕业证和达尔豪斯大学毕业证书的中介代理》
《加拿大本地办假证-寻找办理Dalhousie毕业证和达尔豪斯大学毕业证书的中介代理》《加拿大本地办假证-寻找办理Dalhousie毕业证和达尔豪斯大学毕业证书的中介代理》
《加拿大本地办假证-寻找办理Dalhousie毕业证和达尔豪斯大学毕业证书的中介代理》rnrncn29
 
Kempen ' UK DB Endgame Paper Apr 24 final3.pdf
Kempen ' UK DB Endgame Paper Apr 24 final3.pdfKempen ' UK DB Endgame Paper Apr 24 final3.pdf
Kempen ' UK DB Endgame Paper Apr 24 final3.pdfHenry Tapper
 
The Triple Threat | Article on Global Resession | Harsh Kumar
The Triple Threat | Article on Global Resession | Harsh KumarThe Triple Threat | Article on Global Resession | Harsh Kumar
The Triple Threat | Article on Global Resession | Harsh KumarHarsh Kumar
 
Financial analysis on Risk and Return.ppt
Financial analysis on Risk and Return.pptFinancial analysis on Risk and Return.ppt
Financial analysis on Risk and Return.ppttadegebreyesus
 
BPPG response - Options for Defined Benefit schemes - 19Apr24.pdf
BPPG response - Options for Defined Benefit schemes - 19Apr24.pdfBPPG response - Options for Defined Benefit schemes - 19Apr24.pdf
BPPG response - Options for Defined Benefit schemes - 19Apr24.pdfHenry Tapper
 

Último (20)

Tenets of Physiocracy History of Economic
Tenets of Physiocracy History of EconomicTenets of Physiocracy History of Economic
Tenets of Physiocracy History of Economic
 
Overview of Inkel Unlisted Shares Price.
Overview of Inkel Unlisted Shares Price.Overview of Inkel Unlisted Shares Price.
Overview of Inkel Unlisted Shares Price.
 
Market Morning Updates for 16th April 2024
Market Morning Updates for 16th April 2024Market Morning Updates for 16th April 2024
Market Morning Updates for 16th April 2024
 
Economic Risk Factor Update: April 2024 [SlideShare]
Economic Risk Factor Update: April 2024 [SlideShare]Economic Risk Factor Update: April 2024 [SlideShare]
Economic Risk Factor Update: April 2024 [SlideShare]
 
Monthly Economic Monitoring of Ukraine No 231, April 2024
Monthly Economic Monitoring of Ukraine No 231, April 2024Monthly Economic Monitoring of Ukraine No 231, April 2024
Monthly Economic Monitoring of Ukraine No 231, April 2024
 
原版1:1复刻温哥华岛大学毕业证Vancouver毕业证留信学历认证
原版1:1复刻温哥华岛大学毕业证Vancouver毕业证留信学历认证原版1:1复刻温哥华岛大学毕业证Vancouver毕业证留信学历认证
原版1:1复刻温哥华岛大学毕业证Vancouver毕业证留信学历认证
 
magnetic-pensions-a-new-blueprint-for-the-dc-landscape.pdf
magnetic-pensions-a-new-blueprint-for-the-dc-landscape.pdfmagnetic-pensions-a-new-blueprint-for-the-dc-landscape.pdf
magnetic-pensions-a-new-blueprint-for-the-dc-landscape.pdf
 
(中央兰开夏大学毕业证学位证成绩单-案例)
(中央兰开夏大学毕业证学位证成绩单-案例)(中央兰开夏大学毕业证学位证成绩单-案例)
(中央兰开夏大学毕业证学位证成绩单-案例)
 
GOODSANDSERVICETAX IN INDIAN ECONOMY IMPACT
GOODSANDSERVICETAX IN INDIAN ECONOMY IMPACTGOODSANDSERVICETAX IN INDIAN ECONOMY IMPACT
GOODSANDSERVICETAX IN INDIAN ECONOMY IMPACT
 
The AES Investment Code - the go-to counsel for the most well-informed, wise...
The AES Investment Code -  the go-to counsel for the most well-informed, wise...The AES Investment Code -  the go-to counsel for the most well-informed, wise...
The AES Investment Code - the go-to counsel for the most well-informed, wise...
 
SBP-Market-Operations and market managment
SBP-Market-Operations and market managmentSBP-Market-Operations and market managment
SBP-Market-Operations and market managment
 
The Core Functions of the Bangko Sentral ng Pilipinas
The Core Functions of the Bangko Sentral ng PilipinasThe Core Functions of the Bangko Sentral ng Pilipinas
The Core Functions of the Bangko Sentral ng Pilipinas
 
Call Girls Near Golden Tulip Essential Hotel, New Delhi 9873777170
Call Girls Near Golden Tulip Essential Hotel, New Delhi 9873777170Call Girls Near Golden Tulip Essential Hotel, New Delhi 9873777170
Call Girls Near Golden Tulip Essential Hotel, New Delhi 9873777170
 
Managing Finances in a Small Business (yes).pdf
Managing Finances  in a Small Business (yes).pdfManaging Finances  in a Small Business (yes).pdf
Managing Finances in a Small Business (yes).pdf
 
Unveiling Business Expansion Trends in 2024
Unveiling Business Expansion Trends in 2024Unveiling Business Expansion Trends in 2024
Unveiling Business Expansion Trends in 2024
 
《加拿大本地办假证-寻找办理Dalhousie毕业证和达尔豪斯大学毕业证书的中介代理》
《加拿大本地办假证-寻找办理Dalhousie毕业证和达尔豪斯大学毕业证书的中介代理》《加拿大本地办假证-寻找办理Dalhousie毕业证和达尔豪斯大学毕业证书的中介代理》
《加拿大本地办假证-寻找办理Dalhousie毕业证和达尔豪斯大学毕业证书的中介代理》
 
Kempen ' UK DB Endgame Paper Apr 24 final3.pdf
Kempen ' UK DB Endgame Paper Apr 24 final3.pdfKempen ' UK DB Endgame Paper Apr 24 final3.pdf
Kempen ' UK DB Endgame Paper Apr 24 final3.pdf
 
The Triple Threat | Article on Global Resession | Harsh Kumar
The Triple Threat | Article on Global Resession | Harsh KumarThe Triple Threat | Article on Global Resession | Harsh Kumar
The Triple Threat | Article on Global Resession | Harsh Kumar
 
Financial analysis on Risk and Return.ppt
Financial analysis on Risk and Return.pptFinancial analysis on Risk and Return.ppt
Financial analysis on Risk and Return.ppt
 
BPPG response - Options for Defined Benefit schemes - 19Apr24.pdf
BPPG response - Options for Defined Benefit schemes - 19Apr24.pdfBPPG response - Options for Defined Benefit schemes - 19Apr24.pdf
BPPG response - Options for Defined Benefit schemes - 19Apr24.pdf
 

OneTick and the R mathematical language, a presentation from R in Finance

  • 1. Solutions from OneTick and R Portfolio & Risk Analytics Business Cases Maria Belianina, Ph.D. Director, Pre-Sales Engineering Support
  • 2. Contents  Data Management & Requirements for Portfolio & Risk Analytics  R and OneTick: Addressing the challenges  What is OneTick  R ↔ OneTick integration: Two available methods  Examples  Option pricing with OneTick and R RQuantLib functions  OneTick Value-At-Risk calculations back to R  OneTick Portfolio Pricing back to R
  • 3. Portfolio & Risk Analytics Data Requirements & Challenges:  Increasing data granularity  Increasing data volumes  Daily to continuous intraday  Reference data (corporate  Milli → Micro → Nano → actions, name Picoseconds… changes, continuous contracts, etc)  Data cleansing challenges  Access to both High  Complexity of data and (e.g., Price) and Low data consolidation (e.g., Volatility) frequency  Consolidation across product data types  Security master  Access to complex calculations maintenance  Database schema changes … vs Consolidated Risk and Portfolio Analysis
  • 4. R AND ONETICK: ADDRESSING THE CHALLENGES
  • 5. What is OneTick: Business Cases Our clients: Business Cases:  Hedge Funds & Proprietary  Backtesting & Quantitative Trading Firms Research  Large Asset Managers  High frequency trading signal generation  Banks / Brokers  Pre- & Post- Trade TCA  Marketplaces  Backbone for  Technology & Information Charting / Time and Sales Providers  Compliance & Regulatory Reporting  Risk & Portfolio Analytics
  • 6. What is OneTick: Overview About data model: - Time series with customizable & flexible schema for any asset type Real-Time OneTick Servers Feeds - High and Low frequency - Data collectors - Consolidated - In-memory intraday - Reference data support (corp (Reuters, Bloom actions, continuous contracts, tick database[s] berg, etc) symbology, calendars, etc.) - Exchanges - Historical archives - Custom feeds (file About analytics: based, unlimited, dist - Time series generic functions: Historical ributed) Aggregation, filtering, signal Data - Analytical Engine generation, calculated fields, etc. for - Time sensitive Joins & Merges Historical, Intraday across symbols, databases and - Ascii and CEP real-time tick types - Proprietary binary - ODBC source queries. Extendable - Finance functions (order book - 3rd party (NYSE via: snapshots and consolidation, TAQ, CME, etc) R, C++, C#, Java, Pe statistics, pricing, portfolios) rl & Python Real-time Out-of-box Batch Out-of-box or or custom API custom API
  • 7. What is OneTick: Client Side End Users & Client Apps: OneTick GUI Real-Time OneTick Servers Design & debug Feeds - Data collectors queries, view results, tune - Consolidated performance - In-memory intraday (Reuters, Bloom tick database[s] berg, etc) OneTick API - Exchanges - Historical archives C++, C#, Java, Perl, Pyt - Custom feeds (file hon based, unlimited, dist Historical ributed) R Data - Analytical Engine for MatLab - Ascii Historical, Intraday and CEP real-time Excel - Proprietary binary - ODBC source queries. Extendable ODBC clients - 3rd party (NYSE via: TAQ, CME, etc) R, C++, C#, Java, Pe Command Line Utility rl & Python Real-time Out-of-box Batch Out-of-box or TCP/IP Real-time or custom API custom API or on-demand
  • 8. What is OneTick: GUI Analytics Query Example: Bollinger Bands Buy/Sell Signals A “Nested query” for Bollinger Bands calculations NOTE: One of the nodes can be an R Event Processor calling R functions
  • 9. What is OneTick: Analytics + Financial Reference Data Reference data can be* mixed with analytics:  Symbol Name History * Note:  Name changes  Continuous contracts Market data is stored “as is”  Symbology Mapping across databases Reference data is stored (e.g., CUSIP to SEDOL) separately and  Corporate Actions can be applied as needed  Splits, dividends, etc  Continuous Contracts  E.g. query “ES**” futures as one contract: “ES”  Currency Conversion  With monthly, daily or intraday exchange rates  Market, Exchange & Symbol Calendars
  • 10. What is OneTick: GUI Analytics + R Query Example: using R functions  Create running (a.k.a. sliding) aggregation of 32 ticks  Call R function acf(…) for each sliding group  Pass values of MID and LAG from tick fields or query parameters  Process the results of R function output
  • 11. System Integration: OneTick and R OneTick allows to: R allows to: If YOU Store compressed fast access data  Retrieve OneTick query output work in Pre-process data: in R code via ODBC/OneTick SQL: R:  Normalize and clean • Call tested OneTick query  Apply reference data • Pass parameters  Aggregate, intervalize, filter • Process results in R as usual  JOIN/MERGE trades vs order TIP: Limit amount of data books, news, weather reports, etc. processed within ODBC and R  Set query parameters aggregating & filtering data in OneTick query If YOU  [Above] + Call any number of  Map OneTick fields to R input work in OneTick or R functions • R scalar types or matrices OneTick  Call separate R functions for a  Load required R libraries GUI: bucket entry or exit events  Specify R code to apply  Run historical or CEP queries  Specify OneTick aggregation  View query results via GUI or API parameters  Map R output back to OneTick fields for further OneTick processing TIP: Take full advantage of both packages.
  • 12. Example 1: OPTION PRICING IN ONETICK WITH OR WITHOUT R FUNCTIONS
  • 13. Example: Option Pricing in OneTick/R Sample Business Case I. Input: a. OneTick archive or real-time market data for American equity options and underlying equities (optional) b. Additional calculation parameters (e.g., underlyer volatility and interest rates) can be pre-calculated, pre-loaded from external sources or passed as query parameters II. OneTick Query must produce a. Option Values at a specified time interval (depends on the frequency of the available data) b. Optional: Greeks c. Optional: Apply corporate actions to the underlyers’ prices III. Results a. View in OneTick GUI in on-demand or continuous CEP mode b. Bring back to R on demand for plotting and further processing
  • 14. Example: Option Pricing in OneTick/R Sample Business Case I. Input: a. OneTick archive or real-time market data for American equity options and underlying equities (optional) b. Additional calculation parameters (e.g., underlyer volatility and interest rates) can be pre-calculated, pre-loaded from external 2 sample out-of-box solutions sources or passed as query parameters within OneTick query design: II. OneTick Query must produce a. Option Values at a specified time OneTick OPTION_PRICE 1. Using interval (depends on the frequency of the available data) function b. Optional: Greeks c. 2. Using OneTick R function to Optional: Apply corporate actions to the underlyers’ prices call RQuantLib library, function III. Results AmericanOption a. View in OneTick GUI in on-demand or continuous CEP mode b. Bring back to R on demand for plotting and further processing
  • 15. Example: Option Pricing in OneTick/R OneTick Prep Steps Include: 1. Retrieve a list of underlying equities (csv, ODBC, OneTick archive or via GUI, other) 2. Retrieve, calculate or pass equity volatility as a parameter 3. Retrieve a list of options for the above Optional: Filter by the specified maturity and other parameters 4. Make sure each tick contains all the required attributes 5. Call OneTick R function (a.k.a. Event Processor) 1. Initialize RQuantLib library 2. Call AmericanOption function 6. Process R output
  • 16. OneTick Sample Query Graph Design Retrieve corresponding option Retrieve equity prices master data and prices OT Archive or CEP Engine Tick Processing • JOIN equity and option data for each equity symbol Call R code with R Event Processor • to calculate each option value • for the specified bucket interval • Calculate statistics based on R_OPTION_VALUEs • In “running” mode, re-calculating on each R output tick
  • 17. OneTick Sample Query: Calling R functions Bucket interval aggregation for passing ticks to R R call parameters: mapping fields, R code and special instructions
  • 18. R Functions in OneTick: Parameters 2 subsets of parameters that work together: OneTick aggregation R function specifications BUCKET_INTERVAL, UNITS and R_INITIALIZER to specify one time optional GROUP_BY only initial command to aggregate ticks into buckets R_MACRO_PREFIX for naming OUTPUT_INTERVAL and UNITS INPUT, OUTPUT, R_CALCULATOR to to define frequency of output for map tick fields to R variables and specify running calculations R command. Note: A combination of BUCKET_INTERVAL and INPUT can be used to pass matrices into R IS_RUNNING = true/false R_ENTERING/LEAVING_ for running (a.k.a. sliding) TICK_HANDLER to call different calculations functions for BUCKET_INTERVAL entry and exit events in RUNNING aggregations Other parameters for additional flexibility with aggregation
  • 19. OneTick Sample Query: GUI Output Query parameters (passed from GUI or any calling application): • Standard • Custom for each query View results in OneTick GUI grid, debugger, profiler or chart:
  • 20. An alternative: OneTick OPTION_PRICE function Description: For each bucket, computes call/put option price and related Greeks based on Bucket interval the Black-Scholes aggregation for option pricing passing ticks to R model.
  • 21. An alternative: OneTick OPTION_PRICE function DESIGN STEPS: • Retrieve option info • Retrieve underlyer PRICE • Use OPTION_PRICE event processor View results in OneTick GUI grid, debugger, profiler or chart:
  • 22. Example 2: - VALUE-AT-RISK IN ONETICK - RESULTS BACK TO R
  • 23. Example : Historical VAR in OneTick Sample Business Case I. Input: a. Equity portfolio composition (from csv, ODBC or OneTick) b. Historical daily prices for all portfolio constituents for the specified number of days (preferably 500+) II. OneTick Query must produce For the past X days and Percent P a. Historical Value-At-Risk 1-day values b. Historical Value-At-Risk N-day values III. Results Back to R on demand for plotting and further processing
  • 24. OneTick Sample Query Graph Design Prep Steps – Query 1: • Get portfolio & calculate estimated volatility • This query is executed as an input to the main query Notes: We’re using definition of the daily volatility described by J.C.Hall in “Options, Futures and Other Derivatives”: Daily Volatility = Standard Deviation ( Price Percentage Change in 1 Day ) Using OneTick: • Price Percentage Change in 1 day: PERC_CHANGE = (CLOSE-CLOSE[-1])/CLOSE[-1] where LAST is the closing PRICE for the trading day, and [-1] refers to the previous CLOSE tick • ESTIMATED_VOLATILITY = STDDEV(PERC_CHANGE) over a period of time specified as STDDEV aggregation function bucket interval
  • 25. OneTick Sample Query Graph Design Prep Steps – Query 1: • Get portfolio & calculate estimated volatility Query 2 For each security from the list above • Retrieve daily or high frequency data • Calculate significant number of loss scenarios • MERGE all calculated timeseries for all securities into 1 for further portfolio level calculations • Calculate and rank portfolio LOSSES across scenarios • Calculate Value-At-Risk and Expected Shortfall
  • 26. OneTick Sample Query: Nesting and Ranking Nested Query: Use of aggregation and ranking Prep Steps – Query 1: • Get portfolio & calculate estimated volatility • Aggregate to 2 Query For each security from the list above get PORTFOLIO • Retrieve daily or high frequency data VALUE and • Calculate significant INVESTMENT number of loss scenarios • Calculate LOSS • MERGE all calculated timeseries for all securities into 1 for further portfolio level calculations ticks by • Rank LOSS …
  • 27. OneTick Sample Query Graph Output in GUI Prep Steps – Query 1: • Get portfolio & calculate estimated volatility Query 2 For each security from the list above • Retrieve market data • Calculate $NO_OF_SCENARIOS scenarios • Can use daily or high frequency data as a start • MERGE all calculated timeseries for all securities into 1 for further portfolio level calculations • Calculate and rank portfolio LOSSES across scenarios • Calculate Value-At-Risk and Expected Shortfall • Results: Summary and Detail OneTick GUI Grid Output
  • 28. OneTick Historical VaR Results Back to R library(RODBC) Sample Code: R 2.10.1 # Define function to create # OneTick SQL string  Load RODBC library omdBuildSQLQuery <- function(otq, start_time, end_time, tz, ...){ an R function similar to  Create start_time_tz <- paste(start_time, tz) end_time_tz <- paste(end_time, tz) omdBuildSQLQuery to build OneTick SQL string with parameters sql <- paste("SELECT * FROM OMD.OTQ_FILES."", otq, "" otq ", sep="") sql <- paste(sql, "WHERE ", sep="")  Connect to OneTick & pass SQL sql <- paste(sql, "(otq.TIMESTAMP>='", start_time_tz, "') ", sep="")  Get query results sql <- paste(sql, "AND (otq.TIMESTAMP<'", end_time_tz, "') ", sep="")  Process as usual parms<-list(...) for(n in attributes(parms)$names) { sql <- paste(sql, "AND (param_assign('", n, "','", parms[[n]], "')=1) ", sep="") } # Open ODBC channel to connect to OneTick server[s] channel <- odbcConnect("OMD_LOCAL_DSN") # Call OneTick query VaR_Historical_ saved in the query file var_model_running.otq: sql<-omdBuildSQLQuery("var_model_running::VaR_Historical_", "2009-01-01 09:30:00", "2011-01-01 09:30:00", "EST5EDT" ); sql results<-sqlQuery(channel, sql); results
  • 29. OneTick Historical VaR Results Back to R ….. # Open ODBC channel to connect to OneTick server[s] channel <- odbcConnect("OMD_LOCAL_DSN") # Call OneTick query VaR_Historical_ saved in the query file var_model_running.otq: sql<-omdBuildSQLQuery("var_model_running::VaR_Historical_", "2009-01-01 09:30:00", "2011-01-01 09:30:00", "EST5EDT" ); sql results<-sqlQuery(channel, sql); results # Plot the results: plot(results[, c("PERCENT","VAR_1_DAY")]) title(main="Portfolio Historical 1 Day VaR and Expected Shortfall", col.main="blue", font.main=3) lines(results[, c("PERCENT","ES")], type="o", pch=22, lty=2, col="red")
  • 30. Example 3: - PORTFOLIO PRICING IN ONETICK - RESULTS BACK TO R
  • 31. Portfolio Pricing in OneTick Sample Business Case I. Input: a. Portfolio or Portfolio of Portfolios composition source (CSV, ODBC source or OneTick database); can include weight, side and any other attributes b. Market data II. OneTick Query must produce Portfolio Prices: a. Long, Short and Total side by side b. At a specified interval c. Optional: With corporate actions applied to prices d. Optional: In specified currency III. Results Back to R on demand for plotting and further processing
  • 32. Portfolio Pricing in OneTick: Sample Input #SYMBOL_NAME,WEIGHT A,400 CSCO,-500 GS,600 IBM,-700 MSFT,-900
  • 33. Portfolio Pricing in OneTick: Design OneTick portfolio related aggregation event processors: PORTFOLIO_PRICE and MULTI_PORTFOLIO_PRICE OneTick Query Design Steps: 1. Specify portfolio 2. Retrieve prices 3. Apply CORP_ACTIONS event processor (make sure the corresponding reference data is loaded) 4. Use PORTFOLIO_PRICE event processor or Use COMPUTE “meta-aggregation” event processor to compute side by side: • LONG PORTFOLIO_PRICE • SHORT PORTFOLIO_PRICE • 2-SIDED PORTFOLIO_PRICE 5. Bring results back to R