tarf_monte_carlo 3.60 → 3.65

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3e84d65efa37c58059ce27ed5c949cf99d734804ae813840e7da6b46694394af
4
- data.tar.gz: 54943b6268ddf6ee4f4f7ac72d4dc3fe9f8abbee1176b159fee6c35428ac106e
3
+ metadata.gz: 707623dec4f74afcf22546eb4e00d1eac103b8f09f9b876b485496f8ee720588
4
+ data.tar.gz: f882ae037b74ec0823880a030d71d59f617f8b93ffaaa6d3630078c73e9ceb9e
5
5
  SHA512:
6
- metadata.gz: c49d6bed204c1e80f618c828dabc12febd6576c5b2e663bc3b36de24eda39c5f4d1783006ddf7996865809cb7174acaa4ed28fd353ebcef78505e1f305e75380
7
- data.tar.gz: 5d520f207257d87a69bb9675fc3e6e36853378a0aef16c5f146a94ec2387f1de7bac75081266325a97728c80f5df8045328a2cd32599b076510d215f826c0e8a
6
+ metadata.gz: b11a35791403e6999b76ed1a2501d252a3960ccce81fb918119d87453859e15dd1462d2aaa459bba213ec164bf7b0e518d4ed56d93a5823398351722ece66f06
7
+ data.tar.gz: e5ae1f9e36514c594aa5b29bced3861a17d7f66951f8c8ba0ae20dfd93ff7c00e5f45b0faff6ed86fcb8d6d5324788072078f866986ce2dc1405e74f63c457cd
@@ -12,12 +12,12 @@ NULLCMD = :
12
12
  #### Start of system configuration section. ####
13
13
 
14
14
  srcdir = .
15
- topdir = /Users/vivektripathi/.rvm/rubies/ruby-2.5.1/include/ruby-2.5.0
15
+ topdir = /home/user/.rvm/rubies/ruby-2.5.1/include/ruby-2.5.0
16
16
  hdrdir = $(topdir)
17
- arch_hdrdir = /Users/vivektripathi/.rvm/rubies/ruby-2.5.1/include/ruby-2.5.0/x86_64-darwin18
17
+ arch_hdrdir = /home/user/.rvm/rubies/ruby-2.5.1/include/ruby-2.5.0/x86_64-linux
18
18
  PATH_SEPARATOR = :
19
19
  VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
20
- prefix = $(DESTDIR)/Users/vivektripathi/.rvm/rubies/ruby-2.5.1
20
+ prefix = $(DESTDIR)/home/user/.rvm/rubies/ruby-2.5.1
21
21
  rubysitearchprefix = $(rubylibprefix)/$(sitearch)
22
22
  rubyarchprefix = $(rubylibprefix)/$(arch)
23
23
  rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
@@ -50,7 +50,7 @@ dvidir = $(docdir)
50
50
  htmldir = $(docdir)
51
51
  infodir = $(datarootdir)/info
52
52
  docdir = $(datarootdir)/doc/$(PACKAGE)
53
- oldincludedir = $(SDKROOT)/usr/include
53
+ oldincludedir = $(DESTDIR)/usr/include
54
54
  includedir = $(prefix)/include
55
55
  localstatedir = $(prefix)/var
56
56
  sharedstatedir = $(prefix)/com
@@ -67,8 +67,8 @@ CC = gcc
67
67
  CXX = g++
68
68
  LIBRUBY = $(LIBRUBY_SO)
69
69
  LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
70
- LIBRUBYARG_SHARED = -l$(RUBY_SO_NAME)
71
- LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static -framework Foundation
70
+ LIBRUBYARG_SHARED = -Wl,-rpath,$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
71
+ LIBRUBYARG_STATIC = -Wl,-rpath,$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
72
72
  empty =
73
73
  OUTFLAG = -o $(empty)
74
74
  COUTFLAG = -o $(empty)
@@ -79,30 +79,30 @@ cflags = $(optflags) $(debugflags) $(warnflags)
79
79
  cxxflags = $(optflags) $(debugflags) $(warnflags)
80
80
  optflags = -O3
81
81
  debugflags = -ggdb3
82
- warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wextra-tokens
83
- CCDLFLAGS = -fno-common
84
- CFLAGS = $(CCDLFLAGS) $(cflags) -fno-common -pipe $(ARCH_FLAG)
82
+ warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat -Wsuggest-attribute=noreturn -Wsuggest-attribute=format -Wno-maybe-uninitialized
83
+ CCDLFLAGS = -fPIC
84
+ CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
85
85
  INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir)/ruby/backward -I$(hdrdir) -I$(srcdir)
86
86
  DEFS =
87
- CPPFLAGS = -I/usr/local/opt/libyaml/include -I/usr/local/opt/libksba/include -I/usr/local/opt/readline/include -I/usr/local/opt/zlib/include -I/usr/local/opt/openssl@1.1/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT $(DEFS) $(cppflags)
87
+ CPPFLAGS = $(DEFS) $(cppflags)
88
88
  CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
89
- ldflags = -L. -fstack-protector -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/zlib/lib -L/usr/local/opt/openssl@1.1/lib
90
- dldflags = -Wl,-undefined,dynamic_lookup -Wl,-multiply_defined,suppress -L/usr/local/opt/libyaml/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/zlib/lib -L/usr/local/opt/openssl@1.1/lib
89
+ ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
90
+ dldflags = -Wl,--compress-debug-sections=zlib
91
91
  ARCH_FLAG =
92
92
  DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
93
- LDSHARED = $(CC) -dynamic -bundle
94
- LDSHAREDXX = $(CXX) -dynamic -bundle
95
- AR = libtool -static
93
+ LDSHARED = $(CC) -shared
94
+ LDSHAREDXX = $(CXX) -shared
95
+ AR = ar
96
96
  EXEEXT =
97
97
 
98
98
  RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
99
- RUBY_SO_NAME = ruby.2.5.1
99
+ RUBY_SO_NAME = ruby
100
100
  RUBYW_INSTALL_NAME =
101
101
  RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
102
102
  RUBYW_BASE_NAME = rubyw
103
103
  RUBY_BASE_NAME = ruby
104
104
 
105
- arch = x86_64-darwin18
105
+ arch = x86_64-linux
106
106
  sitearch = $(arch)
107
107
  ruby_version = 2.5.0
108
108
  ruby = $(bindir)/$(RUBY_BASE_NAME)
@@ -111,9 +111,9 @@ ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/backward.h $(hdrdir)/ruby/ruby.h
111
111
 
112
112
  RM = rm -f
113
113
  RM_RF = $(RUBY) -run -e rm -- -rf
114
- RMDIRS = rmdir -p
115
- MAKEDIRS = /usr/local/opt/coreutils/bin/gmkdir -p
116
- INSTALL = /usr/local/opt/coreutils/bin/ginstall -c
114
+ RMDIRS = rmdir --ignore-fail-on-non-empty -p
115
+ MAKEDIRS = /bin/mkdir -p
116
+ INSTALL = /usr/bin/install -c
117
117
  INSTALL_PROG = $(INSTALL) -m 0755
118
118
  INSTALL_DATA = $(INSTALL) -m 644
119
119
  COPY = cp
@@ -122,8 +122,8 @@ TOUCH = exit >
122
122
  #### End of system configuration section. ####
123
123
 
124
124
  preload =
125
- libpath = . $(libdir) /usr/local/opt/libyaml/lib /usr/local/opt/libksba/lib /usr/local/opt/readline/lib /usr/local/opt/zlib/lib /usr/local/opt/openssl@1.1/lib
126
- LIBPATH = -L. -L$(libdir) -L/usr/local/opt/libyaml/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/zlib/lib -L/usr/local/opt/openssl@1.1/lib
125
+ libpath = . $(libdir)
126
+ LIBPATH = -L. -L$(libdir) -Wl,-rpath,$(libdir)
127
127
  DEFFILE =
128
128
 
129
129
  CLEANFILES = mkmf.log
@@ -134,7 +134,7 @@ extout =
134
134
  extout_prefix =
135
135
  target_prefix = /tarf_monte_carlo
136
136
  LOCAL_LIBS =
137
- LIBS = $(LIBRUBYARG_SHARED) -lpthread -ldl -lobjc
137
+ LIBS = $(LIBRUBYARG_SHARED) -lpthread -lgmp -ldl -lcrypt -lm -lc
138
138
  ORIG_SRCS = tarf_monte_carlo.c
139
139
  SRCS = $(ORIG_SRCS)
140
140
  OBJS = tarf_monte_carlo.o
@@ -143,7 +143,7 @@ LOCAL_HDRS =
143
143
  TARGET = tarf_monte_carlo
144
144
  TARGET_NAME = tarf_monte_carlo
145
145
  TARGET_ENTRY = Init_$(TARGET_NAME)
146
- DLLIB = $(TARGET).bundle
146
+ DLLIB = $(TARGET).so
147
147
  EXTSTATIC =
148
148
  STATIC_LIB =
149
149
 
@@ -257,7 +257,6 @@ $(TARGET_SO): $(OBJS) Makefile
257
257
  $(ECHO) linking shared-object tarf_monte_carlo/$(DLLIB)
258
258
  -$(Q)$(RM) $(@)
259
259
  $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
260
- $(Q) $(POSTLINK)
261
260
 
262
261
 
263
262
 
@@ -211,7 +211,6 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
211
211
  //
212
212
  // first create a 1-D array of pointers, and then, for each array entry, create another 1-D array.
213
213
  //
214
- double payoffmet[SCount];
215
214
  double **metrics;
216
215
  if (barrier_variations(KType)){
217
216
  metrics = ( double** ) malloc( BARRIER_DP * sizeof(double*) );
@@ -236,8 +235,6 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
236
235
  // run simulations loop
237
236
  for( sim_count = 0; sim_count < SCount; sim_count += 2 ) {
238
237
  // initial spot rate for each iteration would be current spot rate
239
- payoffmet[sim_count] = 0;
240
- payoffmet[sim_count + 1] = 0;
241
238
  double Spot = S, Spot_dash = S;
242
239
  double sim[NL], sim_pos[NL], sim_neg[NL], sim_dash[NL], sim_dash_pos[NL], sim_dash_neg[NL];
243
240
 
@@ -284,19 +281,37 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
284
281
  } else if(KType == FX_AMERICAN_BARRIER_KIKO_UNTIL_KI || KType == FX_AMERICAN_BARRIER_KIKO_UNTIL_EXP){
285
282
  profit_loss = Spot;
286
283
  profit_loss_dash = Spot_dash;
287
-
288
- if(knockedLeg == -1 && (Spot >= *(Barrier_array + leg))){
289
- knockedLeg = leg;
284
+
285
+ // Both Until KI & Exp
286
+ if ( ((*(Barrier_array + leg) - *(Xs_array + leg)) * cp_sign <= 0) && ((*(Barrier2_array + leg) - *(Xs_array + leg)) * cp_sign >= 0) ){
287
+ if ((knockedLeg == -1) && ((*(Barrier_array + leg) - Spot) * cp_sign >= 0)){ knockedLeg = leg; }
288
+ if ((knockedLeg2 == -1) && ((*(Barrier2_array + leg) - Spot) * cp_sign <= 0)){ knockedLeg2 = leg; }
289
+
290
+ if ((knockedLeg_dash == -1) && ((*(Barrier_array + leg) - Spot_dash) * cp_sign >= 0)){ knockedLeg_dash = leg; }
291
+ if ((knockedLeg2_dash == -1) && ((*(Barrier2_array + leg) - Spot_dash) * cp_sign <= 0)){ knockedLeg2_dash = leg; }
290
292
  }
291
- if(knockedLeg_dash == -1 && (Spot_dash >= *(Barrier_array + leg))){
292
- knockedLeg_dash = leg;
293
+ else if( ((*(Barrier_array + leg) - *(Xs_array + leg)) * cp_sign >= 0) && ((*(Barrier2_array + leg) - *(Xs_array + leg)) * cp_sign <= 0) ){
294
+ if ((knockedLeg == -1) && ((*(Barrier_array + leg) - Spot) * cp_sign <= 0)){ knockedLeg = leg; }
295
+ if ((knockedLeg2 == -1) && ((*(Barrier2_array + leg) - Spot) * cp_sign >= 0)){ knockedLeg2 = leg; }
296
+
297
+ if ((knockedLeg_dash == -1) && ((*(Barrier_array + leg) - Spot_dash) * cp_sign <= 0)){ knockedLeg_dash = leg; }
298
+ if ((knockedLeg2_dash == -1) && ((*(Barrier2_array + leg) - Spot_dash) * cp_sign >= 0)){ knockedLeg2_dash = leg; }
293
299
  }
300
+ // Only Until Exp
301
+ else if( (KType == FX_AMERICAN_BARRIER_KIKO_UNTIL_EXP) && ((*(Barrier_array + leg) - *(Xs_array + leg)) * cp_sign >= 0) && ((*(Barrier2_array + leg) - *(Barrier_array + leg)) * cp_sign >= 0) ){
302
+ if ((knockedLeg == -1) && ((*(Barrier_array + leg) - Spot) * cp_sign <= 0)){ knockedLeg = leg; }
303
+ if ((knockedLeg2 == -1) && ((*(Barrier2_array + leg) - Spot) * cp_sign <= 0)){ knockedLeg2 = leg; }
294
304
 
295
- if(knockedLeg2 == -1 && (Spot >= *(Barrier2_array + leg))){
296
- knockedLeg2 = leg;
305
+ if ((knockedLeg_dash == -1) && ((*(Barrier_array + leg) - Spot_dash) * cp_sign <= 0)){ knockedLeg_dash = leg; }
306
+ if ((knockedLeg2_dash == -1) && ((*(Barrier2_array + leg) - Spot_dash) * cp_sign <= 0)){ knockedLeg2_dash = leg; }
297
307
  }
298
- if(knockedLeg2_dash == -1 && (Spot_dash >= *(Barrier2_array + leg))){
299
- knockedLeg2_dash = leg;
308
+
309
+ else if( (KType == FX_AMERICAN_BARRIER_KIKO_UNTIL_EXP) && ((*(Barrier_array + leg) - *(Xs_array + leg)) * cp_sign <= 0) && ((*(Barrier2_array + leg) - *(Barrier_array + leg)) * cp_sign <= 0) ){
310
+ if ((knockedLeg == -1) && ((*(Barrier_array + leg) - Spot) * cp_sign >= 0)){ knockedLeg = leg; }
311
+ if ((knockedLeg2 == -1) && ((*(Barrier2_array + leg) - Spot) * cp_sign >= 0)){ knockedLeg2 = leg; }
312
+
313
+ if ((knockedLeg_dash == -1) && ((*(Barrier_array + leg) - Spot_dash) * cp_sign >= 0)){ knockedLeg_dash = leg; }
314
+ if ((knockedLeg2_dash == -1) && ((*(Barrier2_array + leg) - Spot_dash) * cp_sign >= 0)){ knockedLeg2_dash = leg; }
300
315
  }
301
316
  } else if(KType == FX_AMERICAN_BARRIER_WINDOW_KNOCKIN || KType == FX_AMERICAN_BARRIER_WINDOW_KNOCKOUT){
302
317
  profit_loss = Spot;
@@ -749,8 +764,6 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
749
764
  pvs_neg[sim_count] = sim_neg_sum;
750
765
  pvs_neg[sim_count + 1] = sim_dash_neg_sum;
751
766
 
752
- payoffmet[sim_count] = sim_pos_sum;
753
- payoffmet[sim_count + 1] = sim_dash_pos_sum;
754
767
 
755
768
  if (barrier_variations(KType)){
756
769
  if ((point_pos < DATAPOINTS) && (sim_count % INTERVAL) == 0){
@@ -826,20 +839,12 @@ VALUE method_run_monte_carlo( VALUE self, VALUE args ) {
826
839
  }
827
840
  }
828
841
 
829
-
830
- VALUE py_final_metrics = rb_ary_new();
831
- for(metric = 0; metric < SCount; metric++) {
832
- VALUE leg_metrics = rb_ary_new();
833
-
834
- rb_ary_push(py_final_metrics, payoffmet[metric]);
835
- }
836
842
  // rb_p(rb_str_new2("Generating output hash"));
837
843
  VALUE final_pvs = rb_hash_new();
838
844
  rb_hash_aset(final_pvs, rb_str_new2("positive_pv"), DBL2NUM( pvs_pos_sum / SCount ));
839
845
  rb_hash_aset(final_pvs, rb_str_new2("negative_pv"), DBL2NUM( pvs_neg_sum / SCount ));
840
846
  rb_hash_aset(final_pvs, rb_str_new2("total_pv"), DBL2NUM( (pvs_neg_sum + pvs_pos_sum) / SCount ));
841
847
  rb_hash_aset(final_pvs, rb_str_new2("metrics"), final_metrics);
842
- rb_hash_aset(final_pvs, rb_str_new2("payoffmetrics"), py_final_metrics);
843
848
 
844
849
  //
845
850
  // free your arrays from memory once you're done using them
@@ -3,5 +3,5 @@
3
3
  # gem yank tarf_monte_carlo -v 2.3
4
4
 
5
5
  module TarfMonteCarlo
6
- VERSION = "3.60"
6
+ VERSION = "3.65"
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tarf_monte_carlo
3
3
  version: !ruby/object:Gem::Version
4
- version: '3.60'
4
+ version: '3.65'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vivek Routh
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-10-13 00:00:00.000000000 Z
11
+ date: 2020-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -140,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
140
140
  - !ruby/object:Gem::Version
141
141
  version: '0'
142
142
  requirements: []
143
- rubygems_version: 3.0.6
143
+ rubygems_version: 3.0.8
144
144
  signing_key:
145
145
  specification_version: 4
146
146
  summary: Monte Carlo Simulation.