You're right about the price of holding equity?

Author: LiteFly, Date: 2021-03-10 21:02:32
Tags: Tool

Most people use this to get holdings at a fair price. position = exchanges[0].GetPosition ((() avgPrice = position[0][Price] But it is not allowed to print the Bitcoin contract position information: [map[Amount:5 ContractType:swap FrozenAmount:0 Info:map[entryPrice:55173.32071038 isAutoAddMargin:false isolatedMargin:0.00000000 isolatedWallet:0 leverage:20 liquidationPrice:0 marginType:cross markPrice:55171.20000000 maxQty:50 notionalValue:-0.00906269 positionAmt:-5 positionSide:BOTH symbol:BTCUSD_PERP unRealizedProfit:0.00000034] Margin:0.0004531349689693174 MarginLevel Price:20:55173.32071038 Profit:3.4e Type-07:1]]

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)
    
    


Related

More

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.