Skip to content

Instantly share code, notes, and snippets.

Avatar
🙃
Proud user of Github Desktop

Andrew Kim andrewkim316

🙃
Proud user of Github Desktop
View GitHub Profile
View alexa-allCh1.js
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"},
View alexa-marketProgress.js
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();
View alexa-stockDict.js
const stock_dict = [
{"abbVie": "ABBV"},
{"apple": "AAPL"},
{"activision blizzard": "ATVI"},
{"ak steel": "AKS"},
{"alibaba": "BABA"},
{"alphabet": "GOOGL"},
{"amazon": "AMZN"},
{"amd": "AMD"},
{"aphria": "APHA"},
View alexa-market.js
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({
View alexa-cancel.js
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,
View alexa-clear.js
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,
View alexa-account.js
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({
View alexa-positions.js
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({
View alexa-orders.js
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({
View alexa-stopLimit.js
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({