@barchart/portfolio-client-js 1.1.15 → 1.1.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/example/example.html +521 -0
- package/example/example.js +52 -10
- package/lib/gateway/PortfolioGateway.js +3 -2
- package/lib/index.js +1 -1
- package/package.json +1 -1
package/example/example.html
CHANGED
|
@@ -274,6 +274,8 @@
|
|
|
274
274
|
.then((data) => {
|
|
275
275
|
writeConsoleText(action, true);
|
|
276
276
|
writeConsoleObject(data);
|
|
277
|
+
|
|
278
|
+
that.position(data.position);
|
|
277
279
|
}).catch((e) => {
|
|
278
280
|
writeConsoleText(action, true);
|
|
279
281
|
writeConsoleObject(e);
|
|
@@ -313,6 +315,507 @@
|
|
|
313
315
|
writeConsoleText(action, true);
|
|
314
316
|
writeConsoleObject(e);
|
|
315
317
|
|
|
318
|
+
that.setConsoleMode();
|
|
319
|
+
});
|
|
320
|
+
};
|
|
321
|
+
var createBuyShortTransaction = function() {
|
|
322
|
+
var action = 'portfolioGateway.createTransaction()';
|
|
323
|
+
|
|
324
|
+
if (!that.portfolio()) {
|
|
325
|
+
toastr.info('A "portfolio" is required.');
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
var transaction = {
|
|
330
|
+
portfolio: that.portfolio(),
|
|
331
|
+
position: that.position() || null,
|
|
332
|
+
type: Barchart.TransactionType.BUY_SHORT,
|
|
333
|
+
instrument: {
|
|
334
|
+
name: 'International Business Machines',
|
|
335
|
+
currency: Barchart.Currency.USD,
|
|
336
|
+
symbol: {
|
|
337
|
+
barchart: 'IBM',
|
|
338
|
+
display: 'IBM'
|
|
339
|
+
}
|
|
340
|
+
},
|
|
341
|
+
currency: Barchart.Currency.CAD,
|
|
342
|
+
date: Barchart.Day.getToday(),
|
|
343
|
+
price: Barchart.Decimal.parse(5),
|
|
344
|
+
quantity: Barchart.Decimal.parse(100),
|
|
345
|
+
fee: Barchart.Decimal.ZERO
|
|
346
|
+
};
|
|
347
|
+
|
|
348
|
+
that.gateway.createTransaction(transaction)
|
|
349
|
+
.then((data) => {
|
|
350
|
+
writeConsoleText(action, true);
|
|
351
|
+
writeConsoleObject(data);
|
|
352
|
+
}).catch((e) => {
|
|
353
|
+
writeConsoleText(action, true);
|
|
354
|
+
writeConsoleObject(e);
|
|
355
|
+
|
|
356
|
+
that.setConsoleMode();
|
|
357
|
+
});
|
|
358
|
+
};
|
|
359
|
+
var createSellShortTransaction = function() {
|
|
360
|
+
var action = 'portfolioGateway.createTransaction()';
|
|
361
|
+
|
|
362
|
+
if (!that.portfolio()) {
|
|
363
|
+
toastr.info('A "portfolio" is required.');
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
if (!that.position()) {
|
|
368
|
+
toastr.info('A "position" is required.');
|
|
369
|
+
return;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
var transaction = {
|
|
373
|
+
portfolio: that.portfolio(),
|
|
374
|
+
position: that.position(),
|
|
375
|
+
type: Barchart.TransactionType.SELL_SHORT,
|
|
376
|
+
instrument: {
|
|
377
|
+
name: 'International Business Machines',
|
|
378
|
+
currency: Barchart.Currency.USD,
|
|
379
|
+
symbol: {
|
|
380
|
+
barchart: 'IBM',
|
|
381
|
+
display: 'IBM'
|
|
382
|
+
}
|
|
383
|
+
},
|
|
384
|
+
currency: Barchart.Currency.CAD,
|
|
385
|
+
date: Barchart.Day.getToday(),
|
|
386
|
+
price: Barchart.Decimal.parse(5),
|
|
387
|
+
quantity: Barchart.Decimal.parse(100),
|
|
388
|
+
fee: Barchart.Decimal.ZERO
|
|
389
|
+
};
|
|
390
|
+
|
|
391
|
+
that.gateway.createTransaction(transaction)
|
|
392
|
+
.then((data) => {
|
|
393
|
+
writeConsoleText(action, true);
|
|
394
|
+
writeConsoleObject(data);
|
|
395
|
+
}).catch((e) => {
|
|
396
|
+
writeConsoleText(action, true);
|
|
397
|
+
writeConsoleObject(e);
|
|
398
|
+
|
|
399
|
+
that.setConsoleMode();
|
|
400
|
+
});
|
|
401
|
+
};
|
|
402
|
+
var createDividendTransaction = function() {
|
|
403
|
+
var action = 'portfolioGateway.createTransaction()';
|
|
404
|
+
|
|
405
|
+
if (!that.portfolio()) {
|
|
406
|
+
toastr.info('A "portfolio" is required.');
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
if (!that.position()) {
|
|
411
|
+
toastr.info('A "position" is required.');
|
|
412
|
+
return;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
var transaction = {
|
|
416
|
+
portfolio: that.portfolio(),
|
|
417
|
+
position: that.position(),
|
|
418
|
+
type: Barchart.TransactionType.DIVIDEND,
|
|
419
|
+
currency: Barchart.Currency.CAD,
|
|
420
|
+
date: Barchart.Day.getToday(),
|
|
421
|
+
price: Barchart.Decimal.parse(5),
|
|
422
|
+
quantity: Barchart.Decimal.parse(100),
|
|
423
|
+
rate: Barchart.Decimal.parse(.125),
|
|
424
|
+
effective: Barchart.Day.getToday(),
|
|
425
|
+
fee: Barchart.Decimal.ZERO
|
|
426
|
+
};
|
|
427
|
+
|
|
428
|
+
that.gateway.createTransaction(transaction)
|
|
429
|
+
.then((data) => {
|
|
430
|
+
writeConsoleText(action, true);
|
|
431
|
+
writeConsoleObject(data);
|
|
432
|
+
}).catch((e) => {
|
|
433
|
+
writeConsoleText(action, true);
|
|
434
|
+
writeConsoleObject(e);
|
|
435
|
+
|
|
436
|
+
that.setConsoleMode();
|
|
437
|
+
});
|
|
438
|
+
};
|
|
439
|
+
var createDividendReinvestTransaction = function() {
|
|
440
|
+
var action = 'portfolioGateway.createTransaction()';
|
|
441
|
+
|
|
442
|
+
if (!that.portfolio()) {
|
|
443
|
+
toastr.info('A "portfolio" is required.');
|
|
444
|
+
return;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
if (!that.position()) {
|
|
448
|
+
toastr.info('A "position" is required.');
|
|
449
|
+
return;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
var transaction = {
|
|
453
|
+
portfolio: that.portfolio(),
|
|
454
|
+
position: that.position(),
|
|
455
|
+
type: Barchart.TransactionType.DIVIDEND_REINVEST,
|
|
456
|
+
currency: Barchart.Currency.CAD,
|
|
457
|
+
date: Barchart.Day.getToday(),
|
|
458
|
+
price: Barchart.Decimal.parse(5),
|
|
459
|
+
quantity: Barchart.Decimal.parse(100),
|
|
460
|
+
rate: Barchart.Decimal.parse(.125),
|
|
461
|
+
effective: Barchart.Day.getToday(),
|
|
462
|
+
fee: Barchart.Decimal.ZERO
|
|
463
|
+
};
|
|
464
|
+
|
|
465
|
+
that.gateway.createTransaction(transaction)
|
|
466
|
+
.then((data) => {
|
|
467
|
+
writeConsoleText(action, true);
|
|
468
|
+
writeConsoleObject(data);
|
|
469
|
+
}).catch((e) => {
|
|
470
|
+
writeConsoleText(action, true);
|
|
471
|
+
writeConsoleObject(e);
|
|
472
|
+
|
|
473
|
+
that.setConsoleMode();
|
|
474
|
+
});
|
|
475
|
+
};
|
|
476
|
+
var createDividendStockTransaction = function() {
|
|
477
|
+
var action = 'portfolioGateway.createTransaction()';
|
|
478
|
+
|
|
479
|
+
if (!that.portfolio()) {
|
|
480
|
+
toastr.info('A "portfolio" is required.');
|
|
481
|
+
return;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
if (!that.position()) {
|
|
485
|
+
toastr.info('A "position" is required.');
|
|
486
|
+
return;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
var transaction = {
|
|
490
|
+
portfolio: that.portfolio(),
|
|
491
|
+
position: that.position(),
|
|
492
|
+
type: Barchart.TransactionType.DIVIDEND_STOCK,
|
|
493
|
+
currency: Barchart.Currency.CAD,
|
|
494
|
+
date: Barchart.Day.getToday(),
|
|
495
|
+
price: Barchart.Decimal.parse(5),
|
|
496
|
+
quantity: Barchart.Decimal.parse(100),
|
|
497
|
+
rate: Barchart.Decimal.parse(.125),
|
|
498
|
+
effective: Barchart.Day.getToday(),
|
|
499
|
+
fee: Barchart.Decimal.ZERO
|
|
500
|
+
};
|
|
501
|
+
|
|
502
|
+
that.gateway.createTransaction(transaction)
|
|
503
|
+
.then((data) => {
|
|
504
|
+
writeConsoleText(action, true);
|
|
505
|
+
writeConsoleObject(data);
|
|
506
|
+
}).catch((e) => {
|
|
507
|
+
writeConsoleText(action, true);
|
|
508
|
+
writeConsoleObject(e);
|
|
509
|
+
|
|
510
|
+
that.setConsoleMode();
|
|
511
|
+
});
|
|
512
|
+
};
|
|
513
|
+
var createDistributionCashTransaction = function() {
|
|
514
|
+
var action = 'portfolioGateway.createTransaction()';
|
|
515
|
+
|
|
516
|
+
if (!that.portfolio()) {
|
|
517
|
+
toastr.info('A "portfolio" is required.');
|
|
518
|
+
return;
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
if (!that.position()) {
|
|
522
|
+
toastr.info('A "position" is required.');
|
|
523
|
+
return;
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
var transaction = {
|
|
527
|
+
portfolio: that.portfolio(),
|
|
528
|
+
position: that.position(),
|
|
529
|
+
type: Barchart.TransactionType.DISTRIBUTION_CASH,
|
|
530
|
+
currency: Barchart.Currency.CAD,
|
|
531
|
+
date: Barchart.Day.getToday(),
|
|
532
|
+
price: Barchart.Decimal.parse(5),
|
|
533
|
+
quantity: Barchart.Decimal.parse(100),
|
|
534
|
+
rate: Barchart.Decimal.parse(.125),
|
|
535
|
+
effective: Barchart.Day.getToday(),
|
|
536
|
+
fee: Barchart.Decimal.ZERO
|
|
537
|
+
};
|
|
538
|
+
|
|
539
|
+
that.gateway.createTransaction(transaction)
|
|
540
|
+
.then((data) => {
|
|
541
|
+
writeConsoleText(action, true);
|
|
542
|
+
writeConsoleObject(data);
|
|
543
|
+
}).catch((e) => {
|
|
544
|
+
writeConsoleText(action, true);
|
|
545
|
+
writeConsoleObject(e);
|
|
546
|
+
|
|
547
|
+
that.setConsoleMode();
|
|
548
|
+
});
|
|
549
|
+
};
|
|
550
|
+
var createDistributionFundTransaction = function() {
|
|
551
|
+
var action = 'portfolioGateway.createTransaction()';
|
|
552
|
+
|
|
553
|
+
if (!that.portfolio()) {
|
|
554
|
+
toastr.info('A "portfolio" is required.');
|
|
555
|
+
return;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
if (!that.position()) {
|
|
559
|
+
toastr.info('A "position" is required.');
|
|
560
|
+
return;
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
var transaction = {
|
|
564
|
+
portfolio: that.portfolio(),
|
|
565
|
+
position: that.position(),
|
|
566
|
+
type: Barchart.TransactionType.DISTRIBUTION_FUND,
|
|
567
|
+
currency: Barchart.Currency.CAD,
|
|
568
|
+
date: Barchart.Day.getToday(),
|
|
569
|
+
price: Barchart.Decimal.parse(5),
|
|
570
|
+
quantity: Barchart.Decimal.parse(100),
|
|
571
|
+
rate: Barchart.Decimal.parse(.125),
|
|
572
|
+
effective: Barchart.Day.getToday(),
|
|
573
|
+
fee: Barchart.Decimal.ZERO
|
|
574
|
+
};
|
|
575
|
+
|
|
576
|
+
that.gateway.createTransaction(transaction)
|
|
577
|
+
.then((data) => {
|
|
578
|
+
writeConsoleText(action, true);
|
|
579
|
+
writeConsoleObject(data);
|
|
580
|
+
}).catch((e) => {
|
|
581
|
+
writeConsoleText(action, true);
|
|
582
|
+
writeConsoleObject(e);
|
|
583
|
+
|
|
584
|
+
that.setConsoleMode();
|
|
585
|
+
});
|
|
586
|
+
};
|
|
587
|
+
var createSplitTransaction = function() {
|
|
588
|
+
var action = 'portfolioGateway.createTransaction()';
|
|
589
|
+
|
|
590
|
+
if (!that.portfolio()) {
|
|
591
|
+
toastr.info('A "portfolio" is required.');
|
|
592
|
+
return;
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
if (!that.position()) {
|
|
596
|
+
toastr.info('A "position" is required.');
|
|
597
|
+
return;
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
var transaction = {
|
|
601
|
+
portfolio: that.portfolio(),
|
|
602
|
+
position: that.position(),
|
|
603
|
+
type: Barchart.TransactionType.SPLIT,
|
|
604
|
+
currency: Barchart.Currency.CAD,
|
|
605
|
+
date: Barchart.Day.getToday(),
|
|
606
|
+
numerator: Barchart.Decimal.parse(3),
|
|
607
|
+
denominator: Barchart.Decimal.parse(1),
|
|
608
|
+
effective: Barchart.Day.getToday(),
|
|
609
|
+
fee: Barchart.Decimal.ZERO
|
|
610
|
+
};
|
|
611
|
+
|
|
612
|
+
that.gateway.createTransaction(transaction)
|
|
613
|
+
.then((data) => {
|
|
614
|
+
writeConsoleText(action, true);
|
|
615
|
+
writeConsoleObject(data);
|
|
616
|
+
}).catch((e) => {
|
|
617
|
+
writeConsoleText(action, true);
|
|
618
|
+
writeConsoleObject(e);
|
|
619
|
+
|
|
620
|
+
that.setConsoleMode();
|
|
621
|
+
});
|
|
622
|
+
};
|
|
623
|
+
var createFeeTransaction = function() {
|
|
624
|
+
var action = 'portfolioGateway.createTransaction()';
|
|
625
|
+
|
|
626
|
+
if (!that.portfolio()) {
|
|
627
|
+
toastr.info('A "portfolio" is required.');
|
|
628
|
+
return;
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
if (!that.position()) {
|
|
632
|
+
toastr.info('A "position" is required.');
|
|
633
|
+
return;
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
var transaction = {
|
|
637
|
+
portfolio: that.portfolio(),
|
|
638
|
+
position: that.position(),
|
|
639
|
+
type: Barchart.TransactionType.FEE,
|
|
640
|
+
date: Barchart.Day.getToday(),
|
|
641
|
+
effective: Barchart.Day.getToday(),
|
|
642
|
+
fee: Barchart.Decimal.ZERO
|
|
643
|
+
};
|
|
644
|
+
|
|
645
|
+
that.gateway.createTransaction(transaction)
|
|
646
|
+
.then((data) => {
|
|
647
|
+
writeConsoleText(action, true);
|
|
648
|
+
writeConsoleObject(data);
|
|
649
|
+
}).catch((e) => {
|
|
650
|
+
writeConsoleText(action, true);
|
|
651
|
+
writeConsoleObject(e);
|
|
652
|
+
|
|
653
|
+
that.setConsoleMode();
|
|
654
|
+
});
|
|
655
|
+
};
|
|
656
|
+
var createFeeUnitsTransaction = function() {
|
|
657
|
+
var action = 'portfolioGateway.createTransaction()';
|
|
658
|
+
|
|
659
|
+
if (!that.portfolio()) {
|
|
660
|
+
toastr.info('A "portfolio" is required.');
|
|
661
|
+
return;
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
if (!that.position()) {
|
|
665
|
+
toastr.info('A "position" is required.');
|
|
666
|
+
return;
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
var transaction = {
|
|
670
|
+
portfolio: that.portfolio(),
|
|
671
|
+
position: that.position(),
|
|
672
|
+
type: Barchart.TransactionType.FEE_UNITS,
|
|
673
|
+
date: Barchart.Day.getToday(),
|
|
674
|
+
effective: Barchart.Day.getToday(),
|
|
675
|
+
fee: Barchart.Decimal.ZERO,
|
|
676
|
+
price: Barchart.Decimal.parse(5)
|
|
677
|
+
};
|
|
678
|
+
|
|
679
|
+
that.gateway.createTransaction(transaction)
|
|
680
|
+
.then((data) => {
|
|
681
|
+
writeConsoleText(action, true);
|
|
682
|
+
writeConsoleObject(data);
|
|
683
|
+
}).catch((e) => {
|
|
684
|
+
writeConsoleText(action, true);
|
|
685
|
+
writeConsoleObject(e);
|
|
686
|
+
|
|
687
|
+
that.setConsoleMode();
|
|
688
|
+
});
|
|
689
|
+
};
|
|
690
|
+
var createDepositTransaction = function() {
|
|
691
|
+
var action = 'portfolioGateway.createTransaction()';
|
|
692
|
+
|
|
693
|
+
if (!that.portfolio()) {
|
|
694
|
+
toastr.info('A "portfolio" is required.');
|
|
695
|
+
return;
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
if (!that.position()) {
|
|
699
|
+
toastr.info('A "position" is required.');
|
|
700
|
+
return;
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
var transaction = {
|
|
704
|
+
portfolio: that.portfolio(),
|
|
705
|
+
position: that.position(),
|
|
706
|
+
type: Barchart.TransactionType.DEPOSIT,
|
|
707
|
+
date: Barchart.Day.getToday(),
|
|
708
|
+
amount: Barchart.Decimal.parse(5),
|
|
709
|
+
fee: Barchart.Decimal.ZERO
|
|
710
|
+
};
|
|
711
|
+
|
|
712
|
+
that.gateway.createTransaction(transaction)
|
|
713
|
+
.then((data) => {
|
|
714
|
+
writeConsoleText(action, true);
|
|
715
|
+
writeConsoleObject(data);
|
|
716
|
+
}).catch((e) => {
|
|
717
|
+
writeConsoleText(action, true);
|
|
718
|
+
writeConsoleObject(e);
|
|
719
|
+
|
|
720
|
+
that.setConsoleMode();
|
|
721
|
+
});
|
|
722
|
+
};
|
|
723
|
+
var createWithdrawalTransaction = function() {
|
|
724
|
+
var action = 'portfolioGateway.createTransaction()';
|
|
725
|
+
|
|
726
|
+
if (!that.portfolio()) {
|
|
727
|
+
toastr.info('A "portfolio" is required.');
|
|
728
|
+
return;
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
if (!that.position()) {
|
|
732
|
+
toastr.info('A "position" is required.');
|
|
733
|
+
return;
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
var transaction = {
|
|
737
|
+
portfolio: that.portfolio(),
|
|
738
|
+
position: that.position(),
|
|
739
|
+
type: Barchart.TransactionType.WITHDRAWAL,
|
|
740
|
+
date: Barchart.Day.getToday(),
|
|
741
|
+
amount: Barchart.Decimal.parse(5),
|
|
742
|
+
fee: Barchart.Decimal.ZERO
|
|
743
|
+
};
|
|
744
|
+
|
|
745
|
+
that.gateway.createTransaction(transaction)
|
|
746
|
+
.then((data) => {
|
|
747
|
+
writeConsoleText(action, true);
|
|
748
|
+
writeConsoleObject(data);
|
|
749
|
+
}).catch((e) => {
|
|
750
|
+
writeConsoleText(action, true);
|
|
751
|
+
writeConsoleObject(e);
|
|
752
|
+
|
|
753
|
+
that.setConsoleMode();
|
|
754
|
+
});
|
|
755
|
+
};
|
|
756
|
+
var createValuationTransaction = function() {
|
|
757
|
+
var action = 'portfolioGateway.createTransaction()';
|
|
758
|
+
|
|
759
|
+
if (!that.portfolio()) {
|
|
760
|
+
toastr.info('A "portfolio" is required.');
|
|
761
|
+
return;
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
if (!that.position()) {
|
|
765
|
+
toastr.info('A "position" is required.');
|
|
766
|
+
return;
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
var transaction = {
|
|
770
|
+
portfolio: that.portfolio(),
|
|
771
|
+
position: that.position(),
|
|
772
|
+
type: Barchart.TransactionType.VALUATION,
|
|
773
|
+
date: Barchart.Day.getToday(),
|
|
774
|
+
value: Barchart.Decimal.parse(5),
|
|
775
|
+
fee: Barchart.Decimal.ZERO
|
|
776
|
+
};
|
|
777
|
+
|
|
778
|
+
that.gateway.createTransaction(transaction)
|
|
779
|
+
.then((data) => {
|
|
780
|
+
writeConsoleText(action, true);
|
|
781
|
+
writeConsoleObject(data);
|
|
782
|
+
}).catch((e) => {
|
|
783
|
+
writeConsoleText(action, true);
|
|
784
|
+
writeConsoleObject(e);
|
|
785
|
+
|
|
786
|
+
that.setConsoleMode();
|
|
787
|
+
});
|
|
788
|
+
};
|
|
789
|
+
var createIncomeTransaction = function() {
|
|
790
|
+
var action = 'portfolioGateway.createTransaction()';
|
|
791
|
+
|
|
792
|
+
if (!that.portfolio()) {
|
|
793
|
+
toastr.info('A "portfolio" is required.');
|
|
794
|
+
return;
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
if (!that.position()) {
|
|
798
|
+
toastr.info('A "position" is required.');
|
|
799
|
+
return;
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
var transaction = {
|
|
803
|
+
portfolio: that.portfolio(),
|
|
804
|
+
position: that.position(),
|
|
805
|
+
type: Barchart.TransactionType.INCOME,
|
|
806
|
+
date: Barchart.Day.getToday(),
|
|
807
|
+
income: Barchart.Decimal.parse(5),
|
|
808
|
+
fee: Barchart.Decimal.ZERO
|
|
809
|
+
};
|
|
810
|
+
|
|
811
|
+
that.gateway.createTransaction(transaction)
|
|
812
|
+
.then((data) => {
|
|
813
|
+
writeConsoleText(action, true);
|
|
814
|
+
writeConsoleObject(data);
|
|
815
|
+
}).catch((e) => {
|
|
816
|
+
writeConsoleText(action, true);
|
|
817
|
+
writeConsoleObject(e);
|
|
818
|
+
|
|
316
819
|
that.setConsoleMode();
|
|
317
820
|
});
|
|
318
821
|
};
|
|
@@ -351,13 +854,31 @@
|
|
|
351
854
|
{ text: 'Create Portfolio', action: createPortfolio },
|
|
352
855
|
{ text: 'Update Portfolio', action: updatePortfolio },
|
|
353
856
|
{ text: 'Delete Portfolio', action: deletePortfolio },
|
|
857
|
+
|
|
354
858
|
{ text: 'Get Positions', action: getPositions },
|
|
355
859
|
{ text: 'Get Positions Summaries', action: readPositionSummaries },
|
|
356
860
|
{ text: 'Delete Position', action: deletePosition },
|
|
861
|
+
|
|
357
862
|
{ text: 'Get Transactions', action: getTransactions },
|
|
358
863
|
{ text: 'Get Transactions (Formatted)', action: getTransactionsFormatted },
|
|
864
|
+
|
|
359
865
|
{ text: 'Create Buy Transaction', action: createBuyTransaction },
|
|
360
866
|
{ text: 'Create Sell Transaction', action: createSellTransaction },
|
|
867
|
+
{ text: 'Create BuyShort Transaction', action: createBuyShortTransaction },
|
|
868
|
+
{ text: 'Create SellShort Transaction', action: createSellShortTransaction },
|
|
869
|
+
{ text: 'Create Dividend Transaction', action: createDividendTransaction },
|
|
870
|
+
{ text: 'Create Dividend Reinvest Transaction', action: createDividendReinvestTransaction },
|
|
871
|
+
{ text: 'Create Dividend Stock Transaction', action: createDividendStockTransaction },
|
|
872
|
+
{ text: 'Create Distribution Cash Transaction', action: createDistributionCashTransaction },
|
|
873
|
+
{ text: 'Create Distribution Fund Transaction', action: createDistributionFundTransaction },
|
|
874
|
+
{ text: 'Create Split Transaction', action: createSplitTransaction },
|
|
875
|
+
{ text: 'Create Fee Transaction', action: createFeeTransaction },
|
|
876
|
+
{ text: 'Create Fee Units Transaction', action: createFeeUnitsTransaction },
|
|
877
|
+
{ text: 'Create Deposit Transaction', action: createDepositTransaction },
|
|
878
|
+
{ text: 'Create Withdrawal Transaction', action: createWithdrawalTransaction },
|
|
879
|
+
{ text: 'Create Valuation Transaction', action: createValuationTransaction },
|
|
880
|
+
{ text: 'Create Income Transaction', action: createIncomeTransaction },
|
|
881
|
+
|
|
361
882
|
{ text: 'Delete Transaction', action: deleteTransaction }
|
|
362
883
|
]);
|
|
363
884
|
|
package/example/example.js
CHANGED
|
@@ -208,6 +208,10 @@ module.exports = function () {
|
|
|
208
208
|
|
|
209
209
|
_this._createTransactionEndpoint = EndpointBuilder.for('create-transaction', 'create transaction').withVerb(VerbType.POST).withProtocol(protocolType).withHost(host).withPort(port).withPathBuilder(function (pb) {
|
|
210
210
|
pb.withLiteralParameter('portfolios', 'portfolios').withVariableParameter('portfolio', 'portfolio', 'portfolio', false).withLiteralParameter('positions', 'positions').withVariableParameter('position', 'position', 'position', false).withLiteralParameter('transactions', 'transactions');
|
|
211
|
+
}).withQueryBuilder(function (qb) {
|
|
212
|
+
qb.withVariableParameter('type', 'type', 'type', false, function (i) {
|
|
213
|
+
return i.code;
|
|
214
|
+
});
|
|
211
215
|
}).withBody('portfolio data').withRequestInterceptor(RequestInterceptor.PLAIN_TEXT_RESPONSE).withRequestInterceptor(requestInterceptorToUse).withResponseInterceptor(responseInterceptorForTransactionDeserialization).withErrorInterceptor(ErrorInterceptor.GENERAL).endpoint;
|
|
212
216
|
|
|
213
217
|
_this._deleteTransactionsEndpoint = EndpointBuilder.for('read-transactions', 'read transactions').withVerb(VerbType.DELETE).withProtocol(protocolType).withHost(host).withPort(port).withPathBuilder(function (pb) {
|
|
@@ -635,8 +639,6 @@ module.exports = function () {
|
|
|
635
639
|
|
|
636
640
|
var responseInterceptorForTransactionDeserialization = ResponseInterceptor.fromDelegate(function (response, ignored) {
|
|
637
641
|
try {
|
|
638
|
-
return TransactionSchema.CLIENT.schema.revive(response.data);
|
|
639
|
-
|
|
640
642
|
return JSON.parse(response.data, TransactionSchema.CLIENT.schema.getReviver());
|
|
641
643
|
} catch (e) {
|
|
642
644
|
console.error('Error serializing transaction data', e);
|
|
@@ -975,7 +977,7 @@ module.exports = function () {
|
|
|
975
977
|
return {
|
|
976
978
|
JwtGateway: JwtGateway,
|
|
977
979
|
PortfolioGateway: PortfolioGateway,
|
|
978
|
-
version: '1.1.
|
|
980
|
+
version: '1.1.17'
|
|
979
981
|
};
|
|
980
982
|
}();
|
|
981
983
|
|
|
@@ -8140,6 +8142,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
|
8140
8142
|
|
|
8141
8143
|
var attributes = require('./../../lang/attributes'),
|
|
8142
8144
|
functions = require('./../../lang/functions'),
|
|
8145
|
+
array = require('./../../lang/array'),
|
|
8143
8146
|
is = require('./../../lang/is');
|
|
8144
8147
|
|
|
8145
8148
|
var LinkedList = require('./../../collections/LinkedList'),
|
|
@@ -8231,6 +8234,45 @@ module.exports = function () {
|
|
|
8231
8234
|
*
|
|
8232
8235
|
* @public
|
|
8233
8236
|
* @returns {Function}
|
|
8237
|
+
*/
|
|
8238
|
+
|
|
8239
|
+
}, {
|
|
8240
|
+
key: 'getSimpleReviver',
|
|
8241
|
+
value: function getSimpleReviver() {
|
|
8242
|
+
var _this = this;
|
|
8243
|
+
|
|
8244
|
+
return function (key, value) {
|
|
8245
|
+
var field = _this.fields.find(function (f) {
|
|
8246
|
+
var fieldName = array.last(f.name.split('.'));
|
|
8247
|
+
|
|
8248
|
+
return fieldName === key;
|
|
8249
|
+
});
|
|
8250
|
+
|
|
8251
|
+
if (is.object(value)) {
|
|
8252
|
+
return value;
|
|
8253
|
+
}
|
|
8254
|
+
|
|
8255
|
+
var returnVal = void 0;
|
|
8256
|
+
|
|
8257
|
+
try {
|
|
8258
|
+
returnVal = field.dataType.reviver(value);
|
|
8259
|
+
} catch (e) {
|
|
8260
|
+
if (_this._strict) {
|
|
8261
|
+
throw Error(e);
|
|
8262
|
+
} else {
|
|
8263
|
+
returnVal = value;
|
|
8264
|
+
}
|
|
8265
|
+
}
|
|
8266
|
+
|
|
8267
|
+
return returnVal;
|
|
8268
|
+
};
|
|
8269
|
+
}
|
|
8270
|
+
|
|
8271
|
+
/**
|
|
8272
|
+
* Generates a function suitable for use by JSON.parse.
|
|
8273
|
+
*
|
|
8274
|
+
* @public
|
|
8275
|
+
* @returns {Function}
|
|
8234
8276
|
*/
|
|
8235
8277
|
|
|
8236
8278
|
}, {
|
|
@@ -8277,10 +8319,10 @@ module.exports = function () {
|
|
|
8277
8319
|
}, {
|
|
8278
8320
|
key: 'getReviverFactory',
|
|
8279
8321
|
value: function getReviverFactory() {
|
|
8280
|
-
var
|
|
8322
|
+
var _this2 = this;
|
|
8281
8323
|
|
|
8282
8324
|
return function () {
|
|
8283
|
-
return
|
|
8325
|
+
return _this2.getReviver();
|
|
8284
8326
|
};
|
|
8285
8327
|
}
|
|
8286
8328
|
}, {
|
|
@@ -8344,11 +8386,11 @@ module.exports = function () {
|
|
|
8344
8386
|
function SchemaError(key, name, message) {
|
|
8345
8387
|
_classCallCheck(this, SchemaError);
|
|
8346
8388
|
|
|
8347
|
-
var
|
|
8389
|
+
var _this3 = _possibleConstructorReturn(this, (SchemaError.__proto__ || Object.getPrototypeOf(SchemaError)).call(this, message));
|
|
8348
8390
|
|
|
8349
|
-
|
|
8350
|
-
|
|
8351
|
-
return
|
|
8391
|
+
_this3.key = key;
|
|
8392
|
+
_this3.name = name;
|
|
8393
|
+
return _this3;
|
|
8352
8394
|
}
|
|
8353
8395
|
|
|
8354
8396
|
_createClass(SchemaError, [{
|
|
@@ -8489,7 +8531,7 @@ module.exports = function () {
|
|
|
8489
8531
|
return Schema;
|
|
8490
8532
|
}();
|
|
8491
8533
|
|
|
8492
|
-
},{"./../../collections/LinkedList":23,"./../../collections/Tree":24,"./../../lang/attributes":38,"./../../lang/functions":39,"./../../lang/is":40,"./Component":44,"./Field":46}],48:[function(require,module,exports){
|
|
8534
|
+
},{"./../../collections/LinkedList":23,"./../../collections/Tree":24,"./../../lang/array":36,"./../../lang/attributes":38,"./../../lang/functions":39,"./../../lang/is":40,"./Component":44,"./Field":46}],48:[function(require,module,exports){
|
|
8493
8535
|
'use strict';
|
|
8494
8536
|
|
|
8495
8537
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
@@ -195,6 +195,9 @@ module.exports = (() => {
|
|
|
195
195
|
.withVariableParameter('position', 'position', 'position', false)
|
|
196
196
|
.withLiteralParameter('transactions', 'transactions');
|
|
197
197
|
})
|
|
198
|
+
.withQueryBuilder((qb) => {
|
|
199
|
+
qb.withVariableParameter('type', 'type', 'type', false, (i) => i.code);
|
|
200
|
+
})
|
|
198
201
|
.withBody('portfolio data')
|
|
199
202
|
.withRequestInterceptor(RequestInterceptor.PLAIN_TEXT_RESPONSE)
|
|
200
203
|
.withRequestInterceptor(requestInterceptorToUse)
|
|
@@ -598,8 +601,6 @@ module.exports = (() => {
|
|
|
598
601
|
|
|
599
602
|
const responseInterceptorForTransactionDeserialization = ResponseInterceptor.fromDelegate((response, ignored) => {
|
|
600
603
|
try {
|
|
601
|
-
return TransactionSchema.CLIENT.schema.revive(response.data);
|
|
602
|
-
|
|
603
604
|
return JSON.parse(response.data, TransactionSchema.CLIENT.schema.getReviver());
|
|
604
605
|
} catch (e) {
|
|
605
606
|
console.error('Error serializing transaction data', e);
|
package/lib/index.js
CHANGED