Last active
August 23, 2019 22:45
-
-
Save andrewkim316/3df8502446f2cf7d65430450cb975ac8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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