# haasomeapi.apis.TradeApi模塊
## 功能
class haasomeapi.apis.TradeApi.TradeApi(connectionstring:str,privatekey:str )
bases: haasomeapi.apis.ApiBase.ApiBase
Trade API類,提供對貿易api端點的訪問
| 參數 |類型 |說明|
|---|---|---|
| connectionstring | str | Connection String Formatted Ex. [http://127.0.0.1:9000](http://127.0.0.1:9000/) |
|privatekey |str|Private Key Set In The Haas Settings|
cancel\_order(accountguid:str,orderguid:str )
取消掛單
| 參數 |類型 |說明|
|---|---|---|
**accountguid** |str|帳戶guid
**orderguid** | str|命令guid取消
| 返回 |
|---|
| [HaasomeClientResponse](https://haasome-tools.github.io/haasomeapi/haasomeapi.dataobjects.util.html "haasomeapi.dataobjects.util.HaasomeClientResponse")
In.result bool|如果訂單成功取消
cancel\_template(templateguid:str )
取消待處理的模板訂單
| 參數 |類型 |說明|
|---|---|---|
**templateguid**|str|模板命令guid
| 返回 |
|---|
| [HaasomeClientResponse](https://haasome-tools.github.io/haasomeapi/haasomeapi.dataobjects.util.html "haasomeapi.dataobjects.util.HaasomeClientResponse")
In.result bool|如果模板成功取消
place\_enter\_long\_order(accountguid: str, primarycoin: str, secondarycoin: str, price: float, amount: float, leverage: float, timeout: int = 0, contractname: str = '', userguid: str = '', templateguid: str = '')
為杠桿/保證金下一個訂單
| 參數 |類型 |說明|
|---|---|---|
| accountguid | str |The account guid|
|primarycoin |str |計價貨幣 Ex. 如果BNB / BTC然后將其設置為BNB|
| secondarycoin|str |基礎貨幣 Ex. 如果BNB / BTC然后將其設置為BTC|
- **price**| float|價格下單
- **amount** | float|交易金額
- **leverage** | float|杠桿百分比金額
- **timeout**|int|(默認值= 0)訂單超時(以分鐘為單位)
- **contractname**| str |(默認值=“”)要使用的合同名稱
- **userguid** |str |(默認值=“”)訂單的用戶guid
- **templateguid** |str |(默認值=“”)訂單模板guid使用
| 返回 |
|---|
| [HaasomeClientResponse](https://haasome-tools.github.io/haasomeapi/haasomeapi.dataobjects.util.html "haasomeapi.dataobjects.util.HaasomeClientResponse")
In.result str| 模板guid
place\_enter\_short\_order(accountguid: str, primarycoin: str, secondarycoin: str, price: float, amount: float, leverage: float, timeout: int = 0, contractname: str = '', userguid: str = '', templateguid: str = '')
下一個杠桿/保證金的短期訂單
| 參數 |類型 |說明|
|---|---|---|
| accountguid | str |The account guid|
|primarycoin |str |計價貨幣 Ex. 如果BNB / BTC然后將其設置為BNB|
| secondarycoin|str |基礎貨幣 Ex. 如果BNB / BTC然后將其設置為BTC|
- **price**| float|價格下單
- **amount** | float|交易金額
- **leverage** | float|杠桿百分比金額
- **timeout**|int|(默認值= 0)訂單超時(以分鐘為單位)
- **contractname**| str |(默認值=“”)要使用的合同名稱
**userguid** |str |(默認值=“”)訂單的用戶guid
**templateguid** |str |(默認值=“”)訂單模板guid使用
| 返回 |
|---|
| [HaasomeClientResponse](https://haasome-tools.github.io/haasomeapi/haasomeapi.dataobjects.util.html "haasomeapi.dataobjects.util.HaasomeClientResponse")
In.result str| 模板guid
place\_exit\_long\_order(accountguid: str, primarycoin: str, secondarycoin: str, price: float, amount: float, leverage: float, timeout: int = 0, contractname: str = '', userguid: str = '', templateguid: str = '')
為杠桿/保證金設置一個退出多頭訂單
| 參數 |類型 |說明|
|---|---|---|
| accountguid | str |The account guid|
|primarycoin |str |計價貨幣 Ex. 如果BNB / BTC然后將其設置為BNB|
| secondarycoin|str |基礎貨幣 Ex. 如果BNB / BTC然后將其設置為BTC|
- **price**| float|價格下單
- **amount** | float|交易金額
- **leverage** | float|杠桿百分比金額
- **timeout**|int|(默認值= 0)訂單超時(以分鐘為單位)
- **contractname**| str |(默認值=“”)要使用的合同名稱
**userguid** |str |(默認值=“”)訂單的用戶guid
**templateguid** |str |(默認值=“”)訂單模板guid使用
| 返回 |
|---|
| [HaasomeClientResponse](https://haasome-tools.github.io/haasomeapi/haasomeapi.dataobjects.util.html "haasomeapi.dataobjects.util.HaasomeClientResponse")
In.result str| 模板guid
place\_exit\_short\_order(accountguid: str, primarycoin: str, secondarycoin: str, price: float, amount: float, leverage: float, timeout: int = 0, contractname: str = '', userguid: str = '', templateguid: str = '')
為杠桿/保證金設置退出空頭訂單
| 參數 |類型 |說明|
|---|---|---|
| accountguid | str |The account guid|
|primarycoin |str |計價貨幣 Ex. 如果BNB / BTC然后將其設置為BNB|
| secondarycoin|str |基礎貨幣 Ex. 如果BNB / BTC然后將其設置為BTC|
- **price**| float|價格下單
- **amount** | float|交易金額
- **leverage** | float|杠桿百分比金額
- **timeout**|int|(默認值= 0)訂單超時(以分鐘為單位)
- **contractname**| str |(默認值=“”)要使用的合同名稱
**userguid** |str |(默認值=“”)訂單的用戶guid
**templateguid** |str |(默認值=“”)訂單模板guid使用
| 返回 |
|---|
| [HaasomeClientResponse](https://haasome-tools.github.io/haasomeapi/haasomeapi.dataobjects.util.html "haasomeapi.dataobjects.util.HaasomeClientResponse")
In.result str| 模板guid
place\_spot\_buy\_order(accountguid: str, primarycoin: str, secondarycoin: str, price: float, amount: float, timeout: int = 0, userguid: str = '', templateguid: str = '')
下一個現貨買單
| 參數 |類型 |說明|
|---|---|---|
| accountguid | str |The account guid|
|primarycoin |str |計價貨幣 Ex. 如果BNB / BTC然后將其設置為BNB|
| secondarycoin|str |基礎貨幣 Ex. 如果BNB / BTC然后將其設置為BTC|
- **price**| float|價格下單
- **amount** | float|交易金額
- **timeout**|int|(默認值= 0)訂單超時(以分鐘為單位)
**userguid** |str |(默認值=“”)訂單的用戶guid
**templateguid** |str |(默認值=“”)訂單模板guid使用
| 返回 |
|---|
| [HaasomeClientResponse](https://haasome-tools.github.io/haasomeapi/haasomeapi.dataobjects.util.html "haasomeapi.dataobjects.util.HaasomeClientResponse")
In.result str| 模板guid
place\_spot\_sell\_order(accountguid: str, primarycoin: str, secondarycoin: str, price: float, amount: float, timeout: int = 0, userguid: str = '', templateguid: str = '')
放置現貨賣單
| 參數 |類型 |說明|
|---|---|---|
| accountguid | str |The account guid|
|primarycoin |str |計價貨幣 Ex. 如果BNB / BTC然后將其設置為BNB|
| secondarycoin|str |基礎貨幣 Ex. 如果BNB / BTC然后將其設置為BTC|
- **price**| float|價格下單
- **amount** | float|交易金額
- **timeout**|int|(默認值= 0)訂單超時(以分鐘為單位)
**userguid** |str |(默認值=“”)訂單的用戶guid
**templateguid** |str |(默認值=“”)訂單模板guid使用
| 返回 |
|---|
| [HaasomeClientResponse](https://haasome-tools.github.io/haasomeapi/haasomeapi.dataobjects.util.html "haasomeapi.dataobjects.util.HaasomeClientResponse")
In.result str| 模板guid