Example #1
0
print(
    f'Запускаем анализ всех пар по валюте {sBase}. Выводы в estimation.txt \n')

# будем писать в файл

sys.stdout = open('estimation.txt', 'wt', encoding='utf-8')

# подключаемся к бирже
bot = Binance(API_KEY='D7...Ejj', API_SECRET='gwQ...u3A')

#  интересующие пары
lPairs = []

# данные по торгуемым парам

lExchangeInfo = bot.exchangeInfo()
iCountPair = 0
lTicker = []
for lEI in lExchangeInfo['symbols']:
    # print(lEI)
    # print(lEI['status'])
    if (lEI['status'] == 'TRADING') and ((lEI['baseAsset'] == sBase) or
                                         (lEI['quoteAsset'] == sBase)):
        lTicker24h = bot.ticker24hr(symbol=lEI['symbol'])
        if lEI['baseAsset'] == sBase:
            lPairs.append([
                lEI['symbol'], lEI['baseAsset'], lEI['quoteAsset'],
                float(lTicker24h['volume'])
            ])
        else:
            lPairs.append([
Example #2
0
settings = dict(
    symbol='EOSBTC',            # Пара для отслеживания
    strategy="Short",           # Стратегия - Long (повышение), Short (понижение)           
    stop_loss_perc = 0.5,       # % оставания от цены
    stop_loss_fixed = 0,        # Изначальный stop-loss, можно установить руками нужную сумму, потом бот подтянет.
                                # Можно указать 0, тогда бот высчитает, возьмет текущую цену и применит к ней процент
    amount = 0.0015             # Кол-во монет, которое планируем продать (в случае Long) или купить (в случае Short)
                                # Если указываем Long, то альты для продажи (Например, продать 0.1 ETH в паре ETHBTC)
                                # Если Short, то кол-во, на которое покупать, например купить на 0.1 BTC по паре ETHBTC
)

multiplier = -1 if settings['strategy'] == "Long" else 1

print("Получаем настройки пар с биржи")
symbols = bot.exchangeInfo()['symbols']
step_sizes = {symbol['symbol']:symbol for symbol in symbols}
for symbol in symbols:
    for f in symbol['filters']:
        if f['filterType'] == 'LOT_SIZE':
            step_sizes[symbol['symbol']] = float(f['stepSize'])


while True:
    try:
        print('Проверяю пару {pair}, стратегия {strategy}'.format(pair=settings['symbol'], strategy=settings['strategy']))
        # Получаем текущие курсы по паре
        current_rates = bot.depth(symbol=settings['symbol'], limit=5)

        bid=float(current_rates['bids'][0][0])
        ask=float(current_rates['asks'][0][0])
Example #3
0
import our_library
'''
bot = binance_api.Binance(
    API_KEY='qRmmGsVlut46jEAYV6oKu6QuvEOrKPkg5aflmYkgmvOglBBbVl0ixMn8u1pf82sc',
    API_SECRET='GGw5Rr5fan9JC1dIhfyQMM5JFR5riPgCcM9wCUOk5NkUDbBaARAajKPlqUi1gx9R'
)
'''

from binance_api import Binance

bot = Binance(
    API_KEY='qRmmGsVlut46jEAYV6oKu6QuvEOrKPkg5aflmYkgmvOglBBbVl0ixMn8u1pf82sc',
    API_SECRET=
    'GGw5Rr5fan9JC1dIhfyQMM5JFR5riPgCcM9wCUOk5NkUDbBaARAajKPlqUi1gx9R')

data = bot.exchangeInfo()
our_library.record_in_file('exchangeInfo', data)
'''
data = bot.depth(symbol='BNBBTC')
our_library.record_in_file('depth', data)

data = bot.trades(symbol='BNBBTC')
our_library.record_in_file('trades', data)
'''
#data = bot.historicalTrades(symbol='BNBBTC', limit=5)
#our_library.record_in_file('historicalTrades', data)
'''
data = bot.aggTrades(symbol='BNBBTC')
our_library.record_in_file('aggTrades', data)

data = bot.klines(symbol='BNBBTC', interval='5m')
Example #4
0
        False,  # Do I need to sell at a loss when the price drops
        'stop_loss':
        2,  # 2% - How much should the price fall to sell at a loss
    }
]

BUY_LIFE_TIME_SEC = 180  # How many(in seconds) to keep a sell order open

STOCK_FEE = 0.00075  # Commission taken by the exchange(0.001 = 0.1%)

# If you decide not to pay a fee in BNB, then set it to False.This is usually not necessary.
USE_BNB_FEES = True

# We get trading restrictions for all pairs from the exchange
local_time = int(time.time())
limits = bot.exchangeInfo()
server_time = int(limits['serverTime']) // 1000


# F-tion, which leads any number to a number multiple of the step indicated by the exchange
# If you pass the parameter increase = True, then rounding will occur to the next step
def adjust_to_step(value, step, increase=False):
    return ((int(value * 100000000) -
             int(value * 100000000) % int(float(step) * 100000000)) /
            100000000) + (float(step) if increase else 0)


# Connect logging
logging.basicConfig(format="%(asctime)s[%(levelname)-5.5s] %(message)s",
                    level=logging.DEBUG,
                    handlers=[
Example #5
0
coin1 = 'LOOM'
coin2 = 'BTC'
settings = dict(
    symbol=coin1 + coin2,  # Пара для отслеживания
    strategy="SELL",  # Стратегия - SELL (повышение), BUY (понижение)           
    stop_loss_perc=1,  # % оставания от цены
    stop_loss_fixed=
    0.00006000,  # Изначальный stop-loss, можно установить руками нужную сумму, потом бот подтянет.
    # Можно указать 0, тогда бот высчитает, возьмет текущую цену и применит к ней процент
    amount=
    0.00001  # Кол-во монет, которое планируем продать (в случае SELL) или купить (в случае BUY)
    # Если указываем SELL, то альты для продажи (Например, продать 0.1 ETH в паре ETHBTC)
)  # Если BUY, то кол-во, на которое покупать, например купить на 0.1 BTC по паре ETHBTC

# Получаем ограничения торгов по всем парам с биржи
limits = bot.exchangeInfo()  # Наши жесткие ограничения перечислены


def fBalance(coin):  # Получаем балансы с биржи по указанным валютам
    return {
        balance['asset']: float(balance['free'])
        for balance in bot.account()['balances'] if balance['asset'] in [coin]
    }


def fCreatOrder(sy, si, qu):
    # Создает ордер по Маркету
    res = bot.createOrder(symbol=sy,
                          recvWindow=15000,
                          side=si,
                          type='MARKET',