fix: 买入不生效
This commit is contained in:
parent
13f7ca8dfd
commit
6cab77a88a
BIN
resources/同花顺系统设置.png
Normal file
BIN
resources/同花顺系统设置.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 68 KiB |
@ -17,8 +17,10 @@ class RealTrader:
|
|||||||
user="35207457", password="351916", exe_path=r"C:\\ths\\xiadan.exe"
|
user="35207457", password="351916", exe_path=r"C:\\ths\\xiadan.exe"
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
time.sleep(3)
|
time.sleep(1)
|
||||||
self.trader.connect(r"C:\\ths\\xiadan.exe")
|
self.trader.connect(r"C:\\ths\\xiadan.exe")
|
||||||
|
self.trader.enable_type_keys_for_editor()
|
||||||
|
self.trader.grid_strategy_instance.tmp_folder = "C:\\temp"
|
||||||
|
|
||||||
def logout(self):
|
def logout(self):
|
||||||
self.trader.exit()
|
self.trader.exit()
|
||||||
@ -42,10 +44,10 @@ class RealTrader:
|
|||||||
self.trader.refresh()
|
self.trader.refresh()
|
||||||
|
|
||||||
def buy(self, code, price, amount):
|
def buy(self, code, price, amount):
|
||||||
self.trader.buy(code, price, amount)
|
return self.trader.buy(code, price, amount)
|
||||||
|
|
||||||
def sell(self, code, price, amount):
|
def sell(self, code, price, amount):
|
||||||
self.trader.sell(code, price, amount)
|
return self.trader.sell(code, price, amount)
|
||||||
|
|
||||||
def cancel(self, entrust_no):
|
def cancel(self, entrust_no):
|
||||||
self.trader.cancel_entrust(entrust_no)
|
return self.trader.cancel_entrust(entrust_no)
|
||||||
|
@ -24,7 +24,7 @@ threading.Thread(target=run_pending_tasks).start()
|
|||||||
trader = RealTrader()
|
trader = RealTrader()
|
||||||
|
|
||||||
### test code start
|
### test code start
|
||||||
# trader.login()
|
trader.login()
|
||||||
# time.sleep(5)
|
# time.sleep(5)
|
||||||
# trader.logout()
|
# trader.logout()
|
||||||
### test code end
|
### test code end
|
||||||
@ -58,7 +58,7 @@ def buy():
|
|||||||
print(f"buy: {code}, {price}, {amount}")
|
print(f"buy: {code}, {price}, {amount}")
|
||||||
result = trader.buy(code, price, amount)
|
result = trader.buy(code, price, amount)
|
||||||
|
|
||||||
response = {"success": True, "message": result}
|
response = {"success": True, "data": result}
|
||||||
return jsonify(response), 200
|
return jsonify(response), 200
|
||||||
except ValueError:
|
except ValueError:
|
||||||
abort(
|
abort(
|
||||||
@ -82,7 +82,7 @@ def sell():
|
|||||||
print(f"sell: {code}, {price}, {amount}")
|
print(f"sell: {code}, {price}, {amount}")
|
||||||
result = trader.sell(code, price, amount)
|
result = trader.sell(code, price, amount)
|
||||||
|
|
||||||
response = {"success": True, "message": result}
|
response = {"success": True, "data": result}
|
||||||
return jsonify(response), 200
|
return jsonify(response), 200
|
||||||
except ValueError:
|
except ValueError:
|
||||||
abort(
|
abort(
|
||||||
@ -96,7 +96,7 @@ def cancel(entrust_no):
|
|||||||
print(f"cancel: {entrust_no}")
|
print(f"cancel: {entrust_no}")
|
||||||
result = trader.cancel(entrust_no)
|
result = trader.cancel(entrust_no)
|
||||||
|
|
||||||
response = {"success": True, "message": result}
|
response = {"success": True, "data": result}
|
||||||
return jsonify(response), 200
|
return jsonify(response), 200
|
||||||
|
|
||||||
|
|
||||||
@ -106,11 +106,7 @@ def get_balance():
|
|||||||
balance = trader.get_balance()
|
balance = trader.get_balance()
|
||||||
print(f"balance: {balance}")
|
print(f"balance: {balance}")
|
||||||
|
|
||||||
response = {
|
response = {"success": True, "data": balance}
|
||||||
"success": True,
|
|
||||||
"message": "Balance retrieved successfully.",
|
|
||||||
"data": balance,
|
|
||||||
}
|
|
||||||
return jsonify(response), 200
|
return jsonify(response), 200
|
||||||
|
|
||||||
|
|
||||||
@ -119,11 +115,7 @@ def get_positions():
|
|||||||
"""Get the positions of the account."""
|
"""Get the positions of the account."""
|
||||||
positions = trader.get_positions()
|
positions = trader.get_positions()
|
||||||
|
|
||||||
response = {
|
response = {"success": True, "data": positions}
|
||||||
"success": True,
|
|
||||||
"message": "Positions retrieved successfully.",
|
|
||||||
"data": positions,
|
|
||||||
}
|
|
||||||
return jsonify(response), 200
|
return jsonify(response), 200
|
||||||
|
|
||||||
|
|
||||||
@ -132,11 +124,7 @@ def get_today_trades():
|
|||||||
"""Get the today's trades of the account."""
|
"""Get the today's trades of the account."""
|
||||||
trades = trader.get_today_trades()
|
trades = trader.get_today_trades()
|
||||||
|
|
||||||
response = {
|
response = {"success": True, "data": trades}
|
||||||
"success": True,
|
|
||||||
"message": "Today's trades retrieved successfully.",
|
|
||||||
"data": trades,
|
|
||||||
}
|
|
||||||
return jsonify(response), 200
|
return jsonify(response), 200
|
||||||
|
|
||||||
|
|
||||||
@ -145,11 +133,7 @@ def get_today_entrust():
|
|||||||
"""Get the today's entrust of the account."""
|
"""Get the today's entrust of the account."""
|
||||||
entrust = trader.get_today_entrust()
|
entrust = trader.get_today_entrust()
|
||||||
|
|
||||||
response = {
|
response = {"success": True, "data": entrust}
|
||||||
"success": True,
|
|
||||||
"message": "Today's entrust retrieved successfully.",
|
|
||||||
"data": entrust,
|
|
||||||
}
|
|
||||||
return jsonify(response), 200
|
return jsonify(response), 200
|
||||||
|
|
||||||
|
|
||||||
@ -158,10 +142,7 @@ def refresh():
|
|||||||
"""Refresh the account."""
|
"""Refresh the account."""
|
||||||
trader.refresh()
|
trader.refresh()
|
||||||
|
|
||||||
response = {
|
response = {"success": True, "data": "Account data refreshed successfully."}
|
||||||
"success": True,
|
|
||||||
"message": "Account data refreshed successfully.",
|
|
||||||
}
|
|
||||||
return jsonify(response), 200
|
return jsonify(response), 200
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user