Most people use this to get holdings at a fair price.
position = exchanges[0].GetPosition ((()
avgPrice = position[0][
It was found that there are two entry price prices, whereas contract transactions are settled on different exchanges every day, and the price changes after settlement, and the entry price is the true original holding price, which is the price at which the transaction is settled. If you use price to calculate the return at this time to stop a stop loss, you may end up with a bigger loss.
For these reasons, the equity price function of the three major stock exchanges has been wrapped up and taken away.
def getAvgPrice(position): if hasattr(position[0],'Info') and hasattr(position[0].Info,'cost_open'):# Huobi return position[0].Info.cost_open elif hasattr(position[0],'Info') and hasattr(position[0].Info,'avg_cost'):#OKex return position[0].Info.avg_cost elif hasattr(position[0],'Info') and hasattr(position[0].Info,'entryPrice'):#binance return position[0].Info.entryPrice else: return position[0]["Price"] def main(): Log(exchange.GetAccount()) position = exchanges[0].GetPosition() if len(position)>0: avgPrice = getAvgPrice(position) Log(avgPrice)
okTradeThis one worked. But I changed it. Def getAvgPrice ((postinInfo)): This is the first time I've seen this post. If hasattr ((postinInfo,'Info') and hasattr ((postinInfo.Info,'cost_open'): # Huobi return postin Info.Info.cost_open This is a list of all the different ways Info.Info.cost_open is credited in the database. Elif hasattr ((postinInfo,'Info') and hasattr ((postinInfo.Info,'avg_cost'): #OKex return postin Info.Info.avg_cost This is the return postin Info.Info.avg_cost elif hasattr ((postinInfo,'Info') and hasattr ((postinInfo.Info,'entryPrice'): #binance return postin Info.Info.entryPrice This is a list of all the different ways Info.Info.entryPrice is credited in the database Other: Return postin Info ["Price"] This is the first time I've seen this post.
Difficult to quantifyBully
q631207207Can you help me see if using the _C bot will pop up the holding information all the time?
LiteFlyYou're in the loop.