Skip to content

Commit

Permalink
fix #1346
Browse files Browse the repository at this point in the history
  • Loading branch information
Rob Carver committed Mar 1, 2024
1 parent 1e0ab52 commit 6c2a9b4
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 11 deletions.
16 changes: 8 additions & 8 deletions data/futures/csvconfig/instrumentconfig.csv
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Instrument,Description,Pointsize,Currency,AssetClass,PerBlock,Percentage,PerTrad
AEX,Netherlands equity index AEX,200,EUR,Equity,2.8,0,0,EMEA
AEX_mini,AEX mini,20,EUR,Equity,0.2,0,0,EMEA
ALUMINIUM,NYMEX Aluminum Index,25,USD,Metals,1.5,0,0,US
ALUMINIUM_LME,High-Grade Primary Aluminium,25,USD,Metals,0,0,0,EMEA
ALUMINIUM_LME,High-Grade Primary Aluminium,25,USD,Metals,1.05,0,0,EMEA
AMERIBOR-1M,CBOE One-Month AMERIBOR Average Rate Index,50,USD,STIR,0,0,0,US
AMERIBOR-3M,CBOE AMERIBOR Term-90,25,USD,STIR,0,0,0,US
AMERIBOR-T30,Cboe AMERIBOR Term-30 Futures Index,25,USD,STIR,0,0,0,US
Expand Down Expand Up @@ -34,7 +34,7 @@ BOVESPA,Bovespa Index - USD,1,USD,Equity,0.85,0,0,US
BOVESPA-HK,Brazil Bovespa Stock Index HK,5,HKD,Equity,0,0,0,ASIA
BRE,BREUSD currency,100000,USD,FX,2.47,0,0,US
BRENT,NYMEX Brent Financial Futures Index,1000,USD,OilGas,0.85,0,0,US
BRENT_W,Brent crude summer,1000,USD,OilGas,0,0,0,EMEA
BRENT_W,Brent crude summer,1000,USD,OilGas,1.05,0,0,EMEA
BRENT-LAST,Brent Crude Oil - Last Day,1000,USD,OilGas,2.47,0,0,US
BRR,CME CF Bitcoin Reference Rate,5,USD,Metals,0,0,0,US
BRREUR,CME CF Bitcoin-Euro Reference Rate,5,EUR,Metals,0,0,0,US
Expand Down Expand Up @@ -67,19 +67,19 @@ CHF_micro,CHFUSD micro,12500,USD,FX,0.85,0,0,US
CHFJPY,CHFJPY,250000,JPY,FX,85,0,0,US
CHFJPY-ICE,CHFJPY,250000,JPY,FX,85,0,0,US
CHINA120,CES China 120 Index,50,HKD,Equity,0,0,0,ASIA
CHINAA-CON,MSCI China A 50 Connect Index,25,USD,Equity,0,0,0,ASIA
CHINAA-CON,MSCI China A 50 Connect Index,25,USD,Equity,1.05,0,0,ASIA
CLP,Chilean peso,50000000,USD,FX,0.85,0,0,US
CNH,SGX US Dollar in offshore Chinese Renminbi (CNH),100000,CNH,FX,11.2,0,0,ASIA
CNH-CME,CNHUSD on CME,1000000,USD,FX,0,0,0,US
CNH-CME_micro,CHNHUSD micro CME,10000,CNH,FX,0,0,0,US
CNH-HK,CNHUSD on HK,100000,CNH,FX,0,0,0,ASIA
CNH-onshore,SGX onshore Chinese Renminbi (CNY) in US Dollar Futures (CY@SGX),500000,USD,FX,1.8,0,0,ASIA
CNHEUR,CNHEUR,1000000,EUR,FX,0,0,0,US
COAL,ICE Rotterdam Coal,1000,USD,OilGas,0,0,0,EMEA
COAL-GEORDIE,ICE Coals to Newcastle,1000,USD,OilGas,0,0,0,EMEA
COAL,ICE Rotterdam Coal,1000,USD,OilGas,1.05,0,0,EMEA
COAL-GEORDIE,ICE Coals to Newcastle,1000,USD,OilGas,1.05,0,0,EMEA
COAL-RICH-BAY,ICE Richards Bay Coal,1000,USD,OilGas,0,0,0,EMEA
COCOA,Cocoa NY,10,USD,Ags,3,0,0,US
COCOA_LDN,Cocoa London,10,GBP,Ags,0,0,0,EMEA
COCOA_LDN,Cocoa London,10,GBP,Ags,1,0,0,EMEA
COFFEE,Coffee,375,USD,Ags,3,0,0,US
COPPER,Copper,25000,USD,Metals,2.42,0,0,US
COPPER_LME,Grade A Copper - LME,25,USD,Metals,0,0,0,EMEA
Expand Down Expand Up @@ -298,8 +298,8 @@ KOSDAQ,KOSDAQ 150 Index,10000,KRW,Equity,2000,0,0,ASIA
KOSPI,Korean equity index KOSPI,250000,KRW,Equity,0,0.0004,0,ASIA
KOSPI_mini,KOSPI mini,50000,KRW,Equity,8500,0,0,ASIA
KOSPI300,KOSPI300 Index,50000,KRW,Equity,0,0,0,ASIA
KR10,Korean 10 year bond,1000000,KRW,Bond,0,4E-05,0,ASIA
KR3,Korean 3 year bond,1000000,KRW,Bond,0,4E-05,0,ASIA
KR10,Korean 10 year bond,1000000,KRW,Bond,0,0.00004,0,ASIA
KR3,Korean 3 year bond,1000000,KRW,Bond,0,0.00004,0,ASIA
KRW,KRWUSD SGX,125000,USD,FX,4.5,0,0,ASIA
KRWJPY,SGX Korean Won in Japanese Yen Futures,25000000,JPY,FX,285,0,0,ASIA
KRWUSD,Korean Won,125000000,USD,FX,0.85,0,0,US
Expand Down
55 changes: 55 additions & 0 deletions sysinit/futures/check_instrument_listst.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
"""
This little utility allows you to keep up with your various sets of instruments, basically designed for those that add a
big load of instruments in one go as is my wont
"""
import pandas as pd
from syscore.interactive.progress_bar import progressBar
from sysproduction.data.prices import diagPrices


diag_prices = diagPrices()

all_instruments_with_prices = diag_prices.get_list_of_instruments_with_contract_prices()
all_instruments_with_prices.sort()

## check for high correlations, likely to be repeats


def check_for_high_correlations():

checked=[]
all_dups = []
returns = dict()
p =progressBar((len(all_instruments_with_prices)**2)/2)
for instrument1 in all_instruments_with_prices:
if instrument1 not in returns.keys():
returns[instrument1] = weekly_perc_returns_last_year(instrument1)
for instrument2 in all_instruments_with_prices:
if instrument1==instrument2:
continue
if (instrument2, instrument1) in checked:
continue
checked.append((instrument1, instrument2))
if instrument2 not in returns.keys():
returns[instrument2] = weekly_perc_returns_last_year(instrument2)

ret1 = returns[instrument1]
ret2 = returns[instrument2]
both = pd.concat([ret1, ret2], axis=1)
both.columns=['1','2']
both = both.dropna()
corr = both.corr()['1']['2']
if corr>0.9:
all_dups.append("Possible duplicates %s %s corr %.3f" % (instrument1,
instrument2, corr))
print(all_dups)

p.iterate()

return all_dups

def weekly_perc_returns_last_year(instrument_code):
weekly_prices = diag_prices.get_adjusted_prices(instrument_code).resample("1W").ffill()
weekly_prices_last_year=weekly_prices[-52:]
return (weekly_prices_last_year/ weekly_prices_last_year.shift(1))-1
6 changes: 3 additions & 3 deletions sysinit/futures/repocsv_spotfx_prices.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
WARNING WILL OVERWRITE EXISTING!
"""
from sysdata.csv.csv_spot_fx import csvFxPricesData
from sysproduction.data.currency_data import fxPricesData
from sysproduction.data.currency_data import dataCurrency

db_fx_price_data = fxPricesData()
db_fx_price_data = dataCurrency()

if __name__ == "__main__":
input("Will overwrite existing prices are you sure?! CTL-C to abort")
Expand All @@ -23,6 +23,6 @@
fx_prices = csv_fx_prices.get_fx_prices(currency_code)
print(fx_prices)

db_fx_price_data.add_fx_prices(
db_fx_price_data.db_fx_prices_data.add_fx_prices(
code=currency_code, fx_price_data=fx_prices, ignore_duplication=True
)

0 comments on commit 6c2a9b4

Please sign in to comment.