text: # -*- coding: utf-8 -*-
  
  # PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
  # https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
  
  from ccxt.async.base.exchange import Exchange
  import hashlib
  
  
  class bit2c (Exchange):
  
      def describe(self):
          return self.deep_extend(super(bit2c, self).describe(), {
              'id': 'bit2c',
              'name': 'Bit2C',
              'countries': 'IL',  # Israel
              'rateLimit': 3000,
              'has': {
                  'CORS': False,
              },
              'urls': {
                  'logo': 'https://user-images.githubusercontent.com/1294454/27766119-3593220e-5ece-11e7-8b3a-5a041f6bcc3f.jpg',
                  'api': 'https://www.bit2c.co.il',
                  'www': 'https://www.bit2c.co.il',
                  'doc': [
                      'https://www.bit2c.co.il/home/api',
                      'https://github.com/OferE/bit2c',
                  ],
              },
              'api': {
                  'public': {
                      'get': [
                          'Exchanges/{pair}/Ticker',
                          'Exchanges/{pair}/orderbook',
                          'Exchanges/{pair}/trades',
                      ],
                  },
                  'private': {
                      'post': [
                          'Account/Balance',
                          'Account/Balance/v2',
                          'Merchant/CreateCheckout',
                          'Order/AccountHistory',
                          'Order/AddCoinFundsRequest',
                          'Order/AddFund',
                          'Order/AddOrder',
                          'Order/AddOrderMarketPriceBuy',
                          'Order/AddOrderMarketPriceSell',
                          'Order/CancelOrder',
                          'Order/MyOrders',
                          'Payment/GetMyId',
                          'Payment/Send',
                      ],
                  },
              },
              'markets': {
                  'BTC/NIS': {'id': 'BtcNis', 'symbol': 'BTC/NIS', 'base': 'BTC', 'quote': 'NIS'},
                  'BCH/NIS': {'id': 'BchNis', 'symbol': 'BCH/NIS', 'base': 'BCH', 'quote': 'NIS'},
                  'LTC/NIS': {'id': 'LtcNis', 'symbol': 'LTC/NIS', 'base': 'LTC', 'quote': 'NIS'},
                  'BTG/NIS': {'id': 'BtgNis', 'symbol': 'BTG/NIS', 'base': 'BTG', 'quote': 'NIS'},
              },
              'fees': {
                  'trading': {
                      'maker': 0.5 / 100,
                      'taker': 0.5 / 100,
                  },
              },
          })
  
      async def fetch_balance(self, params={}):
          balance = await self.privatePostAccountBalanceV2()
          result = {'info': balance}
          currencies = list(self.currencies.keys())
          for i in range(0, len(currencies)):
              currency = currencies[i]
              account = self.account()
              if currency in balance:
                  available = 'AVAILABLE_' + currency
                  account['free'] = balance[available]
                  account['total'] = balance[currency]
                  account['used'] = account['total'] - account['free']
              result[currency] = account
          return self.parse_balance(result)
  
      async def fetch_order_book(self, symbol, limit=None, params={}):
          orderbook = await self.publicGetExchangesPairOrderbook(self.extend({
              'pair': self.market_id(symbol),
          }, params))
          return self.parse_order_book(orderbook)
  
      async def fetch_ticker(self, symbol, params={}):
          ticker = await self.publicGetExchangesPairTicker(self.extend({
              'pair': self.market_id(symbol),
          }, params))
          timestamp = self.milliseconds()
          averagePrice = float(ticker['av'])
          baseVolume = float(ticker['a'])
          quoteVolume = baseVolume * averagePrice
          return {
              'symbol': symbol,
              'timestamp': timestamp,
              'datetime': self.iso8601(timestamp),
              'high': None,
              'low': None,
              'bid': float(ticker['h']),
              'ask': float(ticker['l']),
              'vwap': None,
              'open': None,
              'close': None,
              'first': None,
              'last': float(ticker['ll']),
              'change': None,
              'percentage': None,
              'average': averagePrice,
              'baseVolume': baseVolume,
              'quoteVolume': quoteVolume,
              'info': ticker,
          }
  
      def parse_trade(self, trade, market=None):
          timestamp = int(trade['date']) * 1000
          symbol = None
          if market:
              symbol = market['symbol']
          return {
              'id': str(trade['tid']),
              'info': trade,
              'timestamp': timestamp,
              'datetime': self.iso8601(timestamp),
              'symbol': symbol,
              'order': None,
              'type': None,
              'side': None,
              'price': trade['price'],
              'amount': trade['amount'],
          }
  
      async def fetch_trades(self, symbol, since=None, limit=None, params={}):
          market = self.market(symbol)
          response = await self.publicGetExchangesPairTrades(self.extend({
              'pair': market['id'],
          }, params))
          return self.parse_trades(response, market, since, limit)
  
      async def create_order(self, symbol, type, side, amount, price=None, params={}):
          method = 'privatePostOrderAddOrder'
          order = {
              'Amount': amount,
              'Pair': self.market_id(symbol),
          }
          if type == 'market':
              method += 'MarketPrice' + self.capitalize(side)
          else:
              order['Price'] = price
              order['Total'] = amount * price
              order['IsBid'] = (side == 'buy')
          result = await getattr(self, method)(self.extend(order, params))
          return {
              'info': result,
              'id': result['NewOrder']['id'],
          }
  
      async def cancel_order(self, id, symbol=None, params={}):
          return await self.privatePostOrderCancelOrder({'id': id})
  
      def sign(self, path, api='public', method='GET', params={}, headers=None, body=None):
          url = self.urls['api'] + '/' + self.implode_params(path, params)
          if api == 'public':
              url += '.json'
          else:
              self.check_required_credentials()
              nonce = self.nonce()
              query = self.extend({'nonce': nonce}, params)
              body = self.urlencode(query)
              signature = self.hmac(self.encode(body), self.encode(self.secret), hashlib.sha512, 'base64')
              headers = {
                  'Content-Type': 'application/x-www-form-urlencoded',
                  'key': self.apiKey,
                  'sign': self.decode(signature),
              }
          return {'url': url, 'method': method, 'body': body, 'headers': headers}
  