Skip to content

Instantly share code, notes, and snippets.

View batiaev's full-sized avatar
🚀
Get **it done

Anton Batiaev batiaev

🚀
Get **it done
View GitHub Profile
var settlementCycle = 2; //T+2
var tenor = tenor(“8M”); //tenor is swap period of eight months
var baseCurrencyHolidays = calendar.holidaysIn(swap.baseCurrency);
var counterCurrencyHolidays = calendar.holidaysIn(swap.baseCurrency);
var holidays = Set.of(ownerHolidays, counterpartyHolidays, baseCurrencyHolidays, counterCurrencyHolidays)
var nearSettlementDate = calculateSettlementDate(swap.tradeDate.plusDays(settlementCycle), holidays);
var farSettlementDate = calculateSettlementDate(nearSettlementDate.plus(tenor.toPeriod()), holidays);
LocalDate settlementDate(LocalDate tradeDate) {
return tradeDate.plusDays(shift(tradeDate));
}
int shift(LocalDate tradeDate) {
switch (tradeDate.getDayOfWeek()) {
case THURSDAY:
case FRIDAY:
case SATURDAY:
return 4;
import java.time.LocalDate;
import java.util.UUID;
record Currency(String code);
record Money(
long amount,
Currency currency
);
@batiaev
batiaev / FxSwapRecord.java
Last active December 10, 2021 18:27
fxSwapRecord
class FxSwapRecord {
UUID owner;
UUID counterparty;
Currency baseCurrency;
Currency counterCurrency;
long nearBaseAmount;
long nearCounterAmount;
long farBaseAmount;
long farCounterAmount;
LocalDate tradeDate;
@batiaev
batiaev / gist:48ea306757ed5637768cd8603a96c23f
Created May 25, 2018 21:32 — forked from sgergely/gist:3793166
Midnight Commander Keyboard Shortcuts for Mac OSX
----- Esc -----
Quick change directory: Esc + c
Quick change directory history: Esc + c and then Esc + h
Quick change directory previous entry: Esc + c and then Esc + p
Command line history: Esc + h
Command line previous command: Esc + p
View change: Esc + t (each time you do this shortcut a new directory view will appear)
Print current working directory in command line: Esc + a
Switch between background command line and MC: Ctrl + o
Search/Go to directory in active panel: Esc + s / Ctrl + s then start typing directory name
#!/bin/sh
date=`echo | openssl s_client -connect localhost:443 2>/dev/null | openssl x509 -noout -enddate | cut -d'=' -f2`
#date -d "$date" +%Y%m%d
expired=$(date -d "$date" +%s)
now=$(date -d 'now' +%s)
echo $(( (expired - now) / 86400 )) days
#!/bin/bash
rsync -av --partial --rsh=ssh user@server:/opt/dumps/2015-11-09.backup .
@batiaev
batiaev / myIPv4.sh
Last active October 28, 2015 07:20
Get IPv4 in linux system
#!/bin/bash
ifconfig eth0 | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'
#or
hostname -i