Skip to content

Commit

Permalink
Merge pull request #2 from lowwor/master
Browse files Browse the repository at this point in the history
feat: remove limit of coin pairs
  • Loading branch information
foolcage authored Aug 28, 2020
2 parents 520bf5e + 03199a5 commit ea4648d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
5 changes: 5 additions & 0 deletions zvt_ccxt/accounts/ccxt_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@


class CCXTAccount(object):
exchange_cache = {}
exchanges = COIN_EXCHANGES
exchange_conf = {}

Expand Down Expand Up @@ -37,9 +38,13 @@ def get_safe_sleeping_time(cls, exchange):

@classmethod
def get_ccxt_exchange(cls, exchange_str) -> ccxt.Exchange:
if cls.exchange_cache.get(exchange_str):
return cls.exchange_cache[exchange_str]

exchange = eval("ccxt.{}()".format(exchange_str))
exchange.apiKey = cls.exchange_conf[exchange_str]['apiKey']
exchange.secret = cls.exchange_conf[exchange_str]['secret']
# set to your proxies if need
exchange.proxies = {'http': zvt_env['http_proxy'], 'https': zvt_env['https_proxy']}
cls.exchange_cache[exchange_str] = exchange
return exchange
2 changes: 1 addition & 1 deletion zvt_ccxt/recorders/coin_kdata_recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def __init__(self,
codes=None,
batch_size=10,
force_update=True,
sleeping_time=10,
sleeping_time=1,
default_size=2000,
real_time=False,
fix_duplicate_way='ignore',
Expand Down
11 changes: 6 additions & 5 deletions zvt_ccxt/recorders/coin_recorder.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import pandas as pd

from zvt.contract.api import df_to_db
from zvt.contract.recorder import Recorder

from zvt_ccxt.accounts import CCXTAccount
from zvt_ccxt.domain import Coin
from zvt_ccxt.settings import COIN_EXCHANGES, COIN_PAIRS
from zvt_ccxt.settings import COIN_EXCHANGES


class CoinMetaRecorder(Recorder):
provider = 'ccxt'
data_schema = Coin

def __init__(self, batch_size=10, force_update=False, sleeping_time=10, exchanges=COIN_EXCHANGES) -> None:
def __init__(self, batch_size=10, force_update=False, sleeping_time=1, exchanges=COIN_EXCHANGES) -> None:
super().__init__(batch_size, force_update, sleeping_time)
self.exchanges = exchanges

Expand All @@ -30,6 +30,8 @@ def run(self):

aa = []
for market in markets:
if not market['active']:
continue
if markets_type == dict:
name = market
code = market
Expand All @@ -38,8 +40,7 @@ def run(self):
code = market['symbol']
name = market['symbol']

if name not in COIN_PAIRS:
continue

aa.append(market)

security_item = {
Expand Down

0 comments on commit ea4648d

Please sign in to comment.