Skip to content

Commit 12d236d

Browse files
committed
Some more live tests added
1 parent 239a5b7 commit 12d236d

File tree

1 file changed

+218
-0
lines changed

1 file changed

+218
-0
lines changed

tests/BinanceLiveTests.php

Lines changed: 218 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -696,4 +696,222 @@ public function testPricesV2Futures()
696696
$this->assertArrayHasKey($this->symbol, $res);
697697
$this->assertIsNumeric($res[$this->symbol]);
698698
}
699+
700+
public function testSymbolOrderBookTickerFutures()
701+
{
702+
$res = $this->futuresBinance->futuresSymbolOrderBookTicker($this->symbol);
703+
$this->assertIsArray($res);
704+
$this->assertEquals($this->symbol, $res['symbol']);
705+
$this->assertArrayHasKey('bidPrice', $res);
706+
$this->assertIsNumeric($res['bidPrice']);
707+
$this->assertArrayHasKey('bidQty', $res);
708+
$this->assertIsNumeric($res['bidQty']);
709+
$this->assertArrayHasKey('askPrice', $res);
710+
$this->assertIsNumeric($res['askPrice']);
711+
$this->assertArrayHasKey('askQty', $res);
712+
$this->assertIsNumeric($res['askQty']);
713+
$this->assertArrayHasKey('time', $res);
714+
$this->assertIsInt($res['time']);
715+
}
716+
717+
public function testDeliveryPriceFutures()
718+
{
719+
$this->futuresBinance->useTestnet = false; // set to false for fapiData request
720+
$res = $this->futuresBinance->futuresDeliveryPrice($this->symbol);
721+
$this->assertIsArray($res);
722+
$this->assertIsArray($res[0]);
723+
$this->assertArrayHasKey('deliveryTime', $res[0]);
724+
$this->assertIsInt($res[0]['deliveryTime']);
725+
$this->assertArrayHasKey('deliveryPrice', $res[0]);
726+
$this->assertIsNumeric($res[0]['deliveryPrice']);
727+
$this->futuresBinance->useTestnet = true; // reset to true for other tests
728+
}
729+
730+
public function testOpenInterestFutures()
731+
{
732+
$res = $this->futuresBinance->futuresOpenInterest($this->symbol);
733+
$this->assertIsArray($res);
734+
$this->assertEquals($this->symbol, $res['symbol']);
735+
$this->assertArrayHasKey('openInterest', $res);
736+
$this->assertIsNumeric($res['openInterest']);
737+
$this->assertArrayHasKey('time', $res);
738+
$this->assertIsInt($res['time']);
739+
}
740+
741+
public function testOpenInterestHistoryFutures()
742+
{
743+
$this->futuresBinance->useTestnet = false; // set to false for fapiData request
744+
$res = $this->futuresBinance->futuresOpenInterestHistory($this->symbol, $this->period, $this->limit);
745+
$this->assertIsArray($res);
746+
$entry = $res[0];
747+
$this->assertIsArray($entry);
748+
$this->assertArrayHasKey('symbol', $entry);
749+
$this->assertEquals($this->symbol, $entry['symbol']);
750+
$this->assertArrayHasKey('sumOpenInterest', $entry);
751+
$this->assertIsNumeric($entry['sumOpenInterest']);
752+
$this->assertArrayHasKey('sumOpenInterestValue', $entry);
753+
$this->assertIsNumeric($entry['sumOpenInterestValue']);
754+
$this->assertArrayHasKey('timestamp', $entry);
755+
$this->assertIsInt($entry['timestamp']);
756+
$this->futuresBinance->useTestnet = true; // reset to true for other tests
757+
}
758+
759+
public function testTopLongShortPositionRatioFutures()
760+
{
761+
$this->futuresBinance->useTestnet = false; // set to false for fapiData request
762+
$res = $this->futuresBinance->futuresTopLongShortPositionRatio($this->symbol, $this->period, $this->limit);
763+
$this->assertIsArray($res);
764+
$entry = $res[0];
765+
$this->assertIsArray($entry);
766+
$this->assertArrayHasKey('symbol', $entry);
767+
$this->assertEquals($this->symbol, $entry['symbol']);
768+
$this->assertArrayHasKey('longAccount', $entry);
769+
$this->assertIsNumeric($entry['longAccount']);
770+
$this->assertArrayHasKey('longShortRatio', $entry);
771+
$this->assertIsNumeric($entry['longShortRatio']);
772+
$this->assertArrayHasKey('shortAccount', $entry);
773+
$this->assertIsNumeric($entry['shortAccount']);
774+
$this->assertArrayHasKey('timestamp', $entry);
775+
$this->assertIsInt($entry['timestamp']);
776+
$this->futuresBinance->useTestnet = true; // reset to true for other tests
777+
}
778+
779+
public function testTopLongShortAccountRatioFutures()
780+
{
781+
$this->futuresBinance->useTestnet = false; // set to false for fapiData request
782+
$res = $this->futuresBinance->futuresTopLongShortAccountRatio($this->symbol, $this->period, $this->limit);
783+
$this->assertIsArray($res);
784+
$entry = $res[0];
785+
$this->assertIsArray($entry);
786+
$this->assertArrayHasKey('symbol', $entry);
787+
$this->assertEquals($this->symbol, $entry['symbol']);
788+
$this->assertArrayHasKey('longAccount', $entry);
789+
$this->assertIsNumeric($entry['longAccount']);
790+
$this->assertArrayHasKey('longShortRatio', $entry);
791+
$this->assertIsNumeric($entry['longShortRatio']);
792+
$this->assertArrayHasKey('shortAccount', $entry);
793+
$this->assertIsNumeric($entry['shortAccount']);
794+
$this->assertArrayHasKey('timestamp', $entry);
795+
$this->assertIsInt($entry['timestamp']);
796+
$this->futuresBinance->useTestnet = true; // reset to true for other tests
797+
}
798+
799+
public function testGlobalLongShortAccountRatioFutures()
800+
{
801+
$this->futuresBinance->useTestnet = false; // set to false for fapiData request
802+
$res = $this->futuresBinance->futuresGlobalLongShortAccountRatio($this->symbol, $this->period, $this->limit);
803+
$this->assertIsArray($res);
804+
$entry = $res[0];
805+
$this->assertIsArray($entry);
806+
$this->assertArrayHasKey('symbol', $entry);
807+
$this->assertEquals($this->symbol, $entry['symbol']);
808+
$this->assertArrayHasKey('longAccount', $entry);
809+
$this->assertIsNumeric($entry['longAccount']);
810+
$this->assertArrayHasKey('longShortRatio', $entry);
811+
$this->assertIsNumeric($entry['longShortRatio']);
812+
$this->assertArrayHasKey('shortAccount', $entry);
813+
$this->assertIsNumeric($entry['shortAccount']);
814+
$this->assertArrayHasKey('timestamp', $entry);
815+
$this->assertIsInt($entry['timestamp']);
816+
$this->futuresBinance->useTestnet = true; // reset to true for other tests
817+
}
818+
819+
public function testTakerLongShortRatioFutures()
820+
{
821+
$this->futuresBinance->useTestnet = false; // set to false for fapiData request
822+
$res = $this->futuresBinance->futuresTakerLongShortRatio($this->symbol, $this->period, $this->limit);
823+
$this->assertIsArray($res);
824+
$entry = $res[0];
825+
$this->assertIsArray($entry);
826+
$this->assertArrayHasKey('buySellRatio', $entry);
827+
$this->assertIsNumeric($entry['buySellRatio']);
828+
$this->assertArrayHasKey('sellVol', $entry);
829+
$this->assertIsNumeric($entry['sellVol']);
830+
$this->assertArrayHasKey('buyVol', $entry);
831+
$this->assertIsNumeric($entry['buyVol']);
832+
$this->assertArrayHasKey('timestamp', $entry);
833+
$this->assertIsInt($entry['timestamp']);
834+
$this->futuresBinance->useTestnet = true; // reset to true for other tests
835+
}
836+
837+
public function testBasisFutures()
838+
{
839+
$this->futuresBinance->useTestnet = false; // set to false for fapiData request
840+
$res = $this->futuresBinance->futuresBasis($this->symbol, $this->period, $this->limit, null, null, $this->contractType);
841+
$this->assertIsArray($res);
842+
$entry = $res[0];
843+
$this->assertIsArray($entry);
844+
$this->assertArrayHasKey('indexPrice', $entry);
845+
$this->assertIsNumeric($entry['indexPrice']);
846+
$this->assertArrayHasKey('contractType', $entry);
847+
$this->assertEquals($this->contractType, $entry['contractType']);
848+
$this->assertArrayHasKey('basisRate', $entry);
849+
$this->assertIsNumeric($entry['basisRate']);
850+
$this->assertArrayHasKey('futuresPrice', $entry);
851+
$this->assertIsNumeric($entry['futuresPrice']);
852+
$this->assertArrayHasKey('annualizedBasisRate', $entry);
853+
$this->assertIsNumeric($entry['annualizedBasisRate']);
854+
$this->assertArrayHasKey('basis', $entry);
855+
$this->assertIsNumeric($entry['basis']);
856+
$this->assertArrayHasKey('pair', $entry);
857+
$this->assertEquals($this->symbol, $entry['pair']);
858+
$this->assertArrayHasKey('timestamp', $entry);
859+
$this->assertIsInt($entry['timestamp']);
860+
$this->futuresBinance->useTestnet = true; // reset to true for other tests
861+
}
862+
863+
public function testIndexInfoFutures()
864+
{
865+
$compositeIndex = 'DEFIUSDT';
866+
$res = $this->futuresBinance->futuresIndexInfo($compositeIndex);
867+
$this->assertIsArray($res);
868+
$this->assertArrayHasKey('symbol', $res);
869+
$this->assertEquals($compositeIndex, $res['symbol']);
870+
$this->assertArrayHasKey('time', $res);
871+
$this->assertIsInt($res['time']);
872+
$this->assertArrayHasKey('component', $res);
873+
$this->assertArrayHasKey('baseAssetList', $res);
874+
$this->assertIsArray($res['baseAssetList']);
875+
}
876+
877+
public function testAssetIndexFutures()
878+
{
879+
$res = $this->futuresBinance->futuresAssetIndex();
880+
$this->assertIsArray($res);
881+
$entry = $res[0];
882+
$this->assertIsArray($entry);
883+
$this->assertArrayHasKey('symbol', $entry);
884+
$this->assertIsString($entry['symbol']);
885+
$this->assertArrayHasKey('time', $entry);
886+
$this->assertIsInt($entry['time']);
887+
$this->assertArrayHasKey('index', $entry);
888+
$this->assertIsNumeric($entry['index']);
889+
$this->assertArrayHasKey('bidBuffer', $entry);
890+
$this->assertIsNumeric($entry['bidBuffer']);
891+
$this->assertArrayHasKey('askBuffer', $entry);
892+
$this->assertIsNumeric($entry['askBuffer']);
893+
$this->assertArrayHasKey('bidRate', $entry);
894+
$this->assertIsNumeric($entry['bidRate']);
895+
$this->assertArrayHasKey('askRate', $entry);
896+
$this->assertIsNumeric($entry['askRate']);
897+
$this->assertArrayHasKey('autoExchangeBidBuffer', $entry);
898+
$this->assertIsNumeric($entry['autoExchangeBidBuffer']);
899+
$this->assertArrayHasKey('autoExchangeAskBuffer', $entry);
900+
$this->assertIsNumeric($entry['autoExchangeAskBuffer']);
901+
$this->assertArrayHasKey('autoExchangeBidRate', $entry);
902+
$this->assertIsNumeric($entry['autoExchangeBidRate']);
903+
$this->assertArrayHasKey('autoExchangeAskRate', $entry);
904+
$this->assertIsNumeric($entry['autoExchangeAskRate']);
905+
}
906+
907+
public function testConstituentsFutures()
908+
{
909+
$res = $this->futuresBinance->futuresConstituents($this->symbol);
910+
$this->assertIsArray($res);
911+
$this->assertEquals($this->symbol, $res['symbol']);
912+
$this->assertArrayHasKey('time', $res);
913+
$this->assertIsInt($res['time']);
914+
$this->assertArrayHasKey('constituents', $res);
915+
$this->assertIsArray($res['constituents']);
916+
}
699917
}

0 commit comments

Comments
 (0)