@@ -227,9 +227,20 @@ protected override async Task<IWebSocket> OnGetTradesWebSocketAsync(Func<KeyValu
227
227
await AddMarketSymbolsToChannel ( _socket , "/trade:{0}" , marketSymbols ) ;
228
228
} , async ( _socket , symbol , sArray , token ) =>
229
229
{
230
- ExchangeTrade trade = token . ParseTrade ( amountKey : "size" , priceKey : "price" ,
230
+ ExchangeTrade trade ;
231
+ var instrumentType = GetInstrumentType ( symbol ) ;
232
+ if ( instrumentType == "futures" )
233
+ {
234
+ trade = token . ParseTrade ( amountKey : "qty" , priceKey : "price" ,
235
+ typeKey : "side" , timestampKey : "timestamp" ,
236
+ timestampType : TimestampType . Iso8601 , idKey : "trade_id" ) ;
237
+ }
238
+ else
239
+ {
240
+ trade = token . ParseTrade ( amountKey : "size" , priceKey : "price" ,
231
241
typeKey : "side" , timestampKey : "timestamp" ,
232
242
timestampType : TimestampType . Iso8601 , idKey : "trade_id" ) ;
243
+ }
233
244
await callback ( new KeyValuePair < string , ExchangeTrade > ( symbol , trade ) ) ;
234
245
} ) ;
235
246
}
@@ -733,6 +744,24 @@ async Task sendMessageAsync(string category, IEnumerable<string> symbolsToSend)
733
744
return marketSymbols ;
734
745
}
735
746
736
- #endregion
747
+ private string GetInstrumentType ( string marketSymbol )
748
+ {
749
+ string type ;
750
+ if ( marketSymbol . Split ( '-' ) . Length == 3 && marketSymbol . Split ( '-' ) [ 2 ] == "SWAP" )
751
+ {
752
+ type = "swap" ;
753
+ }
754
+ else if ( marketSymbol . Split ( '-' ) . Length == 3 && int . TryParse ( marketSymbol . Split ( '-' ) [ 2 ] , out _ ) )
755
+ {
756
+ type = "futures" ;
757
+ }
758
+ else
759
+ {
760
+ type = "spot" ;
761
+ }
762
+ return type ;
763
+ }
764
+
765
+ #endregion
737
766
}
738
767
}
0 commit comments