import { Config , OrderSide } from '../types' ; import { Bar , Instrument , Order , Orderbook , Position } from './internal' ; import { RestBarRequest , RestBarResponse , RestFetchOrderRequest , RestFetchPositionRequest , RestInstrumentResponse , RestOrderRequest , RestOrderResponse , RestOrderbookL2Response , RestOrderbookRequest , RestOrdersResponse , RestPositionsResponse , } from './types' ; export class RestBase { protected readonly instrument : Instrument ; protected readonly order : Order ; protected readonly orderbook : Orderbook ; protected readonly bar : Bar ; protected readonly position : Position ; constructor ( config ) { const cfg = { apiKey : '' , apiSecret : '' , testnet : false , ... config , } ; this . instrument = new Instrument ( cfg ) ; this . order = new Order ( cfg ) ; this . orderbook = new Orderbook ( cfg ) ; this . bar = new Bar ( cfg ) ; this . position = new Position ( cfg ) ; } async createOrder ( request ) { return this . order . create ( request ) ; } async fetchOrder ( request ) { return this . order . fetch ( request ) ; } async updateOrder ( request ) { return this . order . update ( request ) ; } async cancelOrder ( request ) { return this . order . cancel ( request ) ; } async fetchOrderbook ( request ) { return this . orderbook . fetch ( request ) ; } async fetchInstrument ( ) { return this . instrument . fetch ( ) ; } async fetchBar ( request ) { return this . bar . fetch ( request ) ; } async fetchPosition ( request ) { return this . position . fetch ( request ) ; } async createPosition ( symbol , side , amount ) { return this . position . create ( symbol , side , amount ) ; } async removePosition ( symbol ) { return this . position . remove ( symbol ) ; } }