robinhood-typescript
Advanced tools
Comparing version 1.9.0 to 1.10.0
@@ -26,3 +26,4 @@ import { AccountsLoaded } from './models/account'; | ||
placeOrders(orderType: 'share' | 'dollar', side: 'buy' | 'sell', symbol: string, amount: number): Promise<PlaceOrder>; | ||
cancelOrder(orderID: string): Promise<any>; | ||
} | ||
export default RobinhoodAPI; |
@@ -215,3 +215,15 @@ "use strict"; | ||
} | ||
async cancelOrder(orderID) { | ||
const config = { | ||
headers: { Authorization: `Bearer ${this._authToken}` }, | ||
}; | ||
try { | ||
const response = await axios_1.default.post(`${defaults_1.apiUrl}${defaults_1.endpoints.cancel_order}${orderID}/cancel/`, {}, config); | ||
return response.data; | ||
} | ||
catch (error) { | ||
return error; | ||
} | ||
} | ||
} | ||
exports.default = RobinhoodAPI; |
{ | ||
"name": "robinhood-typescript", | ||
"version": "1.9.0", | ||
"version": "1.10.0", | ||
"description": "NodeJS Framework to make trades with the private Robinhood API. Using this API is not encouraged, since it's not officially available and it has been reverse engineered. See @Sanko's Unofficial Documentation for more information.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -575,1 +575,25 @@ import RobinhoodAPI from '../index'; | ||
}); | ||
describe('cancel orders', () => { | ||
test('successfully cancelled order', async () => { | ||
const api = new RobinhoodAPI('token'); | ||
const data = {}; | ||
mockedAxios.post.mockResolvedValue({ data }); | ||
const cancelOrder = await api.cancelOrder('903c2ded-10a6-40c3-b98c-7bff48827921'); | ||
expect(cancelOrder).toEqual(data); | ||
}); | ||
test('order not cancelled', async () => { | ||
const api = new RobinhoodAPI('token'); | ||
const errorMessage = 'unable to cancel order'; | ||
mockedAxios.post.mockRejectedValue({ errorMessage }); | ||
const cancelOrder = await api.cancelOrder('903c2ded - 10a6 - 40c3 - b98c - 7bff48827921'); | ||
expect(cancelOrder).toEqual({ errorMessage }); | ||
}); | ||
}); |
@@ -267,4 +267,16 @@ import { apiUrl, endpoints } from './models/defaults'; | ||
} | ||
async cancelOrder(orderID: string) { | ||
const config = { | ||
headers: { Authorization: `Bearer ${this._authToken}` }, | ||
}; | ||
try { | ||
const response = await axios.post(`${apiUrl}${endpoints.cancel_order}${orderID}/cancel/`, {}, config); | ||
return response.data; | ||
} catch (error) { | ||
return error; | ||
} | ||
} | ||
} | ||
export default RobinhoodAPI; |
Sorry, the diff of this file is too big to display
592493
15198