Skip to content

Commit

Permalink
remove PyYAML dependency due to security vulnerability
Browse files Browse the repository at this point in the history
move const to root path for easier access
  • Loading branch information
alpha-xone committed Jan 5, 2019
1 parent 89bdadd commit 12455ae
Show file tree
Hide file tree
Showing 12 changed files with 61 additions and 44 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Bloomberg data toolkit for humans

- [pdbdp](https://github.com/matthewgilbert/pdblp) - pandas wrapper for Bloomberg Open API

- numpy, pandas, pyyaml and pyarrow
- numpy, pandas, ruamel.yaml and pyarrow

## Installation

Expand All @@ -39,6 +39,10 @@ pip install blpapi --index-url=https://bloomberg.bintray.com/pip/simple
pip install xbbg
```

## What's New

_0.1.22_ - Remove PyYAML dependency due to security vulnerability

## Tutorial

```python
Expand Down
7 changes: 6 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Requirements

- pdblp_ - pandas wrapper for Bloomberg Open API

- numpy, pandas, pyyaml and pyarrow
- numpy, pandas, ruamel.yaml and pyarrow

.. _pdblp: https://github.com/matthewgilbert/pdblp
.. _download: https://bloomberg.bintray.com/BLPAPI-Experimental-Generic/blpapi_cpp_3.12.2.1-linux.tar.gz
Expand All @@ -44,6 +44,11 @@ Installation
pip install blpapi --index-url=https://bloomberg.bintray.com/pip/simple
pip install xbbg
What's New
==========

*0.1.22* - Remove PyYAML dependency due to security vulnerability

Tutorial
========

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ pandas>=0.23.4
pdblp>=0.1.7
pyarrow>=0.11.1
pytz>=2018.7
PyYAML>=3.13
ruamel.yaml>=0.15.0
pytest
2 changes: 1 addition & 1 deletion venv/Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pandas = "*"
blpapi = "*"
pdblp = "*"
pyarrow = "*"
pyyaml = "*"
ruamel-yaml = "*"

[requires]
python_version = "3.6"
50 changes: 30 additions & 20 deletions venv/Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion xbbg/blp.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
import sys
import pytest

from xbbg import const
from xbbg.io import files, logs, storage
from xbbg.core import utils, assist, const
from xbbg.core import utils, assist

from xbbg.core.timezone import DEFAULT_TZ
from xbbg.core.conn import with_bloomberg, create_connection

Expand Down
9 changes: 3 additions & 6 deletions xbbg/core/const.py → xbbg/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,12 +244,9 @@ def market_timing(ticker, dt, timing='EOD', tz='local'):
logger.error(f'required exchange info cannot be found in {ticker} ...')
return ''

if timing == 'BOD':
mkt_time = exch.day[0]
elif timing == 'FINISHED':
mkt_time = exch.allday[-1]
else:
mkt_time = exch.day[-1]
mkt_time = {
'BOD': exch.day[0], 'FINISHED': exch.allday[-1]
}.get(timing, exch.day[-1])

cur_dt = pd.Timestamp(str(dt)).strftime('%Y-%m-%d')
if tz == 'local':
Expand Down
2 changes: 1 addition & 1 deletion xbbg/core/intervals.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

from collections import namedtuple

from xbbg import const
from xbbg.io import logs, param
from xbbg.core import const

Session = namedtuple('Session', ['start_time', 'end_time'])
SessNA = Session(None, None)
Expand Down
13 changes: 5 additions & 8 deletions xbbg/core/pdblp.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,13 @@ def start(self): return False

class BCon(object):

def __init__(
self, host='localhost', port=8194, debug=False,
timeout=500, session=None, identity=None
):
self.host = host
def __init__(self, port=8194, timeout=500, **kwargs):
self.host = kwargs.pop('host', 'localhost')
self.port = port
self.debug = debug
self.timeout = timeout
self.session = session
self.identity = identity
self.debug = kwargs.pop('debug', False)
self.session = kwargs.pop('session', None)
self.identity = kwargs.pop('identity', None)
self._session = Session()

@abstractmethod
Expand Down
2 changes: 1 addition & 1 deletion xbbg/core/timezone.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def get_tz(tz):
>>> get_tz('BHP AU Equity')
'Australia/Sydney'
"""
from xbbg.core.const import exch_info
from xbbg.const import exch_info

if tz is None: return DEFAULT_TZ

Expand Down
5 changes: 3 additions & 2 deletions xbbg/io/param.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import pandas as pd

import yaml
import os

from ruamel.yaml import YAML

from xbbg.io import files

PKG_PATH = files.abspath(__file__, 1)
Expand Down Expand Up @@ -55,7 +56,7 @@ def _load_yaml_(file_name):
if not os.path.exists(file_name): return dict()

with open(file_name, 'r', encoding='utf-8') as fp:
return yaml.safe_load(fp)
return YAML().load(stream=fp)


def to_hour(num):
Expand Down
3 changes: 2 additions & 1 deletion xbbg/io/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import os

from xbbg.core import utils, const, assist
from xbbg import const
from xbbg.core import utils, assist
from xbbg.io import files, logs


Expand Down

0 comments on commit 12455ae

Please sign in to comment.