# haasomeapi.apis.TradeBotApi模塊
## 功能
```
class haasomeapi.apis.TradeBotApi.TradeBotApi(connectionstring:str,privatekey:str )
Bases: haasomeapi.apis.ApiBase.ApiBase
```
Trade Bot 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|
```
activate_trade_bot(botguid:str )
```
激活交易機器人
| 參數 |類型 |說明|
|---|---|---|
|**botguid** |str|交易機器人guid
| 返回 |
|---|
| [HaasomeClientResponse](http://www.hmoore.net/zbb1025/gggg/780189)
| In.result bool:如果激活成功|
```
add_indicator(botguid:str,indicatortype:haasomeapi.enums.EnumIndicator.EnumIndicator )
```
交易機器人添加指標
| 參數 |類型 |說明|
|---|---|---|
|**botguid** |str|交易機器人guid
indicatortype| [EnumIndicator](http://www.hmoore.net/zbb1025/cccc/780202)|指標類型
| 返回 |
|---|
| [HaasomeClientResponse](http://www.hmoore.net/zbb1025/gggg/780189)
| In .result [TradeBot](http://www.hmoore.net/zbb1025/nnnn/780246): 交易機器人|
`add_insurance(botguid:str,insurancetype:haasomeapi.enums.EnumInsurance.EnumInsurance )`
為貿易機器人添加保險
| 參數 |類型 |說明|
|---|---|---|
|**botguid** |str|交易機器人guid
insurance| [EnumIndicator](http://www.hmoore.net/zbb1025/cccc/780202)|指標類型
| 返回 |
|---|
| HaasomeClientResponse
| In.result TradeBot:交易機器人|
`add_safety(botguid:str,safetytype:haasomeapi.enums.EnumSafety.EnumSafety )`
為交易機器人添加安全性
| 參數 |類型 |說明|
|---|---|---|
|**botguid** |str|交易機器人guid
safetytype| [EnumSafety](http://www.hmoore.net/zbb1025/cccc/780202)|安全類型
| 返回 |
|---|
| HaasomeClientResponse
| In.result TradeBot:交易機器人|
`backtest_trade\_bot(botguid:str,minutes:int )`
回測(注意:此功能將向交易所發出請求,所以不要經常使用)
| 參數 |類型 |說明|
|---|---|---|
| **botguid** |str|自定義bot guid
|**minutestotest** | int|過去測試的分鐘數
| 返回 |
|---|
| [HaasomeClientResponse](http://www.hmoore.net/zbb1025/gggg/780189)
| In.result [TradeBot](http://www.hmoore.net/zbb1025/nnnn/780246):Tradebot對象|
```
backtest_trade_bot_unix_time(botguid:str,startUnix:int,endUnix:int )
```
回測(注意:此功能會向交易所發出請求,所以不要經常使用)
| 參數 |類型 |說明|
|---|---|---|
|**botguid**|str|自定義bot guid
**startunix** | int|以unix時間表示開始的時間
**endunix** | int|以unix時間表示結束的時間
| 返回 |
|---|
| HaasomeClientResponse
| In.result TradeBot:交易機器人對象|
```
clean_trade_bot(botguid:str )
```
清除交易機器人歷史
| 參數 |類型 |說明|
|---|---|---|
|**botguid**|str|自定義bot guid
| 返回 |
|---|
| HaasomeClientResponse
| In.result TradeBot:交易機器人|
```
clone_indicator(botguid:str,elementguid:str,tobotguid:str )
```
克隆指標
| 參數 |類型 |說明|
|---|---|---|
|**botguid**|str|交易bot 復制guid
**elementguid** | str|要復制的元素Guid
**tobotguid** | str|交易bot 復制guid
| 返回 |
|---|
| HaasomeClientResponse
| In.result TradeBot:交易機器人|
```
clone_insurance(botguid:str,elementguid:str,tobotguid:str )
```
克隆保險
| 參數 |類型 |說明|
|---|---|---|
|**botguid**|str|交易bot 復制guid
**elementguid** | str|要復制的元素Guid
**tobotguid** | str|交易bot復制guid
| 返回 |
|---|
| HaasomeClientResponse
| In.result TradeBot:交易機器人|
```
clone_safety(botguid:str,elementguid:str,tobotguid:str )
```
克隆安全
| 參數 |類型 |說明|
|---|---|---|
|**botguid**|str|交易bot 復制guid
**elementguid** | str|要復制的元素Guid
**tobotguid** | str|交易bot復制guid
| 返回 |
|---|
| HaasomeClientResponse
| In.result TradeBot:交易機器人|
```
clone_trade_bot(accountguid: str, botguid: str, botname: str, primarycoin: str, secondarycoin: str, contractname: str, leverage: float, copysafeties: bool, copyindicators: bool, copyinsurances: bool, copyparameters: bool, copymarkettoelements: bool)
```
克隆交易機器人
| 參數 |類型 |說明|
|---|---|---|
**accountguid**| str|帳戶guid
**botguid** |str|交易機器人guid修改
**botname**|str|新自定義機器人的名稱
**primarycoin** | str|基礎貨幣Ex。如果BNB / BTC然后將其設置為BNB
**secondarycoin** |str|計價貨幣Ex。如果BNB / BTC然后將其設置為BTC
**contractname** | str|合同名稱(可選)
**leverage** | float|杠桿百分比使用(可選)
**copysafeties**|bool|復制安全
**copyindicators**| bool|復制指標
**copyinsurances** | bool|復制保險
**copyparameters** |bool|復制參數
**copymarkettoelements** |bool|將市場復制到元素Copy market to elements
| 返回 |
|---|
| HaasomeClientResponse
| In.result TradeBot:交易機器人|
```
deactivate_trade_bot(botguid:str )
```
停用交易機器人
| 參數 |類型 |說明|
|---|---|---|
|**botguid**|str|交易bot guid
| 返回 |
|---|
| HaasomeClientResponse
| In.result bool:如果激活成功 |
```
edit_bot_indicator_settings(botguid:str,elementguid:str,fieldno:int,value:any )
```
編輯交易機器人指標設置
| 參數 |類型 |說明|
|---|---|---|
**botguid** | str|交易機器人 修改guid
**elementguid** | str|要修改的元素guid
**fieldno**|int|要修改的字段編號
**value** | any|字段的值
| 返回 |
|---|
| HaasomeClientResponse
| In.result TradeBot:交易機器人|
```
edit_bot_insurance_settings(botguid:str,elementguid:str,fieldno:int,value:any )
```
編輯交易機器人保險設置
| 參數 |類型 |說明|
|---|---|---|
**botguid** | str|交易機器人 修改guid
**elementguid** | str|要修改的元素guid
**fieldno**|int|要修改的字段編號
**value** | any|字段的值
| 返回 |
|---|
| HaasomeClientResponse
| In.result TradeBot:交易機器人|
```
edit_bot_safety_settings(botguid:str,elementguid:str,fieldno:int,value:any )
```
編輯交易機器人安全設置
| 參數 |類型 |說明|
|---|---|---|
**botguid** | str|交易機器人 修改guid
**elementguid** | str|要修改的元素guid
**fieldno**|int|要修改的字段編號
**value** | any|字段的值
| 返回 |
|---|
| HaasomeClientResponse
| In.result TradeBot:交易機器人|
```
get_all_trade_bots()
```
返回創建的所有交易機器人
| 返回 |
|---|
| HaasomeClientResponse
| In.result List [TradeBot\]|
```
get_trade_bot(botguid:str )
```
返回交易機器人匹配guid
| 參數 |類型 |說明|
|---|---|---|
**botguid** | str|機器人guid
| 返回 |
|---|
| HaasomeClientResponse
| In.result TradeBot:交易機器人|
```
lock_trade_bot(botguid:str,lockbot:bool )
```
鎖定交易機器人
| 參數 |類型 |說明|
|---|---|---|
**botguid** | str|機器人guid
**lockbot**|bool|鎖定機器人
| 返回 |
|---|
| HaasomeClientResponse
| In.result bool:如果刪除成功|
```
new_trade_bot(accountguid: str, botname: str, primarycoin: str, secondarycoin: str, contractname: str, leverage: float, groupid: str)
```
創建一個新的交易機器人
| 參數 |類型 |說明|
|---|---|---|
| accountguid | str |The account guid|
|**name** |str |高級訂單的名稱|
|primarycoin |str |基礎貨幣 Ex. 如果BNB / BTC然后將其設置為BNB|
| secondarycoin|str |計價貨幣 Ex. 如果BNB / BTC然后將其設置為BTC|
**contractname**| str|合同名稱(可選)
**leverage** |float|杠桿百分比使用(可選)
**groupid** |str|bot的組ID(可選)
| 返回 |
|---|
| HaasomeClientResponse
| In.result TradeBot:交易機器人|
```
remove_indicator(botguid:str,elementguid:str )
```
從交易機器人中刪除指標
| 參數 |類型 |說明|
|---|---|---|
**botguid** | str|交易機器人 修改guid
**elementguid** | str|要刪除的元素guid
| 返回 |
|---|
| HaasomeClientResponse
| In.result TradeBot:交易機器人|
```
remove_insurance(botguid:str,elementguid:str )
```
從交易機器人中刪除保險
| 參數 |類型 |說明|
|---|---|---|
**botguid** | str|交易機器人 修改guid
**elementguid** | str|要刪除的元素guid
| 返回 |
|---|
| HaasomeClientResponse
| In.result TradeBot:交易機器人|
```
remove_safety(botguid:str,elementguid:str )
```
從交易機器人中刪除安全性
| 參數 |類型 |說明|
|---|---|---|
**botguid** | str|交易機器人 修改guid
**elementguid** | str|要刪除的元素guid
| 返回 |
|---|
| HaasomeClientResponse
| In.result TradeBot:交易機器人|
```
remove_trade_bot(botguid:str )
```
刪除(刪除)Trade bot
| 參數 |類型 |說明|
|---|---|---|
**botguid** | str|交易機器人guid
| 返回 |
|---|
| HaasomeClientResponse
| In.result bool:如果刪除是成功的|
```
setup_indicator(botguid:str,elementguid:str,pricesource:haasomeapi.enums.EnumPriceSource.EnumPriceSource,primarycoin :str,secondarycoin:str,contractname:str,interval:int,charttype:haasomeapi.enums.EnumPriceChartType.EnumPriceChartType,delay:int )
```
修改交易機器人指標
| 參數 |類型 |說明|
|---|---|---|
**botguid** | str|交易機器人 修改guid
**elementguid** | str|要修改的元素guid
priceource | [EnumPriceSource](http://www.hmoore.net/zbb1025/cccc/780202)|要使用的指標的價格來源(交換)
**primarycoin** | str|基礎貨幣Ex。如果BNB / BTC然后將其設置為BNB
**secondarycoin**|str|計價貨幣Ex。如果BNB / BTC然后將其設置為BTC
**contractname**| str|合同名稱(可選)
**interval** |int|以分鐘為單位的間隔
priceource| [EnumPriceChartType](http://www.hmoore.net/zbb1025/cccc/780202)|使用指標的價格表
**delay** | int|以分鐘為單位的延遲
| 返回 |
|---|
| HaasomeClientResponse
| In.result TradeBot:交易機器人|
```
setup_indicator_leverage_signals(botguid:str,elementguid:str,uselongsignals:bool,useshortsignals:bool,usenopositionsignals:bool,reversesignals:bool,standalone:bool,mappedbuysignal:haasomeapi.enums.EnumFundPosition.EnumFundPosition,mappedsellsignal:haasomeapi.enums.EnumFundPosition.EnumFundPosition )
```
修改指標杠桿信號
| 參數 |類型 |說明|
|---|---|---|
**botguid**| str|交易機器人 修改guid
**elementguid** |str|要修改的元素guid
**uselongsignals**|bool|使用長信號
**useshortsignals** | bool|使用短信號
**usenopositionsignals** | bool|不使用頭寸信號
**reversesignals**| bool|反向信號
**standalone**|bool|獨自站立
mappedbuysignal | [EnumFundPosition](http://www.hmoore.net/zbb1025/cccc/780202)|映射購買信號Mapped buy signal position
mappedsellsignal |[EnumFundPosition](http://www.hmoore.net/zbb1025/cccc/780202)|映射賣出信號Mapped sell signal position
| 返回 |
|---|
| HaasomeClientResponse
| In.result TradeBot:交易機器人|
```
setup_indicator_spot_signals(botguid:str,elementguid:str,usebuysignal:bool,usesellsignal:bool,reversesignals:bool,standalone:bool )
```
修改指示燈點信號
| 參數 |類型 |說明|
|---|---|---|
**botguid**| str|交易機器人 修改guid
**elementguid** |str|要修改的元素guid
**usebuysignal**| bool|使用買入信號
**usesellsignal** |bool|使用賣出信號
**reversesignals**| bool|反向信號
**standalone**|bool|Stand alone
| 返回 |
|---|
| HaasomeClientResponse
| In.result TradeBot:交易機器人|
```
setup_leverage_bot_trade_amount(botguid: str, coinposition: haasomeapi.enums.EnumFundPosition.EnumFundPosition, tradeamount: float, lastlongprice: float, lastshortprice: float, entertemplateid: str, exittemplateid: str, highspeedenabled: bool, allin: bool, ordertimeout: int, templatetimeout: int, maxtradeamount: bool, limitordertype: haasomeapi.enums.EnumLimitOrderPriceType.EnumLimitOrderPriceType, usehiddenorders: bool, fee: float)
```
修改杠桿/保證金交易機器人金額
| 參數 |類型 |說明|
|---|---|---|
**botguid**| str|交易機器人修改guid
coinposition | [EnumCoinPosition](http://www.hmoore.net/zbb1025/cccc/780202)|代幣頭寸
**tradeamount** |float|交易金額
**lastlongprice** |float|最終做多價格
**lastshortprice** |float|最終做空價格
**entertemplateid** |str|輸入模板guid
**exittemplateid** |str|退出模板guid
**highspeedenabled** | bool|啟用高頻交易
**allin** | bool|梭哈
**ordertimeout** | int|訂單超時(以分鐘為單位)
**templatetimeout** | int|模板超時(以分鐘為單位)
**maxtradeamount** |bool|使用最大交易金額
limitordertype |EnumLimitOrderPriceType|限價訂單類型
**usehiddenorders** | bool|使用隱藏訂單
**fee** | float|計算中使用的費用百分比
| 返回 |
|---|
| HaasomeClientResponse
| In.result TradeBot:交易機器人對象|
```
setup_safety(botguid:str,elementguid:str,pricesource:haasomeapi.enums.EnumPriceSource.EnumPriceSource,primarycoin :str,secondarycoin:str,contractname:str,mappedbuysignal:haasomeapi.enums.EnumFundPosition.EnumFundPosition,mappedsellsignal:haasomeapi.enums.EnumFundPosition.EnumFundPosition,validpositionsignal:haasomeapi.enums.EnumSafetyPositionSignal.EnumSafetyPositionSignal )
```
修改交易機器人安全
| 參數 |類型 |說明|
|---|---|---|
**botguid** |str|交易機器人修改guid
**elementguid**|str|要修改的元素guid
priceource| [EnumPriceSource](http://www.hmoore.net/zbb1025/cccc/780202)|要使用的指標的價格來源(交換)
**primarycoin** |str|基礎貨幣Ex。如果BNB / BTC然后將其設置為BNB
**secondarycoin**| str|計價貨幣Ex。如果BNB / BTC然后將其設置為BTC
**contractname**| str|合同名稱(可選)
mappedbuysignal | [EnumFundPosition](http://www.hmoore.net/zbb1025/cccc/780202)|映射頭寸購買信號
mappedsellsignal| [EnumFundPosition](http://www.hmoore.net/zbb1025/cccc/780202)|映射頭寸賣出信號
validpositionsignal| EnumSafetyPositionSignal|映射頭寸信號
| 返回 |
|---|
| HaasomeClientResponse
| In.result TradeBot:交易機器人|
```
setup_spot_bot_trade_amount(botguid: str, coinposition: haasomeapi.enums.EnumCoinPosition.EnumCoinPosition, tradeamount: float, lastbuyprice: float, lastsellprice: float, buytemplateid: str, selltemplateid: str, highspeedenabled: bool, allin: bool, ordertimeout: int, templatetimeout: int, maxtradeamount: bool, limitordertype: haasomeapi.enums.EnumLimitOrderPriceType.EnumLimitOrderPriceType, usehiddenorders: bool, fee: float)
```
修改現貨交易金額
| 參數 |類型 |說明|
|---|---|---|
**botguid** |str|交易機器人修改guid
coinposition| [EnumCoinPosition](http://www.hmoore.net/zbb1025/cccc/780202)|代幣頭寸
**tradeamount** |float|交易金額
**lastbuyprice** |float|最后買入價
**lastsellprice** |float|最后賣價
**buytemplateid**| str|購買模板guid
**selltemplateid** |str|賣模板guid
**highspeedenabled** |bool|啟用高頻交易
**allin**|bool|梭哈
**ordertimeout** | int|訂單超時(以分鐘為單位)
**templatetimeout** |int|模板超時(以分鐘為單位)
**maxtradeamount** |bool|使用最大交易金額
limitordertype| EnumLimitOrderPriceType|限價訂單類型
**usehiddenorders** | bool|使用隱藏訂單
**fee**|float|計算中使用的費用百分比
| 返回 |
|---|
| HaasomeClientResponse
| In.result TradeBot:交易機器人對象|
```
setup_trade_bot(accountguid: str, botguid: str, botname: str, primarycoin: str, secondarycoin: str, contractname: str, leverage: float, groupid: str, useconsensus: bool, copymarketstoelements: bool)
```
修改交易機器人
| 參數 |類型 |說明|
|---|---|---|
**accountguid**|str|帳戶guid
**botname**| str|新自定義機器人的名稱
**botguid**| str|交易機器人修改guid
**primarycoin** |str|基礎貨幣Ex。如果BNB / BTC然后將其設置為BNB
**secondarycoin** |str|計價貨幣Ex。如果BNB / BTC然后將其設置為BTC
**contractname** | str|合同名稱(可選)
**leverage** | float|杠桿百分比使用(可選)
**groupid** |str|bot的組ID(可選)
**useconsensus**| bool|使用共識模式
**copymarketstoelements**| bool|將市場復制到元素
| 返回 |
|---|
| HaasomeClientResponse
| In.result TradeBot:交易機器人對象|
```
switch_bot_coin_position_with_order(botguid:str,templateguid:str )
```
切換交易機器人代幣頭寸與訂單(現貨市場)
| 參數 |類型 |說明|
|---|---|---|
**botguid** |str|交易機器人修改guid
**templateguid**| str|訂單模板guid
| 返回 |
|---|
| HaasomeClientResponse
| In.result TradeBot:交易機器人|
```
switch_bot_funds_position(botguid:str,position:haasomeapi.enums.EnumFundPosition.EnumFundPosition )
```
切換交易機構資金頭寸(杠桿/保證金市場)
| 參數 |類型 |說明|
|---|---|---|
**botguid**|str|交易機器人修改guid
position |[EnumFundPosition](http://www.hmoore.net/zbb1025/cccc/780202)|Fund position to change to
| 返回 |
|---|
| HaasomeClientResponse
| In.result TradeBot:交易機器人|
```
switch_bot_funds_position_with_order(botguid:str,templateguid:str,targetposition:haasomeapi.enums.EnumFundPosition.EnumFundPosition )
```
切換交易機器人代幣頭寸與訂單(杠桿/保證金市場)
| 參數 |類型 |說明|
|---|---|---|
**botguid**|str|交易機器人修改guid
**templateguid**| str|訂單模板guid
targetposition | [EnumFundPosition](http://www.hmoore.net/zbb1025/cccc/780202)|Fund position to change to
| 返回 |
|---|
| HaasomeClientResponse
| In.result TradeBot:交易機器人|
```
switch_coin_positions(botguid:str,position:haasomeapi.enums.EnumCoinPosition.EnumCoinPosition )
```
切換交易機器人代幣頭寸(現貨市場)
| 參數 |類型 |說明|
|---|---|---|
**botguid**|str|交易機器人修改guid
position |[EnumFundPosition](http://www.hmoore.net/zbb1025/cccc/780202)|Coin position to change to
| 返回 |
|---|
| HaasomeClientResponse
| In.result TradeBot:交易機器人|