Skip to content

Instantly share code, notes, and snippets.

View andrewkim316's full-sized avatar
🙃
Proud user of Github Desktop

Andrew Kim andrewkim316

🙃
Proud user of Github Desktop
View GitHub Profile
const Alexa = require('ask-sdk-core');
const Alpaca = require('@alpacahq/alpaca-trade-api');
const keyId = "KEY_ID_HERE";
const secretKey = "SECRET_KEY_HERE";
const stock_dict = [
{"abbVie": "ABBV"},
{"apple": "AAPL"},
{"activision blizzard": "ATVI"},
const MarketOrderInProgressIntentHandler = {
canHandle(handlerInput) {
return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest'
&& Alexa.getIntentName(handlerInput.requestEnvelope) === 'MarketOrderIntent'
&& Alexa.getDialogState(handlerInput.requestEnvelope) !== 'COMPLETED';
},
handle(handlerInput) {
return handlerInput.responseBuilder
.addDelegateDirective()
.getResponse();
const stock_dict = [
{"abbVie": "ABBV"},
{"apple": "AAPL"},
{"activision blizzard": "ATVI"},
{"ak steel": "AKS"},
{"alibaba": "BABA"},
{"alphabet": "GOOGL"},
{"amazon": "AMZN"},
{"amd": "AMD"},
{"aphria": "APHA"},
const MarketOrderIntentHandler = {
// Triggers when user invokes a market order
canHandle(handlerInput) {
return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest'
&& Alexa.getIntentName(handlerInput.requestEnvelope) === 'MarketOrderIntent';
},
async handle(handlerInput) {
// Get user inputs and declare the Alpaca object
const slots = handlerInput.requestEnvelope.request.intent.slots;
const api = new Alpaca({
const CancelOrderIntentHandler = {
canHandle(handlerInput) {
return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest'
&& Alexa.getIntentName(handlerInput.requestEnvelope) === 'CancelOrderIntent';
},
async handle(handlerInput) {
// Get user inputs and declare the Alpaca object
const slots = handlerInput.requestEnvelope.request.intent.slots;
const api = new Alpaca({
keyId: keyId,
const ClearIntentHandler = {
canHandle(handlerInput) {
return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest'
&& Alexa.getIntentName(handlerInput.requestEnvelope) === 'ClearIntent';
},
async handle(handlerInput) {
// Get user inputs and declare the Alpaca object
const slots = handlerInput.requestEnvelope.request.intent.slots;
const api = new Alpaca({
keyId: keyId,
const AccountIntentHandler = {
// Triggers when user wants to lookup account info
canHandle(handlerInput) {
return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest'
&& Alexa.getIntentName(handlerInput.requestEnvelope) === 'AccountIntent';
},
async handle(handlerInput) {
// Get user inputs and declare the Alpaca object
const slots = handlerInput.requestEnvelope.request.intent.slots;
const api = new Alpaca({
const PositionsIntentHandler = {
// Triggers when user wants to look up positions
canHandle(handlerInput) {
return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest'
&& Alexa.getIntentName(handlerInput.requestEnvelope) === 'PositionsIntent';
},
async handle(handlerInput) {
// Get user inputs and declare the Alpaca object
const slots = handlerInput.requestEnvelope.request.intent.slots;
const api = new Alpaca({
const OrdersIntentHandler = {
// Triggers when user wants to look up orders
canHandle(handlerInput) {
return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest'
&& Alexa.getIntentName(handlerInput.requestEnvelope) === 'OrdersIntent';
},
async handle(handlerInput) {
// Get user inputs and declare the Alpaca object
const slots = handlerInput.requestEnvelope.request.intent.slots;
const api = new Alpaca({
const StopLimitOrderIntentHandler = {
// Triggers when user wants to execute a stop limit order
canHandle(handlerInput) {
return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest'
&& Alexa.getIntentName(handlerInput.requestEnvelope) === 'StopLimitOrderIntent';
},
async handle(handlerInput) {
// Get user inputs and declare the Alpaca object
const slots = handlerInput.requestEnvelope.request.intent.slots;
const api = new Alpaca({