添加web api调用示例
This commit is contained in:
parent
24be80288a
commit
02f67a2424
@ -1,7 +1,7 @@
|
||||
import requests
|
||||
|
||||
# 服务器地址
|
||||
URL = "http://localhost:9527/yu"
|
||||
URL = "http://trader.biggerfish.tech:9527/yu"
|
||||
|
||||
def buy(code: str, price: float, amount: int) -> dict:
|
||||
"""买入股票
|
||||
@ -41,6 +41,7 @@ def sell(code: str, price: float, amount: int) -> dict:
|
||||
response = requests.post(f"{URL}/sell", json=data)
|
||||
return response.json()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# 示例:买入中国银行1000股,价格3.45
|
||||
result = buy("601988.SH", 3.45, 1000)
|
||||
@ -48,4 +49,5 @@ if __name__ == "__main__":
|
||||
|
||||
# 示例:卖出中国银行1000股,价格3.48
|
||||
result = sell("601988.SH", 3.48, 1000)
|
||||
print("卖出结果:", result)
|
||||
print("卖出结果:", result)
|
||||
|
Loading…
x
Reference in New Issue
Block a user