-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for retrieving historical data for Futures and Opti…
…ons (#3)
- Loading branch information
1 parent
df5d392
commit 7b92c67
Showing
4 changed files
with
257 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { RestClientRequest } from "../../client"; | ||
|
||
export interface RestFutOptHistoricalCandlesParams { | ||
symbol: string; | ||
contractMonth?: string; | ||
from?: string; | ||
to?: string; | ||
fields?: string; | ||
timeframe?: string; | ||
} | ||
|
||
export interface RestFutOptHistoricalCandlesResponse { | ||
symbol: string; | ||
contractMonth?: string; | ||
exchange: string; | ||
timeframe: string; | ||
data: Array<{ | ||
date: string; | ||
open: number; | ||
high: number; | ||
low: number; | ||
close: number; | ||
volume: number; | ||
turnover: number; | ||
change: number; | ||
}>; | ||
} | ||
|
||
|
||
export const candles = (request: RestClientRequest, params: RestFutOptHistoricalCandlesParams) => { | ||
const { symbol, ...options } = params; | ||
return request(`historical/candles/${symbol}`, options) as Promise<RestFutOptHistoricalCandlesResponse>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { RestClientRequest } from "../../client"; | ||
|
||
export interface RestFutOptHistoricalDailyParams { | ||
symbol: string; | ||
date?: string; | ||
afterhours?: boolean; | ||
} | ||
|
||
export interface RestFutOptHistoricalDailyResponse { | ||
date: string; | ||
symbol: string; | ||
exchange: string; | ||
session: string; | ||
data: Array<{ | ||
contractMonth: string; | ||
openPrice: number; | ||
highPrice: number; | ||
lowPrice: number; | ||
closePrice: number; | ||
change: number; | ||
changePercent: number; | ||
volume: number; | ||
volumeSpread: number; | ||
openInterest: number; | ||
settlementPrice: number; | ||
}>; | ||
} | ||
|
||
export const daily = (request: RestClientRequest, params: RestFutOptHistoricalDailyParams) => { | ||
const { symbol, ...options } = params; | ||
return request(`historical/daily/${symbol}`, options) as Promise<RestFutOptHistoricalDailyResponse>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters