· 6 years ago · Jul 30, 2019, 02:56 PM
1class LongShort {
2 constructor(API_KEY, API_SECRET, PAPER){
3 this.Alpaca = require('@alpacahq/alpaca-trade-api');
4 this.alpaca = new this.Alpaca({
5 keyId: API_KEY,
6 secretKey: API_SECRET,
7 paper: PAPER
8 });
9
10 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'];
11 // Format the allStocks variable for use in the class.
12 var temp = [];
13 this.allStocks.forEach((stockName) => {
14 temp.push({name: stockName, pc: 0});
15 });
16 this.allStocks = temp.slice();
17
18 this.long = [];
19 this.short = [];
20 this.qShort = null;
21 this.qLong = null;
22 this.adjustedQLong = null;
23 this.adjustedQShort = null;
24 this.blacklist = new Set();
25 this.longAmount = 0;
26 this.shortAmount = 0;
27 this.timeToClose = null;
28 }
29}
30
31// Run the LongShort class
32var ls = new LongShort(API_KEY, API_SECRET, PAPER);
33ls.run();