Skip to content

Commit

Permalink
fix minor issues
Browse files Browse the repository at this point in the history
  • Loading branch information
bitrinjani committed Dec 19, 2017
1 parent fca878c commit 2ecc1f3
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 10 deletions.
24 changes: 20 additions & 4 deletions src/ArbitragerImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,10 @@ export default class ArbitragerImpl implements Arbitrager {
}
}

this.printSpreadAnalysisResult(spreadAnalysisResult);
if (!exitFlag) {
this.printSpreadAnalysisResult(spreadAnalysisResult);
}

const limitChecker = this.limitCheckerFactory.create(spreadAnalysisResult, exitFlag);
const limitCheckResult = limitChecker.check();
if (!limitCheckResult.success) {
Expand All @@ -92,7 +95,8 @@ export default class ArbitragerImpl implements Arbitrager {
}
return;
}
if (exitFlag) {

if (exitFlag) {
this.log.info(t`FoundClosableOrders`);
} else {
this.log.info(t`FoundArbitrageOppotunity`);
Expand Down Expand Up @@ -167,8 +171,8 @@ export default class ArbitragerImpl implements Arbitrager {
if (minExitTargetProfit === undefined && minExitTargetProfitPercent === undefined) {
return false;
}
this.log.debug(`activePairs: ${this.activePairs}`);
for (const pair of _.reverse(this.activePairs)) {
this.printActivePairs();
for (const pair of this.activePairs.slice().reverse()) {
try {
this.log.debug(`Analyzing pair: ${pair}...`);
const result = await this.spreadAnalyzer.analyze(quotes, this.positionService.positionMap, pair);
Expand Down Expand Up @@ -236,4 +240,16 @@ export default class ArbitragerImpl implements Arbitrager {
result.profitPercentAgainstNotional
);
}

private printActivePairs(): void {
if (this.activePairs.length === 0) {
return;
}
this.log.info(t`OpenPairs`);
this.activePairs.forEach(pair => {
this.log.info(
`[${pair[0].broker} ${pair[0].side} ${pair[0].size}, ${pair[1].broker} ${pair[1].side} ${pair[1].size}]`
);
});
}
}
2 changes: 1 addition & 1 deletion src/Coincheck/BrokerApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
import { setTimeout } from 'timers';

export default class BrokerApi {
private static CACHE_MS = 50;
private static CACHE_MS = 1000;
private leveragePositionsCache?: LeveragePosition[];
private readonly baseUrl = 'https://coincheck.com';
private readonly webClient: WebClient = new WebClient(this.baseUrl);
Expand Down
1 change: 0 additions & 1 deletion src/SpreadAnalyzerImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export default class SpreadAnalyzerImpl implements SpreadAnalyzer {
throw new Error('Invalid closing pair.');
}

this.log.info(t`AnalyzingQuotes`);
const { config } = this.configStore;
if (_.isEmpty(positionMap)) {
throw new Error('Position map is empty.');
Expand Down
3 changes: 2 additions & 1 deletion src/config_default.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
"priceMergeSize": 100,
"maxSize": 0.01,
"minSize": 0.01,
"minTargetProfit": 1,
"minTargetProfit": 10,
"minTargetProfitPercent": 0.00,
"minExitTargetProfit": -5,
"iterationInterval": 3000,
"positionRefreshInterval": 5000,
"sleepAfterSend": 5000,
Expand Down
8 changes: 5 additions & 3 deletions src/stringResources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ export const en = {
WaitingForPositionService: 'Waiting for Position Service...',
FilledSummary: 'Filled: %s %s %d BTC filled at %s',
UnfilledSummary: 'Pending: %s %s %d BTC sent at %s, pending size %d BTC',
FoundClosableOrders: 'Found closable orders.'
FoundClosableOrders: 'Found closable orders.',
OpenPairs: 'Open pairs:'
};

export const ja = {
Expand All @@ -57,7 +58,7 @@ export const ja = {
BothLegsAreSuccessfullyFilled: '>>両方のオーダーの約定完了。',
BuyFillPriceIs: '>>買い約定価格: %s',
BuyLegIsNotFilledYetPendingSizeIs: '>>買いオーダー未約定。残り数量%s',
CheckingIfBothLegsAreDoneOrNot: '>>両方のオーダーが約定したか確認中...',
CheckingIfBothLegsAreDoneOrNot: '>>約定確認中...',
ExpectedProfit: '予想収益  ',
FailedToGetASpreadAnalysisResult: 'スプレッド解析結果の取得に失敗しました。取引所設定のmaxLongPosition, maxShortPositionが十分に大きいか確認してください。 %s',
FoundArbitrageOppotunity: '>>裁定機会を発見。',
Expand Down Expand Up @@ -92,5 +93,6 @@ export const ja = {
WaitingForPositionService: 'ポジションサービスの待機中...',
FilledSummary: '>>約定済み: %s %s %d BTC 約定価格 %s',
UnfilledSummary: '>>執行中: %s %s %d BTC 指値 %s, 残り数量 %d BTC',
FoundClosableOrders: 'クローズ可能なオーダーを発見。'
FoundClosableOrders: 'クローズ可能なオーダーを発見。',
OpenPairs: 'オープン状態のオーダーペア:'
};

0 comments on commit 2ecc1f3

Please sign in to comment.