Skip to main content

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

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.1.2.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nobitexv2-0.1.2-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file nobitexv2-0.1.2.tar.gz.

File metadata

  • Download URL: nobitexv2-0.1.2.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.4

File hashes

Hashes for nobitexv2-0.1.2.tar.gz
Algorithm Hash digest
SHA256 2f6b9ee5bc67dba7c4ae113714057b72be79010d023ba41591378f7f107cc79b
MD5 a7b24d904cb8c72ad5245adab7c4d093
BLAKE2b-256 7d5158a593aebf8721e94f0c210706632e7a6f4b3193441c99b5344c0b087e1a

See more details on using hashes here.

File details

Details for the file nobitexv2-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: nobitexv2-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.4

File hashes

Hashes for nobitexv2-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 99c58c499eaf4766e0b9501b581b8d66c80f5a013c55f0692feee2bf01bd8e39
MD5 0a9170e9f9b4168b8437b403d08c97b9
BLAKE2b-256 3f8319b82feba7a9691d75d8df0cfa5ed988e5a98d91aeaced934c104d8e8ce0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page