예제 #1
0
 def __init__(self, api_key, api_secret, subaccount=None):
     if subaccount:
         self.client = ccxt.ftx({
             'apiKey': f'{api_key}',
             'secret': f'{api_secret}',
             'enableRateLimit': True,
             'headers': {
                 'FTX-SUBACCOUNT': f'{subaccount}'
             }
         })
예제 #2
0
 def __init__(self):
     self.account = ccxt.ftx({
         'apiKey': f'{open("secret/ftx_api_key").read()}',
         'secret': f'{open("secret/ftx_api_secret").read()}',
         'enableRateLimit': True,
         'headers': {
             'FTX-SUBACCOUNT': 'arb'
         }
     })
     self.otp = pyotp.TOTP(open("secret/ftx_otp").read())
     # self.thor = ThorOracle()
     self.precision = {'LTC': 2, 'BCH': 3, 'ETH': 3}
     self.market = []
     self.logistics = defaultdict(list)
     self.backlog = []
async def main():
    exchange = ccxt.ftx({
        'apiKey': 'YOUR_API_KEY',
        'secret': 'YOUR_SECRET',
        'enableRateLimit': False,  # not recommended
    })
    markets = await exchange.load_markets()
    # exchange.verbose = True  # uncomment for debugging purposes
    symbol = 'BTC/USDT'
    loops = [
        exchange.fetch_balance(),
        exchange.fetch_order_book(symbol),
        exchange.fetch_open_orders()
    ]
    results = await gather(*loops)
    print('Balance:')
    print(results[0])
    print('------------------------------------------------------------------')
    print(symbol, 'orderbook:')
    print(results[1])
    print('------------------------------------------------------------------')
    print('Open orders:')
    print(results[2])
    await exchange.close()
예제 #4
0
import ccxt.async_support as ccxt
import os
import asyncio
import logging
import builtins
from pprint import pprint
from datetime import datetime

# replace with your key / secret
key = os.environ.get('ftx_key')
secret = os.environ.get('ftx_secret')

current_symbol = "BTC-PERP"
exchange = ccxt.ftx({
    'apiKey': key,
    'secret': secret,
    'enableRateLimit': True,
    'rateLimit': 250  # Could be required for functions like scaled_order.
})


def tprint(msg):
    print(str(datetime.utcnow()) + " - " + str(msg))


async def help(function_str=None):
    if not function_str:
        builtins.help(globals()[function_str])
    else:
        tprint(
            "You need to specify the function you need information on (example: help cancel_all)!"
        )