apexomni-x86-windows-linux


Nameapexomni-x86-windows-linux JSON
Version 3.0.3 PyPI version JSON
download
home_pagehttps://github.com/ApeX-Protocol/apexpro-openapi
SummaryPython3 Apexpro omni HTTP/WebSocket API Connector
upload_time2024-12-17 06:55:07
maintainerNone
docs_urlNone
authorDexter Dickinson
requires_python>=3.6
licenseMIT License
keywords apexomni apexpro api connector
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # apexpro

Official Python3 API connector for Apex omni's HTTP and WebSockets APIs.  
You can get Api information from 
[OpenApi-SDK](https://api-docs.pro.apex.exchange/#introduction)

## About
Put simply, `apex omni` is the official lightweight one-stop-shop module for the Apex omni HTTP and WebSocket APIs. 

## Development
`apex omni` is being actively developed, and new API changes should arrive on `apex omni` very quickly. `apex omni` uses `requests` and `websocket` for its methods, alongside other built-in modules. Anyone is welcome to branch/fork the repository and add their own upgrades. If you think you've made substantial improvements to the module, submit a pull request and we'll gladly take a look.    
If the user's computer using  arm chip,  change libzklink_sdk-arm.dylib to libzklink_sdk.dylib and replace old libzklink_sdk.dylib in the directory  ./apexpro/ and ./test/   
If the user's computer using  x86 chip,  change libzklink_sdk-x86.dylib to libzklink_sdk.dylib and replace old libzklink_sdk.dylib in the directory  ./apexpro/ and ./test/     

## New Basic Usage V3 
You can create an HTTP session for Inverse on APEX_OMNI_HTTP_TEST or APEX_OMNI_HTTP_MAIN:
```python
from apexpro.constants import APEX_OMNI_HTTP_TEST
from apexpro.http_public import HttpPublic

client = HttpPublic(APEX_OMNI_HTTP_TEST)
```
### Public endpoints V3

You can get no authentication information from public endpoints.  
Please refer to [demo_public_v3](https://github.com/ApeX-Protocol/apexpro-openapi/blob/main/tests/demo_public_v3.py)

The V3 version supports  USDT symbols. Users need to request the configs_v3() interface to obtain the configuration of symbols.
```python
client = HttpPublic(APEX_OMNI_HTTP_MAIN)
print(client.configs_v3())
print(client.klines_v3(symbol="ETHUSDT",interval=5,start=1718358480, end=1718950620, limit=5))
print(client.depth_v3(symbol="BTCUSDT"))
print(client.trades_v3(symbol="BTCUSDT"))
print(client.klines_v3(symbol="BTCUSDT",interval="15"))
print(client.ticker_v3(symbol="BTCUSDT"))
print(client.history_funding_v3(symbol="BTC-USDT"))
```

### Register OMNI method V3
- You can get zkKeys from client.derive_zk_key(), for regiter-user, create-order or transfer and withdraw.    
- If the user wants to trade OMNI's symbols, needs to call the register_user_v3() interface to register a OMNI account.   
- If the user has previously registered a pro apex account using the v1 or v2 interface, you also need to use the register_user_v3()   
    interface to register again.        
- You need to call client.configs_v3() after init client.      
- You can get apiKey and accountId for private Api    
- After call register_user_v3(), the user must call change_pub_key_v3() to complete register v3 account.   
- Since the register_user_v3  is a non-blocking process, you need to sleep for 10 sec before call the change_pub_key_v3() action.
Please refer to [demo_register_v3](https://github.com/ApeX-Protocol/apexpro-openapi/blob/main/tests/demo_register_v3.py)


```python
from apexpro.constants import APEX_OMNI_HTTP_MAIN, NETWORKID_OMNI_MAIN_ARB, NETWORKID_MAIN

print("Hello, Apex Omni")
priKey = "your eth private key"

client = HttpPrivate_v3(APEX_OMNI_HTTP_MAIN, network_id=NETWORKID_MAIN, eth_private_key=priKey)
configs = client.configs_v3()

zkKeys = client.derive_zk_key(client.default_address)
print(zkKeys)

nonceRes = client.generate_nonce_v3(refresh="false", l2Key=zkKeys['l2Key'],ethAddress=client.default_address, chainId=NETWORKID_OMNI_MAIN_ARB)

regRes = client.register_user_v3(nonce=nonceRes['data']['nonce'],l2Key=zkKeys['l2Key'], seeds=zkKeys['seeds'],ethereum_address=client.default_address)


key = regRes['data']['apiKey']['key']
secret = regRes['data']['apiKey']['secret']
passphrase = regRes['data']['apiKey']['passphrase']

time.sleep(10)
accountRes = client.get_account_v3()
print(accountRes)


#back zkKeys, apiKey,and accountId for private Api or create-oreder transfer or withdraw

print(regRes['data']['account']['id'])
print(regRes['data']['apiKey'])

changeRes = client.change_pub_key_v3(chainId=NETWORKID_OMNI_MAIN_ARB, seeds=zkKeys.get('seeds'), ethPrivateKey=priKey, zkAccountId = accountRes.get('spotAccount').get('zkAccountId'), subAccountId = accountRes.get('spotAccount').get('defaultSubAccountId'),
                                     newPkHash = zkKeys.get('pubKeyHash'),  nonce= accountRes.get('spotAccount').get('nonce'), l2Key= zkKeys.get('l2Key'))
print(changeRes)

time.sleep(10)
accountRes = client.get_account_v3()
print(accountRes)
```

### Private endpoints V3
Users need to request the configs_v3() and get_account_v3() interface to obtain the configuration of Account.   

some authentication information is required to access private endpoints.   
Please refer to [demo_private_v3](https://github.com/ApeX-Protocol/apexpro-openapi/blob/main/tests/demo_private_v3.py)

```python
from apexpro.constants import APEX_OMNI_HTTP_MAIN, \
    NETWORKID_OMNI_MAIN_ARB

print("Hello, Apex Omni")
# need api_key_credentials={'key': key,'secret': secret, 'passphrase': passphrase} for private api

key = 'your apiKey-key from register V3'
secret = 'your apiKey-secret from register  V3'
passphrase = 'your apiKey-passphrase from register  V3'

client = HttpPrivate_v3(APEX_OMNI_HTTP_MAIN, network_id=NETWORKID_OMNI_MAIN_ARB, api_key_credentials={'key': key,'secret': secret, 'passphrase': passphrase})
configs = client.configs_v3()

userRes = client.get_user_v3()
print(userRes)


accountRes = client.get_account_v3()
print(accountRes)

accountBalanceRes = client.get_account_balance_v3()
print(accountBalanceRes)

fillsRes = client.fills_v3(limit=100,page=0,symbol="BTC-USDT",side="BUY",token="USDT")
print(fillsRes)

transfersRes = client.transfers_v3(limit=100)
print(transfersRes)

transferRes = client.transfer_v3(ids='586213648326721628')
print(transferRes)

transfersRes = client.contract_transfers_v3(limit=100)
print(transfersRes)

transferRes = client.contract_transfer_v3(ids='588301879870489180')
print(transferRes)

#deleteOrderRes = client.delete_order_v3(id="588302655921587036")
#print(deleteOrderRes)

#deleteOrderRes = client.delete_order_by_client_order_id_v3(id="123456")
#print(deleteOrderRes)

openOrdersRes = client.open_orders_v3()
print(openOrdersRes)

deleteOrdersRes = client.delete_open_orders_v3(symbol="BTC-USDT",)
print(deleteOrdersRes)

historyOrdersRes = client.history_orders_v3(token='USDT')
print(historyOrdersRes)

getOrderRes = client.get_order_v3(id="123456")
print(getOrderRes)

getOrderRes = client.get_order_by_client_order_id_v3(id="123456")
print(getOrderRes)

fundingRes = client.funding_v3(limit=100)
print(fundingRes)

historicalPnlRes = client.historical_pnl_v3(limit=100)
print(historicalPnlRes)

yesterdayPnlRes = client.yesterday_pnl_v3()
print(yesterdayPnlRes)

historyValueRes = client.history_value_v3()
print(historyValueRes)

setInitialMarginRateRes = client.set_initial_margin_rate_v3(symbol="BTC-USDT",initialMarginRate="0.05")
print(setInitialMarginRateRes)

```

### zkKey sign withdraw or transfer method
Users need to request the configs_v3() and get_account_v3() interface to obtain the configuration of Account.    

Several endpoints require a seeds and l2Key signature authentication, namely as following:    
- create_withdrawal_v3()  to withdraw or fast withdraw
- create_transfer_out_v3()   to transfer asset from spot account to contract account   
- create_contract_transfer_out_v3()   to transfer asset from contract account to spot account    

Please refer to [demo_transfer_v3](https://github.com/ApeX-Protocol/apexpro-openapi/blob/main/tests/demo_transfer_v3.py)

```python
key = 'your apiKey-key from register'
secret = 'your apiKey-secret from register'
passphrase = 'your apiKey-passphrase from register'

seeds = 'your zk seeds from register'
l2Key = 'your l2Key seeds from register'

client = HttpPrivateSign(APEX_OMNI_HTTP_TEST, network_id=NETWORKID_TEST,
                          zk_seeds=seeds,zk_l2Key=l2Key,
                          api_key_credentials={'key': key, 'secret': secret, 'passphrase': passphrase})
configs = client.configs_v3()
accountData = client.get_account_v3()

#smple1 withdraw
#createWithdrawRes = client.create_withdrawal_v3(amount='3',asset='USDT', toChainId=3)
#print(createWithdrawRes)

#smple2 fast withdraw
#withdraw_feeRes = client.withdraw_fee_v3(amount="3",chainIds="3",tokenId='140')
#print(withdraw_feeRes)
#createWithdrawRes = client.create_withdrawal_v3(amount='3',asset='USDT', toChainId=3, fee=withdraw_feeRes.get('data').get('withdrawFeeAndPoolBalances')[0].get('fee'), isFastWithdraw=True)
#print(createWithdrawRes)

#smple3 transfer_out
#createTransferRes = client.create_transfer_out_v3(amount='3.4359738368',asset='USDT')
#print(createTransferRes)

#smple4 contract transfer_out
createContractTransferRes = client.create_contract_transfer_out_v3(amount='3.4359738368',asset='USDT')
print(createContractTransferRes)

```


### zkKey sign create order method
Users need to request the configs_v3() and get_account_v3() interface to obtain the configuration of Account.    
Several endpoints require a seeds and l2Key signature authentication, namely as following:    
- create_order_v3()  to create order

```python
from apexpro.constants import NETWORKID_TEST, APEX_OMNI_HTTP_TEST

print("Hello, Apex omni")

key = 'your apiKey-key from register'
secret = 'your apiKey-secret from register'
passphrase = 'your apiKey-passphrase from register'

seeds = 'your zk seeds from register'
l2Key = 'your l2Key seeds from register'


client = HttpPrivateSign(APEX_OMNI_HTTP_TEST, network_id=NETWORKID_TEST,
                          zk_seeds=seeds,zk_l2Key=l2Key,
                          api_key_credentials={'key': key, 'secret': secret, 'passphrase': passphrase})
configs = client.configs_v3()
accountData = client.get_account_v3()


currentTime = time.time()
createOrderRes = client.create_order_v3(symbol="BTC-USDT", side="SELL",
                                        type="MARKET", size="0.001", timestampSeconds= currentTime,
                                        price="60000")
print(createOrderRes)

# sample6
# Create a  TP/SL order
# first, Set a slippage to get an acceptable slPrice or tpPrice
#slippage is recommended to be greater than 0.1
# when buying, the price = price*(1 + slippage). when selling, the price = price*(1 - slippage)
slippage = decimal.Decimal("-0.1")
slPrice =  decimal.Decimal("58000") * (decimal.Decimal("1") + slippage)
tpPrice =  decimal.Decimal("79000") * (decimal.Decimal("1") - slippage)

createOrderRes = client.create_order_v3(symbol="BTC-USDT", side="BUY",
                                     type="LIMIT", size="0.01",
                                     price="65000",
                                     isOpenTpslOrder=True,
                                     isSetOpenSl=True,
                                     slPrice=slPrice,
                                     slSide="SELL",
                                     slSize="0.01",
                                     slTriggerPrice="58000",
                                     isSetOpenTp=True,
                                     tpPrice=tpPrice,
                                     tpSide="SELL",
                                     tpSize="0.01",
                                     tpTriggerPrice="79000",
                                     )
print(createOrderRes)

print("end, Apexpro")

```

### WebSocket
To see comprehensive examples of how to subscribe topics from websockets.
Please refer to [demo_ws_v3](https://github.com/ApeX-Protocol/apexpro-openapi/blob/main/tests/demo_ws_v3.py)


```python
from time import sleep

from apexpro.constants import APEX_OMNI_WS_MAIN
from apexpro.websocket_api import WebSocket

key = 'your apiKey-key from register V3'
secret = 'your apiKey-secret from register  V3'
passphrase = 'your apiKey-passphrase from register  V3'


# Connect with authentication!
# APEX_OMNI_WS_MAIN for mainnet, APEX_OMNI_WS_TEST for testnet
ws_client = WebSocket(
    endpoint=APEX_OMNI_WS_MAIN,
    api_key_credentials={'key': key, 'secret': secret, 'passphrase': passphrase},
)

def handle_account(message):
    print(message)
    contents_data = message["contents"]
    print(len(contents_data))

def h1(message):
    print(1, message)
def h2(message):
    print(2, message)
def h3(message):
    print(3, message)
def h4(message):
    print(4, message)

#ws_client.depth_stream(h1,'BTCUSDT',25)
#ws_client.ticker_stream(h2,'BTCUSDT')
ws_client.trade_stream(h3,'BTCUSDT')
ws_client.klines_stream(h4,'BTCUSDT',1)
ws_client.account_info_stream_v3(handle_account)


while True:
    # Run your main trading logic here.
    sleep(1)

```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/ApeX-Protocol/apexpro-openapi",
    "name": "apexomni-x86-windows-linux",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": "apexomni apexpro api connector",
    "author": "Dexter Dickinson",
    "author_email": "xxx@apexomni.com",
    "download_url": "https://files.pythonhosted.org/packages/3c/06/99ad28a451ce04883a4afa8dd478af394e68e00c44161221b12b82933787/apexomni_x86_windows_linux-3.0.3.tar.gz",
    "platform": null,
    "description": "# apexpro\n\nOfficial Python3 API connector for Apex omni's HTTP and WebSockets APIs.  \nYou can get Api information from \n[OpenApi-SDK](https://api-docs.pro.apex.exchange/#introduction)\n\n## About\nPut simply, `apex omni` is the official lightweight one-stop-shop module for the Apex omni HTTP and WebSocket APIs. \n\n## Development\n`apex omni` is being actively developed, and new API changes should arrive on `apex omni` very quickly. `apex omni` uses `requests` and `websocket` for its methods, alongside other built-in modules. Anyone is welcome to branch/fork the repository and add their own upgrades. If you think you've made substantial improvements to the module, submit a pull request and we'll gladly take a look.    \nIf the user's computer using  arm chip,  change libzklink_sdk-arm.dylib to libzklink_sdk.dylib and replace old libzklink_sdk.dylib in the directory  ./apexpro/ and ./test/   \nIf the user's computer using  x86 chip,  change libzklink_sdk-x86.dylib to libzklink_sdk.dylib and replace old libzklink_sdk.dylib in the directory  ./apexpro/ and ./test/     \n\n## New Basic Usage V3 \nYou can create an HTTP session for Inverse on APEX_OMNI_HTTP_TEST or APEX_OMNI_HTTP_MAIN:\n```python\nfrom apexpro.constants import APEX_OMNI_HTTP_TEST\nfrom apexpro.http_public import HttpPublic\n\nclient = HttpPublic(APEX_OMNI_HTTP_TEST)\n```\n### Public endpoints V3\n\nYou can get no authentication information from public endpoints.  \nPlease refer to [demo_public_v3](https://github.com/ApeX-Protocol/apexpro-openapi/blob/main/tests/demo_public_v3.py)\n\nThe V3 version supports  USDT symbols. Users need to request the configs_v3() interface to obtain the configuration of symbols.\n```python\nclient = HttpPublic(APEX_OMNI_HTTP_MAIN)\nprint(client.configs_v3())\nprint(client.klines_v3(symbol=\"ETHUSDT\",interval=5,start=1718358480, end=1718950620, limit=5))\nprint(client.depth_v3(symbol=\"BTCUSDT\"))\nprint(client.trades_v3(symbol=\"BTCUSDT\"))\nprint(client.klines_v3(symbol=\"BTCUSDT\",interval=\"15\"))\nprint(client.ticker_v3(symbol=\"BTCUSDT\"))\nprint(client.history_funding_v3(symbol=\"BTC-USDT\"))\n```\n\n### Register OMNI method V3\n- You can get zkKeys from client.derive_zk_key(), for regiter-user, create-order or transfer and withdraw.    \n- If the user wants to trade OMNI's symbols, needs to call the register_user_v3() interface to register a OMNI account.   \n- If the user has previously registered a pro apex account using the v1 or v2 interface, you also need to use the register_user_v3()   \n    interface to register again.        \n- You need to call client.configs_v3() after init client.      \n- You can get apiKey and accountId for private Api    \n- After call register_user_v3(), the user must call change_pub_key_v3() to complete register v3 account.   \n- Since the register_user_v3  is a non-blocking process, you need to sleep for 10 sec before call the change_pub_key_v3() action.\nPlease refer to [demo_register_v3](https://github.com/ApeX-Protocol/apexpro-openapi/blob/main/tests/demo_register_v3.py)\n\n\n```python\nfrom apexpro.constants import APEX_OMNI_HTTP_MAIN, NETWORKID_OMNI_MAIN_ARB, NETWORKID_MAIN\n\nprint(\"Hello, Apex Omni\")\npriKey = \"your eth private key\"\n\nclient = HttpPrivate_v3(APEX_OMNI_HTTP_MAIN, network_id=NETWORKID_MAIN, eth_private_key=priKey)\nconfigs = client.configs_v3()\n\nzkKeys = client.derive_zk_key(client.default_address)\nprint(zkKeys)\n\nnonceRes = client.generate_nonce_v3(refresh=\"false\", l2Key=zkKeys['l2Key'],ethAddress=client.default_address, chainId=NETWORKID_OMNI_MAIN_ARB)\n\nregRes = client.register_user_v3(nonce=nonceRes['data']['nonce'],l2Key=zkKeys['l2Key'], seeds=zkKeys['seeds'],ethereum_address=client.default_address)\n\n\nkey = regRes['data']['apiKey']['key']\nsecret = regRes['data']['apiKey']['secret']\npassphrase = regRes['data']['apiKey']['passphrase']\n\ntime.sleep(10)\naccountRes = client.get_account_v3()\nprint(accountRes)\n\n\n#back zkKeys, apiKey,and accountId for private Api or create-oreder transfer or withdraw\n\nprint(regRes['data']['account']['id'])\nprint(regRes['data']['apiKey'])\n\nchangeRes = client.change_pub_key_v3(chainId=NETWORKID_OMNI_MAIN_ARB, seeds=zkKeys.get('seeds'), ethPrivateKey=priKey, zkAccountId = accountRes.get('spotAccount').get('zkAccountId'), subAccountId = accountRes.get('spotAccount').get('defaultSubAccountId'),\n                                     newPkHash = zkKeys.get('pubKeyHash'),  nonce= accountRes.get('spotAccount').get('nonce'), l2Key= zkKeys.get('l2Key'))\nprint(changeRes)\n\ntime.sleep(10)\naccountRes = client.get_account_v3()\nprint(accountRes)\n```\n\n### Private endpoints V3\nUsers need to request the configs_v3() and get_account_v3() interface to obtain the configuration of Account.   \n\nsome authentication information is required to access private endpoints.   \nPlease refer to [demo_private_v3](https://github.com/ApeX-Protocol/apexpro-openapi/blob/main/tests/demo_private_v3.py)\n\n```python\nfrom apexpro.constants import APEX_OMNI_HTTP_MAIN, \\\n    NETWORKID_OMNI_MAIN_ARB\n\nprint(\"Hello, Apex Omni\")\n# need api_key_credentials={'key': key,'secret': secret, 'passphrase': passphrase} for private api\n\nkey = 'your apiKey-key from register V3'\nsecret = 'your apiKey-secret from register  V3'\npassphrase = 'your apiKey-passphrase from register  V3'\n\nclient = HttpPrivate_v3(APEX_OMNI_HTTP_MAIN, network_id=NETWORKID_OMNI_MAIN_ARB, api_key_credentials={'key': key,'secret': secret, 'passphrase': passphrase})\nconfigs = client.configs_v3()\n\nuserRes = client.get_user_v3()\nprint(userRes)\n\n\naccountRes = client.get_account_v3()\nprint(accountRes)\n\naccountBalanceRes = client.get_account_balance_v3()\nprint(accountBalanceRes)\n\nfillsRes = client.fills_v3(limit=100,page=0,symbol=\"BTC-USDT\",side=\"BUY\",token=\"USDT\")\nprint(fillsRes)\n\ntransfersRes = client.transfers_v3(limit=100)\nprint(transfersRes)\n\ntransferRes = client.transfer_v3(ids='586213648326721628')\nprint(transferRes)\n\ntransfersRes = client.contract_transfers_v3(limit=100)\nprint(transfersRes)\n\ntransferRes = client.contract_transfer_v3(ids='588301879870489180')\nprint(transferRes)\n\n#deleteOrderRes = client.delete_order_v3(id=\"588302655921587036\")\n#print(deleteOrderRes)\n\n#deleteOrderRes = client.delete_order_by_client_order_id_v3(id=\"123456\")\n#print(deleteOrderRes)\n\nopenOrdersRes = client.open_orders_v3()\nprint(openOrdersRes)\n\ndeleteOrdersRes = client.delete_open_orders_v3(symbol=\"BTC-USDT\",)\nprint(deleteOrdersRes)\n\nhistoryOrdersRes = client.history_orders_v3(token='USDT')\nprint(historyOrdersRes)\n\ngetOrderRes = client.get_order_v3(id=\"123456\")\nprint(getOrderRes)\n\ngetOrderRes = client.get_order_by_client_order_id_v3(id=\"123456\")\nprint(getOrderRes)\n\nfundingRes = client.funding_v3(limit=100)\nprint(fundingRes)\n\nhistoricalPnlRes = client.historical_pnl_v3(limit=100)\nprint(historicalPnlRes)\n\nyesterdayPnlRes = client.yesterday_pnl_v3()\nprint(yesterdayPnlRes)\n\nhistoryValueRes = client.history_value_v3()\nprint(historyValueRes)\n\nsetInitialMarginRateRes = client.set_initial_margin_rate_v3(symbol=\"BTC-USDT\",initialMarginRate=\"0.05\")\nprint(setInitialMarginRateRes)\n\n```\n\n### zkKey sign withdraw or transfer method\nUsers need to request the configs_v3() and get_account_v3() interface to obtain the configuration of Account.    \n\nSeveral endpoints require a seeds and l2Key signature authentication, namely as following:    \n- create_withdrawal_v3()  to withdraw or fast withdraw\n- create_transfer_out_v3()   to transfer asset from spot account to contract account   \n- create_contract_transfer_out_v3()   to transfer asset from contract account to spot account    \n\nPlease refer to [demo_transfer_v3](https://github.com/ApeX-Protocol/apexpro-openapi/blob/main/tests/demo_transfer_v3.py)\n\n```python\nkey = 'your apiKey-key from register'\nsecret = 'your apiKey-secret from register'\npassphrase = 'your apiKey-passphrase from register'\n\nseeds = 'your zk seeds from register'\nl2Key = 'your l2Key seeds from register'\n\nclient = HttpPrivateSign(APEX_OMNI_HTTP_TEST, network_id=NETWORKID_TEST,\n                          zk_seeds=seeds,zk_l2Key=l2Key,\n                          api_key_credentials={'key': key, 'secret': secret, 'passphrase': passphrase})\nconfigs = client.configs_v3()\naccountData = client.get_account_v3()\n\n#smple1 withdraw\n#createWithdrawRes = client.create_withdrawal_v3(amount='3',asset='USDT', toChainId=3)\n#print(createWithdrawRes)\n\n#smple2 fast withdraw\n#withdraw_feeRes = client.withdraw_fee_v3(amount=\"3\",chainIds=\"3\",tokenId='140')\n#print(withdraw_feeRes)\n#createWithdrawRes = client.create_withdrawal_v3(amount='3',asset='USDT', toChainId=3, fee=withdraw_feeRes.get('data').get('withdrawFeeAndPoolBalances')[0].get('fee'), isFastWithdraw=True)\n#print(createWithdrawRes)\n\n#smple3 transfer_out\n#createTransferRes = client.create_transfer_out_v3(amount='3.4359738368',asset='USDT')\n#print(createTransferRes)\n\n#smple4 contract transfer_out\ncreateContractTransferRes = client.create_contract_transfer_out_v3(amount='3.4359738368',asset='USDT')\nprint(createContractTransferRes)\n\n```\n\n\n### zkKey sign create order method\nUsers need to request the configs_v3() and get_account_v3() interface to obtain the configuration of Account.    \nSeveral endpoints require a seeds and l2Key signature authentication, namely as following:    \n- create_order_v3()  to create order\n\n```python\nfrom apexpro.constants import NETWORKID_TEST, APEX_OMNI_HTTP_TEST\n\nprint(\"Hello, Apex omni\")\n\nkey = 'your apiKey-key from register'\nsecret = 'your apiKey-secret from register'\npassphrase = 'your apiKey-passphrase from register'\n\nseeds = 'your zk seeds from register'\nl2Key = 'your l2Key seeds from register'\n\n\nclient = HttpPrivateSign(APEX_OMNI_HTTP_TEST, network_id=NETWORKID_TEST,\n                          zk_seeds=seeds,zk_l2Key=l2Key,\n                          api_key_credentials={'key': key, 'secret': secret, 'passphrase': passphrase})\nconfigs = client.configs_v3()\naccountData = client.get_account_v3()\n\n\ncurrentTime = time.time()\ncreateOrderRes = client.create_order_v3(symbol=\"BTC-USDT\", side=\"SELL\",\n                                        type=\"MARKET\", size=\"0.001\", timestampSeconds= currentTime,\n                                        price=\"60000\")\nprint(createOrderRes)\n\n# sample6\n# Create a  TP/SL order\n# first, Set a slippage to get an acceptable slPrice or tpPrice\n#slippage is recommended to be greater than 0.1\n# when buying, the price = price*(1 + slippage). when selling, the price = price*(1 - slippage)\nslippage = decimal.Decimal(\"-0.1\")\nslPrice =  decimal.Decimal(\"58000\") * (decimal.Decimal(\"1\") + slippage)\ntpPrice =  decimal.Decimal(\"79000\") * (decimal.Decimal(\"1\") - slippage)\n\ncreateOrderRes = client.create_order_v3(symbol=\"BTC-USDT\", side=\"BUY\",\n                                     type=\"LIMIT\", size=\"0.01\",\n                                     price=\"65000\",\n                                     isOpenTpslOrder=True,\n                                     isSetOpenSl=True,\n                                     slPrice=slPrice,\n                                     slSide=\"SELL\",\n                                     slSize=\"0.01\",\n                                     slTriggerPrice=\"58000\",\n                                     isSetOpenTp=True,\n                                     tpPrice=tpPrice,\n                                     tpSide=\"SELL\",\n                                     tpSize=\"0.01\",\n                                     tpTriggerPrice=\"79000\",\n                                     )\nprint(createOrderRes)\n\nprint(\"end, Apexpro\")\n\n```\n\n### WebSocket\nTo see comprehensive examples of how to subscribe topics from websockets.\nPlease refer to [demo_ws_v3](https://github.com/ApeX-Protocol/apexpro-openapi/blob/main/tests/demo_ws_v3.py)\n\n\n```python\nfrom time import sleep\n\nfrom apexpro.constants import APEX_OMNI_WS_MAIN\nfrom apexpro.websocket_api import WebSocket\n\nkey = 'your apiKey-key from register V3'\nsecret = 'your apiKey-secret from register  V3'\npassphrase = 'your apiKey-passphrase from register  V3'\n\n\n# Connect with authentication!\n# APEX_OMNI_WS_MAIN for mainnet, APEX_OMNI_WS_TEST for testnet\nws_client = WebSocket(\n    endpoint=APEX_OMNI_WS_MAIN,\n    api_key_credentials={'key': key, 'secret': secret, 'passphrase': passphrase},\n)\n\ndef handle_account(message):\n    print(message)\n    contents_data = message[\"contents\"]\n    print(len(contents_data))\n\ndef h1(message):\n    print(1, message)\ndef h2(message):\n    print(2, message)\ndef h3(message):\n    print(3, message)\ndef h4(message):\n    print(4, message)\n\n#ws_client.depth_stream(h1,'BTCUSDT',25)\n#ws_client.ticker_stream(h2,'BTCUSDT')\nws_client.trade_stream(h3,'BTCUSDT')\nws_client.klines_stream(h4,'BTCUSDT',1)\nws_client.account_info_stream_v3(handle_account)\n\n\nwhile True:\n    # Run your main trading logic here.\n    sleep(1)\n\n```\n",
    "bugtrack_url": null,
    "license": "MIT License",
    "summary": "Python3 Apexpro omni HTTP/WebSocket API Connector",
    "version": "3.0.3",
    "project_urls": {
        "Homepage": "https://github.com/ApeX-Protocol/apexpro-openapi"
    },
    "split_keywords": [
        "apexomni",
        "apexpro",
        "api",
        "connector"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c0c0a5584edb6c933701aad1f035202dfedb27069c51397f76f0a3d4141fbde5",
                "md5": "ce8978fe8b788babcf0dadbfbd88d9db",
                "sha256": "95a28276a134e39712371b936bb14aa5419abb62041c09597ce596a725995423"
            },
            "downloads": -1,
            "filename": "apexomni_x86_windows_linux-3.0.3-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ce8978fe8b788babcf0dadbfbd88d9db",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=3.6",
            "size": 8924543,
            "upload_time": "2024-12-17T06:55:02",
            "upload_time_iso_8601": "2024-12-17T06:55:02.308257Z",
            "url": "https://files.pythonhosted.org/packages/c0/c0/a5584edb6c933701aad1f035202dfedb27069c51397f76f0a3d4141fbde5/apexomni_x86_windows_linux-3.0.3-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3c0699ad28a451ce04883a4afa8dd478af394e68e00c44161221b12b82933787",
                "md5": "2e68d3ee3b5271dd0fea0c0d13ae3764",
                "sha256": "9f72c51401707131cad0b44ba7fa20d7b12d259c8ea8fdc857a5d82e19873dbf"
            },
            "downloads": -1,
            "filename": "apexomni_x86_windows_linux-3.0.3.tar.gz",
            "has_sig": false,
            "md5_digest": "2e68d3ee3b5271dd0fea0c0d13ae3764",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 8143366,
            "upload_time": "2024-12-17T06:55:07",
            "upload_time_iso_8601": "2024-12-17T06:55:07.130324Z",
            "url": "https://files.pythonhosted.org/packages/3c/06/99ad28a451ce04883a4afa8dd478af394e68e00c44161221b12b82933787/apexomni_x86_windows_linux-3.0.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-17 06:55:07",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ApeX-Protocol",
    "github_project": "apexpro-openapi",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "apexomni-x86-windows-linux"
}
        
Elapsed time: 1.94478s