ccxt / ccxt

A JavaScript / TypeScript / Python / C# / PHP cryptocurrency trading API with support for more than 100 bitcoin/altcoin exchanges
https://docs.ccxt.com
MIT License
32.97k stars 7.53k forks source link

New version bittrex not working #973

Closed hunsnowboarder closed 6 years ago

hunsnowboarder commented 6 years ago

I had a code running without any problems. I updated the bittrex.py file and now I get an error:

Traceback (most recent call last): File "C:/Lori/Adam/bitcoin/cryptoarb/rsi_bot.py", line 50, in balance_btc = xchange.fetch_balance()['BTC']['total'] File "C:\Python27\lib\site-packages\ccxt\bittrex.py", line 201, in fetch_balance response = self.accountGetBalances() File "C:\Python27\lib\site-packages\ccxt\bittrex.py", line 616, in request response = self.fetch2(path, api, method, params, headers, body) File "C:\Python27\lib\site-packages\ccxt\base\exchange.py", line 258, in fetch2 request = self.sign(path, api, method, params, headers, body) File "C:\Python27\lib\site-packages\ccxt\bittrex.py", line 584, in sign self.check_required_credentials() AttributeError: 'bittrex' object has no attribute 'check_required_credentials'

OS: Win7
Programming Language: Python 2.7
CCXT version: 10.477
Exchange: Bittrex
Method: fetch_ohlcv()

This is my code... so far it worked allright, now it wont work because of the error message. What is wrong? Thank you in advance!

import ccxt
import time
import pandas as pd
from stockstats import StockDataFrame as sdf
from openpyxl import load_workbook

proxies = [
    '',  # no proxy by default
    'https://crossorigin.me/',
    'https://cors-anywhere.herokuapp.com/',
]

wait_time = 600 # seconds
counter = 1
max_rsi = 31.0
min_vol = 0.1 # btc
min_gain = 0.015
stop_loss_ratio = 0.15

stop_loss_rate = 1 - stop_loss_ratio

while(True):

    # -----------------------------------------------
    # connection

    maxRetries = 30
    for numRetries in range(0, maxRetries):
        try:
            currentProxy = proxies[(numRetries + 1) % len(proxies) - 1]
            xchange = ccxt.bittrex({'proxy': currentProxy,
                                     'apiKey': 'XXX',
                                     'secret': 'XXX'
                                     })
            xchange.load_markets()
            symbols_list = xchange.symbols
            break
        except :
           print 'Proxy fail:', currentProxy
           print 'numRetries:', numRetries
           if currentProxy == 'https://cors-anywhere.herokuapp.com/' :
               print 'waiting'
               time.sleep(30)

    # -----------------------------------------------
    # check if we are in BTC and have no open orders

    balance_btc = xchange.fetch_balance()['BTC']['total']
kroitor commented 6 years ago

Does this work:

import ccxt
exchange = ccxt.bittrex({
    'apiKey': 'YOUR_API_KEY',
    'secret': 'YOUR_SECRET',
})
print(exchange.fetch_balance()['BTC']['total'])

?

hunsnowboarder commented 6 years ago

Yes, it solved my problem!

Thank you very much for your help!

kroitor commented 6 years ago

@hunsnowboarder would be cool if you could reply to #962 ;)

hunsnowboarder commented 6 years ago

Yes, I will now. Thank you!

hunsnowboarder commented 6 years ago

I dont understand. The code you just pasted here works with jupyter notebook, but it produces error with pycharm. They both use python2.7.

What could be the problem?

Thank you

kroitor commented 6 years ago

@hunsnowboarder what's the version of ccxt in pycharm? ccxt.__version__ = ?

hunsnowboarder commented 6 years ago

Sorry for my late reply. I had very strange issues and finally figured out what the problem was. I did not update ccxt for a while now only some of the exchanges.

So I did a thorough update of everything and now it works like a charm. Thank you again for your continuous support and help! Have a happy new year!