Skip to content

Commit

Permalink
#64 Trial & Error
Browse files Browse the repository at this point in the history
  • Loading branch information
pantunes committed May 9, 2020
1 parent d7f7d9a commit 0096bbc
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 3 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
All changes will be registered here per release.

## [0.6.0] - Current date
Added exchange:
Added the following exchanges:

* Bitstamp
* Kucoin

Code fixes and improvements.

Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ beautifulsoup4
millify
py-etherscan-api
cfscrape
python-kucoin
# versioned library dependencies
marshmallow==2.20.5
jsonschema==2.6.0
Expand Down
2 changes: 2 additions & 0 deletions xtcryptosignals/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
BITMAX,
BILAXY,
BITSTAMP,
KUCOIN,
) # noqa

__all__ = [
Expand All @@ -77,6 +78,7 @@
"BITMAX",
"BILAXY",
"BITSTAMP",
"KUCOIN",
"TICKER_SCHEDULE",
"HISTORY_FREQUENCY",
"PRICE_CHANGE_FREQUENCIES",
Expand Down
7 changes: 7 additions & 0 deletions xtcryptosignals/settings_exchanges.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
BITMAX = "bitmax"
BILAXY = "bilaxy"
BITSTAMP = "bitstamp"
KUCOIN = "kucoin"


EXCHANGES = [
Expand All @@ -42,6 +43,7 @@
BITMAX,
BILAXY,
BITSTAMP,
KUCOIN,
]


Expand Down Expand Up @@ -87,6 +89,11 @@
{OKEX: {"pairs": [("BTC", "USDT"), ("ETH", "USDT"), ("LTC", "USDT"),]}}
)

# Kucoin
SYMBOLS_PER_EXCHANGE.append(
{KUCOIN: {"pairs": [("BTC", "USDT"), ("ETH", "USDT"),]}}
)

# BIBOX
SYMBOLS_PER_EXCHANGE.append(
{BIBOX: {"pairs": [("BTC", "USDT"), ("ETH", "USDT"), ("LTC", "USDT"),]}}
Expand Down
34 changes: 34 additions & 0 deletions xtcryptosignals/tasks/exchanges/kucoin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
__author__ = "Paulo Antunes"
__copyright__ = "Copyright 2018, XTCryptoSignals"
__credits__ = [
"Paulo Antunes",
]
__license__ = "GPL"
__maintainer__ = "Paulo Antunes"
__email__ = "[email protected]"


from kucoin.client import Client
from kucoin.exceptions import KucoinAPIException
from xtcryptosignals.tasks import settings as s


class Kucoin:
def __init__(self):
self.client = Client(s.KUCOIN_API_KEY, s.KUCOIN_API_SECRET, s.KUCOIN_API_PASSPHRASE)

def get_ticker(self, symbol):
_symbol = "-".join(symbol)

try:
item = self.client.get_ticker(_symbol)
except (KucoinAPIException, Exception) as err:
raise ValueError(str(err))

try:
item.update(self.client.get_24hr_stats(_symbol))
except (KucoinAPIException, Exception) as err:
raise ValueError(str(err))

item.update(ticker=symbol[0])
return item
38 changes: 38 additions & 0 deletions xtcryptosignals/tasks/schemas/kucoin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
__author__ = "Paulo Antunes"
__copyright__ = "Copyright 2018, XTCryptoSignals"
__credits__ = [
"Paulo Antunes",
]
__license__ = "GPL"
__maintainer__ = "Paulo Antunes"
__email__ = "[email protected]"


from marshmallow import (
fields,
pre_load,
post_load,
)
from xtcryptosignals.tasks.schemas.base import BaseSchema
from xtcryptosignals.tasks import settings as s


class Kucoin(BaseSchema):
symbol = fields.Str(required=True)
source = fields.Str(required=True)
last = fields.Float(required=True, attribute="price")
vol = fields.Float(required=True, attribute="volume_24h")
high = fields.Float(required=True, attribute="highest_price_24h")
low = fields.Float(required=True, attribute="lowest_price_24h")

@pre_load
def pre_load(self, data):
data["source"] = s.KUCOIN
data["symbol"] = data["symbol"].replace("-", "")
data["vol"] = float(data["vol"]) * float(data["last"])
return data

@post_load
def post_load(self, data):
super().post_load(data)
return data
10 changes: 8 additions & 2 deletions xtcryptosignals/tasks/settings_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,11 @@
__email__ = "[email protected]"


BINANCE_API_KEY = "" # Add Personal Binance API KEY
BINANCE_API_SECRET = "" # Add Personal Binance API SECRET
# Add the following Personal Exchange keys in order to be able to Trade

BINANCE_API_KEY = ""
BINANCE_API_SECRET = ""

KUCOIN_API_KEY = ""
KUCOIN_API_SECRET = ""
KUCOIN_API_PASSPHRASE = ""

0 comments on commit 0096bbc

Please sign in to comment.