Last active
May 14, 2021 00:16
-
-
Save Silur/b88803352736bfbf2c20c5f291cf5826 to your computer and use it in GitHub Desktop.
Fuck you elon
This file contains hidden or 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
# This script will buy 1 DOGE on +5% ask price every time Elon tweets something slightly positive | |
import nltk, ccxt, re, time | |
import twitter | |
from nltk.sentiment import SentimentIntensityAnalyzer | |
twitter = twitter.Api(consumer_key='YOUR_TWITTER_CREDS', | |
consumer_secret='YOUR_TWITTER_CREDS', | |
access_token_key='YOUR_TWITTER_CREDS', | |
access_token_secret='YOUR_TWITTER_CREDS') | |
binance = ccxt.binance({ | |
'apiKey': 'YOUR_BINANCE_KEY', | |
'secret': 'YOUR_BINANCE_SECRET', | |
}) | |
sia = SentimentIntensityAnalyzer() | |
doge_filter = re.compile('.*doge.*') | |
last_tweet = '' | |
while True: | |
new_tweet = twitter.GetUserTimeline(screen_name='@elonmusk')[0] | |
if new_tweet == last_tweet: | |
time.sleep(5) | |
continue | |
last_tweet = new_tweet | |
if doge_filter.match(last_tweet['text'].lower()) is not None: | |
ask_price = binance.fetch_ticker('DOGE/USDT')['ask'] | |
result = sia.polarity_scores(last_tweet['text']) | |
if result['pos'] > 0.35 and result['neg'] < 0.1: | |
print(binance.id, binance.create_limit_buy_order('DOGE/USDT', 1, ask_price*1.05)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment