/
package-info.java
92 lines (92 loc) · 3.99 KB
/
package-info.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
* Copyright (C) 2012 - present by Yann Le Tallec.
* Please see distribution for license.
*/
/**
* jBloomberg is a high-level API that wraps the low level Bloomberg API. Although most features of the
* underlying Bloomberg API are available, some options might not be reachable through the jBloomberg API.
* <p>
* A typical use is to start a BloombergSession and to submit static or historical requests or to subscribe to real
* time updates. Once the session is not in use any longer, it can be stopped. Note that in the below examples, sessions
* are started then stopped right after a request has been sent. In practice, starting a session can be a time consuming
* operation and once a session has been opened, it is preferable to reuse it unless it is not going to be used for a
* long time.
* <p>
*
* <b> Example: start and stop a session</b>
* <pre> {@code
* BloombergSession session = new DefaultBloombergSession();
* session.start();
* session.stop();
* }</pre>
*
* <b> Example: retrieve the last price of the S&P 500 in Yen</b>
* <pre> {@code
* RequestBuilder<ReferenceData> hrb = new ReferenceRequestBuilder(
* "SPX Index", "CRNCY_ADJ_PX_LAST")
* .addOverride("EQY_FUND_CRNCY", "JPY");
* ReferenceData result = session.submit(hrb).get();
* double priceInYen = result.forSecurity("SPX Index").forField("CRNCY_ADJ_PX_LAST").asDouble();
* System.out.println("SPX in Yen = " + priceInYen);
* }</pre>
*
* <b> Example: retrieve historical data synchronously</b>
* <pre> {@code
* LocalDate now = LocalDate.now();
* RequestBuilder<HistoricalData> hrb = new HistoricalRequestBuilder("SPX Index", "PX_LAST", now.minusDays(7), now)
* .fill(HistoricalRequestBuilder.Fill.NIL_VALUE)
* .days(HistoricalRequestBuilder.Days.ALL_CALENDAR_DAYS);
* HistoricalData result = session.submit(hrb).get();
* Map<LocalDate, TypedObject> data = result.forSecurity("SPX Index").forField("PX_LAST").get();
* for (Map.Entry<LocalDate, TypedObject> e : data.entrySet()) {
* LocalDate dt = e.getKey();
* double price = e.getValue().asDouble();
* System.out.println("[" + dt + "] " + price);
* }
* }</pre>
*
* <b> Example: retrieve 60-minute bars for the S&P 500 over the past week </b>
* <pre> {@code
* OffsetDateTime now = OffsetDateTime.now();
* RequestBuilder<IntradayBarData> hrb = new IntradayBarRequestBuilder("SPX Index", now.minusDays(7), now)
* .adjustSplits()
* .fillInitialBar()
* .period(1, TimeUnit.HOURS);
* IntradayBarData result = session.submit(hrb).get();
* Map<OffsetDateTime, TypedObject> data = result.forField(IntradayBarField.CLOSE).get();
* for (Map.Entry<OffsetDateTime, TypedObject> e : data.entrySet()) {
* OffsetDateTime dt = e.getKey();
* double price = e.getValue().asDouble();
* System.out.println("[" + dt + "] " + price);
* }
* }</pre>
*
*
* <b> Example: retrieve tick data for the S&P 500 over the past 2 hours </b>
* <pre> {@code
* OffsetDateTime now = OffsetDateTime.now();
* RequestBuilder<IntradayTickData> hrb = new IntradayTickRequestBuilder("SPX Index", now.minusHours(2), now)
* .includeBrokerCodes()
* .includeConditionCodes();
* IntradayTickData result = session.submit(hrb).get();
* Multimap<OffsetDateTime, TypedObject> data = result.forField(IntradayTickField.VALUE);
* for (Map.Entry<OffsetDateTime, TypedObject> e : data.entries()) {
* OffsetDateTime dt = e.getKey();
* double price = e.getValue().asDouble();
* System.out.println("[" + dt + "] " + price);
* }
* }</pre>
*
* <b> Example: subscribe to real time price updates </b>
* <pre> <code>
* SubscriptionBuilder builder = new SubscriptionBuilder()
* .addSecurity("ESA Index")
* .addField(RealtimeField.LAST_PRICE)
* .addField(RealtimeField.ASK)
* .addField(RealtimeField.ASK_SIZE)
* .addListener(System.out::println);
* session.subscribe(builder);
* Thread.sleep(3000); //to allow data to start coming in
* </code></pre>
*/
package com.assylias.jbloomberg;