/**
 * Minified by jsDelivr using Terser v5.19.2.
 * Original file: /npm/yahoo-finance-data@3.2.0/lib/index.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
const yql=require("yql-node"),rp=require("request-promise"),Promise=require("bluebird");class YahooFinanceAPI{constructor(e){if(!e)throw new Error("You need to provide an API key and secret.");this.yql=yql.formatAsJSON().withOAuth(e.key,e.secret),this.yql.setQueryParameter({env:"store://datatables.org/alltableswithkeys",diagnostics:!0}),this.xhr=rp}fetch(e){return new Promise(((t,r)=>{this.yql.execute(e,((e,a)=>{e&&r({error:!0,message:e.message}),"object"==typeof a&&t(a);try{const e=JSON.parse(a);t(e)}catch(e){r({error:!0,message:e.message})}}))}))}ajax(e){return new Promise(((t,r)=>{this.xhr(e).then((e=>{try{const r=JSON.parse(e);t(r)}catch(e){r({error:!0,message:e.message})}})).catch((e=>{r({error:!0,message:e.message})}))}))}uppercaseList(e){return e.split(",").map((e=>e.toUpperCase())).join(",")}getRealtimeQuotes(e){const t=`select * from pm.finance where symbol="${this.uppercaseList(e)}"`;return this.fetch(t)}getHistoricalData(e,t="1d",r="1y"){const a=`https://query1.finance.yahoo.com/v8/finance/chart/${e}?formatted=true&lang=en-US&region=US&interval=${t}&events=div%7Csplit&range=${r}&corsDomain=finance.yahoo.com`;return this.ajax(a)}getForexData(e){const t=e.split(",").map((e=>e.toUpperCase()+"=X")).join(",");return this.commodities(t)}getHeadlinesByTicker(e){const t=`select * from pm.finance.articles where symbol in ("${e.toUpperCase()}")`;return this.fetch(t)}getIntradayChartData(e,t="2m",r=!0){const a=`https://query1.finance.yahoo.com/v8/finance/chart/${e}?range=1d&includePrePost=${r}&interval=${t}&corsDomain=finance.yahoo.com&.tsrc=finance`;return this.ajax(a)}tickerSearch(e,t="US",r="en-US"){const a=`http://d.yimg.com/aq/autoc?query=${encodeURIComponent(e)}&region=${t}&lang=${r}`;return this.ajax(a)}quoteSummary(e){const t=`https://query2.finance.yahoo.com/v10/finance/quoteSummary/${e}?formatted=true&lang=en-US&region=US&modules=assetProfile%2CsecFilings&corsDomain=finance.yahoo.com`;return this.ajax(t)}optionChain(e){const t=`https://query2.finance.yahoo.com/v7/finance/options/${e}?formatted=true&lang=en-US&region=US&corsDomain=finance.yahoo.com`;return this.ajax(t)}recommendations(e){const t=`https://query1.finance.yahoo.com/v6/finance/recommendationsbysymbol/${e}`;return this.ajax(t)}futures(e,t="5d",r="1d",a=!1){const n=`https://query1.finance.yahoo.com/v8/finance/chart/${e}?range=${t}&includePrePost=${a}&interval=${r}&corsDomain=finance.yahoo.com&.tsrc=finance`;return this.ajax(n)}commodities(e,t="1d",r="5m",a=!1){const n=`https://query1.finance.yahoo.com/v7/finance/spark?symbols=${e}&range=${t}&interval=${r}&indicators=close&includeTimestamps=true&includePrePost=${a}&corsDomain=finance.yahoo.com&.tsrc=finance`;return this.ajax(n)}}module.exports=YahooFinanceAPI;
//# sourceMappingURL=/sm/03170712bd548d0d563b923c75f9ee0cb961615670a4536a8e891d173f5eeb7c.map