sprgn / MTEEBot-main

Modular Trading Execution Engine

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MTEEBot Modular Trade Execution Engine (MTEEBot TEE)

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)

This is not a financial advisor. USE AT YOUR OWN RISK.

DISCLAIMER: This software is provided AS IS. It is not responsible for any financial loss or gain.

This project is independent and not affiliated with the signal provider

How to use

Once you clone this repository run: npm install to install all dependencies

Once dependencies are installed run: npm start in your terminal

Before you start

You will need two accounts:

  1. Twitter Developer Account: https://developer.twitter.com/
  2. Alpaca Account: https://www.alpaca.markets

From the Twitter Developer account you will need to get:

  1. consumer_api_key
  2. consumer_api_secret
  3. access_token_key
  4. access_token_secret

From the Alpaca Paper Trading Account you will need to get

  1. keyId
  2. 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

OTHER NOTES

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" },
        ]
    }
}

Follow yourself

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/

Authorize Trades From Yourself

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.

TESTING

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.

About

Modular Trading Execution Engine

License:MIT License


Languages

Language:TypeScript 100.0%