Nobitex client for python
Project description
nobitexv2
install (نصب)
pip install nobitexv2
example usage (استفاده نمونه)
نمونه استفاده از nobitexv2. اسکریپتی که روزانه با استفاده از moving average سفارشتان market خرید و فروش میذارد.(بازار BTCUSDT)
import time
import requests
from datetime import datetime,timedelta
from nobitexv2 import NobitexV2
# توکن خودت رو میتونی از پنل بگیری یا متد auth_login
# https://apidocs.nobitex.ir/#login
nv2=NobitexV2(requests.Session()) # توکن رو از environment variables 'NOBITEX_TOKEN' میگیره
while True:
# BTCUSDT OHLCV data
history=nv2.market_udf_history(to=time.time(),
from_=(datetime.now()-timedelta(days=10)).timestamp(), # 10 days before
symbol='BTCUSDT',
resolution='D')
# closing prices (oldest0 to news)
closingprices=history['c']
# last trade price
last_trade_price=float(nv2.orderbook('BTCUSDT')['lastTradePrice'])
print("BTCUSDT last trade price:",last_trade_price)
# select usdt wallet from wallets
usdt_wallet=[wallet for wallet in nv2.wallets_list()['wallets'] if wallet['currency']=='usdt'][0]
# usdt balance available to trade
usdt_balance=float(usdt_wallet['balance'])-float(usdt_wallet['blockedBalance'])
print("usdt balance available to trade:",usdt_balance)
if usdt_balance<5.1:
print('balance less than minimum trade requirement')
break
# SMA10 value
mean=sum(closingprices)/len(closingprices)
trade_amount=usdt_balance*0.5/last_trade_price # 50% of the usdt balance
# market buy if current price is higher than SMA10
if last_trade_price>mean:
print(f"buying {trade_amount} btc")
nv2.add_spot_order(
type='buy',
execution='market',
srcCurrency='btc',
dstCurrency='usdt',
amount=trade_amount
)
else: # sell otherwise
print(f"selling {trade_amount} btc")
nv2.add_spot_order(
type='sell',
execution='market',
srcCurrency='btc',
dstCurrency='usdt',
amount=trade_amount
)
# iterate after a day
time.sleep(timedelta(days=1).total_seconds())
implementation progress nobitex docs
مواردی که 🟩 گذاشته شده پیاده سازی شده اند. 🟧 ناقص. 🟥 پیاده سازی نشده
| بخش | وضیعت |
|---|---|
| اطلاعات بازار (عمومی) | 🟩 |
| اطلاعات کاربر | 🟧 |
| معامله در بازار اسپات | 🟩 |
| معامله در بازار تعهدی | 🟧 |
| برداشت | 🟥 |
| وبسوکت (آزمایشی) | 🟥 |
| دفتر آدرس و حالت برداشت امن | 🟥 |
| امنیت | 🟥 |
| احراز هویت | 🟩 |
| سود و زیان | 🟥 |
| طرح معرفی دوستان | 🟥 |
| سایر | 🟥 |
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
nobitexv2-0.2.0.tar.gz
(7.6 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nobitexv2-0.2.0.tar.gz.
File metadata
- Download URL: nobitexv2-0.2.0.tar.gz
- Upload date:
- Size: 7.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
39bdc7dea1ec57c119ca312c6f55e401bf99e6670a0be25ea3e925d03d57e3a3
|
|
| MD5 |
419bea4288b0128b3428b23a93463f11
|
|
| BLAKE2b-256 |
085a60cb27958a441bf8a94e4ff247dfaa2c417462eb2fb8b0432737096d6edc
|
File details
Details for the file nobitexv2-0.2.0-py3-none-any.whl.
File metadata
- Download URL: nobitexv2-0.2.0-py3-none-any.whl
- Upload date:
- Size: 8.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f3906fb45ae867f3dda7a3625a5fd83bde035aed2585b624aa897d9aa5bd6c42
|
|
| MD5 |
4aed2b0e9c7daf3847ff6a46ae1aa50d
|
|
| BLAKE2b-256 |
12ddf0371d4f8688f056abfc242e7082f1e496e30463a7f1812afa4e0c5ee0ff
|