trader  v0.1a
A framework to build trading applications
krakenapi.h
1 
2 #pragma once
3 #include "app.h"
4 #include "api.h"
5 #include "krakenconfig.h"
6 #include "helper.h"
7 
8 
9 namespace trader {
10 
11  namespace KrakenApi {
12 
13  class AccountBalance : public Poco::RefCountedObject {
14  public:
15 
17 
18  ~AccountBalance();
19 
20  void readFile(const std::string& _fileName);
21 
22  void read(Poco::Dynamic::Var val);
23 
24  struct DataObject {
25 
26  typedef double ResultMap;
27 
28  typedef std::map<std::string, ResultMap> Result;
29  Result result;
30  DataObject()
31  {
32  }
33 
34  };
35 
36  DataObject dataObject;
37  }; //AccountBalance
38 
39  class AssetInfo : public Poco::RefCountedObject {
40  public:
41 
42  AssetInfo();
43 
44  ~AssetInfo();
45 
46  void readFile(const std::string& _fileName);
47 
48  void read(Poco::Dynamic::Var val);
49 
50  struct DataObject {
51 
52  struct ResultMap {
53 
54  void SetAclass(std::string val)
55  {
56  aclass = val;
57  }
58 
59  bool isSetAclass() {
60  return (aclass != "Empty");
61  }
62 
63  std::string aclass;
64 
65  void SetAltname(std::string val)
66  {
67  altname = val;
68  }
69 
70  bool isSetAltname() {
71  return (altname != "Empty");
72  }
73 
74  std::string altname;
75 
76  void SetDecimals(Poco::Int32 val)
77  {
78  decimals = val;
79  }
80 
81  bool isSetDecimals() {
82  return (decimals != std::numeric_limits<Poco::Int32>::max());
83  }
84 
85  Poco::Int32 decimals;
86 
87  void SetDisplay_decimals(Poco::Int32 val)
88  {
89  display_decimals = val;
90  }
91 
92  bool isSetDisplay_decimals() {
93  return (display_decimals != std::numeric_limits<Poco::Int32>::max());
94  }
95 
96  Poco::Int32 display_decimals;
97 
98  ResultMap()
99  : aclass("Empty")
100  , altname("Empty")
101  , decimals(std::numeric_limits<Poco::Int32>::max())
102  , display_decimals(std::numeric_limits<Poco::Int32>::max())
103  {
104  }
105 
106  };
107 
108  typedef std::map<std::string, ResultMap> Result;
109  Result result;
110  DataObject()
111  {
112  }
113 
114  };
115 
116  DataObject dataObject;
117  }; //AssetInfo
118 
119  class AssetInfoParams : public Poco::RefCountedObject {
120  public:
121 
122  AssetInfoParams();
123 
124  ~AssetInfoParams();
125 
126  void readFile(const std::string& _fileName);
127 
128  void read(Poco::Dynamic::Var val);
129 
130  struct DataObject {
131 
132  // Asset Class - currency (default)
133  void SetAclass(std::string val)
134  {
135  aclass = val;
136  }
137 
138  bool isSetAclass() {
139  return (aclass != "Empty");
140  }
141 
142  std::string aclass;
143 
144  // Comma delimited list of assets to get info on (optional. default = all for given asset class)
145  void SetAsset(std::string val)
146  {
147  asset = val;
148  }
149 
150  bool isSetAsset() {
151  return (asset != "Empty");
152  }
153 
154  std::string asset;
155 
156  // Info to retrieve - all info (default)
157  void SetInfo(std::string val)
158  {
159  info = val;
160  }
161 
162  bool isSetInfo() {
163  return (info != "Empty");
164  }
165 
166  std::string info;
167 
168  DataObject()
169  : aclass("Empty")
170  , asset("Empty")
171  , info("Empty")
172  {
173  }
174 
175  };
176 
177  DataObject dataObject;
178  }; //AssetInfoParams
179 
180  class AssetPairs : public Poco::RefCountedObject {
181  public:
182 
183  AssetPairs();
184 
185  ~AssetPairs();
186 
187  void readFile(const std::string& _fileName);
188 
189  void read(Poco::Dynamic::Var val);
190 
191  struct DataObject {
192 
193  struct ResultMap {
194 
195  // asset class of base component
196  void SetAclass_base(std::string val)
197  {
198  aclass_base = val;
199  }
200 
201  bool isSetAclass_base() {
202  return (aclass_base != "Empty");
203  }
204 
205  std::string aclass_base;
206 
207  // asset class of quote component
208  void SetAclass_quote(std::string val)
209  {
210  aclass_quote = val;
211  }
212 
213  bool isSetAclass_quote() {
214  return (aclass_quote != "Empty");
215  }
216 
217  std::string aclass_quote;
218 
219  // alternate pair name
220  void SetAltname(std::string val)
221  {
222  altname = val;
223  }
224 
225  bool isSetAltname() {
226  return (altname != "Empty");
227  }
228 
229  std::string altname;
230 
231  // asset id of base component
232  void SetBase(std::string val)
233  {
234  base = val;
235  }
236 
237  bool isSetBase() {
238  return (base != "Empty");
239  }
240 
241  std::string base;
242 
243  // volume discount currency
244  void SetFee_volume_currency(std::string val)
245  {
246  fee_volume_currency = val;
247  }
248 
249  bool isSetFee_volume_currency() {
250  return (fee_volume_currency != "Empty");
251  }
252 
253  std::string fee_volume_currency;
254 
255  typedef double FeesArrayArray;
256 
257  typedef std::vector<FeesArrayArray> FeesArray;
258  typedef std::vector<FeesArray> Fees;
259  Fees fees;
260  typedef double Fees_makerArrayArray;
261 
262  typedef std::vector<Fees_makerArrayArray> Fees_makerArray;
263  typedef std::vector<Fees_makerArray> Fees_maker;
264  Fees_maker fees_maker;
265  typedef double Leverage_buyArray;
266 
267  typedef std::vector<Leverage_buyArray> Leverage_buy;
268  Leverage_buy leverage_buy;
269  typedef double Leverage_sellArray;
270 
271  typedef std::vector<Leverage_sellArray> Leverage_sell;
272  Leverage_sell leverage_sell;
273  // volume lot size
274  void SetLot(std::string val)
275  {
276  lot = val;
277  }
278 
279  bool isSetLot() {
280  return (lot != "Empty");
281  }
282 
283  std::string lot;
284 
285  // scaling decimal places for volume
286  void SetLot_decimals(Poco::Int32 val)
287  {
288  lot_decimals = val;
289  }
290 
291  bool isSetLot_decimals() {
292  return (lot_decimals != std::numeric_limits<Poco::Int32>::max());
293  }
294 
295  Poco::Int32 lot_decimals;
296 
297  // amount to multiply lot volume by to get currency volume
298  void SetLot_multiplier(Poco::Int32 val)
299  {
300  lot_multiplier = val;
301  }
302 
303  bool isSetLot_multiplier() {
304  return (lot_multiplier != std::numeric_limits<Poco::Int32>::max());
305  }
306 
307  Poco::Int32 lot_multiplier;
308 
309  // margin call level
310  void SetMargin_call(Poco::Int32 val)
311  {
312  margin_call = val;
313  }
314 
315  bool isSetMargin_call() {
316  return (margin_call != std::numeric_limits<Poco::Int32>::max());
317  }
318 
319  Poco::Int32 margin_call;
320 
321  // stop-out/liquidation margin level
322  void SetMargin_stop(Poco::Int32 val)
323  {
324  margin_stop = val;
325  }
326 
327  bool isSetMargin_stop() {
328  return (margin_stop != std::numeric_limits<Poco::Int32>::max());
329  }
330 
331  Poco::Int32 margin_stop;
332 
333  // scaling decimal places for pair
334  void SetPair_decimals(Poco::Int32 val)
335  {
336  pair_decimals = val;
337  }
338 
339  bool isSetPair_decimals() {
340  return (pair_decimals != std::numeric_limits<Poco::Int32>::max());
341  }
342 
343  Poco::Int32 pair_decimals;
344 
345  // asset id of quote component
346  void SetQuote(std::string val)
347  {
348  quote = val;
349  }
350 
351  bool isSetQuote() {
352  return (quote != "Empty");
353  }
354 
355  std::string quote;
356 
357  ResultMap()
358  : aclass_base("Empty")
359  , aclass_quote("Empty")
360  , altname("Empty")
361  , base("Empty")
362  , fee_volume_currency("Empty")
363  , lot("Empty")
364  , lot_decimals(std::numeric_limits<Poco::Int32>::max())
365  , lot_multiplier(std::numeric_limits<Poco::Int32>::max())
366  , margin_call(std::numeric_limits<Poco::Int32>::max())
367  , margin_stop(std::numeric_limits<Poco::Int32>::max())
368  , pair_decimals(std::numeric_limits<Poco::Int32>::max())
369  , quote("Empty")
370  {
371  }
372 
373  };
374 
375  typedef std::map<std::string, ResultMap> Result;
376  Result result;
377  DataObject()
378  {
379  }
380 
381  };
382 
383  DataObject dataObject;
384  }; //AssetPairs
385 
386  class AssetPairsParams : public Poco::RefCountedObject {
387  public:
388 
390 
391  ~AssetPairsParams();
392 
393  void readFile(const std::string& _fileName);
394 
395  void read(Poco::Dynamic::Var val);
396 
397  struct DataObject {
398 
399  // info to retrieve (optional), info = all info (default), leverage = leverage info, fees = fees schedule, margin = margin info
400  void SetInfo(std::string val)
401  {
402  info = val;
403  }
404 
405  bool isSetInfo() {
406  return (info != "Empty");
407  }
408 
409  std::string info;
410 
411  // comma delimited list of asset pairs to get info on (optional. default = all)
412  void SetPair(std::string val)
413  {
414  pair = val;
415  }
416 
417  bool isSetPair() {
418  return (pair != "Empty");
419  }
420 
421  std::string pair;
422 
423  DataObject()
424  : info("Empty")
425  , pair("Empty")
426  {
427  }
428 
429  };
430 
431  DataObject dataObject;
432  }; //AssetPairsParams
433 
434  class ErrorIntrospector : public Poco::RefCountedObject {
435  public:
436 
438 
440 
441  void readFile(const std::string& _fileName);
442 
443  void read(Poco::Dynamic::Var val);
444 
445  struct DataObject {
446 
447  typedef std::string ErrorArray;
448 
449  typedef std::vector<ErrorArray> Error;
450  Error error;
451  DataObject()
452  {
453  }
454 
455  };
456 
457  DataObject dataObject;
458  }; //ErrorIntrospector
459 
460  class OHLCData : public Poco::RefCountedObject {
461  public:
462 
463  OHLCData();
464 
465  ~OHLCData();
466 
467  void readFile(const std::string& _fileName);
468 
469  void read(Poco::Dynamic::Var val);
470 
471  struct DataObject {
472 
473  typedef double ResultMapArrayArray;
474 
475  typedef std::vector<ResultMapArrayArray> ResultMapArray;
476  typedef std::vector<ResultMapArray> ResultMap;
477  typedef std::map<std::string, ResultMap> Result;
478  Result result;
479  // id to be used as since when polling for new, committed OHLC data
480  void SetLast(Poco::Int32 val)
481  {
482  last = val;
483  }
484 
485  bool isSetLast() {
486  return (last != std::numeric_limits<Poco::Int32>::max());
487  }
488 
489  Poco::Int32 last;
490 
491  DataObject()
492  {
493  }
494 
495  };
496 
497  DataObject dataObject;
498  }; //OHLCData
499 
500  class OHLCDataParams : public Poco::RefCountedObject {
501  public:
502 
503  OHLCDataParams();
504 
505  ~OHLCDataParams();
506 
507  void readFile(const std::string& _fileName);
508 
509  void read(Poco::Dynamic::Var val);
510 
511  struct DataObject {
512 
513  // time frame interval in minutes (optional): 1 (default), 5, 15, 30, 60, 240, 1440, 10080, 21600
514  void SetInterval (double val)
515  {
516  interval = val;
517  }
518 
519  bool isSetInterval () {
520  return (interval != std::numeric_limits<double>::max());
521  }
522 
523  double interval ;
524 
525  // asset pair to get OHLC data for
526  void SetPair(std::string val)
527  {
528  pair = val;
529  }
530 
531  bool isSetPair() {
532  return (pair != "Empty");
533  }
534 
535  std::string pair;
536 
537  // return committed OHLC data since given id (optional. exclusive)
538  void SetSince(double val)
539  {
540  since = val;
541  }
542 
543  bool isSetSince() {
544  return (since != std::numeric_limits<double>::max());
545  }
546 
547  double since;
548 
549  DataObject()
550  : interval (std::numeric_limits<double>::max())
551  , pair("Empty")
552  , since(std::numeric_limits<double>::max())
553  {
554  }
555 
556  };
557 
558  DataObject dataObject;
559  }; //OHLCDataParams
560 
561  class OrderBook : public Poco::RefCountedObject {
562  public:
563 
564  OrderBook();
565 
566  ~OrderBook();
567 
568  void readFile(const std::string& _fileName);
569 
570  void read(Poco::Dynamic::Var val);
571 
572  struct DataObject {
573 
574  struct ResultMap {
575 
576  typedef double AsksArrayArray;
577 
578  typedef std::vector<AsksArrayArray> AsksArray;
579  typedef std::vector<AsksArray> Asks;
580  Asks asks;
581  typedef double BidsArrayArray;
582 
583  typedef std::vector<BidsArrayArray> BidsArray;
584  typedef std::vector<BidsArray> Bids;
585  Bids bids;
586  ResultMap()
587  {
588  }
589 
590  };
591 
592  typedef std::map<std::string, ResultMap> Result;
593  Result result;
594  DataObject()
595  {
596  }
597 
598  };
599 
600  DataObject dataObject;
601  }; //OrderBook
602 
603  class OrderBookParams : public Poco::RefCountedObject {
604  public:
605 
606  OrderBookParams();
607 
608  ~OrderBookParams();
609 
610  void readFile(const std::string& _fileName);
611 
612  void read(Poco::Dynamic::Var val);
613 
614  struct DataObject {
615 
616  // maximum number of asks/bids (optional)
617  void SetCount(Poco::Int32 val)
618  {
619  count = val;
620  }
621 
622  bool isSetCount() {
623  return (count != std::numeric_limits<Poco::Int32>::max());
624  }
625 
626  Poco::Int32 count;
627 
628  // asset pair to get OHLC data for
629  void SetPair(std::string val)
630  {
631  pair = val;
632  }
633 
634  bool isSetPair() {
635  return (pair != "Empty");
636  }
637 
638  std::string pair;
639 
640  DataObject()
641  : count(std::numeric_limits<Poco::Int32>::max())
642  , pair("Empty")
643  {
644  }
645 
646  };
647 
648  DataObject dataObject;
649  }; //OrderBookParams
650 
651  class RecentSpread : public Poco::RefCountedObject {
652  public:
653 
654  RecentSpread();
655 
656  ~RecentSpread();
657 
658  void readFile(const std::string& _fileName);
659 
660  void read(Poco::Dynamic::Var val);
661 
662  struct DataObject {
663 
664  typedef double ResultMapArrayArray;
665 
666  typedef std::vector<ResultMapArrayArray> ResultMapArray;
667  typedef std::vector<ResultMapArray> ResultMap;
668  typedef std::map<std::string, ResultMap> Result;
669  Result result;
670  // id to be used as since when polling for new spread data
671  void SetLast(Poco::Int32 val)
672  {
673  last = val;
674  }
675 
676  bool isSetLast() {
677  return (last != std::numeric_limits<Poco::Int32>::max());
678  }
679 
680  Poco::Int32 last;
681 
682  DataObject()
683  {
684  }
685 
686  };
687 
688  DataObject dataObject;
689  }; //RecentSpread
690 
691  class RecentSpreadParams : public Poco::RefCountedObject {
692  public:
693 
695 
697 
698  void readFile(const std::string& _fileName);
699 
700  void read(Poco::Dynamic::Var val);
701 
702  struct DataObject {
703 
704  void SetPair(std::string val)
705  {
706  pair = val;
707  }
708 
709  bool isSetPair() {
710  return (pair != "Empty");
711  }
712 
713  std::string pair;
714 
715  // return spread data since given id (optional. inclusive)
716  void SetSince(Poco::Int32 val)
717  {
718  since = val;
719  }
720 
721  bool isSetSince() {
722  return (since != std::numeric_limits<Poco::Int32>::max());
723  }
724 
725  Poco::Int32 since;
726 
727  DataObject()
728  : pair("Empty")
729  , since(std::numeric_limits<Poco::Int32>::max())
730  {
731  }
732 
733  };
734 
735  DataObject dataObject;
736  }; //RecentSpreadParams
737 
738  class RecentTrades : public Poco::RefCountedObject {
739  public:
740 
741  RecentTrades();
742 
743  ~RecentTrades();
744 
745  void readFile(const std::string& _fileName);
746 
747  void read(Poco::Dynamic::Var val);
748 
749  struct DataObject {
750 
751  typedef std::string ResultMapArrayArray;
752 
753  typedef std::vector<ResultMapArrayArray> ResultMapArray;
754  typedef std::vector<ResultMapArray> ResultMap;
755  typedef std::map<std::string, ResultMap> Result;
756  Result result;
757  // id to be used as since when polling for new trade data
758  void SetLast(std::string val)
759  {
760  last = val;
761  }
762 
763  bool isSetLast() {
764  return (last != "Empty");
765  }
766 
767  std::string last;
768 
769  DataObject()
770  {
771  }
772 
773  };
774 
775  DataObject dataObject;
776  }; //RecentTrades
777 
778  class RecentTradesParams : public Poco::RefCountedObject {
779  public:
780 
782 
784 
785  void readFile(const std::string& _fileName);
786 
787  void read(Poco::Dynamic::Var val);
788 
789  struct DataObject {
790 
791  // asset pair to get OHLC data for
792  void SetPair(std::string val)
793  {
794  pair = val;
795  }
796 
797  bool isSetPair() {
798  return (pair != "Empty");
799  }
800 
801  std::string pair;
802 
803  // return trade data since given id (optional. exclusive)
804  void SetSince(Poco::Int32 val)
805  {
806  since = val;
807  }
808 
809  bool isSetSince() {
810  return (since != std::numeric_limits<Poco::Int32>::max());
811  }
812 
813  Poco::Int32 since;
814 
815  DataObject()
816  : pair("Empty")
817  , since(std::numeric_limits<Poco::Int32>::max())
818  {
819  }
820 
821  };
822 
823  DataObject dataObject;
824  }; //RecentTradesParams
825 
826  class ServerTime : public Poco::RefCountedObject {
827  public:
828 
829  ServerTime();
830 
831  ~ServerTime();
832 
833  void readFile(const std::string& _fileName);
834 
835  void read(Poco::Dynamic::Var val);
836 
837  struct DataObject {
838 
839  struct ResultObject {
840 
841  void SetRfc1123(std::string val)
842  {
843  rfc1123 = val;
844  }
845 
846  bool isSetRfc1123() {
847  return (rfc1123 != "Empty");
848  }
849 
850  std::string rfc1123;
851 
852  void SetUnixtime(Poco::Int32 val)
853  {
854  unixtime = val;
855  }
856 
857  bool isSetUnixtime() {
858  return (unixtime != std::numeric_limits<Poco::Int32>::max());
859  }
860 
861  Poco::Int32 unixtime;
862 
863  ResultObject()
864  : rfc1123("Empty")
865  , unixtime(std::numeric_limits<Poco::Int32>::max())
866  {
867  }
868 
869  };
870 
871  ResultObject resultObject;
872  DataObject()
873  {
874  }
875 
876  };
877 
878  DataObject dataObject;
879  }; //ServerTime
880 
881  class StandardOrder : public Poco::RefCountedObject {
882  public:
883 
884  StandardOrder();
885 
886  ~StandardOrder();
887 
888  void readFile(const std::string& _fileName);
889 
890  void read(Poco::Dynamic::Var val);
891 
892  struct DataObject {
893 
894  struct ResultObject {
895 
896  struct DescrObject {
897 
898  // conditional close order description (if conditional close set)
899  void SetClose(std::string val)
900  {
901  close = val;
902  }
903 
904  bool isSetClose() {
905  return (close != "Empty");
906  }
907 
908  std::string close;
909 
910  // order description
911  void SetOrder(std::string val)
912  {
913  order = val;
914  }
915 
916  bool isSetOrder() {
917  return (order != "Empty");
918  }
919 
920  std::string order;
921 
922  DescrObject()
923  : close("Empty")
924  , order("Empty")
925  {
926  }
927 
928  };
929 
930  DescrObject descrObject;
931  typedef std::string TxidArray;
932 
933  typedef std::vector<TxidArray> Txid;
934  Txid txid;
935  ResultObject()
936  {
937  }
938 
939  };
940 
941  ResultObject resultObject;
942  DataObject()
943  {
944  }
945 
946  };
947 
948  DataObject dataObject;
949  }; //StandardOrder
950 
951  class StandardOrderParams : public Poco::RefCountedObject {
952  public:
953 
955 
957 
958  void readFile(const std::string& _fileName);
959 
960  void read(Poco::Dynamic::Var val);
961 
962  struct DataObject {
963 
964  // expiration time (optional):
965  // 0 = no expiration (default)
966  // +<n> = expire <n> seconds from now
967  // <n> = unix timestamp of expiration time
968  void SetExpiretm(std::string val)
969  {
970  expiretm = val;
971  }
972 
973  bool isSetExpiretm() {
974  return (expiretm != "Empty");
975  }
976 
977  std::string expiretm;
978 
979  // amount of leverage desired
980  // (optional. default = none)
981  void SetLeverage(Poco::Int32 val)
982  {
983  leverage = val;
984  }
985 
986  bool isSetLeverage() {
987  return (leverage != std::numeric_limits<Poco::Int32>::max());
988  }
989 
990  Poco::Int32 leverage;
991 
992  // comma delimited list of order flags (optional):
993  // viqc = volume in quote currency (not available for leveraged orders)
994  // fcib = prefer fee in base currency
995  // fciq = prefer fee in quote currency
996  // nompp = no market price protection
997  // post = post only order (available when ordertype = limit)
998  void SetOflags(std::string val)
999  {
1000  oflags = val;
1001  }
1002 
1003  bool isSetOflags() {
1004  return (oflags != "Empty");
1005  }
1006 
1007  std::string oflags;
1008 
1009  // order type:
1010  // market
1011  // limit (price = limit price)
1012  // stop-loss (price = stop loss price)
1013  // take-profit (price = take profit price)
1014  // stop-loss-profit (price = stop loss price, price2 = take profit price)
1015  // stop-loss-profit-limit (price = stop loss price, price2 = take profit price)
1016  // stop-loss-limit (price = stop loss trigger price, price2 = triggered limit price)
1017  // take-profit-limit (price = take profit trigger price, price2 = triggered limit price)
1018  // trailing-stop (price = trailing stop offset)
1019  // trailing-stop-limit (price = trailing stop offset, price2 = triggered limit offset)
1020  // stop-loss-and-limit (price = stop loss price, price2 = limit price)
1021  // settle-position
1022  void SetOrdertype(std::string val)
1023  {
1024  ordertype = val;
1025  }
1026 
1027  bool isSetOrdertype() {
1028  return (ordertype != "Empty");
1029  }
1030 
1031  std::string ordertype;
1032 
1033  // asset pair
1034  void SetPair(std::string val)
1035  {
1036  pair = val;
1037  }
1038 
1039  bool isSetPair() {
1040  return (pair != "Empty");
1041  }
1042 
1043  std::string pair;
1044 
1045  // price (optional. dependent upon ordertype)
1046  void SetPrice(std::string val)
1047  {
1048  price = val;
1049  }
1050 
1051  bool isSetPrice() {
1052  return (price != "Empty");
1053  }
1054 
1055  std::string price;
1056 
1057  // secondary price
1058  // (optional. dependent upon ordertype)
1059  void SetPrice2(std::string val)
1060  {
1061  price2 = val;
1062  }
1063 
1064  bool isSetPrice2() {
1065  return (price2 != "Empty");
1066  }
1067 
1068  std::string price2;
1069 
1070  // scheduled start time (optional):
1071  // 0 = now (default)
1072  // +<n> = schedule start time <n> seconds from now
1073  // <n> = unix timestamp of start time
1074  void SetStarttm(std::string val)
1075  {
1076  starttm = val;
1077  }
1078 
1079  bool isSetStarttm() {
1080  return (starttm != "Empty");
1081  }
1082 
1083  std::string starttm;
1084 
1085  // type of order (buy/sell)
1086  void SetType(std::string val)
1087  {
1088  type = val;
1089  }
1090 
1091  bool isSetType() {
1092  return (type != "Empty");
1093  }
1094 
1095  std::string type;
1096 
1097  // user reference id. 32-bit signed number. (optional)
1098  void SetUserref(Poco::Int32 val)
1099  {
1100  userref = val;
1101  }
1102 
1103  bool isSetUserref() {
1104  return (userref != std::numeric_limits<Poco::Int32>::max());
1105  }
1106 
1107  Poco::Int32 userref;
1108 
1109  // validate inputs only. do not submit order (optional)
1110  void SetValidate(bool val)
1111  {
1112  validate = val;
1113  validateSet = true;
1114  }
1115 
1116  bool isSetValidate() {
1117  return (validateSet != false);
1118  }
1119 
1120  bool validate;
1121  bool validateSet;
1122 
1123  // order volume in lots
1124  void SetVolume(double val)
1125  {
1126  volume = val;
1127  }
1128 
1129  bool isSetVolume() {
1130  return (volume != std::numeric_limits<double>::max());
1131  }
1132 
1133  double volume;
1134 
1135  DataObject()
1136  : expiretm("Empty")
1137  , leverage(std::numeric_limits<Poco::Int32>::max())
1138  , oflags("Empty")
1139  , ordertype("Empty")
1140  , pair("Empty")
1141  , price("Empty")
1142  , price2("Empty")
1143  , starttm("Empty")
1144  , type("Empty")
1145  , userref(std::numeric_limits<Poco::Int32>::max())
1146  , validate(false)
1147  , validateSet(false)
1148  , volume(std::numeric_limits<double>::max())
1149  {
1150  }
1151 
1152  };
1153 
1154  DataObject dataObject;
1155  }; //StandardOrderParams
1156 
1157  class TickerInformation : public Poco::RefCountedObject {
1158  public:
1159 
1161 
1162  ~TickerInformation();
1163 
1164  void readFile(const std::string& _fileName);
1165 
1166  void read(Poco::Dynamic::Var val);
1167 
1168  struct DataObject {
1169 
1170  struct ResultMap {
1171 
1172  typedef double AArray;
1173 
1174  typedef std::vector<AArray> A;
1175  A a;
1176  typedef double BArray;
1177 
1178  typedef std::vector<BArray> B;
1179  B b;
1180  typedef double CArray;
1181 
1182  typedef std::vector<CArray> C;
1183  C c;
1184  typedef double HArray;
1185 
1186  typedef std::vector<HArray> H;
1187  H h;
1188  typedef double LArray;
1189 
1190  typedef std::vector<LArray> L;
1191  L l;
1192  // today's opening price
1193  void SetO(double val)
1194  {
1195  o = val;
1196  }
1197 
1198  bool isSetO() {
1199  return (o != std::numeric_limits<double>::max());
1200  }
1201 
1202  double o;
1203 
1204  typedef double PArray;
1205 
1206  typedef std::vector<PArray> P;
1207  P p;
1208  typedef double TArray;
1209 
1210  typedef std::vector<TArray> T;
1211  T t;
1212  typedef double VArray;
1213 
1214  typedef std::vector<VArray> V;
1215  V v;
1216  ResultMap()
1217  : o(std::numeric_limits<double>::max())
1218  {
1219  }
1220 
1221  };
1222 
1223  typedef std::map<std::string, ResultMap> Result;
1224  Result result;
1225  DataObject()
1226  {
1227  }
1228 
1229  };
1230 
1231  DataObject dataObject;
1232  }; //TickerInformation
1233 
1234  class TickerInformationParams : public Poco::RefCountedObject {
1235  public:
1236 
1238 
1240 
1241  void readFile(const std::string& _fileName);
1242 
1243  void read(Poco::Dynamic::Var val);
1244 
1245  struct DataObject {
1246 
1247  // comma delimited list of asset pairs to get info on
1248  void SetPair(std::string val)
1249  {
1250  pair = val;
1251  }
1252 
1253  bool isSetPair() {
1254  return (pair != "Empty");
1255  }
1256 
1257  std::string pair;
1258 
1259  DataObject()
1260  : pair("Empty")
1261  {
1262  }
1263 
1264  };
1265 
1266  DataObject dataObject;
1267  }; //TickerInformationParams
1268 
1269  class EndPoints {
1270  public:
1271 
1272  EndPoints(Poco::AutoPtr<trader::App> app, Api* api);
1273 
1274  ~EndPoints();
1275 
1276 
1277  // Get server time
1278  Poco::AutoPtr<ServerTime> GetServerTime();
1279 
1280  // Returns list of asset names and info
1281  Poco::AutoPtr<AssetInfo> GetAssetInfo(Poco::AutoPtr<AssetInfoParams> assetInfoParams);
1282 
1283  // Get tradable asset pairs
1284  Poco::AutoPtr<AssetPairs> GetAssetPairs(Poco::AutoPtr<AssetPairsParams> assetPairsParams);
1285 
1286  // Get Ticker Information -
1287  // Note: Today's prices start at 00:00:00 UTC
1288  Poco::AutoPtr<TickerInformation> GetTickerInformation(Poco::AutoPtr<TickerInformationParams> tickerInformationParams);
1289 
1290  // Get OHLC data -
1291  // Note: the last entry in the OHLC array is for the current,
1292  // not-yet-committed frame and will always be present,
1293  // regardless of the value of "since".
1294  Poco::AutoPtr<OHLCData> GetOHLCData(Poco::AutoPtr<OHLCDataParams> oHLCDataParams);
1295 
1296  // Array of asset names and balance amount
1297  Poco::AutoPtr<AccountBalance> GetAccountBalance();
1298 
1299  // Get Order Book
1300  Poco::AutoPtr<OrderBook> GetOrderBook(Poco::AutoPtr<OrderBookParams> orderBookParams);
1301 
1302  // Get Recent Trades
1303  Poco::AutoPtr<RecentTrades> GetRecentTrades(Poco::AutoPtr<RecentTradesParams> recentTradesParams);
1304 
1305  // Recent Spread Data
1306  Poco::AutoPtr<RecentSpread> GetRecentSpread(Poco::AutoPtr<RecentSpreadParams> recentSpreadParams);
1307 
1308  // Add Standard Order
1309  Poco::AutoPtr<StandardOrder> AddStandardOrder(Poco::AutoPtr<StandardOrderParams> standardOrderParams);
1310 
1311  KrakenConfig config;
1312 
1313  Poco::AutoPtr<trader::App> _app;
1314  Api* _api;
1315  std::string _uri;
1316  }; //EndPoints
1317 
1318  } //KrakenApi
1319 } //trader
Definition: krakenapi.h:778
Definition: krakenapi.h:951
Definition: krakenapi.h:1157
Definition: krakenapi.h:500
Definition: krakenapi.h:471
Definition: krakenconfig.h:7
Definition: krakenapi.h:386
Definition: krakenapi.h:603
Definition: krakenapi.h:434
Definition: krakenapi.h:13
Definition: krakenapi.h:460
Definition: api.h:15
Definition: krakenapi.h:180
Definition: krakenapi.h:572
Definition: krakenapi.h:651
Definition: krakenapi.h:826
Definition: krakenapi.h:119
Definition: krakenapi.h:881
Definition: krakenapi.h:39
Definition: krakenapi.h:561
Definition: krakenapi.h:1234
Definition: app.h:7
Definition: krakenapi.h:691
Definition: krakenapi.h:738
Definition: krakenapi.h:1269