Comments (9)
> dim(pair_pnl_matrix)
[1] 731 101
>
from pairs.
duke_pair_look_vs_outright<-readLines(
if(off_site){
"https://raw.githubusercontent.com/satrapade/pairs/master/data/duke_pair_look_vs_outright.csv"
} else {
"N:/Depts/Share/UK Alpha Team/Analytics/duke_summary/duke_pair_look_vs_outright.csv"
}
) %>% paste0(collapse="\n") %>% fread
look_through_pair_exposure<-duke_pair_look_vs_outright[
TRUE,
.(
Exposure=sum(Outright+LookThrough)
),
keyby=c("Pair","SuperSectorIndex")
]
pair_lt_matrix<-NNcast(
look_through_pair_exposure,
i_name="Pair",
j_name="gsub(' Index','',SuperSectorIndex)%>%{ifelse(.=='','Unknown',.)}",
v_name="Exposure"
)%>%{.[,colnames(.)!="Unknown"]}
from pairs.
> dim(pair_lt_matrix)
[1] 103 19
from pairs.
> setdiff(rownames(pair_lt_matrix),colnames(pair_pnl_matrix))
[1] "MC140" "MC154"
from pairs.
the look-through calculation did not run today
from pairs.
> mapply(fetch_index_weights,duke_index_exposure$Ticker)
Error: <SQL> 'SELECT MAX(HistoricalDate) FROM tHistoricalProductHolding WHERE ProductId=NA'
nanodbc/nanodbc.cpp:1587: 42S22: [Microsoft][ODBC SQL Server Driver][SQL Server]Invalid column name 'NA'.
Show Traceback
Rerun with Debug
Error: <SQL> 'SELECT MAX(HistoricalDate) FROM tHistoricalProductHolding WHERE ProductId=NA'
nanodbc/nanodbc.cpp:1587: 42S22: [Microsoft][ODBC SQL Server Driver][SQL Server]Invalid column name 'NA'.
>
from pairs.
> fetch_index_weights
function(
equity_index_ticker="UKX Index",
db=get("db",parent.frame())
){
product_types<-query("SELECT * FROM tProductType",db=db)[,.SD,keyby=Name]
equity_index_products<-query(make_query(
product_type=product_types["Equity Index",ProductTypeId],
query_string = "SELECT * FROM tProduct WHERE ProductTypeId=--R{product_type}--"
),db=db)[,.SD,keyby=PrimaryDataSourceProductCode]
equity_index_update<-query(make_query(
product_id=equity_index_products[equity_index_ticker,ProductId],
query_string = "SELECT MAX(HistoricalDate) FROM tHistoricalProductHolding WHERE ProductId=--R{product_id}--"
),db=db)[[1]]
equity_index_weights<-query(make_query(
product_id=equity_index_products[equity_index_ticker,ProductId],
update_date=equity_index_update,
query_string = "
SELECT
tProduct.PrimaryDataSourceProductCode AS IndexTicker,
tSecurity.Ticker AS Ticker,
tSecurity.UniqueId AS UniqueId,
tHistoricalProductHolding.SecurityUnits AS Weight
FROM tHistoricalProductHolding
LEFT JOIN tProduct ON tProduct.ProductId=tHistoricalProductHolding.ProductId
LEFT JOIN tSecurity ON tSecurity.SecurityId=tHistoricalProductHolding.SecurityId
WHERE tHistoricalProductHolding.ProductId=--R{product_id}--
AND tHistoricalProductHolding.HistoricalDate='--R{update_date}--'
"
),db=db)
equity_index_weights
}
<bytecode: 0x000000002ee42678>
from pairs.
> mapply(
+ function(ndx){
+ cat(ndx,"\n")
+ fetch_index_weights(ndx)
+ },
+ duke_index_exposure$Ticker
+ )
CAC Index
DAX Index
F3BANK Index
F3FINS Index
Error: <SQL> 'SELECT MAX(HistoricalDate) FROM tHistoricalProductHolding WHERE ProductId=NA'
nanodbc/nanodbc.cpp:1587: 42S22: [Microsoft][ODBC SQL Server Driver][SQL Server]Invalid column name 'NA'.
Show Traceback
Rerun with Debug
Error: <SQL> 'SELECT MAX(HistoricalDate) FROM tHistoricalProductHolding WHERE ProductId=NA'
nanodbc/nanodbc.cpp:1587: 42S22: [Microsoft][ODBC SQL Server Driver][SQL Server]Invalid column name 'NA'.
>
from pairs.
F3FINS Index does seem to cause the error
from pairs.
Related Issues (20)
- the GMV portfolio HOT 4
- pair_risk_contribution report is out of date HOT 9
- ABC: can we add implied vols or credit spreads as measures of market risk? HOT 1
- pair_risk_contribution_new: sector gross looks wrong HOT 1
- the cross product
- custom PM report HOT 3
- loading "all results" is a really bad idea HOT 1
- intraday.csv is 25mb, too large to push to git HOT 3
- 2 year correlation looks wrong HOT 1
- CIX uploads dont work HOT 4
- AC112 has no single stock positions
- pair ACTW7 has exposure but is not in duke_pair_look_vs_outright HOT 4
- CIX uploads do not work HOT 7
- AC's position is the sum of AC and ACTW. needs to be fixed.
- James Rodgers requests
- The fund pair risk contribution table
- The correlation of my portfolio to markets
- the correlation of my pairs to one another in an easy to read format
- the look-through exposures
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pairs.