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

Uploaded Python 3

File details

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

File metadata

  • Download URL: nobitexv2-0.1.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.1.tar.gz
Algorithm Hash digest
SHA256 bf9b6dbbf189b2705c6120457b02fe9b4311b1829574857395843c983ae144e8
MD5 d2c02ef88e538ef02e57900481b6208c
BLAKE2b-256 359513fb16461ec074120a7e16bbe8ee25df040abd80093012da9fe8a4200ee2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: nobitexv2-0.1.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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 872659d8b0aee031ae63e56cb8467de3c4fdb6df28516fd5da513b8e59769d05
MD5 dfeb82968f496e43da8f1ccf2bdb37b5
BLAKE2b-256 f9b03352b30fc1e6c4e0c8d81c11c387deb1b84745d16796e03b9df4540ea853

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