StaticnewReturns the member ID
Returns the quote level
Returns the quote package details
Set quote callback, after receiving the quote data push, it will call back to this function.
Set depth callback, after receiving the depth data push, it will call back to this function.
Set brokers callback, after receiving the brokers data push, it will call back to this function.
Set trades callback, after receiving the trades data push, it will call back to this function.
Set candlestick callback, after receiving the trades data push, it will call back to this function.
Subscribe
const { OAuth, Config, QuoteContext, SubType } = require('longbridge')
const oauth = await OAuth.build('your-client-id', (_, url) => console.log('Visit:', url));
const ctx = QuoteContext.new(Config.fromOAuth(oauth));
ctx.setOnQuote((_, event) => console.log(event.toString()));
await ctx.subscribe(["700.HK", "AAPL.US"], [SubType.Quote]);
Unsubscribe
const { OAuth, Config, QuoteContext, SubType } = require('longbridge')
const oauth = await OAuth.build('your-client-id', (_, url) => console.log('Visit:', url));
const ctx = QuoteContext.new(Config.fromOAuth(oauth));
await ctx.subscribe(["700.HK", "AAPL.US"], [SubType.Quote]);
await ctx.unsubscribe(["AAPL.US"], [SubType.Quote]);
Subscribe security candlesticks
Get subscription information
const { OAuth, Config, QuoteContext, SubType } = require('longbridge')
const oauth = await OAuth.build('your-client-id', (_, url) => console.log('Visit:', url));
const ctx = QuoteContext.new(Config.fromOAuth(oauth));
await ctx.subscribe(["700.HK", "AAPL.US"], [SubType.Quote]);
const resp = await ctx.subscriptions();
console.log(resp.toString());
Get basic information of securities
const { OAuth, Config, QuoteContext } = require('longbridge')
const oauth = await OAuth.build('your-client-id', (_, url) => console.log('Visit:', url));
const ctx = QuoteContext.new(Config.fromOAuth(oauth));
const resp = await ctx.staticInfo(["700.HK", "AAPL.US", "TSLA.US", "NFLX.US"]);
for (let obj of resp) {
console.log(obj.toString());
}
Get quote of securities
const { OAuth, Config, QuoteContext } = require('longbridge')
const oauth = await OAuth.build('your-client-id', (_, url) => console.log('Visit:', url));
const ctx = QuoteContext.new(Config.fromOAuth(oauth));
const resp = await ctx.quote(["700.HK", "AAPL.US", "TSLA.US", "NFLX.US"]);
for (let obj of resp) {
console.log(obj.toString());
}
Get quote of option securities
const { OAuth, Config, QuoteContext } = require('longbridge')
const oauth = await OAuth.build('your-client-id', (_, url) => console.log('Visit:', url));
const ctx = QuoteContext.new(Config.fromOAuth(oauth));
const resp = await ctx.optionQuote(["AAPL230317P160000.US"]);
for (let obj of resp) {
console.log(obj.toString());
}
Get quote of warrant securities
const { OAuth, Config, QuoteContext } = require('longbridge')
const oauth = await OAuth.build('your-client-id', (_, url) => console.log('Visit:', url));
const ctx = QuoteContext.new(Config.fromOAuth(oauth));
const resp = await ctx.warrantQuote(["21125.HK"]);
for (let obj of resp) {
console.log(obj.toString());
}
Get security depth
const { OAuth, Config, QuoteContext } = require('longbridge')
const oauth = await OAuth.build('your-client-id', (_, url) => console.log('Visit:', url));
const ctx = QuoteContext.new(Config.fromOAuth(oauth));
const resp = await ctx.depth("700.HK");
console.log(resp.toString());
Get security brokers
const { OAuth, Config, QuoteContext } = require('longbridge')
const oauth = await OAuth.build('your-client-id', (_, url) => console.log('Visit:', url));
const ctx = QuoteContext.new(Config.fromOAuth(oauth));
const resp = await ctx.brokers("700.HK");
console.log(resp.toString());
Get participants
const { OAuth, Config, QuoteContext } = require('longbridge')
const oauth = await OAuth.build('your-client-id', (_, url) => console.log('Visit:', url));
const ctx = QuoteContext.new(Config.fromOAuth(oauth));
const resp = await ctx.participants();
for (let obj of resp) {
console.log(obj.toString());
}
Get security trades
const { OAuth, Config, QuoteContext } = require('longbridge')
const oauth = await OAuth.build('your-client-id', (_, url) => console.log('Visit:', url));
const ctx = QuoteContext.new(Config.fromOAuth(oauth));
const resp = await ctx.trades("700.HK", 10);
for (let obj of resp) {
console.log(obj.toString());
}
Get security intraday
const { OAuth, Config, QuoteContext, TradeSessions } = require('longbridge')
const oauth = await OAuth.build('your-client-id', (_, url) => console.log('Visit:', url));
const ctx = QuoteContext.new(Config.fromOAuth(oauth));
const resp = await ctx.intraday("700.HK", TradeSessions.Intraday);
for (let obj of resp) {
console.log(obj.toString());
}
Get security candlesticks
const { OAuth, Config, QuoteContext, Period, AdjustType, TradeSessions } = require('longbridge')
const oauth = await OAuth.build('your-client-id', (_, url) => console.log('Visit:', url));
const ctx = QuoteContext.new(Config.fromOAuth(oauth));
const resp = await ctx.candlesticks("700.HK", Period.Day, 10, AdjustType.NoAdjust, TradeSessions.Intraday);
for (let obj of resp) {
console.log(obj.toString());
}
Get security history candlesticks by offset
Get security history candlesticks by date
Get option chain expiry date list
const { OAuth, Config, QuoteContext } = require('longbridge')
const oauth = await OAuth.build('your-client-id', (_, url) => console.log('Visit:', url));
const ctx = QuoteContext.new(Config.fromOAuth(oauth));
const resp = await ctx.optionChainExpiryDateList("AAPL.US");
for (let obj of resp) {
console.log(obj.toString());
}
Get option chain info by date
const { OAuth, Config, QuoteContext, NaiveDate } = require('longbridge')
const oauth = await OAuth.build('your-client-id', (_, url) => console.log('Visit:', url));
const ctx = QuoteContext.new(Config.fromOAuth(oauth));
const resp = await ctx.optionChainInfoByDate("AAPL.US", new NaiveDate(2023, 1, 20));
for (let obj of resp) {
console.log(obj.toString());
}
Get warrant issuers
const { OAuth, Config, QuoteContext } = require('longbridge')
const oauth = await OAuth.build('your-client-id', (_, url) => console.log('Visit:', url));
const ctx = QuoteContext.new(Config.fromOAuth(oauth));
const resp = await ctx.warrantIssuers();
for (let obj of resp) {
console.log(obj.toString());
}
Query warrant list
const { OAuth, Config, QuoteContext, WarrantSortBy, SortOrderType } = require('longbridge')
const oauth = await OAuth.build('your-client-id', (_, url) => console.log('Visit:', url));
const ctx = QuoteContext.new(Config.fromOAuth(oauth));
const resp = await ctx.warrantList("700.HK", WarrantSortBy.LastDone, SortOrderType.Asc);
for (let obj of resp) {
console.log(obj.toString());
}
OptionalwarrantType: WarrantType[] | nullOptionalissuer: number[] | nullOptionalexpiryDate: FilterWarrantExpiryDate[] | nullOptionalpriceType: FilterWarrantInOutBoundsType[] | nullOptionalstatus: WarrantStatus[] | nullGet trading session of the day
const { OAuth, Config, QuoteContext } = require('longbridge')
const oauth = await OAuth.build('your-client-id', (_, url) => console.log('Visit:', url));
const ctx = QuoteContext.new(Config.fromOAuth(oauth));
const resp = await ctx.tradingSession();
for (let obj of resp) {
console.log(obj.toString());
}
Get trading session of the day
const { OAuth, Config, QuoteContext, Market, NaiveDate } = require('longbridge')
const oauth = await OAuth.build('your-client-id', (_, url) => console.log('Visit:', url));
const ctx = QuoteContext.new(Config.fromOAuth(oauth));
const resp = await ctx.tradingDays(Market.HK, new NaiveDate(2022, 1, 20), new NaiveDate(2022, 2, 20));
console.log(resp.toString());
Get capital flow intraday
const { OAuth, Config, QuoteContext } = require('longbridge')
const oauth = await OAuth.build('your-client-id', (_, url) => console.log('Visit:', url));
const ctx = QuoteContext.new(Config.fromOAuth(oauth));
const resp = await ctx.capitalFlow("700.HK");
for (let obj of resp) {
console.log(obj.toString());
}
Get capital distribution
const { OAuth, Config, QuoteContext } = require('longbridge')
const oauth = await OAuth.build('your-client-id', (_, url) => console.log('Visit:', url));
const ctx = QuoteContext.new(Config.fromOAuth(oauth));
const resp = await ctx.capitalDistribution("700.HK");
console.log(resp.toString());
Get calc indexes
Get watchlist
const { OAuth, Config, QuoteContext } = require('longbridge')
const oauth = await OAuth.build('your-client-id', (_, url) => console.log('Visit:', url));
const ctx = QuoteContext.new(Config.fromOAuth(oauth));
const resp = await ctx.watchList();
console.log(resp.toString());
Create watchlist group
const { OAuth, Config, QuoteContext } = require('longbridge')
const oauth = await OAuth.build('your-client-id', (_, url) => console.log('Visit:', url));
const ctx = QuoteContext.new(Config.fromOAuth(oauth));
const groupId = await ctx.createWatchlistGroup({
name: "Watchlist1",
securities: ["700.HK", "BABA.US"],
});
console.log(groupId);
Delete watchlist group
const { OAuth, Config, QuoteContext } = require('longbridge')
const oauth = await OAuth.build('your-client-id', (_, url) => console.log('Visit:', url));
const ctx = QuoteContext.new(Config.fromOAuth(oauth));
await ctx.deleteWatchlistGroup({ id: 10086 });
Update watchlist group
const { OAuth, Config, QuoteContext } = require('longbridge')
const oauth = await OAuth.build('your-client-id', (_, url) => console.log('Visit:', url));
const ctx = QuoteContext.new(Config.fromOAuth(oauth));
await ctx.updateWatchlistGroup({
id: 10086,
name: "Watchlist2",
securities: ["700.HK", "BABA.US"],
});
Get security list
const { OAuth, Config, QuoteContext, Market, SecurityListCategory } = require('longbridge')
const oauth = await OAuth.build('your-client-id', (_, url) => console.log('Visit:', url));
const ctx = QuoteContext.new(Config.fromOAuth(oauth));
const resp = await ctx.securityList(Market.US, SecurityListCategory.Overnight);
console.log(resp.toString());
Get current market temperature
const { OAuth, Config, QuoteContext, Market } = require('longbridge')
const oauth = await OAuth.build('your-client-id', (_, url) => console.log('Visit:', url));
const ctx = QuoteContext.new(Config.fromOAuth(oauth));
const resp = await ctx.marketTemperature(Market.HK);
console.log(resp.toString());
Get historical market temperature
const { OAuth, Config, QuoteContext, Market, NaiveDate } = require('longbridge')
const oauth = await OAuth.build('your-client-id', (_, url) => console.log('Visit:', url));
const ctx = QuoteContext.new(Config.fromOAuth(oauth));
const resp = await ctx.historyMarketTemperature(Market.HK, new NaiveDate(2023, 1, 20), new NaiveDate(2023, 2, 20));
console.log(resp.toString());
Get real-time quote
const { OAuth, Config, QuoteContext, SubType } = require('longbridge')
const oauth = await OAuth.build('your-client-id', (_, url) => console.log('Visit:', url));
const ctx = QuoteContext.new(Config.fromOAuth(oauth));
await ctx.subscribe(["700.HK", "AAPL.US"], [SubType.Quote]);
await new Promise((resolve) => setTimeout(resolve, 5000));
const resp = await ctx.realtimeQuote(["700.HK", "AAPL.US"]);
for (let obj of resp) {
console.log(obj.toString());
}
Get real-time depth
const { OAuth, Config, QuoteContext, SubType } = require('longbridge')
const oauth = await OAuth.build('your-client-id', (_, url) => console.log('Visit:', url));
const ctx = QuoteContext.new(Config.fromOAuth(oauth));
await ctx.subscribe(["700.HK", "AAPL.US"], [SubType.Depth]);
await new Promise((resolve) => setTimeout(resolve, 5000));
const resp = await ctx.realtimeDepth("700.HK");
console.log(resp.toString());
Get real-time brokers
const { OAuth, Config, QuoteContext, SubType } = require('longbridge')
const oauth = await OAuth.build('your-client-id', (_, url) => console.log('Visit:', url));
const ctx = QuoteContext.new(Config.fromOAuth(oauth));
await ctx.subscribe(["700.HK", "AAPL.US"], [SubType.Brokers]);
await new Promise((resolve) => setTimeout(resolve, 5000));
const resp = await ctx.realtimeBrokers("700.HK");
console.log(resp.toString());
Get real-time trades
const { OAuth, Config, QuoteContext, SubType } = require('longbridge')
const oauth = await OAuth.build('your-client-id', (_, url) => console.log('Visit:', url));
const ctx = QuoteContext.new(Config.fromOAuth(oauth));
await ctx.subscribe(["700.HK", "AAPL.US"], [SubType.Trade]);
await new Promise((resolve) => setTimeout(resolve, 5000));
const resp = await ctx.realtimeTrades("700.HK", 10);
for (let obj of resp) {
console.log(obj.toString());
}
Get real-time candlesticks
const { OAuth, Config, QuoteContext, Period } = require('longbridge')
const oauth = await OAuth.build('your-client-id', (_, url) => console.log('Visit:', url));
const ctx = QuoteContext.new(Config.fromOAuth(oauth));
await ctx.subscribeCandlesticks("700.HK", Period.Min_1);
await new Promise((resolve) => setTimeout(resolve, 5000));
const resp = await ctx.realtimeCandlesticks("700.HK", Period.Min_1, 10);
for (let obj of resp) {
console.log(obj.toString());
}
Quote context