Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Boomerang #76

Closed
wants to merge 210 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
210 commits
Select commit Hold shift + click to select a range
567d945
Added audio file.
ctubio Apr 8, 2016
531d08a
Removed useless files.
ctubio Apr 8, 2016
63beeee
Added bold to Value.
ctubio Apr 9, 2016
177cc40
Added max/min.
ctubio Apr 9, 2016
62fe449
Added default values.
ctubio Apr 9, 2016
908e114
Removed useless block.
ctubio Apr 9, 2016
14799a7
Added moar mktN.
ctubio Apr 9, 2016
f660253
Fixed width of val column.
ctubio Apr 9, 2016
d205e64
Added Top to min/max.
ctubio Apr 9, 2016
b3cffc9
Added displays.
ctubio Apr 9, 2016
a3ac6fb
Added fiat value.
ctubio Apr 9, 2016
e514764
Updated fiat value.
ctubio Apr 9, 2016
e814d29
Updated fiat value.
ctubio Apr 9, 2016
b2dd025
Fixed qty column.
ctubio Apr 9, 2016
aa9c894
Added moar digits.
ctubio Apr 9, 2016
6ea6ecb
Added width of qBid/qAsk.
ctubio Apr 10, 2016
7f03f93
Fixed morning typo.
ctubio Apr 10, 2016
bb0ed27
Added dummy quote style.
ctubio Apr 10, 2016
e57f908
Fixed style.
ctubio Apr 10, 2016
38a0e92
Merged remote-branch upstream/master.
ctubio Apr 11, 2016
9254765
Merge remote-tracking branch 'origin/master' into pingpong
ctubio Apr 11, 2016
0712509
Added PingPong display.
ctubio Apr 11, 2016
c73a758
Added PingPong calc.
ctubio Apr 11, 2016
9cc64c0
Fixed ts.
ctubio Apr 11, 2016
89dd479
Fixed ts.
ctubio Apr 11, 2016
06d17eb
Fixed prev trades.
ctubio Apr 11, 2016
54a07bf
Fixed trades calc.
ctubio Apr 12, 2016
c5b1bde
Fixed trades calc.
ctubio Apr 12, 2016
f25e5f6
Fixed trades calc.
ctubio Apr 12, 2016
5aee9ad
Fixed trades calc.
ctubio Apr 12, 2016
876b286
Fixed trades calc.
ctubio Apr 12, 2016
0fbfd42
Fixed trades calc.
ctubio Apr 12, 2016
50b76d3
Added debug.
ctubio Apr 12, 2016
19254bc
Added debug.
ctubio Apr 12, 2016
ff6d7f3
Added debug.
ctubio Apr 12, 2016
4fbe732
Added debug.
ctubio Apr 12, 2016
0035b16
Thank you debug\!
ctubio Apr 12, 2016
4d73381
Fixed max calc.
ctubio Apr 12, 2016
1a23171
Fixed max calc.
ctubio Apr 12, 2016
5ea09aa
Fixed calc display.
ctubio Apr 12, 2016
e8a1aeb
Added PingPong calc.
ctubio Apr 12, 2016
ba9cfd3
Merge branch 'pingpong'
ctubio Apr 12, 2016
53174fd
Fixed morning typo.
ctubio Apr 12, 2016
c3dd436
Fixed price accommodation.
ctubio Apr 14, 2016
8299c8f
Merge remote-tracking branch 'upstream/master'.
ctubio Apr 17, 2016
80491ad
Merge remote-tracking branch 'upstream/master'.
ctubio Apr 17, 2016
f70ad4a
Merge remote-tracking branch 'upstream/master'.
ctubio Apr 17, 2016
067095f
Fixed displays.
ctubio Apr 17, 2016
6bf362d
Merge branch 'add_pingpong_quotingmode' into ctubio
ctubio Apr 17, 2016
70d91c6
Merge remote-tracking branch 'upstream/master' into ctubio
ctubio Apr 18, 2016
5b8e7e9
Fixed calc.
ctubio Apr 18, 2016
7d5d113
Fixed calc.
ctubio May 5, 2016
7980611
Fixed new ETH.
ctubio May 24, 2016
32cbfc2
Fixed new ETH.
ctubio May 25, 2016
0a84d5b
Fixed new ETH.
ctubio May 25, 2016
f390d15
Fixed new ETH.
ctubio May 25, 2016
093edfa
Added Boomerang quoting style.
ctubio Jul 21, 2016
7f59d04
Added Boomerang calcs.
ctubio Jul 22, 2016
29f82db
Added Boomerang calcs.
ctubio Jul 22, 2016
bb2ca02
Added Boomerang calcs.
ctubio Jul 22, 2016
938b512
Added Boomerang calcs.
ctubio Jul 22, 2016
fd55163
Added Boomerang calcs.
ctubio Jul 22, 2016
0fad077
Added Boomerang calcs.
ctubio Jul 22, 2016
16d619d
Added Boomerang calcs.
ctubio Jul 22, 2016
95886b7
Added Boomerang calcs.
ctubio Jul 22, 2016
6d07003
Added Boomerang calcs.
ctubio Jul 22, 2016
fb2adc7
Added Boomerang calcs.
ctubio Jul 22, 2016
cd28f40
Added Boomerang calcs.
ctubio Jul 22, 2016
275fa14
Added Boomerang calcs.
ctubio Jul 22, 2016
feb1694
Added Boomerang calcs.
ctubio Jul 22, 2016
7ce716e
Added Boomerang calcs.
ctubio Jul 22, 2016
3d026c1
Added Boomerang calcs.
ctubio Jul 22, 2016
0de9409
Added Boomerang calcs.
ctubio Jul 22, 2016
3f0eaaa
Added CAD currency.
ctubio Jul 23, 2016
8f8367d
Fixed loop.
ctubio Jul 23, 2016
54a1e92
Fixed side.
ctubio Jul 23, 2016
c5a3f75
Fixed calcs.
ctubio Jul 24, 2016
e986346
Fixed calcs.
ctubio Jul 24, 2016
3ba3b2b
Fixed calcs.
ctubio Jul 24, 2016
750d1a2
Fixed calcs.
ctubio Jul 24, 2016
e383e57
Fixed calcs.
ctubio Jul 24, 2016
c8ed754
Fixed calcs.
ctubio Jul 24, 2016
1cf9aea
Fixed calcs.
ctubio Jul 24, 2016
ff67848
Fixed calcs.
ctubio Jul 24, 2016
15be468
Fixed calcs.
ctubio Jul 24, 2016
f3dbdac
Fixed calcs.
ctubio Jul 24, 2016
3cccc24
Fixed calcs.
ctubio Jul 24, 2016
9afa850
Fixed calcs.
ctubio Jul 24, 2016
6471897
Fixed loop.
ctubio Jul 24, 2016
11d30ff
Fixed calcs.
ctubio Jul 24, 2016
eaf2e56
Fixed calcs.
ctubio Jul 24, 2016
dcd12ed
Fixed calcs.
ctubio Jul 24, 2016
f4d8df8
Fixed calcs.
ctubio Jul 24, 2016
b6d75c7
Fixed calcs.
ctubio Jul 24, 2016
446d2d8
Fixed calcs.
ctubio Jul 24, 2016
7cb64a1
Fixed calcs.
ctubio Jul 24, 2016
4b95bc6
Fixed calcs.
ctubio Jul 24, 2016
2ba9bad
Fixed calcs.
ctubio Jul 24, 2016
6d50c8f
Fixed calcs.
ctubio Jul 24, 2016
fe46716
Fixed calcs.
ctubio Jul 24, 2016
f04aa84
Fixed calcs.
ctubio Jul 24, 2016
417c39e
Fixed calcs.
ctubio Jul 24, 2016
e764957
Fixed calcs.
ctubio Jul 24, 2016
ca4a14a
Fixed calcs.
ctubio Jul 24, 2016
7a212f8
Fixed calcs.
ctubio Jul 24, 2016
61bdaaa
Fixed calcs.
ctubio Jul 24, 2016
75c711b
Fixed calcs.
ctubio Jul 24, 2016
b51a4b5
Fixed calcs.
ctubio Jul 24, 2016
08f06f8
Fixed calcs.
ctubio Jul 24, 2016
3dca3f0
Fixed calcs.
ctubio Jul 24, 2016
5d4934a
Fixed calcs.
ctubio Jul 24, 2016
d3ca3f8
Fixed calcs.
ctubio Jul 24, 2016
de8a96c
Fixed calcs.
ctubio Jul 24, 2016
8caf7fc
Fixed calcs.
ctubio Jul 24, 2016
82922de
Fixed calcs.
ctubio Jul 24, 2016
54e6c23
Fixed calcs.
ctubio Jul 24, 2016
77595e2
Fixed calcs.
ctubio Jul 24, 2016
4e6d9d4
Fixed calcs.
ctubio Jul 24, 2016
66465a4
Fixed calcs.
ctubio Jul 24, 2016
406174b
Fixed calcs.
ctubio Jul 24, 2016
c6f48f6
Fixed calcs.
ctubio Jul 24, 2016
f1d274f
Fixed calcs.
ctubio Jul 24, 2016
808b608
Fixed calcs.
ctubio Jul 24, 2016
49e9d0d
Fixed calcs.
ctubio Jul 24, 2016
baae0a5
Fixed calcs.
ctubio Jul 24, 2016
0d7440a
Fixed calcs.
ctubio Jul 24, 2016
a06d70a
Fixed calcs.
ctubio Jul 24, 2016
010946c
Fixed calcs.
ctubio Jul 25, 2016
d0353dd
Fixed calcs.
ctubio Jul 25, 2016
f68cd36
Added sounds.
ctubio Jul 25, 2016
b7d6f11
Fixed calcs.
ctubio Jul 25, 2016
65fca11
Fixed calcs.
ctubio Jul 25, 2016
cfb9a0e
Fixed calcs.
ctubio Jul 25, 2016
3a5a947
Fixed calcs.
ctubio Jul 25, 2016
f7a855d
Updated upstream
ctubio Jul 25, 2016
5838798
Fixed calcs.
ctubio Jul 26, 2016
5d0f3de
Fixed calcs.
ctubio Jul 26, 2016
5762885
Fixed calcs.
ctubio Jul 26, 2016
7aa6c6f
Fixed calcs.
ctubio Jul 26, 2016
e35b9c8
Fixed calcs.
ctubio Jul 26, 2016
77f973b
Fixed calcs.
ctubio Jul 26, 2016
d96d118
Fixed calcs.
ctubio Jul 26, 2016
87c93e2
Fixed calcs.
ctubio Jul 26, 2016
b688153
Fixed calcs.
ctubio Jul 26, 2016
894f7c6
Fixed calcs.
ctubio Jul 26, 2016
a32a5e3
Fixed calcs.
ctubio Jul 26, 2016
80a2aec
Fixed calcs.
ctubio Jul 27, 2016
28dbd83
Fixed calcs.
ctubio Jul 27, 2016
e885e4f
Fixed calcs.
ctubio Jul 27, 2016
abd813e
Fixed calcs.
ctubio Jul 28, 2016
392319d
Fixed calcs.
ctubio Jul 28, 2016
aa348bc
Fixed calcs.
ctubio Jul 28, 2016
a3b3d76
Fixed calcs.
ctubio Jul 28, 2016
bfc6bfb
Fixed calcs.
ctubio Jul 28, 2016
886d396
Fixed calcs.
ctubio Jul 29, 2016
fa9f055
Fixed calcs.
ctubio Jul 29, 2016
65c2c2a
Fixed calcs.
ctubio Jul 29, 2016
a030530
Fixed calcs.
ctubio Jul 29, 2016
1a49477
Fixed calcs.
ctubio Jul 29, 2016
d74649d
Fixed calcs.
ctubio Jul 29, 2016
1a2598f
Fixed calcs.
ctubio Jul 29, 2016
a839bef
Fixed calcs.
ctubio Jul 29, 2016
f43d358
Fixed calcs.
ctubio Jul 29, 2016
c84b130
Merge remote-tracking branch 'upstream/master' into boomerang
ctubio Jul 29, 2016
8098c18
Fixed calcs.
ctubio Jul 30, 2016
724f261
Fixed calcs.
ctubio Jul 30, 2016
dd10cc5
Fixed calcs.
ctubio Jul 30, 2016
65db8b4
Fixed calcs.
ctubio Jul 30, 2016
dc8abcf
Fixed calcs.
ctubio Jul 30, 2016
9ecfc6e
Fixed calcs.
ctubio Jul 30, 2016
9d9f308
Fixed calcs.
ctubio Jul 30, 2016
2f1a9c5
Fixed calcs.
ctubio Jul 30, 2016
80f7bc5
Fixed calcs.
ctubio Jul 30, 2016
61dc8a2
Fixed calcs.
ctubio Jul 30, 2016
2b5fd5d
Fixed calcs.
ctubio Jul 30, 2016
ebd04a7
Fixed calcs.
ctubio Jul 30, 2016
a56d85d
Fixed calcs.
ctubio Jul 30, 2016
2fccf43
Fixed calcs.
ctubio Jul 30, 2016
bd8dc13
Fixed calcs.
ctubio Jul 30, 2016
29d54d1
Fixed calcs.
ctubio Jul 30, 2016
41fc71d
Fixed calcs.
ctubio Jul 30, 2016
7d9fb50
Fixed calcs.
ctubio Jul 30, 2016
53c2d2d
Fixed calcs.
ctubio Jul 30, 2016
2c77d29
Fixed calcs.
ctubio Jul 30, 2016
a2321d9
Fixed calcs.
ctubio Jul 30, 2016
e786899
Fixed calcs.
ctubio Jul 30, 2016
47324fc
Fixed calcs.
ctubio Jul 30, 2016
44e5373
Fixed calcs.
ctubio Jul 30, 2016
8349dff
Fixed calcs.
ctubio Jul 30, 2016
5bd671e
Fixed calcs.
ctubio Jul 30, 2016
16fff8c
Fixed calcs.
ctubio Jul 30, 2016
1ef01f1
Fixed calcs.
ctubio Jul 30, 2016
b9ec9de
Fixed calcs.
ctubio Jul 30, 2016
5ff0232
Fixed calcs.
ctubio Jul 30, 2016
296e5c2
Fixed calcs.
ctubio Jul 31, 2016
128f5bd
Fixed calcs.
ctubio Jul 31, 2016
bacdc19
Fixed calcs.
ctubio Jul 31, 2016
40103a5
Fixed calcs.
ctubio Jul 31, 2016
73474d9
Fixed calcs.
ctubio Jul 31, 2016
09302ab
Fixed calcs.
ctubio Jul 31, 2016
b6577ea
Fixed calcs.
ctubio Jul 31, 2016
784f4bf
Fixed calcs.
ctubio Jul 31, 2016
276900d
Fixed calcs.
ctubio Jul 31, 2016
71a2625
Fixed commented log about Event looped blocked.
ctubio Jul 31, 2016
47c6fa0
Fixed broken ewmaProtection after matching trades.
ctubio Aug 6, 2016
e234555
Fixed audioReady timer.
ctubio Aug 6, 2016
54ab3f6
Fixed commented log msgs.
ctubio Aug 6, 2016
8b95170
Fixed audioReady timer.
ctubio Aug 6, 2016
26821a2
Fixed old naming.
ctubio Aug 7, 2016
7bfd458
Fixed truncated collections.
ctubio Aug 7, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions src/admin/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ interface MainWindowScope extends ng.IScope {
exch_name : string;
pair_name : string;
cancelAllOrders();
cleanAllClosedOrders();
cleanAllOrders();
}

class DisplayOrder {
Expand Down Expand Up @@ -84,10 +86,16 @@ var uiCtrl = ($scope : MainWindowScope,
$log : ng.ILogService,
subscriberFactory : Shared.SubscriberFactory,
fireFactory : Shared.FireFactory) => {

var cancelAllFirer = fireFactory.getFire(Messaging.Topics.CancelAllOrders);
$scope.cancelAllOrders = () => cancelAllFirer.fire(new Models.CancelAllOrdersRequest());


var cleanAllClosedFirer = fireFactory.getFire(Messaging.Topics.CleanAllClosedOrders);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain the trading necessity to have a UI element for cleaning trades? Is cleaning a manual process when the market moves away enough that trading won't match any longer?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this button because now trades are always displayed forever. The user can look at all the trades opened and also at all closed trades where the final net income is displayed.

Using this button, the user can manualy clean the closed trades and "start a new cycle" anytime he/she wishes.

For example, for myself, i wakeup on the morning and see all closed trades during the night with all the net incomes. Then i clean all closed trades and go to work. Once im back in the afternoon i can examinate what new trades has been closed and the net incomes during the day. Then clean them and go to sleep. And so on every day :D

The other button of clean all orders, is because what you said, in case the market moves way too off, you can manualy clean all the historic and therefore assume the losses if any.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ctubio Are you running these current changes in this pull request? Is everything stable?

$scope.cleanAllClosedOrders = () => cleanAllClosedFirer.fire(new Models.CleanAllClosedOrdersRequest());

var cleanAllFirer = fireFactory.getFire(Messaging.Topics.CleanAllOrders);
$scope.cleanAllOrders = () => cleanAllFirer.fire(new Models.CleanAllOrdersRequest());

$scope.order = new DisplayOrder(fireFactory, $log);
$scope.pair = null;

Expand Down Expand Up @@ -130,11 +138,11 @@ var requires = ['ui.bootstrap',
Trades.tradeListDirective,
MarketQuoting.marketQuotingDirective,
MarketTrades.marketTradeDirective,
Messages.messagesDirective,
Messages.messagesDirective,
Position.positionDirective,
Tbp.targetBasePositionDirective,
TradeSafety.tradeSafetyDirective,
Shared.sharedDirectives];

angular.module('projectApp', requires)
.controller('uiCtrl', uiCtrl);
.controller('uiCtrl', uiCtrl);
9 changes: 8 additions & 1 deletion src/admin/market-quoting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class Level {
bidSize: number;
askPrice: number;
askSize: number;
diffWidth: number;

bidClass: string;
askClass: string;
Expand Down Expand Up @@ -86,8 +87,14 @@ var MarketQuotingController = ($scope: MarketQuotingScope,
$scope.levels[i] = new Level();
$scope.levels[i].bidPrice = update.bids[i].price;
$scope.levels[i].bidSize = update.bids[i].size;
$scope.levels[i].diffWidth = i==0
? $scope.levels[i].askPrice - $scope.levels[i].bidPrice : (
(i==1 && $scope.qBidPx && $scope.qAskPx)
? $scope.qAskPx - $scope.qBidPx : 0
);
}


updateQuoteClass();
};

Expand Down Expand Up @@ -194,4 +201,4 @@ angular
templateUrl: "market_display.html",
controller: MarketQuotingController
}
});
});
2 changes: 1 addition & 1 deletion src/admin/market-trades.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,4 @@ angular
template: template,
controller: MarketTradeGrid
}
});
});
2 changes: 1 addition & 1 deletion src/admin/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export var messagesDirective = "messagesDirective";
angular
.module(messagesDirective, ['ui.bootstrap', 'ui.grid', Shared.sharedDirectives])
.directive("messagesGrid", () => {
var template = '<div><div style="height: 50px" class="table table-striped table-hover table-condensed" ui-grid="messageOptions"></div></div>';
var template = '<div style="display:none;"><div style="height: 81px" class="table table-striped table-hover table-condensed" ui-grid="messageOptions"></div></div>';

return {
restrict: 'E',
Expand Down
2 changes: 1 addition & 1 deletion src/admin/orderlist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ var OrderListController = ($scope: OrderListScope,
rowHeight: 20,
headerRowHeight: 20,
columnDefs: [
{ width: 120, field: 'time', displayName: 'time', cellFilter: "momentFullDate",
{ width: 120, field: 'time', displayName: 'time', cellFilter: "momentFullDate",
sortingAlgorithm: (a: moment.Moment, b: moment.Moment) => a.diff(b),
sort: { direction: uiGridConstants.DESC, priority: 1} },
{ width: 90, field: 'orderId', displayName: 'id' },
Expand Down
12 changes: 6 additions & 6 deletions src/admin/pair.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ class FormViewModel<T> {
private _submitConverter: (disp: T) => T = null) {
if (this._submitConverter === null)
this._submitConverter = d => d;

_sub.registerConnectHandler(() => this.connected = true)
.registerDisconnectedHandler(() => this.connected = false)
.registerSubscriber(this.update, us => us.forEach(this.update));

this.connected = _sub.connected;
this.master = angular.copy(defaultParameter);
this.display = angular.copy(defaultParameter);
Expand All @@ -36,7 +36,7 @@ class FormViewModel<T> {
};

public update = (p: T) => {
console.log("updating parameters", p);
// console.log("updating parameters", p);
this.master = angular.copy(p);
this.display = angular.copy(p);
this.pending = false;
Expand Down Expand Up @@ -68,7 +68,7 @@ class DisplayQuotingParameters extends FormViewModel<Models.QuotingParameters> {

constructor(sub: Messaging.ISubscribe<Models.QuotingParameters>,
fire: Messaging.IFire<Models.QuotingParameters>) {
super(new Models.QuotingParameters(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null), sub, fire);
super(new Models.QuotingParameters(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null), sub, fire);

this.availableQuotingModes = DisplayQuotingParameters.getMapping(Models.QuotingMode);
this.availableFvModels = DisplayQuotingParameters.getMapping(Models.FairValueModel);
Expand Down Expand Up @@ -125,11 +125,11 @@ export class DisplayPair {
}

public dispose = () => {
console.log("dispose client");
// console.log("dispose client");
this._subscribers.forEach(s => s.disconnect());
};

public updateParameters = (p: Models.QuotingParameters) => {
this.quotingParameters.update(p);
};
}
}
2 changes: 1 addition & 1 deletion src/admin/shared_directives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export class EvalAsyncSubscriber<T> implements Messaging.ISubscribe<T> {
};

public disconnect = () => this._wrapped.disconnect();

public get connected() { return this._wrapped.connected; }
}

Expand Down
2 changes: 1 addition & 1 deletion src/admin/target-base-position.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ angular
template: template,
controller: TargetBasePositionController
}
});
});
10 changes: 8 additions & 2 deletions src/admin/trade-safety.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import Shared = require("./shared_directives");
interface TradeSafetyScope extends ng.IScope {
buySafety: number;
sellSafety: number;
buySizeSafety: number;
sellSizeSafety: number;
tradeSafetyValue : number;
}

Expand All @@ -24,12 +26,16 @@ var TradeSafetyController = ($scope : TradeSafetyScope, $log : ng.ILogService, s
$scope.tradeSafetyValue = value.combined;
$scope.buySafety = value.buy;
$scope.sellSafety = value.sell;
$scope.buySizeSafety = value.buyPing;
$scope.sellSizeSafety = value.sellPong;
};

var clear = () => {
$scope.tradeSafetyValue = null;
$scope.buySafety = null;
$scope.sellSafety = null;
$scope.buySizeSafety = null;
$scope.sellSizeSafety = null;
};

var subscriber = subscriberFactory.getSubscriber($scope, Messaging.Topics.TradeSafetyValue)
Expand All @@ -49,7 +55,7 @@ export var tradeSafetyDirective = "tradeSafetyDirective";
angular
.module(tradeSafetyDirective, ['sharedDirectives'])
.directive("tradeSafety", () => {
var template = '<span>BuyTS: {{ buySafety|number:2 }}, SellTS: {{ sellSafety|number:2 }}, TotalTS: {{ tradeSafetyValue|number:2 }}</span>';
var template = '<span>BuyLT: <b>{{ buySizeSafety|number:2 }}</b>, SellLT: <b>{{ sellSizeSafety|number:2 }}</b>, BuyTS: {{ buySafety|number:2 }}, SellTS: {{ sellSafety|number:2 }}, TotalTS: {{ tradeSafetyValue|number:2 }}</span>';
Copy link
Contributor Author

@ctubio ctubio Jul 30, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this displays the current safety values based on the history of trades (im not sure how to not display this in all other quoting modes)


return {
restrict: 'E',
Expand All @@ -58,4 +64,4 @@ angular
template: template,
controller: TradeSafetyController
}
});
});
97 changes: 86 additions & 11 deletions src/admin/trades.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ interface TradesScope extends ng.IScope {
exch : Models.Exchange;
pair : Models.CurrencyPair;
gridOptions : any;
gridApi : any;
audio: boolean;
}

class DisplayTrade {
Expand All @@ -23,15 +25,19 @@ class DisplayTrade {
side : string;
value : number;
liquidity : string;
Kqty : number;
Kprice : number;

constructor(public trade : Models.Trade) {
constructor($scope : TradesScope, public trade : Models.Trade) {
this.tradeId = trade.tradeId;
this.side = trade.side === Models.Side.Ask ? "S" : "B";
this.side = (trade.Kqty >= trade.quantity) ? 'K' : (trade.side === Models.Side.Ask ? "S" : "B");
this.time = (moment.isMoment(trade.time) ? trade.time : moment(trade.time));
this.price = trade.price;
this.quantity = trade.quantity;
this.value = trade.value;

this.Kqty = trade.Kqty;
this.Kprice = trade.Kprice;

if (trade.liquidity === 0 || trade.liquidity === 1) {
this.liquidity = Models.Liquidity[trade.liquidity].charAt(0);
}
Expand All @@ -53,36 +59,105 @@ var TradesListController = ($scope : TradesScope, $log : ng.ILogService, subscri
rowHeight: 20,
headerRowHeight: 20,
columnDefs: [
{width: 80, field:'time', displayName:'t', cellFilter: 'momentShortDate',
{width: 75, field:'time', displayName:'t', cellFilter: 'momentShortDate',
sortingAlgorithm: (a: moment.Moment, b: moment.Moment) => a.diff(b),
sort: { direction: uiGridConstants.DESC, priority: 1} },
{width: 55, field:'price', displayName:'px', cellFilter: 'currency'},
{width: 50, field:'quantity', displayName:'qty'},
{width: 30, field:'side', displayName:'side', cellClass: (grid, row, col, rowRenderIndex, colRenderIndex) => {
{width: 50, field:'price', displayName:'px', cellFilter: 'currency', cellClass: (grid, row, col, rowRenderIndex, colRenderIndex) => {
if (row.entity.side === 'K') return (row.entity.price > row.entity.Kprice) ? "sell" : "buy"; else return "";
}},
{width: 50, field:'quantity', displayName:'qty', cellClass: (grid, row, col, rowRenderIndex, colRenderIndex) => {
if (row.entity.side === 'K') return (row.entity.price > row.entity.Kprice) ? "sell" : "buy"; else return "";
}},
{width: 20, field:'side', displayName:'side', cellClass: (grid, row, col, rowRenderIndex, colRenderIndex) => {
if (grid.getCellValue(row, col) === 'B') {
return 'buy';
}
else if (grid.getCellValue(row, col) === 'S') {
return "sell";
}
else if (grid.getCellValue(row, col) === 'K') {
return "kira";
}
else {
return "unknown";
}
}},
{width: 30, field:'liquidity', displayName:'liq'},
{width: 60, field:'value', displayName:'val', cellFilter: 'currency:"$":3'}
]
{width: 60, field:'value', displayName:'val', cellFilter: 'currency:"$":3', cellClass: (grid, row, col, rowRenderIndex, colRenderIndex) => {
if (row.entity.side === 'K') return "kira"; else return "";
}},
{width: 50, field:'Kqty', displayName:'Kqty', visible:false, cellClass: (grid, row, col, rowRenderIndex, colRenderIndex) => {
if (row.entity.side === 'K') return (row.entity.price < row.entity.Kprice) ? "sell" : "buy"; else return "";
}},
{width: 55, field:'Kprice', displayName:'Kpx', cellFilter: 'currency', visible:false, cellClass: (grid, row, col, rowRenderIndex, colRenderIndex) => {
if (row.entity.side === 'K') return (row.entity.price < row.entity.Kprice) ? "sell" : "buy"; else return "";
}}
],
onRegisterApi: function(gridApi) {
$scope.gridApi = gridApi;
}
};

var addTrade = t => $scope.trade_statuses.push(new DisplayTrade(t));
var addTrade = t => {
if (t.Kqty<0) {
for(var i = 0;i<$scope.trade_statuses.length;i++) {
if ($scope.trade_statuses[i].tradeId==t.tradeId) {
$scope.trade_statuses.splice(i, 1);
break;
}
}
} else {
var exists = false;
for(var i = 0;i<$scope.trade_statuses.length;i++) {
if ($scope.trade_statuses[i].tradeId==t.tradeId) {
exists = true;
$scope.trade_statuses[i].time = (moment.isMoment(t.time) ? t.time : moment(t.time));
var merged = ($scope.trade_statuses[i].quantity != t.quantity);
$scope.trade_statuses[i].quantity = t.quantity;
$scope.trade_statuses[i].value = t.value;
$scope.trade_statuses[i].Kqty = t.Kqty;
$scope.trade_statuses[i].Kprice = t.Kprice;
if ($scope.trade_statuses[i].Kqty >= $scope.trade_statuses[i].quantity)
$scope.trade_statuses[i].side = 'K';
$scope.gridApi.grid.notifyDataChange(uiGridConstants.dataChange.ALL);
if (t.loadedFromDB === false && $scope.audio) {
var audio = new Audio('/audio/'+(merged?'boom':'erang')+'.mp3');
audio.volume = 0.5;
audio.play();
}
break;
}
}
if (!exists) {
$scope.trade_statuses.push(new DisplayTrade($scope, t));
if (t.loadedFromDB === false && $scope.audio) {
var audio = new Audio('/audio/boom.mp3');
audio.volume = 0.5;
audio.play();
}
}
}
};

var sub = subscriberFactory.getSubscriber($scope, Messaging.Topics.Trades)
.registerConnectHandler(() => $scope.trade_statuses.length = 0)
.registerDisconnectedHandler(() => $scope.trade_statuses.length = 0)
.registerSubscriber(addTrade, trades => trades.forEach(addTrade));

var updateQP = qp => {
$scope.audio = qp.audio;
$scope.gridOptions.columnDefs[$scope.gridOptions.columnDefs.map(function (e) { return e.field; }).indexOf('Kqty')].visible = (qp.mode === Models.QuotingMode.Boomerang);
$scope.gridOptions.columnDefs[$scope.gridOptions.columnDefs.map(function (e) { return e.field; }).indexOf('Kprice')].visible = (qp.mode === Models.QuotingMode.Boomerang);
$scope.gridApi.grid.refresh();
};

var qpSub = subscriberFactory.getSubscriber($scope, Messaging.Topics.QuotingParametersChange)
.registerConnectHandler(() => $scope.trade_statuses.length = 0)
.registerDisconnectedHandler(() => $scope.trade_statuses.length = 0)
.registerSubscriber(updateQP, qp => qp.forEach(updateQP));

$scope.$on('$destroy', () => {
sub.disconnect();
qpSub.disconnect();
$log.info("destroy trades list");
});

Expand Down
Loading