Skip to content

Commit

Permalink
#67 Add Bitstamp exchange (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
pantunes authored May 9, 2020
1 parent fabbf1f commit d7f7d9a
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 18 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
All changes will be registered here per release.

## [0.6.0] - Current date
Code fixes and improvements.
Added exchange:

* Bitstamp

Code fixes and improvements.

## [0.5.0] - 2020-05-04
Added Projects Coin or Token Wikipedia summary info with Twitter number of followers.
Expand Down
2 changes: 2 additions & 0 deletions xtcryptosignals/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
DCOIN,
BITMAX,
BILAXY,
BITSTAMP,
) # noqa

__all__ = [
Expand All @@ -75,6 +76,7 @@
"DCOIN",
"BITMAX",
"BILAXY",
"BITSTAMP",
"TICKER_SCHEDULE",
"HISTORY_FREQUENCY",
"PRICE_CHANGE_FREQUENCIES",
Expand Down
41 changes: 24 additions & 17 deletions xtcryptosignals/settings_exchanges.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
DCOIN = "dcoin"
BITMAX = "bitmax"
BILAXY = "bilaxy"
BITSTAMP = "bitstamp"


EXCHANGES = [
Expand All @@ -40,6 +41,7 @@
DCOIN,
BITMAX,
BILAXY,
BITSTAMP,
]


Expand Down Expand Up @@ -75,36 +77,21 @@
}
)

# Binance DEX
# Bitstamp
SYMBOLS_PER_EXCHANGE.append(
{BINANCE_DEX: {"pairs": [("LTO", "BNB"),], "single_request": True,}}
{BITSTAMP: {"pairs": [("BTC", "USD"), ("ETH", "USD"),]}}
)

# OKEx
SYMBOLS_PER_EXCHANGE.append(
{OKEX: {"pairs": [("BTC", "USDT"), ("ETH", "USDT"), ("LTC", "USDT"),]}}
)

# IDEX
SYMBOLS_PER_EXCHANGE.append(
{IDEX: {"pairs": [("LTO", "ETH"), ("LQD", "ETH"), ("IDEX", "ETH"),]}}
)

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

# OKCoin
SYMBOLS_PER_EXCHANGE.append(
{OKCOIN: {"pairs": [("BTC", "USD"), ("ETH", "USD"), ("LTC", "USD"),]}}
)

# Coinbene
SYMBOLS_PER_EXCHANGE.append(
{COINBENE: {"pairs": [("BTC", "USDT"), ("ETH", "USDT"), ("LTC", "USDT"),]}}
)

# Bitmax
SYMBOLS_PER_EXCHANGE.append(
{
Expand All @@ -120,6 +107,21 @@
}
)

# IDEX
SYMBOLS_PER_EXCHANGE.append(
{IDEX: {"pairs": [("LTO", "ETH"), ("LQD", "ETH"), ("IDEX", "ETH"),]}}
)

# OKCoin
SYMBOLS_PER_EXCHANGE.append(
{OKCOIN: {"pairs": [("BTC", "USD"), ("ETH", "USD"), ("LTC", "USD"),]}}
)

# Coinbene
SYMBOLS_PER_EXCHANGE.append(
{COINBENE: {"pairs": [("BTC", "USDT"), ("ETH", "USDT"), ("LTC", "USDT"),]}}
)

# Hotbit
SYMBOLS_PER_EXCHANGE.append(
{
Expand Down Expand Up @@ -152,6 +154,11 @@
{UPHOLD: {"pairs": [("BTC", "USD"), ("ETH", "USD"), ("LTC", "USD"),]}}
)

# Binance DEX
SYMBOLS_PER_EXCHANGE.append(
{BINANCE_DEX: {"pairs": [("LTO", "BNB"),], "single_request": True,}}
)

# DCoin
SYMBOLS_PER_EXCHANGE.append({DCOIN: {"pairs": [], "single_request": True,}})

Expand Down
26 changes: 26 additions & 0 deletions xtcryptosignals/tasks/exchanges/bitstamp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
__author__ = "Paulo Antunes"
__copyright__ = "Copyright 2018, XTCryptoSignals"
__credits__ = [
"Paulo Antunes",
]
__license__ = "GPL"
__maintainer__ = "Paulo Antunes"
__email__ = "[email protected]"


import requests


class Bitstamp:
def __init__(self):
self.base_url = "https://www.bitstamp.net/api/v2/ticker/{}"

def get_ticker(self, symbol):
_symbol = "".join(symbol).lower()
url = self.base_url.format(_symbol)
request = requests.get(url)
if request.status_code != 200:
raise ValueError("Error connecting Bitstamp on URL: {}".format(url))
item = request.json()
item.update(symbol="".join(symbol), ticker=symbol[0])
return item
37 changes: 37 additions & 0 deletions xtcryptosignals/tasks/schemas/bitstamp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
__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 Bitstamp(BaseSchema):
symbol = fields.Str(required=True)
source = fields.Str(required=True)
last = fields.Float(required=True, attribute="price")
volume = 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.BITSTAMP
data["volume"] = float(data["volume"]) * float(data["last"])
return data

@post_load
def post_load(self, data):
super().post_load(data)
return data
1 change: 1 addition & 0 deletions xtcryptosignals/tasks/tether.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@


TETHER_CONTRACT_ADDRESS = "0xdac17f958d2ee523a2206206994597c13d831ec7"

URL = f"https://etherscan.io/token/{TETHER_CONTRACT_ADDRESS}"


Expand Down

0 comments on commit d7f7d9a

Please sign in to comment.