bitbns-official / bitbnspy Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
HTTPSConnectionPool(host='api.bitbns.com', port=443): Read timed out. (read timeout=30)
{'data': None, 'status': 0, 'error': 'Invalid Non-JSON response - swapLimitINR'}
i got above error when i place swap order
this command i used
bitbnsObj.swapLimitINR({'coin': 'BTC', 'quantity':0.000005, 'rate': 3358000, 'type': 0})
Since the api rate limits are quite low, I would suggest it is added to send multiple orders in one post, and also support changing an existing order
AttributeError: type object 'bitbns' has no attribute 'publicEndpoints'
python -V
)AttributeError: type object 'bitbns' has no attribute 'publicEndpoints'
from bitbnspy import bitbns
bitbnsObj = bitbns.publicEndpoints()
print(bitbnsObj.fetchTickers())
key = 'your key'
secretKey = 'your secret key'
>>> bitbns(key, secretKey)
JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Currently BNT support is not there. Please add support for it in API.
When I try to instantiate Bitbns Object with my API Key and Secret, it fails with server time key error. I know this issue had already been raised but it was closed without any solution. This same issue has happened to me before but it will usually automatically get resolved in a few minutes. This time around it has been persisting for 2-3 days.
from bitbnspy import bitbns
key = ''
secretKey = '****'
bitbnsObj = bitbns(key, secretKey)
C:\ProgramData\Anaconda3\lib\site-packages\bitbnspy\bitbns.py in init(self, apiKey, apiSecretKey, timeout)
29 response = self.connectionsAdaptor.get('https://api.bitbns.com/api/trade/v1/getServerTime', headers=headers)
30 response = response.json()
---> 31 serverTime = int(response['serverTime'])
32 localTime = int(time.time() * 1000.0)
33 self.timeOffset = localTime - serverTime
KeyError: 'serverTime'
Sample Code used
from bitbnspy import bitbns
key = '***********************'
secretKey = '**********************'
bitbnsObj = bitbns(key, secretKey)
print(bitbnsObj.getSellOrderBook('XRPUSDT'))
Error -
C:\Users\**********\PycharmProjects\bitbns\venv\Scripts\python.exe C:/Users/singha2/PycharmProjects/bitbns/test.py
Traceback (most recent call last):
File "C:/Users/*********/PycharmProjects/bitbns/test.py", line 4, in <module>
bitbnsObj = bitbns(key, secretKey)
File "C:\Users\********\PycharmProjects\bitbns\venv\lib\site-packages\bitbnspy\bitbnspy.py", line 25, in __init__
serverTime = int(response['serverTime'])
KeyError: 'serverTime'
Process finished with exit code 1
currentCoinBalance
returns no data for recently added pairs.
this issue is observed in USDC, BUSD, RUNE, SOL, SAND, MANA etc (while opening issue, there were most recently added)
currentCoinBalance
function.# Your code here
print(bitbnsObj.currentCoinBalance('BUSD'))
{'code': 200, 'data': {}, 'error': None, 'status': 1}
Can you provide example on socket usage mentioned in README
I would suggest to add a new endpoint to check the amount of fee rebate that users are getting from bitbns
Coins BNB/USDT, BNSD/USDT, FET/USDT & FUN/USDT are returning not supported coins as response for placeOrders for order types - normal and stoploss
bitbnsObj.placeOrders({'symbol': 'BNB_USDT', 'side': 'BUY', 'quantity': 0.01, 'rate': 290})
{
'data': None,
'status': 0,
'error': 'Coin Type Not Valid or Not Supported Yet!!',
'code': 406
}
Three tickers - WBTC, ZEBI and PHB have been returning coins not supported error.
bitbnsObj.getBuyOrderBook('WBTC') #Could be any function except getTickerApi
{
'data': '',
'status': 0,
'msg': 'coin name not supplied',
'code': 406
}
platformStatus only returns status for a few tickers
API_KEY, SECRET_KEY = "####", "####"
bitbnsObj = bitbns(API_KEY, SECRET_KEY)
bitbnsObj.platformStatus()
{'code': 200,
'data': {'ADA': {'status': 1},
'BCH': {'status': 1},
'BTC': {'status': 1},
'DASH': {'status': 1},
'DGD': {'status': 1},
'ETH': {'status': 1},
'GAS': {'status': 1},
'LSK': {'status': 1},
'LTC': {'status': 1},
'NEO': {'status': 1},
'OMG': {'status': 1},
'ONT': {'status': 1},
'POLY': {'status': 1},
'POWR': {'status': 1},
'QTUM': {'status': 1},
'REP': {'status': 1},
'TEL': {'status': 1},
'TRX': {'status': 1},
'USDT': {'status': 1},
'VET': {'status': 1},
'WAVES': {'status': 1},
'XLM': {'status': 1},
'XRP': {'status': 1},
'XVG': {'status': 1},
'ZRX': {'status': 1}},
'error': None,
'status': 1}
Unable to place Buy Order on SHIBA INU coin worth more than around 50$. Getting "volume asked not acceptable" response with a 413 error code.
However, for a smaller SHIB volume, it places orders successfully
API_KEY, SECRET_KEY = "####", "####"
bitbnsObj = bitbns(API_KEY, SECRET_KEY)
bitbnsObj.placeBuyOrder('SHIB', 5000000, 0.001)
{
'data': '', 'status': 0, 'error': 'volume asked not acceptable', 'code': 413
}
While running the following code, it is giving error :
bitbnsObj = bitbns(key, secretKey)
bitbnsObj
Out[23]: <bitbnspy.bitbnspy.bitbns at 0x224b0b8b2b0>
bitbnsObj.getTickerApi( 'MATIC' )
Traceback (most recent call last):
File "<ipython-input-24-17c6c2c9e69c>", line 1, in <module>
bitbnsObj.getTickerApi( 'MATIC' )
File "C:\anaconda\lib\site-packages\bitbnspy\bitbnspy.py", line 99, in getTickerApi
req[key].pop('yes_price', None)
AttributeError: 'str' object has no attribute 'pop'
Coins VEN, RPX and PUNDIX have changed their names while KSM, REN, UMA, AMPL, WNXM & SRM is not there on the website
I would suggest removing them from the response of getTickerApi()
Please include a timeout of a predefined period say 10 seconds or 15 seconds or maybe user defined in each of the api calls. Otherwise if it takes too long time to get response, the code is just hanging and is not recovering from the api call.
To be specific, using this few lines of code mentioned here will fix for all the requests globally.
import bitbnspy
help("bitbnspy")
Help on package bitbnspy:
NAME
bitbnspy
PACKAGE CONTENTS
bitbns
bitbnspy
main
FILE
c:\users\singha2\appdata\local\programs\python\python36\lib\site-packages\bitbnspy_init_.py
from bitbns import bitbnsApi
Traceback (most recent call last):
File "", line 1, in
ModuleNotFoundError: No module named 'bitbns'
python -V
)unable to place order using bitbns API on bituniverse
it shows the following error
Error_in_grpc_call
Explain the problem you have encountered
# Your code here
// paste your log here
It is not possible to get the withdrawal history for USDT
>BITBNS_API.withdrawHistory("USDT", page=0)
Out[1]: {'data': [], 'status': 1, 'error': None, 'code': 204}
There should be data, and code = 200
Does this require a separate code per withdrawal network?
Thank you
running this Api:
pd.json_normalize(bitbnsObj.getBuyOrderBook(BTC), "data", meta=["status", "error","code"])
please opine
hi I have installed bitbnspy from anaconda command prompt in windows10 using following:
pip3 install python-socketio
pip3 install bitbnspy
Installation was successful. When I am trying to import bitbnspy I am getting error:
(base) C:\Users\USER>python
Python 3.7.4 (default, Aug 9 2019, 18:34:13) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from bitbnspy import bitbns
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'bitbnspy'
Could you please advice how to resolve this error?
team,
did step 1:
Installation
sudo -H pip3 install python-socketio[client]
pip3 install bitbnspy
Step 2 ran this in spyder - python:
and got error of: "ModuleNotFoundError: No module named 'bitbnspy'"
please help how to resolve this
thanks
sukhwant
code used to run on spyder:
from bitbnspy import bitbns
key = 'yourKey'
secretKey = 'yourSecretKey'
bitbnsObj = bitbns(key, secretKey)
print(bitbnsObj.getSellOrderBook('XRPUSDT'))
Currently getExecutedOrders
is nto enabled and it returns error. Please enable it.
bitbnsObj.getExecutedOrders('EOS')
Hi, how can I use getTickerApi function to get the price of the symbol in both INR and USDT markets? Or there's a different method to achieve this?
Coins BCHSV, DENT, LET, CLOAK, BTT have been showing irregular price problem.
#Actual market price during the posting of this issue was 12800
bitbnsObj.placeBuyOrder('BCHSV', 0.0043, 11500)
{
'data': None,
'status': 0,
'error': 'Price seems Irregular from current market price. 31974.284532737227',
'code': 428
}
How can I get higher api rate limits? 100 write calls is not enough
A completed bracket order is shown in the response when listOpenBracketOrders is passed as type for getOrders
bitbnsObj.getOrders({'side': 'listOpenBracketOrders', 'symbol': 'XRP', 'page': 0})
{
'data': [
{
'entry_id': 44912,
'type': 0,
'target_rate': 100,
'limit_rate': 81,
'status': 2,
'quantity': 0.25,
'coin': 1,
'trail': 0.02,
'order_id': 10865255,
'sl_id': 126268,
'entry_rate': 83,
'tried': 0,
'profit': 0,
'amt_total': 0
},
.
.
]
}
Implementation of market order via API trading, would help place orders immediately and ensures the user is able to enter/exit their position irrespective of market condition.
Currently this is achieved by calling two functions (example for exiting BTC/USDT position):
bitbnsObj.getSellOrderBook('BTCUSDT')
bitbnsObj.placeOrders({'symbol': 'BTCUSDT', 'side': 'SELL', 'quantity': 0.1, 'rate': 33000})
this action could be achieved by just 1 action by user:
bitbnsObj.placeOrders({'symbol': 'BTCUSDT', 'side': 'SELL', 'type':'MARKET', 'quantity': 0.1})
note: rate is not considered in this case.
orderStatus function does not retrieve data for stop loss orders
bitbnsObj.buyStopLoss('USDT', 1, 80, 79)
bitbnsObj.orderStatus('USDT', 147718)
{
'data': 'Successfully placed order for stop loss buy',
'status': 1,
'error': None,
'id': 147718,
'code': 200
}
{
'data': [],
'status': 0,
'error': 'Nothing to show',
'code': 417
}
python -V
)Explain the problem you have encountered
# Your code here
// paste your log here
Facing issue for sockets.
image attached above.
code: `from bitbnspy import bitbns
bitbnsObj = bitbns.publicEndpoints()
data = bitbnsObj.getOrderBookSocket(coinName = 'BTC', marketName = 'INR')
print("datahere===> ", data)
socket = data['socket']
@socket.event
def news(data):
print(data)`
getting status 204, when tried to get withdraw and deposit history for a coin
{'data': [], 'status': 1, 'error': None, 'code': 204}
how to execute a coin in USDT market via api
import pandas as pd
import datetime as dt
import time
import numpy as np
import http.client
import json
from bitbnspy import bitbns
from BitbnsTradeSuggestions import tradexecute
key = ''
secretKey = ''
bitbnsObj = bitbns(key, secretKey)
tdticker1 = 'XRP_USDT'
tdtickerqty1 = 146.43
tdtickerprice1 = 0.6829
tdticker2 = 'XRP'
tdtickerqty2 = 146.43
tdtickerprice2 = 51
bitbnsObj.placeBuyOrder(tdticker1, tdtickerqty1, tdtickerprice1)
time.sleep(5)
bitbnsObj.placeSellOrder(tdticker2, tdtickerqty2, tdtickerprice2)
Pleas note: Trade does not get executed, even if USDT of $100 is in the wallet. Rates mentioned in the Ask to buy and bid to sell are present in the order book
Please opine
Coin LRC have been showing irregular price problem.
Place order for the coin mentioned above
{
'data': None,
'status': 0,
'error': 'Price seems Irregular from current market price. 18.180279665397926',
'code': 428
}
Hello All,
Is there a way to get tickers data (last traded price) for the last "n" hours? If yes, could someone please post the method to get thsi data?
Also, can we restrict the fetchTickers method to get the data for a specified coin? When I checked the source code, looks like fetchTickers is not accepting any parameters. Is there any other method to retrieve tickers data for a specific coin?
Thanks!
I'm trying to fetch the open orders, some of them are partailly executed.
what should I do to get the % of the partially executed order?
CPX has been delisted from the marketplace. However, we can still get buy & sell order book, use getTickerApi, place stoploss orders and cancelOrders.
API_KEY, SECRET_KEY = "####", "####"
bitbnsObj = bitbns(API_KEY, SECRET_KEY)
print(bitbnsObj.getTickerApi("CPX"))
print(bitbnsObj.buyStopLoss("CPX", 200, 0.35, 0.3))
print(bitbnsObj.cancelOrder("CPX", 47996))
{
'CPX':
{'highest_buy_bid': 0.35,
'lowest_sell_bid': 0.36,
'last_traded_price': 0.36
}
}
{
'data': 'Successfully placed order for stop loss buy',
'status': 1,
'error': None,
'id': 147703,
'code': 200
}
{
'data': 'Successfully cancelled the order',
'status': 1,
'error': None,
'code': 200
}
symbol: ETN
quantity: 500
after placing an order for 500 ETN, while checking for executed orders the amount field the returned amount was showing 5000 ETN (10x more than the originally placed quantity),
this issue seems to be only with this endpoint as on bitbns website the quantity was 500 ETN.
# to place an order
side = 'BUY'
symbol = 'ETN'
min_amount = 380
rate = 0.755
quantity = (min_amount / rate)
print(bitbnsObj.placeOrders({"symbol":symbol,"side":side,"quantity":quantity,"rate":rate}))
# to fetch executed order for ETN
symbol = 'ETN'
since_date = '2021-01-01T00:00:00Z'
page_no = 0
print(bitbnsObj.listExecutedOrders(symbol, since=since_date, pageNo=page_no))
// response for placing order
{'data': 'Successfully placed bid to purchase currency', 'status': 1, 'error': None, 'id': 549056, 'code': 200}
// response for fetch executed order for ETN
{'code': 200,
'data': [{'amount': 3750,
'crypto': 3750,
'date': '2021-06-01T06:19:16.000Z',
'del_btc': 3750,
'del_inr': 2.63,
'delh_btc': 0,
'delh_inr': -283.84,
'factor': 10,
'fee': 0.71,
'id': '547003',
'rate': '0.755',
'type': 'ETN Buy order executed',
'typeI': 7,
'unit': 'ETN'},
{'amount': 1250,
'crypto': 1250,
'date': '2021-06-01T06:19:16.000Z',
'del_btc': 1250,
'del_inr': 0,
'delh_btc': 0,
'delh_inr': -94.62,
'factor': 10,
'fee': 0.24,
'id': '547003',
'rate': '0.755',
'type': 'ETN Buy order executed',
'typeI': 7,
'unit': 'ETN'}],
'error': None,
'status': 1}
When placing margin orders, the response does not return a ID.
API_KEY, SECRET_KEY = "####", "####"
bitbnsObj = bitbns(API_KEY, SECRET_KEY)
bitbnsObj.placeMarginOrders({'symbol': 'BTC', 'side': 'placeOrder', 'type': 'BORROW', 'qnty': 0.00102, 'days': 1, 'rate': 0.000001})
{
'status': 1,
'error': 'Successfully placed borrow order for Margin trading.',
'code': 200
}
Is it possible to give high, low and volume for a coin. It helps to implement trading logic.
Get error code 200, while running a loop for 10 coins
import pandas as pd
import http.client
import json
import requests
from bitbnspy import bitbns
# BNS Private Keys
key = ''
secretKey = ''
bitbnsObj = bitbns(key, secretKey)
#Get Tickers
tickerdf = pd.read_excel (r'C:\Documents\Crptos\StaticData.xlsx', sheet_name= 'BNS')
for index,row in tickerdf.iterrows():
ticker1 = row['BNSTicker']
# -------------------------------------------get the order book for specific pair
#get sell/ask orderbook
data = bitbnsObj.getSellOrderBook(ticker1)
CoinBuy = pd.json_normalize(data, "data", meta=["status", "error","code"])
#get Buy/bid orderbook
data = bitbnsObj.getBuyOrderBook(ticker1)
CoinSell = pd.json_normalize(data, "data", meta=["status", "error","code"])
time.sleep(10)
Please advise solution, as i dont want to use time.sleep function and sometimes, it still gives error in fetching data
Ticker list is here:
BTCUSDT
ETHUSDT
XRPUSDT
ADAUSDT
TRXUSDT
LTCUSDT
BCHUSDT
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.