Skip to content

Commit

Permalink
add examples
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosmiei committed Oct 17, 2024
1 parent 8630b96 commit b5997dc
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
40 changes: 40 additions & 0 deletions examples/create_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import os
import sys

root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.append(root)

from binance.client import Client


api_key = "" # your api_key here
secret = "" # your secret here
client = Client(api_key, secret, testnet=True)

# create futures order
def create_futures_order():
order = client.futures_create_order(
symbol="LTCUSDT",
side="BUY",
type="MARKET",
quantity=0.1,
positionSide="LONG" # BOTH for One-way Mode ; LONG or SHORT for Hedge Mode
)
print(order)

def create_spot_order():
order = client.create_order(
symbol="LTCUSDT",
side="BUY",
type="LIMIT",
price=60,
quantity=0.1
)
print(order)


def main():
create_futures_order()
create_spot_order()

main()
25 changes: 25 additions & 0 deletions examples/create_order_async.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import os
import sys
import asyncio

root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.append(root)

from binance.client import AsyncClient

# create futures order
async def main():
api_key = "" # your api_key here
secret = "" # your secret here
client = AsyncClient(api_key, secret, testnet=True)
order = await client.futures_create_order(
symbol="LTCUSDT",
side="BUY",
type="MARKET",
quantity=0.1,
positionSide="LONG" # BOTH for One-way Mode ; LONG or SHORT for Hedge Mode
)
print(order)
await client.close_connection()

asyncio.run(main())

0 comments on commit b5997dc

Please sign in to comment.