@@ -737,6 +737,90 @@ int main() {
737
737
s.Clear ();
738
738
}
739
739
}
740
+ if (KdbShape (response, ticker, 15 )) {
741
+ std::cout << " Processing Ticker table " << std::endl;
742
+ StringBuffer s;
743
+ Writer<StringBuffer> writer (s);
744
+
745
+ K table= kK (response)[2 ]->k ;
746
+ K columnNames= kK (table)[0 ];
747
+ K columnValues= kK (table)[1 ];
748
+
749
+ for (int i= 0 ; i < kK (columnValues)[0 ]->n ; i++) {
750
+ std::string price = kS (kK (columnValues)[1 ])[i]; // price : symbol
751
+ std::string instrument = kS (kK (columnValues)[2 ])[i]; // instrument : symbol
752
+ std::string baseAsset = kS (kK (columnValues)[3 ])[i]; // asset base : symbol
753
+ std::string quoteAsset = kS (kK (columnValues)[4 ])[i]; // asset quote : symbol
754
+ std::string high = kS (kK (columnValues)[5 ])[i]; // 24h high : symbol
755
+ std::string low = kS (kK (columnValues)[6 ])[i]; // 24h low : symbol
756
+ std::string pctChange = kS (kK (columnValues)[7 ])[i]; // 24h pct change : symbol
757
+ std::string volBase = kS (kK (columnValues)[8 ])[i]; // 24h vol base : symbol
758
+ std::string volQuote = kS (kK (columnValues)[9 ])[i]; // 24h vol quote : symbol
759
+ std::string bestBid = kS (kK (columnValues)[10 ])[i]; // best bid : symbol
760
+ std::string bestAsk = kS (kK (columnValues)[11 ])[i]; // best ask : symbol
761
+ long timestamp = kJ (kK (columnValues)[12 ])[i]; // timestamp : long
762
+
763
+ writer.StartObject ();
764
+ writer.Key (" table" );
765
+ writer.String (" ticker" );
766
+
767
+ writer.Key (" action" );
768
+ writer.String (" insert" );
769
+
770
+ writer.Key (" data" );
771
+
772
+ writer.StartObject ();
773
+ writer.Key (" instrument" );
774
+ writer.String (instrument.c_str ());
775
+
776
+ writer.Key (" asset_base" );
777
+ writer.String (baseAsset.c_str ());
778
+
779
+ writer.Key (" asset_quote" );
780
+ writer.String (quoteAsset.c_str ());
781
+
782
+ writer.Key (" high" );
783
+ writer.String (high.c_str ());
784
+
785
+ writer.Key (" low" );
786
+ writer.String (low.c_str ());
787
+
788
+ writer.Key (" percent_change" );
789
+ writer.String (pctChange.c_str ());
790
+
791
+ writer.Key (" volume_base" );
792
+ writer.String (volBase.c_str ());
793
+
794
+ writer.Key (" volume_quote" );
795
+ writer.String (volQuote.c_str ());
796
+
797
+ writer.Key (" last" );
798
+ writer.String (price.c_str ());
799
+
800
+ writer.Key (" best_bid" );
801
+ writer.String (bestBid.c_str ());
802
+
803
+ writer.Key (" best_ask" );
804
+ writer.String (bestAsk.c_str ());
805
+
806
+ writer.Key (" timestamp" );
807
+ writer.Uint64 (timestamp);
808
+
809
+ writer.Key (" market" );
810
+ writer.String (" crypto" );
811
+
812
+ writer.Key (" is_frozen" );
813
+ writer.Bool (false );
814
+
815
+ writer.EndObject ();
816
+ writer.EndObject ();
817
+
818
+ auto tickerJson = s.GetString ();
819
+ auto topic = std::string (" ticker:" ).append (instrument);
820
+ global->publish (topic, tickerJson, uWS::OpCode::TEXT, true );
821
+ s.Clear ();
822
+ }
823
+ }
740
824
if (KdbShape (response, depth_l3, 8 )) {
741
825
std::cout << " Processing depthL3 table " << std::endl;
742
826
K table= kK (response)[2 ]->k ;
0 commit comments