Financial Datafeeds

Fahim Chandurwala, Wolfram Research Inc.

ABSTRACT

Wolfram Finance Platform enables access to live market data feeds, from key financial data providers.
In this talk, we will discuss retrieving financial data from such sources--through knowledge base interface, i.e. EntityValue, and through performance-centric APIs.

Support for services such as BloombergTerminal and Bloomberg Data License will be discussed.

More Information about WFP

(HyperlinkURL["Wolfram Finance Platform", https://www.wolfram.com/finance-platform/?source=nav])

Built-In Financial Data

Example

LinguisticAssistant["Last"]

Available Properties

wlProperties=LinguisticAssistant["Properties"]

Length[wlProperties]

Limitations

15 minutes delayed data

No subscriptions/streaming data

Fewer properties

Service Interface

ServiceConnect

pubchem=ServiceConnect["PubChem"]

ServiceExecute

ServiceExecute[pubchem,"CompoundDescription",{"InChI"-> "InChI=1S/ClO2/c2-1-3"}]

ServiceSubmit

task =ServiceSubmit[ServiceRequest[pubchem,"CompoundDescription",{"InChI"-> "InChI=1S/ClO2/c2-1-3"}],HandlerFunctions-><|"ResultReceived"-> ((resp=#ServiceResponse)&)|>]

resp

Bloomberg Data License

Contents

Connecting to Bloomberg Data License Server

Entity Interface

Service Interface

Deploying Scheduled Requests

Limitations

Connecting to the Bloomberg Data License Server

Connection

Authentication via SSL Certificates

bdl=ServiceConnect["BloombergDataLicense",ConnectionSettings-><|"DataDictionary"->File["/Users/fahimc/Downloads/fields.csv"]|>]

Entity Interface

Properties

bdlProperties=EntityProperties["BloombergDataLicense"];

Length[bdlProperties]

RandomSample[bdlProperties,12]

Property Data

Entity["BloombergDataLicense","VOD LN Equity"]["PX_LAST"]

Historical Data

EntityValue[
Entity["BloombergDataLicense","MSFT US Equity"],
EntityProperty["BloombergDataLicense","PX_LAST",{"Date"->Interval[{DateObject[{1990}],Today}]}]
]

DateListPlot[%]

Service Interface

GetData

Submit GetData request:

getDataRequest = ServiceExecute[ServiceRequest[bdl,"Request",<|"Request"->"GetData","Instruments"->{"AZO UN Equity","MSFT US Equity"},"Fields"->{"PX_LAST"}|>]]

Get result:

data= ServiceExecute[getDataRequest]

GetHistory

getHistoryRequest = ServiceExecute[bdl,"Request",<|"Request"->"GetHistory","Instruments"->{"AAPL US Equity"},"Fields"->{"PX_LAST"},"Period"->DateObject[{1990}];;Today|>]

tsData=ServiceExecute[getHistoryRequest];

timeSeries=TimeSeries[tsData["AAPL US Equity"]["PX_LAST"],{tsData["AAPL US Equity"]["Dates"]}]

DateListPlot[timeSeries]

GetQuotes

getQuotesRequest = ServiceExecute[ServiceRequest[bdl,"Request",<|"Request"->"GetQuotes","Instruments"->{"AZO UN Equity"},"Period"->DatePlus[Today,-2];;DatePlus[Today,-2]|>]]

ServiceExecute[getQuotesRequest]

GetAllQuotes

getAllQuotesRequest = ServiceExecute[ServiceRequest[bdl,"Request",<|"Request"->"GetAllQuotes","Instruments"->{"AZO UN Equity"},"Period"->DatePlus[Today,-2];;DatePlus[Today,-2]|>]]

ServiceExecute[getAllQuotesRequest]

GetCompanyData

getCompanyData = ServiceExecute[ServiceRequest[bdl,"GetCompanyData",<|"ResponseID"->"1572458833-711956165","Instruments"->{"AZO UN Equity"},"Fields"->{"COMPANY_ADDRESS"}|>]]

Deploying Scheduled Requests

Create a request

getDataRequest = ServiceRequest[bdl,"GetData",<|"Instruments"->{"AZO UN Equity"},"Fields"->{"PX_LAST","BID","ASK"}|>]

Submit the request

ServiceSubmit[
ScheduledTask[getDataRequest,"Weekly"],
HandlerFunctions-><|"ResultReceived"->Print|>,
HandlerFunctionsKeys->{"EvaluationResult"}
]

Query deployed tasks

tasks = ServiceExecute[bdl,"RemoteScheduledTasks",<|"ResponseID"->"1572459742-71679169"|>];

tasks//Length

Redeploy tasks

task = ServiceSubmit[
tasks[[4]],
HandlerFunctions-><|"ResultReceived"->Print|>,
HandlerFunctionsKeys->{"EvaluationResult"}
]

Limitations

Synchronous evaluations could be  slow

AbsoluteTiming[Entity["BloombergDataLicense","VOD LN Equity"]["PX_LAST"]]

Why does it take so long...

No live streaming of market data

Bloomberg Terminal

Contents

Connecting to Bloomberg Terminal

Entity Interface

Service Interface

Service Submit

Live Subscription

Connecting to Bloomberg Terminal

Connection

terminal=ServiceConnect["BloombergTerminal"]

Entity Interface

EnitityProperties

RandomSample[EntityProperties["BloombergTerminal"],20]

EntityProperties["BloombergTerminal"]//Length

Reference Data

Entity["BloombergTerminal","MSFT US Equity"][{"PX_LAST","BID","ASK"}]

EntityValue[
{
Entity["BloombergTerminal","MSFT US Equity"],
Entity["BloombergTerminal","AAPL US Equity"]
}
,
{
EntityProperty["BloombergTerminal","PX_LAST"],
EntityProperty["BloombergTerminal","BID"],
EntityProperty["BloombergTerminal","ASK"]
}
,
"EntityPropertyAssociation"]

Historical Data

ts = Entity["BloombergTerminal","MSFT US Equity"]["HIGH",{"Date"->CurrentDate["Year"];;Today;;LinguisticAssistant}]

DateListPlot[ts]

Tick Data

Example: Ticks (5 minutes)

es1=EntityValue[
Entity["BloombergTerminal","MSFT US Equity"],
EntityProperty["BloombergTerminal","TickEvents",
{
"Event"->"TRADE","Date"->DateObject[{2019,10,28,8,30,0}];;DateObject[{2019,10,28,8,35,0}]
}
]
]

EventSeries contains list of associations:

es1["Values"]

data =Flatten[Values/@es1["Values"]]

EventCount:

Length[data]

Volume:

Merge[data,Total]["Size"]

Quantity vs. Price

trade = Flatten@Map[ConstantArray[#[[2]],#[[1]]]&,Values/@Flatten[Values/@es1["Values"]]];

Histogram[trade,ChartLegends->{"TRADE"}]

Market Bar Data

Get market bar data:

barData =EntityValue[Entity["BloombergTerminal","MSFT US Equity"],
EntityProperty[
"BloombergTerminal",
"IntradayBars",{
"Event"->"TRADE",
"Date"->DateObject[{2019,10,30,8,30,0}];;DateObject[{2019,10,30,10,40,0}];;LinguisticAssistant
}

]
]

values = Map[Lookup[#,{"Open","High","Low","Close","Volume"}]&,barData["Values"]]

TradingChart[TimeSeries[values,{barData["Dates"]}]]

Compare market bar data with tick data:

barData["Values"][[1]]

Service Interface

Reference Data

Get reference data:

ServiceExecute[terminal,"ReferenceData",
<|
"Instruments"->{"AAPL Equity","IBM Equity"},
"Fields"->{"CUR_MKT_CAP","LAST_PRICE","TWITTER_SENTIMENT"}
|>
]

Documentation for the field TWITTER_SENTIMENT

ServiceExecute[terminal,"FieldInformation",<|"Fields"->{"TWITTER_SENTIMENT"}|>]

Historical Data

hist=ServiceExecute[terminal,"HistoricalData",<|"Instruments"->{"MSFT US Equity"},"Fields"->{"OPEN"},"Period"->DatePlus[Today,Quantity[-15,"Days"]];;Today|>]

DateListPlot[TimeSeries[hist["MSFT US Equity"]["OPEN"],{hist["MSFT US Equity"]["Dates"]}]]

Tick Data

ServiceExecute[terminal,"IntradayTickData",<|"Instrument"->"MSFT US Equity","EventTypes"->{"TRADE"}|>]

Market Bar Data

ServiceExecute[terminal,"IntradayBarData",<|"Instrument"->"MSFT US Equity","Period"->DateObject[{2019,10,30,8,30,0}];;DateObject[{2019,10,30,8,40,0}];;LinguisticAssistant|>]

Service Submit

Field List

Asynchronously fetch properties:

req = ServiceRequest[terminal,"FieldList"]

fields={};
ServiceSubmit[req,HandlerFunctions-><|"FieldResponse"->((fields=Join[fields,#Result])&)|>]

Dynamic[Length[fields]]

Subscription

Market bar subscription

Monitor live market bar data:

req=ServiceRequest[terminal,"MarketBarData",<|"Instrument"->"MSFT US Equity"|>]

res = <||>;
update = ((res=Join[res,<|#Event->#Result|>])&);
append=((res=Merge[{res,<|#Event->#Result|>},Flatten])&);

ServiceSubmit[ContinuousTask[req],
HandlerFunctions-><|
"MarketBarUpdate"->update,
"MarketBarIntervalEnd"->append,
"MarketBarStart"->append
|>
]

Dynamic[Dataset[res["MarketBarUpdate"]]]

Dynamic@Dataset[res["MarketBarStart"]]

Market data subscription

Monitor changes to market data:

mktReq=ServiceRequest[terminal,"MarketData",<|"Instrument"->"AAPL US Equity","TriggerFields"->{"BID","ASK"}|>]

task = ServiceSubmit[ContinuousTask[mktReq],HandlerFunctions-><|"MarketDataEvents"->((mktData=#Result)&)|>]

mktData

Compatibility

BloombergTerminal, and Bloomberg Data License : Windows, macOS, Linux

Reuters: Windows, Linux