fromAsset = "JPY"
toAsset = "USD"
// rate will be our conversion result
rate = 1
// symbols are the ProtoOASymbolsForConversionRes symbols field
symbols[] = ProtoOASymbolsForConversionRes(fromAsset,toAsset)
asset = fromAsset
FOR symbol in symbols:
IF symbol.baseAsset == asset:
rate = rate * symbol.price
asset = symbol.quoteAsset
ELSE:
rate = rate * 1 / symbol.price
asset = symbol.baseAsset
However from the pseudo code indicated it's not clear to me if symbol.price represents the bid price or the ask price of the symbol? I should consider it the ask price since I'm supposed to buy the deposit currency with the symbol quote asset?
For now this is my solution but I'm not 100% sure if it's totally correct.
fromAsset = "JPY"
toAsset = "USD"
// rate will be our conversion result
rate = 1
// symbols are the ProtoOASymbolsForConversionRes symbols field
symbols[] = ProtoOASymbolsForConversionRes(fromAsset,toAsset)
asset = fromAsset
FOR symbol in symbols:
IF positionDirection == SHORT:
closePrice = symbol.ask
ELSE:
closePrice = symbol.bid
IF symbol.baseAsset == asset:
rate = rate * closePrice
asset = symbol.quoteAsset
ELSE:
rate = rate * 1 / closePrice
asset = symbol.baseAsset
Hello, at https://spotware.github.io/open-api-docs/profit-loss-calculation/ the following pseudo code is indicated to calculate rate for converting P&L to deposit currency
However from the pseudo code indicated it's not clear to me if
symbol.price
represents the bid price or the ask price of the symbol? I should consider it the ask price since I'm supposed to buy the deposit currency with the symbol quote asset? For now this is my solution but I'm not 100% sure if it's totally correct.