Git Product home page Git Product logo

py4fi2nd's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

py4fi2nd's Issues

Issue creating envirionment using p4fi2nd.yml

I have a linux Mint system and am using latest version of miniconda.

I have followed the installation instructions as per the github page for creating an environment for py4fi2nd.

When I issue the terminal command:
conda env create -f py4fi2nd.yml

I get the following issue:

ResolvePackageNotFound:

  • libcxxabi=4.0.1
  • clangxx_osx-64=4.0.1
  • clangxx=4.0.1
  • cctools=895
  • libgfortran=3.0.1
  • llvm=4.0.1
  • appnope=0.1.0
  • clang_osx-64=4.0.1
  • libcxx=4.0.1
  • llvm-lto-tapi=4.0.1
  • clang=4.0.1
  • ld64=274.2
  • compiler-rt=4.0.1
    The environment is not created.

Do I need to change the yaml file in some way?

Kind Regards

Mark

couldn't install yaml

I am using Anaconda 4.7.10, and couldn't install the env from yaml

Here is the message

Collecting package metadata (repodata.json): done
Solving environment: failed

ResolvePackageNotFound:

  • libgfortran=3.0.1
  • cctools=895
  • libcxxabi=4.0.1
  • appnope=0.1.0
  • libffi=3.2.1
  • clangxx_osx-64=4.0.1
  • glib=2.56.2
  • llvm-lto-tapi=4.0.1
  • expat=2.2.6
  • gettext=0.19.8.1
  • ld64=274.2
  • clang=4.0.1
  • libedit=3.1.20170329
  • ncurses=6.1
  • dbus=1.13.2
  • clang_osx-64=4.0.1
  • llvm=4.0.1
  • gmp=6.1.2
  • libcxx=4.0.1
  • clangxx=4.0.1
  • mpc=1.1.0
  • compiler-rt=4.0.1
  • readline=7.0
  • ptyprocess=0.6.0

Solving enviroment: failed py4fi2nd

Windows OS
Anaconda installed
Run through Anaconda command line as Administrator

R:\py4fi2nd>conda env create -f py4fi2nd.yml
Collecting package metadata (repodata.json): done
Solving environment: failed

ResolvePackageNotFound:

  • dbus=1.13.2
  • libcxxabi=4.0.1
  • libcxx=4.0.1
  • gmp=6.1.2
  • gettext=0.19.8.1
  • cctools=895
  • ncurses=6.1
  • clangxx_osx-64=4.0.1
  • appnope=0.1.0
  • clang_osx-64=4.0.1
  • libedit=3.1.20170329
  • ld64=274.2
  • compiler-rt=4.0.1
  • clang=4.0.1
  • glib=2.56.2
  • llvm=4.0.1
  • libgfortran=3.0.1
  • readline=7.0
  • clangxx=4.0.1
  • llvm-lto-tapi=4.0.1
  • expat=2.2.6

Ch 02 Cloud: install linux system tools, basic packages and jupyter notebook fails

Now I'm installing from local to remote machine.
The files are correctly copied over to remote machine, and run as ROOT.

The installation works fine. Jupyter notebook is started.

I have two problems.
First, I can't restart the notebook. If I write : jupyter notebook then I only get the suggestion to install with apt install jupyter-core

Input/Output chapter 9 has path commands that throw errors in windows

Referring the the Cell numbers as in the PFF second edition, chapter 9.

Cell 8: ll Spath*
ll is possibly intended to refer to a python module/library, but if so it has not been declared.
$path* fails as a Syntax error at the $.
There are multiple occurrences of this case in the notebook.

Cell 25: Code in the Notebook differs from that in the Book.
Book has: !rm -f $path*
Notebook has: get_ipython().system('rm -f $path*')
However, !rm -f appears to be a linux system command. [Windows: del /f {path/filename}
The path variable intended by $path* has not been successfully declared, due the Cell 8 issue.

Some guidance on how both of these are supposed to work in windows would be appreciated.

Help on Chapter 17

Hello. I was hoping to get help on a error that I cannot figure out. The code is as follows:


[1]
import numpy as np
import pandas as pd
import datetime as dt

[2]
from pylab import mpl, plt
plt.style.use('seaborn')
mpl.rcParams['font.family'] = 'serif'
%matplotlib inline

[3]
import sys
sys.path.append(r'C:\Users****\dx-master\dx')
#I was getting an error without 'r' in front of C

[4]
dates = [dt.datetime(2020, 1, 1), dt.datetime(2020, 7, 1),
dt.datetime(2021, 1, 1)]

[5]
(dates[1] - dates[0]).days / 365.
Out:0.4986301369863014

[6]
(dates[2] - dates[1]).days / 365.
Out:0.5041095890410959

[7]
fractions = [0.0, 0.5, 1.0]

#DX Package

#Frame -- Helper Function

#get_year_deltas.py

#Python for Finance, 2nd ed.
#(c) Dr. Yvess J. Hilpisch

import numpy as np

def get_year_deltas(date_list, day_count=365.):
''' Return vector of floats with day deltas in years.
Initial value normalized to zero.

Parameters
==========
date_list : list or array
collection of datetime objects
day_count : float
number of days for a year
(to account for different conventions)

Results
=======
delta_list : array
    year fractions
'''

start = date_list[0]
delta_list = [(date - start).days / day_count
              for date in date_list]
return np.array(delta_list)

[8]
from get_year_deltas import get_year_deltas

ModuleNotFoundError Traceback (most recent call last)
in
----> 1 from get_year_deltas import get_year_deltas

ModuleNotFoundError: No module named 'get_year_deltas'


I cant seem to figure out why the module isnt being found. Any help would be appreciated.

Ch_02: there's no explicit solution in the book for the issue of Floating Point Arithmetic

this book is good and comprehensive for people who want to enter the word of Python for finance but when I read the ch2 for the issue Floating-Point Arithmetic, I don't find the explicit way to address it in the book (yes, the author mentions Decimal module but he does not provide the corresponding fix to the example he describes before) - I don't know if the author intends to want the readers to search for the answer on their own.

so I posted in StackOverflow to look for the answer and those are Q/A

Questions

1. First Example

Expecting:

In[1]: a = 0.35 + 0.1
In[2]: print(a)
0.45

Actual:

In[1]: a = 0.35 + 0.1
In[2]: print(a)
0.44999999999999996

My take to present:

format(a, '.2f')
'0.45'

I thought Decimal could help but it looks like the same

In[1]:import decimal
      from decimal import Decimal

In[2]:Decimal(0.35) + Decimal(0.1)
Decimal('0.4499999999999999833466546306')

2. Second Example

Expecting:

In[1]:b = 0.35
In[2]:b.as_integer_ratio()
(7, 20)

Actual:

In[1]:b = 0.35
In[2]:b.as_integer_ratio()
(3152519739159347, 9007199254740992)

Answers using Decimal and fractions

You are starting with imprecise floats. Start with exact decimals, from string representation:

Decimal("0.35") + Decimal("0.1")
# => Decimal('0.45')

Decimal("0.35").as_integer_ratio()
# => (9, 20)

Or start with exact numbers (e.g. integers):

 Decimal(35) / Decimal(100)
 # => Decimal('0.35')

 from fractions import Fraction
 Fraction(35, 100)
 # => Fraction(7, 20)







where can download the pylab model?

i see the issue on working code
ModuleNotFoundError Traceback (most recent call last)
in
1 import numpy as np
2 import pandas as pd
----> 3 from pylab import plt, mpl
4 plt.style.use('seaborn')
5 mpl.rcParams['font.family'] = 'serif'
ModuleNotFoundError: No module named 'pylab'
could you can tell me where can download the module? thank you.

question: chapter 15, regression, the calculation of return

chapter 15, regression section, in the book, it is:
In [28]: data['strat_ols_1'] = data['pos_ols_1'] * data['returns']
In [29]: data['strat_ols_2'] = data['pos_ols_2'] * data['returns']

should we use shift(1) as same as in section "Vectorized Backtesting" (cell 15)?
In [28]: data['strat_ols_1'] = data['pos_ols_1'].shift(1) * data['returns']
In [29]: data['strat_ols_2'] = data['pos_ols_2'].shift(1) * data['returns']

(cell 15 is : In [15]: data['Strategy'] = data['Position'].shift(1) * data['Returns'] )

Chapter 19 19.3 In[95]

I have a question related to American Put Option Analysis by using the valuation_mcs_american.py and the code given in Chapter 19 Section 19.3:
For In[95]: for maturity in (dt.datetime(2020, 12, 31), dt.datetime(2021, 12, 31):
When I type this and after finish the whole In[95]: It reported an error of saying: Only size-1 arrays can be converted to Python scalars
However, if I only designate: maturity=dt.datetime(2020, 12, 31), there is no error happening again
I would like to know what could have happened and if there are some further guidelines, please let me know, thanks

Conda environment creation fails for 2nd Edition also?

I noticed there was a similar conda env create issue for the 1st edition's repo.

conda 4.5.11

conda env create -f py4fi2nd.yml
Using Anaconda API: https://api.anaconda.org
Solving environment: failed

ResolvePackageNotFound:
  - readline=7.0
  - compiler-rt=4.0.1
  - libffi=3.2.1
  - llvm-lto-tapi=4.0.1
  - clang=4.0.1
  - gettext=0.19.8.1
  - dbus=1.13.2
  - mpc=1.1.0
  - ld64=274.2
  - gmp=6.1.2
  - clangxx=4.0.1
  - llvm=4.0.1
  - expat=2.2.6
  - cctools=895
  - libedit=3.1.20170329
  - ptyprocess=0.6.0
  - libcxx=4.0.1
  - libcxxabi=4.0.1
  - clangxx_osx-64=4.0.1
  - glib=2.56.2
  - ncurses=6.1
  - clang_osx-64=4.0.1
  - libgfortran=3.0.1
  - appnope=0.1.0

Docker install: /bin/sh: 1: /install.sh not found

I've put the Dockerfile and install.sh in an droplet, directory /install/Setup/Docker$
Runs$ sudo docker build -t py4fi:basic .

this goes well, down to Step 5/7, when I get the /bin/sh: 1: /install.sh not found error.

So what's going on? why is Docker looking in bin/sh and not in current directory? It did find /install.sh the moment earlier?

.yml - Solving environment failed

i could use some help with the following error message. i'm on a Windows7 system running anaconda3.

when i run the following command in a conda window to setup the py4fi2nd environment, i get the following:

\py4fi2nd\>conda env create -f py4fi2nd.yml
Collecting package metadata (repodata.json): done
Solving environment: failed

ResolvePackageNotFound:
- ncurses=6.1
- glib-2.56.2
-compiler-rt=4.0.1
... (long list of packages)
-clang_osx-64=4.0.1
-gmp=6.1.2
-readline=7.0

thanks for any suggestions that might help. i'm open to modifying the .yml file if it needs to be customized for Windows, for example- clang_osx-64=4.0.1 is probably for MacOS?

Or, I can import the libraries to the env as needed.

-jw

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.