Skip to main content

No project description provided

Project description

sunny-order-splitter-python-sdk

安装

pip install sunny-order-splitter --upgrade

现货使用方式

测试网地址 : https://testnet.binance.vision

from sunny_order_splitter.binance_spot import SpotOrderSplitter

def main():
  	production = False # True正式环境,不传默认True
        
	api_key = "EpcFiKyNEZ6GwpW4w1px60og0SYy0W4A2slX32UeH2hV9FjJfOdKPJDY9NNlbRrB"
	secret_key = "OeIwlnfB0ImKdqTq4n4jLqYxdzYO87Lc8Mr2Z1bbCqraerpomMUJMD7EvtyIFFWh"
	symbol = 'BTCUSDT'
	sos = SpotOrderSplitter(symbol, api_key, secret_key, production)
	    
	# Call split_order method with test parameters
	    
	params = {
	    "side": "BUY",
	    "orderAmount": 90,
	    #"totalAmount": 100,
	    "percentTotalAmount": 80, # 总金额百分比
	    "interval": 2
	}
	"""
	params = {
	    "side": "SELL",
	    "orderAmount": 1,
	    #"totalAmount": 100,
	    "percentTotalAmount":  100,
	    "interval": 2
	}
	"""
	result = sos.split_order(params)
	if result:
	    print(f"Orders placed successfully: {result['num_orders_success']} out of {result['num_orders']}")
	    print(f"Total quantity bought: {result['quantity']}")
	else:
	    print("Failed to place orders.")

if __name__ == "__main__":
    main()

合约使用方式(币本位)

现在只支持单项持仓,如果现在使用的是双向模式,会先改成单向模式

测试网地址: https://testnet.binancefuture.com

from sunny_order_splitter.binance_umfutures import UMFuturesOrderSplitter

def main():
    production = False # Set to True for production
          
    api_key = "63551008d09ed3a1d619644fbef3b27469b9518f0218c83e499843973e703146"
    secret_key = "ae8a0dd6278350d19d796ceade26e7acf552b64178398a1dd9fb8f7191ccbddb"
    symbol = 'BTCUSDT'
    umfos = UMFuturesOrderSplitter(symbol, api_key, secret_key, production)

    # Call split_order method with test parameters

    params = {
        "side": "SELL", # "BUY 多" or "SELL 空"
        "orderAmount": 1000,
        #"totalAmount": 200,
        "percentTotalAmount": 20, # 总金额百分比
        "leverage": 5, # 开仓杠杆 最大5倍
        "interval": 5 # 间隔时间
    }

    #开仓
    result = umfos.split_order(params)
    if result:
        print(f"Orders placed successfully: {result['num_orders_success']} out of {result['num_orders']}")
        print(f"Total quantity bought: {result['quantity']}")
    else:
        print("Failed to place orders.")


    #平仓
    results_close_order = umfos.close_position()
    if results_close_order:
        print(f"Order closed successfully:{results_close_order['symbol']} {results_close_order['quantity']}")
    else:
        print("Failed to close order.")

if __name__ == "__main__":
    main()

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

sunny_order_splitter-0.2.2.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

sunny_order_splitter-0.2.2-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file sunny_order_splitter-0.2.2.tar.gz.

File metadata

  • Download URL: sunny_order_splitter-0.2.2.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.3

File hashes

Hashes for sunny_order_splitter-0.2.2.tar.gz
Algorithm Hash digest
SHA256 3039149746ce5491fe6a10799f9486ca4fae3b7cfc85129b9067e3a30d387560
MD5 95058ec4e95d0be138a29aee192e5376
BLAKE2b-256 63d9971759fa0a4a62aae29c782f9d96456d07cf31605e7b5c144ed035b1ea3c

See more details on using hashes here.

File details

Details for the file sunny_order_splitter-0.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for sunny_order_splitter-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 4f3684979de739258596fa47891f1c69f77a2d76670fb672a8284f916d6d9990
MD5 2749b73f83ed15b4e9ef8be20b07b645
BLAKE2b-256 d282e797585698d147b38993474fb1a9d17edae4b1ed78bebdde8f1402501dae

See more details on using hashes here.

Supported by

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