mirror of
https://github.com/codez0mb1e/resistance.git
synced 2024-11-21 18:02:23 +00:00
Minor changes
This commit is contained in:
parent
28450cdeab
commit
5c6ea177dd
@ -54,7 +54,7 @@ class AzureDbConnection:
|
|||||||
con=self._db,
|
con=self._db,
|
||||||
schema='dbo',
|
schema='dbo',
|
||||||
name=target_table,
|
name=target_table,
|
||||||
if_exists='replace', # or append
|
if_exists='append', # or replace
|
||||||
index=False,
|
index=False,
|
||||||
chunksize=chunksize,
|
chunksize=chunksize,
|
||||||
dtype=db_mapping
|
dtype=db_mapping
|
||||||
|
@ -21,7 +21,7 @@ from azure import AzureDbConnection, ConnectionSettings
|
|||||||
#> kaggle datasets download tencars/392-crypto-currency-pairs-at-minute-resolution
|
#> kaggle datasets download tencars/392-crypto-currency-pairs-at-minute-resolution
|
||||||
#> unzip 392-crypto-currency-pairs-at-minute-resolution.zip
|
#> unzip 392-crypto-currency-pairs-at-minute-resolution.zip
|
||||||
|
|
||||||
input_dir = "../data"
|
input_dir: str = "../data"
|
||||||
|
|
||||||
# Get names and number of available currency pairs
|
# Get names and number of available currency pairs
|
||||||
pair_names = [x[:-4] for x in os.listdir(input_dir)]
|
pair_names = [x[:-4] for x in os.listdir(input_dir)]
|
||||||
@ -79,10 +79,10 @@ ethusd_1h.tail()
|
|||||||
|
|
||||||
# %% ----
|
# %% ----
|
||||||
conn_settings = ConnectionSettings(
|
conn_settings = ConnectionSettings(
|
||||||
'datainstinct',
|
'<server_name>',
|
||||||
'market-data-db',
|
'<db_name>',
|
||||||
'demo',
|
'<user_name>',
|
||||||
'0test_test_AND_test'
|
'****'
|
||||||
)
|
)
|
||||||
|
|
||||||
db_conn = AzureDbConnection(conn_settings)
|
db_conn = AzureDbConnection(conn_settings)
|
||||||
@ -112,6 +112,7 @@ pd.options.mode.chained_assignment = None
|
|||||||
|
|
||||||
min_candels_n = 10000
|
min_candels_n = 10000
|
||||||
|
|
||||||
|
i = 1
|
||||||
for pair in usd_pairs:
|
for pair in usd_pairs:
|
||||||
print(f'INFO | {pair} > Starting read dataset...')
|
print(f'INFO | {pair} > Starting read dataset...')
|
||||||
|
|
||||||
@ -119,7 +120,7 @@ for pair in usd_pairs:
|
|||||||
|
|
||||||
if len(candles_df) > min_candels_n:
|
if len(candles_df) > min_candels_n:
|
||||||
|
|
||||||
df = candles_df.loc['2022-07-01':'2022-10-01']
|
df = candles_df.loc[:'2022-10-01']
|
||||||
|
|
||||||
if len(df) > 0:
|
if len(df) > 0:
|
||||||
df = calc_ohlcv_1h(df)
|
df = calc_ohlcv_1h(df)
|
||||||
@ -131,10 +132,10 @@ for pair in usd_pairs:
|
|||||||
df['interval'] = '1H'
|
df['interval'] = '1H'
|
||||||
df.drop(columns='hour', inplace=True)
|
df.drop(columns='hour', inplace=True)
|
||||||
|
|
||||||
print(f'INFO | {pair} > Starting insert to DB...')
|
print(f'INFO | {pair} > Starting insert to DB ({i} of {len(usd_pairs)})...')
|
||||||
print('DEBUG | {} rows from {} to {}'.format(df.shape[0], min(df['time']), max(df['time'])))
|
print('DEBUG | {} rows from {} to {}'.format(df.shape[0], min(df['time']), max(df['time'])))
|
||||||
try:
|
try:
|
||||||
db_conn.insert(df, 'crypto', db_mapping)
|
db_conn.insert(df, 'crypto_1h', db_mapping)
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
print(f'ERROR | {pair} > {ex}')
|
print(f'ERROR | {pair} > {ex}')
|
||||||
|
|
||||||
@ -142,6 +143,7 @@ for pair in usd_pairs:
|
|||||||
print(f'WARN | {pair} > No new records')
|
print(f'WARN | {pair} > No new records')
|
||||||
else:
|
else:
|
||||||
print(f'WARN | {pair} > Only {candles_df.shape[0]} records')
|
print(f'WARN | {pair} > Only {candles_df.shape[0]} records')
|
||||||
|
i += 1
|
||||||
|
|
||||||
|
|
||||||
# %%
|
# %%
|
||||||
|
Loading…
Reference in New Issue
Block a user