-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
* feat: Place order fixes, wWsJsonClient as interface * fix package exports * remove unneeded disclaimer * prettier * minor nits
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,182 @@ | ||
import { WsJsonClient } from "./wsJsonClient"; | ||
import { PositionsResponse } from "./services/positionsMessageHandler"; | ||
import { RawLoginResponseBody } from "./services/loginMessageHandler"; | ||
import { AlertsResponse } from "./types/alertTypes"; | ||
import { CancelOrderResponse } from "./services/cancelOrderMessageHandler"; | ||
import { | ||
ChartRequestParams, | ||
ChartResponse, | ||
} from "./services/chartMessageHandler"; | ||
import { CreateAlertRequestParams } from "./services/createAlertMessageHandler"; | ||
import { OptionChainResponse } from "./services/optionSeriesMessageHandler"; | ||
import { | ||
OptionChainDetailsRequest, | ||
OptionChainDetailsResponse, | ||
} from "./services/optionChainDetailsMessageHandler"; | ||
import { OptionSeriesQuotesResponse } from "./services/optionSeriesQuotesMessageHandler"; | ||
import { | ||
OptionQuotesRequestParams, | ||
OptionQuotesResponse, | ||
} from "./services/optionQuotesMessageHandler"; | ||
import { | ||
PlaceLimitOrderRequestParams, | ||
PlaceOrderSnapshotResponse, | ||
} from "./services/placeOrderMessageHandler"; | ||
import { OrderEventsResponse } from "./services/orderEventsMessageHandler"; | ||
import { QuotesResponse } from "./services/quotesMessageHandler"; | ||
import { InstrumentSearchResponse } from "./services/instrumentSearchMessageHandler"; | ||
import { UserPropertiesResponse } from "./services/userPropertiesMessageHandler"; | ||
|
||
export default class MockWsJsonClient implements WsJsonClient { | ||
async *accountPositions(_: string): AsyncIterable<PositionsResponse> { | ||
Check warning on line 31 in src/client/mockWsJsonClient.ts GitHub Actions / build (16.x)
Check warning on line 31 in src/client/mockWsJsonClient.ts GitHub Actions / build (18.x)
|
||
return yield { | ||
positions: [], | ||
}; | ||
} | ||
|
||
authenticate(): Promise<RawLoginResponseBody | null> { | ||
return Promise.resolve(null); | ||
} | ||
|
||
cancelAlert(_: number): Promise<AlertsResponse> { | ||
Check warning on line 41 in src/client/mockWsJsonClient.ts GitHub Actions / build (16.x)
Check warning on line 41 in src/client/mockWsJsonClient.ts GitHub Actions / build (18.x)
|
||
return Promise.resolve({ | ||
alerts: [], | ||
}); | ||
} | ||
|
||
cancelOrder(_: number): Promise<CancelOrderResponse> { | ||
Check warning on line 47 in src/client/mockWsJsonClient.ts GitHub Actions / build (16.x)
Check warning on line 47 in src/client/mockWsJsonClient.ts GitHub Actions / build (18.x)
|
||
return Promise.resolve({ | ||
service: "cancel_order", | ||
orderId: 123, | ||
type: "snapshot", | ||
body: {}, | ||
}); | ||
} | ||
|
||
async *chart(_: ChartRequestParams): AsyncIterable<ChartResponse> { | ||
Check warning on line 56 in src/client/mockWsJsonClient.ts GitHub Actions / build (16.x)
Check warning on line 56 in src/client/mockWsJsonClient.ts GitHub Actions / build (18.x)
|
||
return yield { | ||
symbol: "", | ||
candles: [], | ||
}; | ||
} | ||
|
||
createAlert(_: CreateAlertRequestParams): Promise<AlertsResponse> { | ||
Check warning on line 63 in src/client/mockWsJsonClient.ts GitHub Actions / build (16.x)
Check warning on line 63 in src/client/mockWsJsonClient.ts GitHub Actions / build (18.x)
|
||
return Promise.resolve({ | ||
alerts: [], | ||
}); | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-empty-function | ||
disconnect(): void {} | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-empty-function | ||
ensureConnected(): void {} | ||
|
||
isConnected(): boolean { | ||
return true; | ||
} | ||
|
||
isConnecting(): boolean { | ||
return false; | ||
} | ||
|
||
async *lookupAlerts(): AsyncIterable<AlertsResponse> { | ||
return yield { | ||
alerts: [], | ||
}; | ||
} | ||
|
||
optionChain(_: string): Promise<OptionChainResponse> { | ||
Check warning on line 89 in src/client/mockWsJsonClient.ts GitHub Actions / build (16.x)
Check warning on line 89 in src/client/mockWsJsonClient.ts GitHub Actions / build (18.x)
|
||
return Promise.resolve({ | ||
series: [], | ||
service: "optionSeries", | ||
}); | ||
} | ||
|
||
optionChainDetails( | ||
_: OptionChainDetailsRequest | ||
Check warning on line 97 in src/client/mockWsJsonClient.ts GitHub Actions / build (16.x)
Check warning on line 97 in src/client/mockWsJsonClient.ts GitHub Actions / build (18.x)
|
||
): Promise<OptionChainDetailsResponse> { | ||
return Promise.resolve({ | ||
seriesDetails: [], | ||
}); | ||
} | ||
|
||
async *optionChainQuotes( | ||
_: string | ||
Check warning on line 105 in src/client/mockWsJsonClient.ts GitHub Actions / build (16.x)
Check warning on line 105 in src/client/mockWsJsonClient.ts GitHub Actions / build (18.x)
|
||
): AsyncIterable<OptionSeriesQuotesResponse> { | ||
return yield { | ||
series: [], | ||
service: "optionSeries/quotes", | ||
}; | ||
} | ||
|
||
async *optionQuotes( | ||
_: OptionQuotesRequestParams | ||
Check warning on line 114 in src/client/mockWsJsonClient.ts GitHub Actions / build (16.x)
Check warning on line 114 in src/client/mockWsJsonClient.ts GitHub Actions / build (18.x)
|
||
): AsyncIterable<OptionQuotesResponse> { | ||
return yield { | ||
items: [], | ||
service: "quotes/options", | ||
}; | ||
} | ||
|
||
placeOrder( | ||
_: PlaceLimitOrderRequestParams | ||
Check warning on line 123 in src/client/mockWsJsonClient.ts GitHub Actions / build (16.x)
Check warning on line 123 in src/client/mockWsJsonClient.ts GitHub Actions / build (18.x)
|
||
): Promise<PlaceOrderSnapshotResponse> { | ||
return Promise.resolve({ | ||
service: "place_order", | ||
orders: [], | ||
}); | ||
} | ||
|
||
async *quotes(_: string[]): AsyncIterable<QuotesResponse> { | ||
return yield { | ||
quotes: [], | ||
}; | ||
} | ||
|
||
replaceOrder( | ||
_: Required<PlaceLimitOrderRequestParams> | ||
): Promise<OrderEventsResponse> { | ||
return Promise.resolve({ | ||
service: "order_events", | ||
orders: [], | ||
}); | ||
} | ||
|
||
searchInstruments(_: string): Promise<InstrumentSearchResponse> { | ||
return Promise.resolve({ | ||
instruments: [], | ||
}); | ||
} | ||
|
||
userProperties(): Promise<UserPropertiesResponse> { | ||
return Promise.resolve({ | ||
defaultAccountCode: "foo", | ||
nickname: "foo", | ||
plDisplayMethod: "foo", | ||
stocksOrderDefaultType: "foo", | ||
stocksOrderDefaultQuantity: 0, | ||
stocksOrderQuantityIncrement: 0, | ||
optionsOrderDefaultType: "foo", | ||
optionsOrderDefaultQuantity: 0, | ||
optionsOrderQuantityIncrement: 0, | ||
futuresOrderOrderDefaultType: "foo", | ||
futuresOrderDefaultType: "foo", | ||
futuresOrderDefaultQuantity: 0, | ||
futuresOrderQuantityIncrement: 0, | ||
futureOptionsOrderDefaultType: "foo", | ||
futureOptionsOrderDefaultQuantity: 0, | ||
futureOptionsOrderQuantityIncrement: 0, | ||
forexOrderDefaultType: "foo", | ||
forexOrderDefaultQuantity: 0, | ||
forexOrderQuantityIncrement: 0, | ||
}); | ||
} | ||
|
||
async *workingOrders(_: string): AsyncIterable<OrderEventsResponse> { | ||
return yield { | ||
orders: [], | ||
service: "order_events", | ||
}; | ||
} | ||
} |