It will listen to Twitter signals from:
"Trade Spotter" (@TipperBeats)
And will execute all signals as paper trades on:
Alpaca Stock Brokerage (www.alpaca.markets)
Once you clone this repository run: npm install
to install all dependencies
Once dependencies are installed run: npm start
in your terminal
- Twitter Developer Account: https://developer.twitter.com/
- Alpaca Account: https://www.alpaca.markets
- consumer_api_key
- consumer_api_secret
- access_token_key
- access_token_secret
- keyId
- secretKey
IF YOU RESET YOUR ALPACA PAPER TRADING ACCOUNT YOU WILL NEED TO RE-GENERATE YOUR KEYS OR THE APP WILL NOT WORK
Once you have all credentials open the src/settings.ts
file and add your credentials:
twitter: {
api: {
consumer_key: '--- TWITTER CONSUMER API KEY HERE ---',
consumer_secret: '--- TWITTER CONSUMER API SECRET HERE ---',
access_token_key: '--- TWITTER AUTHENTICATION ACCESS TOKEN KEY HERE ---',
access_token_secret: '--- TWITTER AUTHENTICATION ACCESS TOKEN SECRET HERE --- ',
},
followUsers: [
{ name: "@TipperBeats", id: "1385168716258742272" },
],
authorizedSignalsFromUsers: ['@TipperBeats']
},
alpaca: {
accountName: 'Paper Account',
api: {
keyId: '--- ALPACA API KEY HERE ---',
secretKey: '--- ALPACA SECRET KEY HERE ---',
},
trades: {
amountPerTradeInDollars: 10000
}
},
Don't forget to set the amount you want to trade per signal, default is set to $10,000
Since TipperBeats does not provide a stop loss, rather positions are held until the end of the day we set the stop loss to be equal distance from the entry price to the profit target. This can be modified based on your risk tolerance.
This setup will only follow (and trade) "TradeSpotter" (@Tipperbeats):
{
twitter: {
followUsers: [
{ name: "@TipperBeats", id: "1385168716258742272" },
]
}
}
You can follow yourself as well. This is good for testing and making sure the twitter stream is set up and working. If you add yourself and tweet something, you should see your tweet show up in the terminal. To add yourself:
{
twitter: {
followUsers: [
{ name: "@TipperBeats", id: "1385168716258742272" },
{ name: "@my-twitter-handle", id: "my-id-number" },
]
}
}
HOW TO GET YOUR TWITTER ID: To get your Twitter ID # go to: https://www.codeofaninja.com/tools/find-twitter-id/
Currently, the only authorized signals are from twitter user @TipperBeats. That is evident in the src/settings.ts
file:
{
twitter: {
authorizedSignalsFromUsers: ['@TipperBeats']
}
}
You can add yourself to that list (but you also must add yourself to the followUsers
list as well). Such as:
{
twitter: {
followUsers: [
{ name: "@TipperBeats", id: "1385168716258742272" },
{ name: "@my-twitter-handle", id: "my-id-number" },
],
authorizedSignalsFromUsers: ['@TipperBeats', '@my-twitter-handle']
}
}
Then, as long as you follow the Tweet format from you can tweet out and the engine will execute your paper trade. This is great for testing and making sure the system is working properly.
NOTE: You can test and execute trades on Alpaca even when markets are closed. The trade will show up in the order history as
accepted/held
and wont be executed until the markets open. You can always go in any time and cancel it yourself manually.
There are a couple of quick tests at the bottom of the src/index.ts
file that are commented out. You can uncomment them and run them individually to test that the system is working properly. All credentials must be added to the src/settings.ts
file before any tests can run.