Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

small QOL changes #13

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 37 additions & 12 deletions news-analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,37 @@
# Use each list to define keywords separated by commas: 'XRP': ['ripple', 'xrp']
# keywords are case sensitive
keywords = {
'XRP': ['ripple', 'xrp', 'XRP', 'Ripple', 'RIPPLE'],
'BTC': ['BTC', 'bitcoin', 'Bitcoin', 'BITCOIN'],
'XLM': ['Stellar Lumens', 'XLM'],
#'BCH': ['Bitcoin Cash', 'BCH'],
'ETH': ['ETH', 'Ethereum'],
'BNB' : ['BNB', 'Binance Coin'],
'LTC': ['LTC', 'Litecoin']
'XRP': ['ripple', 'xrp', 'XRP', 'Ripple', 'RIPPLE'],
# 'DOGE':['DOGE','Doge','DOGECOIN','Dogecoin','dogecoin'],
# 'ADA': ['ADA', 'Cardano', 'CARDANO'],
# 'LTC': ['LTC', 'Litecoin'],
# 'BCH': ['Bitcoin Cash', 'BCH'],
# 'COCOS':['COCOS','Cocos-BCX','Cocos'],
# 'LINK':['LINK','Chainlink'],
# 'VET': ['VET','VeChain'],
# 'XLM': ['Stellar Lumens', 'XLM'],
# 'THETA': ['Theta Token', 'THETA'],
# 'EOS': ['EOS'],
# 'NEO': ['NEO'],
# 'IOTA': ['IOTA','MIOTA'],
# 'XMR': ['XMR','Moreno','MORENO'],
# 'FTT': ['FTT','FTX Token'],
# 'ATOM': ['ATOM','COSMOS','Cosmos'],
# 'ALGO': ['ALGO','Algorand'],
# 'XTZ': ['XTZ','Tezos'],
# 'XEM': ['XEM','NEM'],
# 'DASH': ['DASH','Dash'],
# 'ZIL': ['ZIL', 'Zilliqa', 'ZILLIQA'],
# 'QTUM': ['QTUM','Qtum'],
# 'ZRX' :['ZRX','0x','0X'],
# 'ZEC': ['ZEC','Zcash'],
# 'DATA':['DATA','Streamr Network'],
# 'ICX' :['ICX','ICON'],
# '1INCH': ['1INCH', '1inch'],
# 'KAVA':['KAVA','Kava'],
'BTC': ['BTC', 'bitcoin', 'Bitcoin', 'BITCOIN']
}

# The Buy amount in the PAIRING symbol, by default USDT
Expand All @@ -84,8 +108,8 @@
# define how positive the news should be in order to place a trade
# the number is a compound of neg, neu and pos values from the nltk analysis
# input a number between -1 and 1
SENTIMENT_THRESHOLD = 0
NEGATIVE_SENTIMENT_THRESHOLD = 0
BUY_SENTIMENT_THRESHOLD = 0
SELL_SENTIMENT_THRESHOLD = 0

# define the minimum number of articles that need to be analysed in order
# for the sentiment analysis to qualify for a trade signal
Expand Down Expand Up @@ -255,7 +279,7 @@ async def get_headlines():
# This makes sure we finish all tasks/requests before we continue executing our code
await asyncio.gather(*tasks)
end = timer()
print("Time it took to parse feeds: ", end - start)
print("\nTime it took to parse feeds: ", end - start)


def categorise_headlines():
Expand Down Expand Up @@ -341,10 +365,11 @@ def buy(compiled_sentiment, headlines_analysed):
for coin in compiled_sentiment:

# check if the sentiment and number of articles are over the given threshold
if compiled_sentiment[coin] > SENTIMENT_THRESHOLD and headlines_analysed[coin] >= MINUMUM_ARTICLES:
if compiled_sentiment[coin] > BUY_SENTIMENT_THRESHOLD and headlines_analysed[coin] >= MINUMUM_ARTICLES:

# check the volume looks correct
print(f'preparing to buy {volume[coin+PAIRING]} {coin} with {PAIRING} at {CURRENT_PRICE[coin+PAIRING]}')
print(f'preparing to buy {volume[coin+PAIRING]} {coin} at rate 1 {coin} /{CURRENT_PRICE[coin+PAIRING]} USDT')
#print(f'preparing to buy {volume[coin+PAIRING]} {coin} with {PAIRING} at {CURRENT_PRICE[coin+PAIRING]}')

# create test order before pushing an actual order
test_order = client.create_test_order(symbol=coin+PAIRING, side='BUY', type='MARKET', quantity=volume[coin+PAIRING])
Expand Down Expand Up @@ -396,10 +421,10 @@ def sell(compiled_sentiment, headlines_analysed):
for coin in compiled_sentiment:

# check if the sentiment and number of articles are over the given threshold
if compiled_sentiment[coin] < NEGATIVE_SENTIMENT_THRESHOLD and headlines_analysed[coin] >= MINUMUM_ARTICLES and coins_in_hand[coin]>0:
if compiled_sentiment[coin] < SELL_SENTIMENT_THRESHOLD and headlines_analysed[coin] >= MINUMUM_ARTICLES and coins_in_hand[coin]>0:

# check the volume looks correct
print(f'preparing to sell {coins_in_hand[coin]} {coin} at {CURRENT_PRICE[coin+PAIRING]}')
print(f'preparing to sell {coins_in_hand[coin]} {coin} at rate 1 {coin} /{CURRENT_PRICE[coin+PAIRING]} USDT')

# create test order before pushing an actual order
test_order = client.create_test_order(symbol=coin+PAIRING, side='SELL', type='MARKET', quantity=coins_in_hand[coin]*99.5/100 )
Expand Down