Beispiel #1
0
def get_all_base_assets():
    a = client.Client("", "")
    b = a.get_exchange_info()
    symbols = b["symbols"]
    all_base_assets = set()
    [all_base_assets.add(item["baseAsset"]) for item in symbols]
    return all_base_assets
Beispiel #2
0
 def connect_client(self, api_key, api_secret):
     """
     Create Binance Client
     Input:
         api_key - str - Binance account api key
         api_secret - str - Binance account api secret
     Return:
         client - obj - Binance client object
     """
     return client.Client(api_key, api_secret)
Beispiel #3
0
def get_tickers():
    bin_client = client.Client(api_key=os.getenv("API_KEY"),
                               api_secret=os.getenv("SECRET_KEY"))
    tickers = bin_client.get_all_tickers()
    tickers = [
        ticker for ticker in tickers if ticker["symbol"].endswith("USDT")
    ]
    return sorted(tickers,
                  key=lambda value: Decimal(value["price"]),
                  reverse=True)
Beispiel #4
0
 def __init__(self):
     self.c = client.Client()
     self.stop_event = threading.Event()
     self.update = threading.Thread(target=self._update_loop)
     self.update.daemon = True
     self.update.start()
Beispiel #5
0
import os
from pandas import Series
import pandas as pd
import numpy as np
from sklearn import preprocessing
import matplotlib
from math import pi
import matplotlib.pyplot as plt
import matplotlib.ticker as mticker
import matplotlib.dates as mdates
import mpl_finance  # import candlestick_ohlc
from binance import client
from bokeh.plotting import figure, show, output_file
import time

binance_client = client.Client(environ.get('BINANCE_API_KEY'),
                               environ.get('BINANCE_API_SECRET'))

client_intervals = {
    '1m': KLINE_INTERVAL_1MINUTE,
    '5m': KLINE_INTERVAL_5MINUTE,
    '15m': KLINE_INTERVAL_15MINUTE,
    '30m': KLINE_INTERVAL_30MINUTE,
    '1h': KLINE_INTERVAL_1HOUR,
    '2h': KLINE_INTERVAL_2HOUR,
    '4h': KLINE_INTERVAL_4HOUR,
    '6h': KLINE_INTERVAL_6HOUR,
    '12h': KLINE_INTERVAL_12HOUR,
    '1d': KLINE_INTERVAL_1DAY,
    '3d': KLINE_INTERVAL_3DAY,
    '1w': KLINE_INTERVAL_1WEEK
}
Beispiel #6
0
    def __init__(self, account_secret):
        super().__init__(account_secret)

        self.rest_clt = client.Client(api_key=self.account_secret.api_key, api_secret=self.account_secret.api_secret)
import binance.client as client

#https://docs.bokeh.org/en/latest/docs/gallery/candlestick.html <- used as reference code for graph

#This is my first attempt at making a trading bot.
#Right now what it does is it trades the macd crossovers based on the provided time frame

####ACCESS ACCOUNT####
api_key = input("KEY:")
api_secret = input("SECRET:")

timeframe = "30m"

#Binance US
#https://www.reddit.com/r/BinanceExchange/comments/dahxcq/binance_us_api_python_wrapper/
client = client.Client(api_key, api_secret, tld="us")

#Open time
#Open
#High
#Low
#Close
#Volume
#Close time

#Quote asset volume
#Number of trades
#Taker buy base asset volume
#Taker Buy quote asset volume
#Ignore
 def get_binance_client(self):
     return client.Client(self.b_api_key, self.b_secret_key)