-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.py
More file actions
50 lines (40 loc) · 1.5 KB
/
Copy pathcli.py
File metadata and controls
50 lines (40 loc) · 1.5 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
45
46
47
48
49
50
import argparse
from bot.orders import place_order
from bot.validators import validate_order, validate_side
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--symbol", required=True)
parser.add_argument("--side", required=True)
parser.add_argument("--type", required=True)
parser.add_argument("--quantity", type=float, required=True)
parser.add_argument("--price", type=float)
# TODO: add credentials here
args = parser.parse_args()
try:
validate_side(args.side)
validate_order(args.type, args.price)
print("\n===== ORDER SUMMARY =====")
print(f"Symbol: {args.symbol}")
print(f"Side: {args.side}")
print(f"Type: {args.type}")
print(f"Quantity: {args.quantity}")
if args.price:
print(f"Price: {args.price}")
print("\n(Checking market conditions and adjusting if needed...)")
order = place_order(
symbol=args.symbol,
side=args.side,
order_type=args.type,
quantity=args.quantity,
price=args.price
)
print("\n===== ORDER RESPONSE =====")
print(f"Order ID: {order.get('orderId')}")
print(f"Status: {order.get('status')}")
print(f"Executed Qty: {order.get('executedQty')}")
print(f"Avg Price: {order.get('avgPrice', 'N/A')}")
print("\n✅ Order placed successfully!")
except Exception as e:
print(f"\n❌ Error: {str(e)}")
if __name__ == "__main__":
main()