def main():
    config.load_config()
    print "Notifying users of upcoming items"

    for user in config.get_users():
        dataset = config.get_random_dataset()

        from common import random_date
        from datetime import datetime, timedelta

        start = datetime.now()
        end = datetime.now() + timedelta(days=60)
        date = random_date(start, end)

        address = common.generate_token_and_address(user, dataset.get('name'),
                                                    date)
        common.send_notification(user, "data.gov.uk <{}>".format(address),
                                 dataset)
Example #2
0
def get_users_info():
    from config import get_users
    users = get_users()

    exchange_dict = {}
    telegram_id_dict = {}

    for user in users:
        API_KEY = users[user]['API_KEY']
        SECRET_KEY = users[user]['SECRET_KEY']
        PASSPHRASE = users[user]['PASSPHRASE']
        if users[user]['exchange'].lower() == 'binance':
            exchange = Binance(API_KEY, SECRET_KEY)
            exchange_dict[user] = exchange
        elif users[user]['exchange'].lower() == 'coinbase':
            exchange = CoinbasePro(API_KEY, SECRET_KEY, PASSPHRASE)
            exchange_dict[user] = exchange

        telegram_id = users[user]['telegram_id']
        telegram_id_dict[user] = telegram_id

    return users, exchange_dict, telegram_id_dict
Example #3
0
                inplace=True)
    data.to_sql(name='stockdata_stage',
                con=engine,
                if_exists='append',
                index=False)

    connection = engine.connect()
    result = connection.execute(
        "replace into stockdata select * from stockdata_stage")
    print("replace into, return : ")

    print("clean stage table")
    result = connection.execute("delete from stockdata_stage")


_users = config.get_users()
_passwords = config.get_passwords()

if __name__ == "__main__":
    print("try to use db connection " + config.config['db_url'])
    print("THS login")
    ret = THS_iFinDLogin(_users[0], _passwords[0])
    print("ths login return : " + str(ret))

    if False:
        codes = '600026.SH,600027.SH'
        dt_from = '2018-04-03 09:15:00'
        dt_to = '2018-04-03 10:15:00'
    if False:
        THS_HighFrequenceSequence(
            '600028.SH,600029.SH,600030.SH,600031.SH,600033.SH,600035.SH,600036.SH,600037.SH,600038.SH,600039.SH,600048.SH,600050.SH',
Example #4
0
from bs4 import BeautifulSoup
from telethon import events

import sys
sys.path.append('../')

from Binance import BinanceException, Binance
from Secrets import api_id, api_hash  #insert here your Binance API keys
from config import get_users
from utils import *

client = TelegramClient('DCAVG_bot_session', api_id, api_hash).start()
users_path = '../datasets/users.csv'
data_path = '../datasets/data.csv'

users = get_users(users_path, data_path)


@client.on(events.NewMessage())
async def my_event_handler(event):
    sender = await event.get_sender()
    print(sender.username, str(event.chat_id))

    if 'start' in event.text:
        users = pd.read_csv(users_path)
        if sender.username in list(users.telegram_username):
            rows = users[users.telegram_username == sender.username].index
            for row_index in rows:
                users.loc[row_index, 'telegram_id'] = event.chat_id
            users.to_csv(users_path, index=False)
            await event.respond(