mirror of
https://github.com/Xe138/AI-Trader.git
synced 2026-04-09 20:27:25 -04:00
Compare commits
1 Commits
v0.3.0-alp
...
v0.3.0-alp
| Author | SHA1 | Date | |
|---|---|---|---|
| 8521f685c7 |
@@ -61,9 +61,7 @@ def buy(symbol: str, amount: int, signature: str = None, today_date: str = None)
|
|||||||
try:
|
try:
|
||||||
current_position, current_action_id = get_latest_position(today_date, signature)
|
current_position, current_action_id = get_latest_position(today_date, signature)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
return {"error": f"Failed to get position: {str(e)}", "signature": signature, "date": today_date}
|
||||||
print(current_position, current_action_id)
|
|
||||||
print(today_date, signature)
|
|
||||||
# Step 3: Get stock opening price for the day
|
# Step 3: Get stock opening price for the day
|
||||||
# Use get_open_prices function to get the opening price of specified stock for the day
|
# Use get_open_prices function to get the opening price of specified stock for the day
|
||||||
# If stock symbol does not exist or price data is missing, KeyError exception will be raised
|
# If stock symbol does not exist or price data is missing, KeyError exception will be raised
|
||||||
@@ -153,7 +151,10 @@ def sell(symbol: str, amount: int, signature: str = None, today_date: str = None
|
|||||||
# Step 2: Get current latest position and operation ID
|
# Step 2: Get current latest position and operation ID
|
||||||
# get_latest_position returns two values: position dictionary and current maximum operation ID
|
# get_latest_position returns two values: position dictionary and current maximum operation ID
|
||||||
# This ID is used to ensure each operation has a unique identifier
|
# This ID is used to ensure each operation has a unique identifier
|
||||||
current_position, current_action_id = get_latest_position(today_date, signature)
|
try:
|
||||||
|
current_position, current_action_id = get_latest_position(today_date, signature)
|
||||||
|
except Exception as e:
|
||||||
|
return {"error": f"Failed to get position: {str(e)}", "signature": signature, "date": today_date}
|
||||||
|
|
||||||
# Step 3: Get stock opening price for the day
|
# Step 3: Get stock opening price for the day
|
||||||
# Use get_open_prices function to get the opening price of specified stock for the day
|
# Use get_open_prices function to get the opening price of specified stock for the day
|
||||||
|
|||||||
Reference in New Issue
Block a user