コード例 #1
0
    def __init__(self, options: ExchangeConfig) -> None:
        super(GeminiExchange, self).__init__(options)
        self._type = ExchangeType.GEMINI
        self._last = None

        if options.trading_type == TradingType.LIVE:
            self._key, self._secret, self._passphrase = get_keys_from_environment('GEMINI')
            self._client = ccxt.gemini({
                'apiKey': self._key,
                'secret': self._secret,
            })
        elif options.trading_type == TradingType.SANDBOX:
            self._key, self._secret, self._passphrase = get_keys_from_environment('GEMINI_SANDBOX')
            self._client = ccxt.gemini({
                'apiKey': self._key,
                'secret': self._secret,
            })
            self._client.urls['api'] = self._client.urls['test']

        val = self._client.fetchBalance() if hasattr(self, '_client') else {}

        self._accounts = []
        for i, jsn in enumerate(val.get('info', [])):
            currency = str_to_currency_type(jsn.get('currency'))
            balance = float(jsn.get('available', 0))
            id = str(i)
            account = Account(id=id, currency=currency, balance=balance)
            self._accounts.append(account)

        self._subscription = [GeminiExchange.currencyPairToString(x) for x in options.currency_pairs]
        self._seqnum_enabled = False  # FIXME?
コード例 #2
0
ファイル: gemini.py プロジェクト: abhitopia/algo-coin
    def __init__(self, options: ExchangeConfig) -> None:
        super(GeminiExchange, self).__init__(options)
        self._type = ExchangeType.GEMINI
        self._last = None

        if options.trading_type == TradingType.LIVE:
            self._key, self._secret, self._passphrase = get_keys_from_environment('GEMINI')
            self._client = ccxt.gemini({
                'apiKey': self._key,
                'secret': self._secret,
            })
        elif options.trading_type == TradingType.SANDBOX:
            self._key, self._secret, self._passphrase = get_keys_from_environment('GEMINI_SANDBOX')
            self._client = ccxt.gemini({
                'apiKey': self._key,
                'secret': self._secret,
            })
            self._client.urls['api'] = self._client.urls['test']

        val = self._client.get_balances() if hasattr(self, '_client') else {}

        self._accounts = []
        for i, jsn in enumerate(val.get('info', [])):
            currency = str_to_currency_type(jsn.get('currency'))
            balance = float(jsn.get('available', 0))
            id = str(i)
            account = Account(id=id, currency=currency, balance=balance)
            self._accounts.append(account)

        # self._subscription = json.dumps({"type": "subscribe",
        #                                  "product_id": "BTC-USD"})
        # self._heartbeat = json.dumps({"type": "heartbeat",
        #                               "on": True})

        self._seqnum_enabled = False
コード例 #3
0
def get_gemini_static(file):
    gemini = ccxt.gemini()
    fee = gemini.fees
    taker_fee, maker_fee = fee['trading']['taker'] * 10000, fee['trading'][
        'maker'] * 10000

    session = HTMLSession()
    url = 'https://docs.gemini.com/websocket-api/#timestamps'
    r = session.get(url)
    text = r.html.text
    start = text.find('Minimum price increment')
    end = text.find('Sequence numbers')
    text = text[start:end]
    with open(file, 'a') as csvFile:
        csvwriter = csv.writer(csvFile)
        for currency in ['btcusd', 'ethusd']:
            uid = list(currency)
            uid.insert(3, '_')
            uid = ''.join(uid).upper()
            uid = uid + '-gemini'
            text = text[text.find(currency):]
            texts = text.split('\n')
            csvwriter.writerow([
                uid, 'Gemini', currency, texts[5].split(' ')[0], '1',
                texts[4].split(' ')[0], '', texts[3].split(' ')[0], '', '8',
                '2', taker_fee, maker_fee, 0, 0, 'cryptocurrency'
            ])
コード例 #4
0
 def __init__(self, keypath):
     with open(keypath, "r") as f:
         key = f.readline().strip()
         secret = f.readline().strip()
     Exchange.__init__(self, 'Gemini',
                       gemini({
                           'apiKey': key,
                           'secret': secret
                       }))
コード例 #5
0
ファイル: main.py プロジェクト: xhaferllari11/liveTrader
 def __init__(self):
     self.exchanges = {
         'binanceus': ccxt.binanceus(),
         'bittrex': ccxt.bittrex(),
         # 'coinbase': ccxt.coinbase(),   # coinbase has most currency pairs, by like 3 times the next highest, consider removing. Also coinbase limits API to 3-6 calls/sec
         'gemini': ccxt.gemini(),
         # 'kraken': ccxt.kraken(),       # updating their API
         'livecoin': ccxt.livecoin(),
         'theocean': ccxt.theocean(),
         # 'okex': ccxt.okex(),            #Canadian, does not allow us
         'bitmart': ccxt.bitmart(),
         # 'cex': ccxt.cex(),  # EU
         # 'bitbay': ccxt.bitbay(),  # EU, Updating API
         # 'bcex': ccxt.bcex(),            #candian exch, their API is updating
         # 'bitbay': ccxt.bitbay(),
         'paymium': ccxt.paymium(),
         'binance': ccxt.binance(),
         'okcoin': ccxt.okcoin(),
         'bitfinex': ccxt.bitfinex()  # non-US
     }
     # creates a markets variable in each exchange instance.  ex. exchages[0].markets will return markets
     self.loadMarkets()
     # these are tickers available on exchnage, but not US customers, or don't allow deposits/withdrawals
     self.unavailableTickers = {
         'binanceus': [],
         'bittrex': [
             'LUNA/BTC', 'ABBC/BTC', 'Capricoin/BTC', 'DRGN/BTC', 'CVT/BTC',
             'NXT/BTC'
         ],
         # 'coinbase': [],
         'gemini': [],
         # 'kraken': [],               # Updating their API
         'livecoin': [
             'BTM/BTC', 'BTM/ETH', 'NANO/BTC', 'NANO/ETH', 'XTZ/BTC',
             'XTZ/ETH', 'THETA/BTC', 'THETA/ETH', 'ABBC/BTC', 'ABBC/ETH',
             'AE/BTC', 'AE/ETH', 'IOST/BTC', 'IOST/ETH'
         ],
         'theocean': [],
         # 'okex': ['AET/ETH','AET/BTC'],             # does not allow US, but allows canadian
         'bitmart': [],
         # 'cex': [],
         # 'bitbay': [],
         # 'bcex': [],             #candian exch, their API is updating
         'bitbay': [],
         'paymium': [],
         'binance': [],
         'okcoin': [],
         'bitfinex': []
     }
     self.commonTickers = self.getCommonTickers()
     # then only call fetch_tickers for common_tickers between exchanges
     self.minProfit = 1  # percent profit
     # in USD NOTE: still need to incorporate this. I think coinmarketcap API has a quick conversion call
     self.minVolume = 200
     self.txfrCosts = []
コード例 #6
0
def exchangeObject(exchange_in):
    exchanges = [ccxt.acx(),ccxt.bitbay(),ccxt.bitfinex(),ccxt.bitflyer(),ccxt.bithumb(),ccxt.bitlish(),ccxt.bitmarket(),ccxt.bitmex(),ccxt.bitso(),
                         ccxt.bitstamp(),ccxt.bitstamp1(),ccxt.bittrex(),ccxt.bl3p(),ccxt.bleutrade(),ccxt.btcbox(),ccxt.btcchina(),ccxt.btcexchange(),ccxt.btcmarkets(),ccxt.btctradeua(),ccxt.btcturk(),
                         ccxt.btcx(),ccxt.bxinth(),ccxt.ccex(),ccxt.cex(),ccxt.chbtc(),ccxt.chilebit(),ccxt.coincheck(),ccxt.coinfloor(),ccxt.coingi(),ccxt.coinmarketcap(),ccxt.coinmate(),
                         ccxt.coinsecure(),ccxt.coinspot(),ccxt.cryptopia(),ccxt.dsx(),ccxt.exmo(),ccxt.flowbtc(),ccxt.foxbit(),ccxt.fybse(),ccxt.fybsg(),ccxt.gatecoin(),ccxt.gateio(),ccxt.gdax(),
                         ccxt.gemini(),ccxt.getbtc(),ccxt.hitbtc(),ccxt.huobi(),ccxt.huobicny(),ccxt.independentreserve(),ccxt.itbit(),ccxt.jubi(),ccxt.kraken(),ccxt.kucoin(),
                         ccxt.kuna(),ccxt.lakebtc(),ccxt.liqui(),ccxt.livecoin(),ccxt.luno(),ccxt.mercado(),ccxt.mixcoins(),ccxt.nova(),ccxt.okcoincny(),ccxt.okcoinusd(),ccxt.okex(),ccxt.paymium(),
                         ccxt.poloniex(),ccxt.qryptos(),ccxt.quadrigacx(),ccxt.southxchange(),ccxt.surbitcoin(),ccxt.therock(),ccxt.tidex(),ccxt.urdubit(),ccxt.vaultoro(),ccxt.vbtc(),
                         ccxt.virwox(),ccxt.wex(),ccxt.xbtce(),ccxt.yobit(),ccxt.yunbi(),ccxt.zaif(),ccxt.zb()]

    for count, exchange in enumerate([str(x) for x in exchanges]):
            if exchange_in.lower() in exchange:
                return exchanges[count]
                break
    'exchangeName': "btcmarkets"
    , 'database': btcmarkets_db
})

coinfloor = ccxt.coinfloor({
    'rateLimit': 3000,
    'enableRateLimit': True,
    # 'verbose': True,
    'exchangeName': "coinfloor",
    'database': coinfloor_db
})

gemini = ccxt.gemini({
    'rateLimit': 3000,
    'enableRateLimit': True,
    # 'verbose': True,
    'exchangeName': "gemini",
    'database': gemini_db
})

tidex = ccxt.tidex({
    'rateLimit': 3000,
    'enableRateLimit': True,
    # 'verbose': True,
    'exchangeName': "tidex",
    'database': tidex_db
})

cex = ccxt.cex({
    'rateLimit': 3000,
    'enableRateLimit': True,
コード例 #8
0
ファイル: backtest.py プロジェクト: kevin15987/lwvolatility
#Importing libraries
import ccxt
import numpy as np
import pandas as pd
from datetime import datetime

#Fetching historical data from Gemini
since = '01.01.2021'  #MM.DD.YYYY
gemini = ccxt.gemini()
dt_obj = datetime.strptime(since, '%m.%d.%Y')
since = dt_obj.timestamp() * 1000
stock_ohlcv = gemini.fetch_ohlcv("BTC/USD", timeframe='1d', since=since)
df = pd.DataFrame(stock_ohlcv,
                  columns=['date', 'open', 'high', 'low', 'close', 'volume'])
df['date'] = pd.to_datetime(df['date'], unit='ms')
df.set_index('date', inplace=True)

#Back testing equation. For backtesting purpose, assume you start off with 1 BTC
k = 0.68
df['range'] = (df['high'] - df['low']) * k
df['target'] = df['open'] + df['range'].shift(1)

#Fee assumption
fee = 0.0035

#To Buy or Not To Buy
df['ror'] = np.where(df['high'] > df['target'],
                     df['close'] / df['target'] - fee, 1)
#Compound Return
df['hpr'] = df['ror'].cumprod()
#Drawdown
コード例 #9
0
    'enableRateLimit': True,
})
# enter your API public/secret keys here:
coinbase.apiKey = API_keys.coinbase.apiKey
coinbase.secret = API_keys.coinbase.secret

#
# coindeal = ccxt.coindeal({
#         'enableRateLimit':True,
# })
# # enter your API public/secret keys here:
# coindeal.apiKey = my_API_keys.coindeal.apiKey
# coindeal.secret = my_API_keys.coindeal.secret

gemini = ccxt.gemini({
    'enableRateLimit': True,
})
# enter your API public/secret keys here:
gemini.apiKey = API_keys.gemini.apiKey
gemini.secret = API_keys.gemini.secret

hitbtc = ccxt.hitbtc({
    'enableRateLimit': True,
})
# enter your API public/secret keys here:
hitbtc.apiKey = API_keys.hitbtc.apiKey
hitbtc.secret = API_keys.hitbtc.secret

kraken = ccxt.kraken({
    'enableRateLimit': True,
})
コード例 #10
0
def init_supported_exchanges():
    objects = {
        "acx": ccxt.acx(),
        "aofex": ccxt.aofex(),
        "bequant": ccxt.bequant(),
        "bibox": ccxt.bibox(),
        "bigone": ccxt.bigone(),
        "binance": ccxt.binance(),
        "bitbank": ccxt.bitbank(),
        "bitbay": ccxt.bitbay(),
        "bitfinex": ccxt.bitfinex(),
        "bitflyer": ccxt.bitflyer(),
        "bitforex": ccxt.bitforex(),
        "bithumb": ccxt.bithumb(),
        "bitkk": ccxt.bitkk(),
        "bitmax": ccxt.bitmax(),
        "bitstamp": ccxt.bitstamp(),
        "bittrex": ccxt.bittrex(),
        "bitz": ccxt.bitz(),
        "bl3p": ccxt.bl3p(),
        "bleutrade": ccxt.bleutrade(),
        "braziliex": ccxt.braziliex(),
        "btcalpha": ccxt.btcalpha(),
        "btcbox": ccxt.btcbox(),
        "btcmarkets": ccxt.btcmarkets(),
        "btctradeua": ccxt.btctradeua(),
        "bw": ccxt.bw(),
        "bybit": ccxt.bybit(),
        "bytetrade": ccxt.bytetrade(),
        "cex": ccxt.cex(),
        "chilebit": ccxt.chilebit(),
        "coinbase": ccxt.coinbase(),
        "coinbasepro": ccxt.coinbasepro(),
        "coincheck": ccxt.coincheck(),
        "coinegg": ccxt.coinegg(),
        "coinex": ccxt.coinex(),
        "coinfalcon": ccxt.coinfalcon(),
        "coinfloor": ccxt.coinfloor(),
        "coinmate": ccxt.coinmate(),
        "coinone": ccxt.coinone(),
        "crex24": ccxt.crex24(),
        "currencycom": ccxt.currencycom(),
        "digifinex": ccxt.digifinex(),
        "dsx": ccxt.dsx(),
        "eterbase": ccxt.eterbase(),
        "exmo": ccxt.exmo(),
        "exx": ccxt.exx(),
        "foxbit": ccxt.foxbit(),
        "ftx": ccxt.ftx(),
        "gateio": ccxt.gateio(),
        "gemini": ccxt.gemini(),
        "hbtc": ccxt.hbtc(),
        "hitbtc": ccxt.hitbtc(),
        "hollaex": ccxt.hollaex(),
        "huobipro": ccxt.huobipro(),
        "ice3x": ccxt.ice3x(),
        "independentreserve": ccxt.independentreserve(),
        "indodax": ccxt.indodax(),
        "itbit": ccxt.itbit(),
        "kraken": ccxt.kraken(),
        "kucoin": ccxt.kucoin(),
        "lakebtc": ccxt.lakebtc(),
        "latoken": ccxt.latoken(),
        "lbank": ccxt.lbank(),
        "liquid": ccxt.liquid(),
        "livecoin": ccxt.livecoin(),
        "luno": ccxt.luno(),
        "lykke": ccxt.lykke(),
        "mercado": ccxt.mercado(),
        "oceanex": ccxt.oceanex(),
        "okcoin": ccxt.okcoin(),
        "okex": ccxt.okex(),
        "paymium": ccxt.paymium(),
        "poloniex": ccxt.poloniex(),
        "probit": ccxt.probit(),
        "southxchange": ccxt.southxchange(),
        "stex": ccxt.stex(),
        "surbitcoin": ccxt.surbitcoin(),
        "therock": ccxt.therock(),
        "tidebit": ccxt.tidebit(),
        "tidex": ccxt.tidex(),
        "upbit": ccxt.upbit(),
        "vbtc": ccxt.vbtc(),
        "wavesexchange": ccxt.wavesexchange(),
        "whitebit": ccxt.whitebit(),
        "yobit": ccxt.yobit(),
        "zaif": ccxt.zaif(),
        "zb": ccxt.zb()
    }
    return objects
コード例 #11
0
 ccxt.coinsecure(),
 ccxt.coinspot(),
 ccxt.coolcoin(),
 ccxt.cryptopia(),
 ccxt.dsx(),
 ccxt.ethfinex(),
 ccxt.exmo(),
 ccxt.exx(),
 ccxt.flowbtc(),
 ccxt.foxbit(),
 ccxt.fybse(),
 ccxt.fybsg(),
 ccxt.gatecoin(),
 ccxt.gateio(),
 ccxt.gdax(),
 ccxt.gemini(),
 ccxt.getbtc(),
 ccxt.hadax(),
 ccxt.hitbtc(),
 ccxt.hitbtc2(),
 ccxt.huobi(),
 ccxt.huobicny(),
 ccxt.huobipro(),
 ccxt.ice3x(),
 ccxt.independentreserve(),
 ccxt.indodax(),
 ccxt.itbit(),
 ccxt.jubi(),
 ccxt.kraken(),
 ccxt.kucoin(),
 ccxt.kuna(),
コード例 #12
0
### DISPLAY ####
def display():
    os.system('clear && figlet "COINBASE"')
    print('\n')


### ACCOUNT CREDINTIALS ####
coinbase_pro = ccxt.coinbasepro({
    'apiKey': '2851606201d8765e5f91a93cd710707b',
    'secret': 'DVYqJXYxdaiinH7sTeWsTV5alpYRy2jtT/5P3xFbh96OTuDcVjdmmBKPbQMv7sWuGWQM88Ho9O/L/oIn50Ip1g==',
    'password': '******'
})

gemini = ccxt.gemini({
    'apiKey': 'master-bkm4AS6XfKmmctFaJ5n1',
    'secret': '3q2B8futRKUqmF53eiPf6zK7Gihz'
    # 'password': ''
})



### TRADING PAIRS ###


# trading_pairs = coinbase_pro.load_markets()

# for x in trading_pairs:
    # print(x)


# for x in coinbase_pro.id, trading_pairs: