Compare commits

..

No commits in common. "28386cdf1275492091f6b99d777dfd95591fffb6" and "c776c95d69b9b4f20e0840605853252d7cbe24b5" have entirely different histories.

4 changed files with 12 additions and 22 deletions

View File

@ -11,7 +11,6 @@ The enhanced `pt_backtest.py` script now supports multi-day and multi-instrument
- Support for wildcard patterns in configuration files
- CLI override for data file specification
### 2. Dynamic Instrument Selection
- Auto-detection of instruments from database
- CLI override for instrument specification

View File

@ -376,16 +376,16 @@ class TradingPair:
open_trades = self.user_data_["open_trades"]
if len(open_trades) == 0:
return 0.0
def _single_instrument_return(symbol: str) -> float:
instrument_open_trades = open_trades[open_trades["symbol"] == symbol]
instrument_sign = -1 if instrument_open_trades["action"].iloc[0] == "SELL" else 1
instrument_price = predicted_row[f"{self.price_column_}_{symbol}"]
instrument_return = instrument_sign * (instrument_price - instrument_open_trades["price"].iloc[0]) / instrument_open_trades["price"].iloc[0]
return float(instrument_return) * 100.0
def _stock_return(stock: str) -> float:
stock_open_trades = open_trades[open_trades["symbol"] == stock]
stock_sign = -1 if stock_open_trades["action"].iloc[0] == "SELL" else 1
stock_price = predicted_row[f"{self.price_column_}_{stock}"]
stock_return = stock_sign * (stock_price - stock_open_trades["price"].iloc[0]) / stock_open_trades["price"].iloc[0]
return float(stock_return)
instrument_a_return = _single_instrument_return(self.symbol_a_)
instrument_b_return = _single_instrument_return(self.symbol_b_)
return (instrument_a_return + instrument_b_return)
stock_a_return = _stock_return(self.symbol_a_)
stock_b_return = _stock_return(self.symbol_b_)
return (stock_a_return + stock_b_return) * 100.0
return 0.0
def __repr__(self) -> str:

View File

@ -16,12 +16,7 @@ cd $(realpath $(dirname $0))/..
mkdir -p ./data/crypto
pushd ./data/crypto
Files=$1
if [ -z "$Files" ]; then
Files="*.gz"
fi
Cmd="rsync -ahvv cvtt@hs01.cvtt.vpn:/works/cvtt/md_archive/crypto/sim/${Files} ./"
Cmd="rsync -ahvv cvtt@hs01.cvtt.vpn:/works/cvtt/md_archive/crypto/sim/*.gz ./"
echo $Cmd
eval $Cmd
# -------------------------------------

View File

@ -26,12 +26,8 @@ for srcfname in $(ls *.db.gz); do
tgtfile=${dt}.mktdata.ohlcv.db
echo "${srcfname} -> ${tgtfile}"
Cmd="gunzip -c $srcfname > temp.db && rm $srcfname"
echo ${Cmd}
eval ${Cmd}
Cmd="rm -f ${tgtfile} && sqlite3 temp.db '.dump md_1min_bars' | sqlite3 ${tgtfile}"
echo ${Cmd}
eval ${Cmd}
gunzip -c $srcfname > temp.db
rm -f ${tgtfile} && sqlite3 temp.db ".dump md_1min_bars" | sqlite3 ${tgtfile} && rm ${srcfname}
done
rm temp.db
popd