File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -883,6 +883,35 @@ public function aggTrades(string $symbol)
883883 "symbol " => $ symbol ,
884884 ]));
885885 }
886+
887+ /**
888+ * historicalTrades Get historical trades for a specific currency
889+ *
890+ * $ENJHistTrades = $api->historicalTrades("ENJUSDT");
891+ * $limitENJHistTrades = $api->historicalTrades("ENJUSDT",5);
892+ * $limitENJHistTradesFromId = $api->historicalTrades("ENJUSDT",5,3);
893+ *
894+ * @param $symbol string (mandatory) the currency symbol
895+ * @param $limit int (optional) the amount of trades returned, default=500 max=1000
896+ * @param $fromTradeId int (optional) return the orders from this order onwards. negative for all
897+ * @return Array of trades
898+ * @throws \Exception
899+ */
900+ public function historicalTrades (string $ symbol , int $ limit = 500 , int $ fromTradeId = -1 )
901+ {
902+ $ parameters = [
903+ "symbol " => $ symbol ,
904+ "limit " => $ limit ,
905+ ];
906+ if ($ fromTradeId > 0 ) {
907+ $ parameters ["fromId " ] = $ fromTradeId ;
908+ }
909+
910+ // The endpoint cannot handle extra parameters like 'timestamp' or 'signature',
911+ // but it needs the http header with the key so we need to construct it here
912+ $ query = http_build_query ($ parameters , '' , '& ' );
913+ return $ this ->httpRequest ("v3/historicalTrades? $ query " );
914+ }
886915
887916 /**
888917 * depth get Market depth
You can’t perform that action at this time.
0 commit comments