Skip to main content

Nobitex client for python

Project description

nobitexv2

install (نصب)

pip install nobitexv2

example usage (استفاده نمونه)

نمونه استفاده از nobitexv2. اسکریپتی که روزانه با استفاده از moving average سفارشتان market خرید و فروش میذارد.(بازار BTCUSDT)

import time
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.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-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: nobitexv2-0.1.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.tar.gz
Algorithm Hash digest
SHA256 fca5dc7c5355980cf4d2b6c93b5ff82dcc1afdf0a7a531dbabac1c2568e41bd1
MD5 6e54f500281cea6c436049516a89f5f0
BLAKE2b-256 14d4f3fafaffa85ba7bd63ae39ca575f37754c3f4e1d3128562a699f5a40de15

See more details on using hashes here.

File details

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

File metadata

  • Download URL: nobitexv2-0.1-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-py3-none-any.whl
Algorithm Hash digest
SHA256 9a37e484ca125a9360f2176ebeaf5b33c5859afa768458d700b0183134013c27
MD5 368af5abc9dadb0fbf6e6968fc6e5674
BLAKE2b-256 275f1ca1c11a536e326e2f24e92c1baa5b5a964f9409008b4fa64732f5b9735b

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