-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8630b96
commit b5997dc
Showing
2 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) |