Skip to content

Instantly share code, notes, and snippets.

@andrewkim316
Last active August 23, 2019 22:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewkim316/3df8502446f2cf7d65430450cb975ac8 to your computer and use it in GitHub Desktop.
Save andrewkim316/3df8502446f2cf7d65430450cb975ac8 to your computer and use it in GitHub Desktop.
class LongShort {
constructor(API_KEY, API_SECRET, PAPER){
this.Alpaca = require('@alpacahq/alpaca-trade-api');
this.alpaca = new this.Alpaca({
keyId: API_KEY,
secretKey: API_SECRET,
paper: PAPER
});
this.allStocks = ['DOMO', 'TLRY', 'SQ', 'MRO', 'AAPL', 'GM', 'SNAP', 'SHOP', 'SPLK', 'BA', 'AMZN', 'SUI', 'SUN', 'TSLA', 'CGC', 'SPWR', 'NIO', 'CAT', 'MSFT', 'PANW', 'OKTA', 'TWTR', 'TM', 'RTN', 'ATVI', 'GS', 'BAC', 'MS', 'TWLO', 'QCOM'];
// Format the allStocks variable for use in the class.
var temp = [];
this.allStocks.forEach((stockName) => {
temp.push({name: stockName, pc: 0});
});
this.allStocks = temp.slice();
this.long = [];
this.short = [];
this.qShort = null;
this.qLong = null;
this.adjustedQLong = null;
this.adjustedQShort = null;
this.blacklist = new Set();
this.longAmount = 0;
this.shortAmount = 0;
this.timeToClose = null;
}
}
// Run the LongShort class
var ls = new LongShort(API_KEY, API_SECRET, PAPER);
ls.run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment