Skip to content

Commit

Permalink
Updated dependencies and bug fix
Browse files Browse the repository at this point in the history
Skip duplicate symbol creation in database setup.
  • Loading branch information
SlashGordon committed Aug 15, 2019
1 parent ceeb806 commit ba0409d
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 18 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ deploy:
secure: "C0KD/7KNq1mM7q8U+KaPf7zEzTVI9QOjBqVZ1+/uKHUOIRciQGo4vA1e9aAtC+MxXzEpxX4aUb4lHrxEx17Dqqcf4PNt5A9bz8mAf+8yO6Q3SjlxGcCAqS8JMTBWNXWaIHiGnQ3aPGA5rOq66d+mRZo5rRPl/Of+rKcauDK42vBR8XaE7W9N/5+Z9+v4WUjTuXR3LMoE1cx2QwHPr2lyMEhYkFlj1T9/s5O0rTWNKlzFih76AOsdnKsjM5cvrrulXujXaYLU89UakIuBd/Om5Qf2V4p5SN8gPaLzMfHoPQdWtJG6FE2uJOCDRv8tByyooF0ADD0PaO2tV5luS+wM4nMcPQI/ZUenMrFefHvk9bvNihyVeyIe7gFxPKqWJkVJeaWid6NT6IiZdRKsn0d+Wo0QLTuYq/qG9UoMQr9z8hqeESyPMLY5wzJugyYxZ2aP7HDdzV6BTy6W/5XhmL1yAUY+0xwi7ukwbXMB9Vs3IWWh4zHkuYYGzqhD7qosTEFOj4ZpcvHYR05EW8CDT7iwzwunZMMnNBRbXu5zQPhJdC2ndAh5Pgq8jVsvguUEgF8YyYF+Gtfm3bXVLl51Ia1XSlu6dpGoRd2wZgR0D6pFwnSzybwdV8zccsoW8vFggGioJgQrg0SmIUA8fckPwj5qFQ/9dAs2pIymqeI9Vv6EhE8="
on:
branch: master
skip_existing: true
after_success:
- coveralls --verbose
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pytickersymbols==1.1.4
pytickersymbols==1.1.5
pandas==0.24.2
yfinance==0.1.44
uplink==0.9.0
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
from setuptools import setup, find_packages

EXCLUDE_FROM_PACKAGES = ['test', 'test.*', 'test*']
VERSION = '1.0.4'
VERSION = '1.0.5'

with open("README.md", "r") as fh:
long_description = fh.read()

INSTALL_REQUIRES = (
[
'pytickersymbols>=1.1.4', 'pandas==0.24.2', 'yfinance>=0.1.44',
'pytickersymbols>=1.1.5', 'pandas==0.24.2', 'yfinance>=0.1.44',
'uplink>=0.9.0', 'pony==0.7.10'
]
)
Expand Down
36 changes: 21 additions & 15 deletions src/pystockdb/tools/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@
import logging

from pony.orm import commit, db_session

from pytickersymbols import PyTickerSymbols

from pystockdb.db.schema.stocks import (Index, Item, PriceItem, Stock, Tag,
Type, db)
from pystockdb.db.schema.stocks import (Index, Item, PriceItem, Stock, Symbol,
Tag, Type, db)
from pystockdb.tools.data_crawler import DataCrawler


Expand Down Expand Up @@ -83,18 +82,10 @@ def __add_stock_to_index(self, index, stock_info):
usd = Tag.get(name=Tag.USD)
eur = Tag.get(name=Tag.EUR)
for symbol in stock_info['symbols']:
if Tag.GOG in symbol:
cur = eur if symbol[Tag.GOG].startswith('FRA') else usd
item = Item()
item.add_tags([gog, cur])
stock.price_item.symbols.create(item=item,
name=symbol[Tag.GOG])
if Tag.YAO in symbol:
cur = eur if symbol[Tag.YAO].endswith('.F') else usd
item = Item()
item.add_tags([yao, cur])
stock.price_item.symbols.create(item=item,
name=symbol[Tag.YAO])
if Tag.GOG in symbol and symbol[Tag.GOG] != '-':
self.__create_symbol(stock, Tag.GOG, gog, symbol, eur, usd)
if Tag.YAO in symbol and symbol[Tag.YAO] != '-':
self.__create_symbol(stock, Tag.YAO, yao, symbol, eur, usd)
index.stocks.add(stock)
# connect stock with industry and country
# country
Expand All @@ -109,6 +100,21 @@ def __add_stock_to_index(self, index, stock_info):
for industry in industries:
industry.items.add(stock.price_item.item)

@db_session
def __create_symbol(self, stock, my_tag, my_tag_item, symbol, eur, usd):
if my_tag in symbol and symbol[my_tag] != '-':
cur = eur if symbol[my_tag].startswith('FRA') else usd
item = Item()
item.add_tags([my_tag_item, cur])
if Symbol.get(name=symbol[my_tag]):
self.logger.warning(
'Symbol {} is related to more than one'
' stock.'.format(symbol[my_tag])
)
else:
stock.price_item.symbols.create(item=item,
name=symbol[my_tag])

@db_session
def download_historicals(self, symbols, start, end):
if not (start and end):
Expand Down

0 comments on commit ba0409d

Please sign in to comment.