-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.py
More file actions
44 lines (34 loc) · 1.2 KB
/
cli.py
File metadata and controls
44 lines (34 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import typer
from dotenv import load_dotenv
import logging
from services.logging_config import setup_logging
from services.orders import place_futures_order
app = typer.Typer()
@app.command()
def place_order(
symbol: str = typer.Option(..., help="Trading symbol e.g. BTCUSDT"),
side: str = typer.Option(..., help="BUY or SELL"),
order_type: str = typer.Option(..., help="MARKET or LIMIT"),
quantity: float = typer.Option(..., help="Order quantity"),
price: float = typer.Option(None, help="Price (required for LIMIT orders)"),
):
try:
response = place_futures_order(
symbol=symbol,
side=side,
order_type=order_type,
quantity=quantity,
price=price,
)
typer.echo("Order placed successfully")
typer.echo(f"Order ID: {response.get('orderId')}")
typer.echo(f"Status: {response.get('status')}")
typer.echo(f"Executed Qty: {response.get('executedQty')}")
typer.echo(f"Avg Price: {response.get('avgPrice', 'N/A')}")
except Exception as e:
logging.error(str(e))
typer.echo(f"Error: {e}")
if __name__ == "__main__":
load_dotenv()
setup_logging()
app()