Skip to content

Commit

Permalink
アプリケーションで使うデータの定義ファイルを作成
Browse files Browse the repository at this point in the history
  • Loading branch information
tktk4751 committed Jan 22, 2024
1 parent cc675da commit 0a7434e
Show file tree
Hide file tree
Showing 11 changed files with 223 additions and 12 deletions.
11 changes: 11 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]

[dev-packages]

[requires]
python_version = "3.11"
36 changes: 31 additions & 5 deletions config/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type Envlist struct {
DbName string
TradeDuration time.Duration
Durations map[string]time.Duration
ProductCode string
ProductCode []string
}

var env Envlist
Expand All @@ -33,12 +33,38 @@ func init() {
log.Fatal("Error loading .env file")
}

Productcode := []string{"BTCUSDT", "ETHUSDT", "SOLUSDT", "AVAXUSDT", "OPUSDT", "ARBUSDT", "PEPEUSDT", "SUIUSDT", "SEIUSDT"}

m := time.Minute
h := time.Hour

durations := map[string]time.Duration{
"1s": time.Second,
"1m": time.Minute,
"1h": time.Hour,
"1m": m,
"5m": m * 5,
"10m": m * 10,
"30m": m * 30,
"1h": h,
"2h": h * 2,
"4h": h * 4,
"6h": h * 6,
"8h": h * 8,
"12h": h * 12,
"1d": h * 24,
"3d": h * 24 * 3,
"1w": h * 24 * 7,
"2w": h * 24 * 14,
}

// productcode := os.Getenv("PRODUCT_CODE")

// for i, v := range productcode {

// v := productcode[i]
// Tradelist =

// productcvode = append(v)
// }

Env := Envlist{
EthereumAddress: os.Getenv("ETH_WALLET_ADDRESS"),
EthereumPrivateAddress: os.Getenv("ETH_PRUVATE_KEY"),
Expand All @@ -53,7 +79,7 @@ func init() {
DbName: os.Getenv("DBNAME"),
Durations: durations,
TradeDuration: durations[os.Getenv("trade_duration")],
ProductCode: os.Getenv("PRODUCT_CODE"),
ProductCode: Productcode,
}

env = Env
Expand Down
46 changes: 46 additions & 0 deletions factory/define_data/acount.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package define_data

import (
"time"
)

type Acount struct {
AcountID string
EthereumAddress string

Blance float64
Withdrawals float64
Deposits float64
TotalBlance float64
TotalFees float64
isWinner bool

MaillAddress string
USername string
}

type AcountTradeData struct {
AllTradeData []string
TradeID []string
TradeAsset []string
EntryPrice []float64
ExitPrice []float64
EntryAmount []float64
ExitAmount []float64
EntryDate []time.Time
ExitDate []time.Time
//Entryとエグジットのペアをグループ化する
TradingPea [][]string

//トレード回数
Totaltrade int64
Wintrade int64
Losstrade int64

Timeframe string
isWinner bool
Bankruptcy bool
Strategy []string

ProfittLoss float64
}
73 changes: 73 additions & 0 deletions factory/define_data/analytics.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package define_data

type Analytics struct {
AcountBalance float64
NetProfit float64
TotalProfit float64
TotalLoss float64
TotalFees float64
MaxBalance float64
MaxProfit float64
MaxLoss float64
MaxDrawdown float64
MinBalance float64
ifBuyAndHoldReturn float64
SharepRatio float64
SoltinoRatio float64
PnL float64
ProfitFactor float64
WintradeRatio float64
LosstradeRatio float64
WintradeUSD float64
LosstradeUSD float64
MAXWintradeUSD float64
MAXLosstradeUSD float64

//トレード回数
TotalTrade int64
TotalWintrade int64
TotalLosstrade int64

///勝ちトレードの利益(USDと%表記)
BuyWintradeUSD float64
BuyWintradeRatio float64

//負けトレードの利益(USDと%表記)
SellWintradeRatio float64
SellWintradeUSD float64

//平均トレードの利益(USDと%表記)
AverageTradeRatio float64
AveragProfitRatio float64
AverageLossRatio float64
AverageTradeUSD float64
AveragProfitUSD float64
AverageLossUSD float64

//(平均勝ち / 平均負けの比率)
PayOffRatio float64

//最も利益を上げた銘柄、損失を出した銘柄
MaxProfitAsset string
MaxLossAsset string

//建玉の保有期間
TradingBars int64
AverageTradingBars int64
AverageWinTradingBars int64
AverageLossTradingBars int64

//タクティ丸F
OriginalRisksizeRatio float64
OriginalRisksizeUSD int64

//バルサラの破産確率
BalsarRatio float64

//調子の良さ
isLucky bool
isUnlucku bool

//SquareRoot(取引数) * 平均(取引利益) / StdDev(取引利益)
SQN float64
}
1 change: 1 addition & 0 deletions factory/define_data/manegement.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package define_data
18 changes: 18 additions & 0 deletions factory/define_data/market.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package define_data

import (
"time"
)

type Candle struct {
AssetName string
Duration time.Duration
Time time.Time
//CSVのデータ用
Date string
Open float64
Close float64
High float64
Low float64
Volume float64
}
28 changes: 28 additions & 0 deletions factory/define_data/strategy.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package define_data

type Signals struct {
Date string
Side string
Price float64
Amount float64
RiskPercent float64
RiskUSD int64
ProfitManegement bool
}

type Strategy struct {
Signal Signals

GordenCross bool
DeadCross bool
Long bool
Short bool
Hoald string
Stay string
LongTrend bool
ShortTrend bool
TrendForow bool
CounterTrend bool
LangeTrading bool
Squeeze bool
}
1 change: 1 addition & 0 deletions factory/define_data/trade.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package define_data
17 changes: 12 additions & 5 deletions utils/get_candle_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"strconv"
)

// ディレクトリ内のCSVファイルを結合して、ATR関数に渡せるデータに加工する関数
func GetCandleData(dir string) [][]float64 {
// ディレクトリ内のファイルのパスを取得する
files, err := ioutil.ReadDir(dir)
Expand All @@ -32,7 +31,7 @@ func GetCandleData(dir string) [][]float64 {
// パスのリストをソートする
sort.Strings(paths)
// 結合したデータを格納するスライスを作成する
data := [][]float64{}
data := []Data{}
// 各CSVファイルを読み込む
for _, path := range paths {
// ファイルを開く
Expand Down Expand Up @@ -83,10 +82,18 @@ func GetCandleData(dir string) [][]float64 {
if err != nil {
log.Fatal(err)
}
// 高値、安値、終値の列を抽出する
row := []float64{csvData.High, csvData.Low, csvData.Close}
// 全ての列を抽出する
Alldata := Data{
Timestamp: csvData.Timestamp,
Open: csvData.Open,
High: csvData.High,
Low: csvData.Low,
Close: csvData.Close,
Volume: csvData.Volume}

// 結合したデータに追加する
data = append(data, row)
data = append(data, Alldata)

}
}
// 結合したデータを返す
Expand Down
2 changes: 1 addition & 1 deletion utils/get_csv_data/Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ python_version = "3.11"
python_full_version = "3.11.2"

[script]
get = "pipenv run python3 /home/lux/dev/go_trading_bot/utils/get_csv_data/get_data.py"
get = "python3 /home/lux/dev/go_trading_bot/utils/get_csv_data/get_data.py"
2 changes: 1 addition & 1 deletion utils/get_csv_data/get_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
path_dir_where_to_dump="/home/lux/dev/go_trading_bot/data",
asset_class="spot", # spot, um, cm
data_type="klines", # aggTrades, klines, trades
data_frequency="5m",
data_frequency="12h",
)

data_dumper.dump_data(
Expand Down

0 comments on commit 0a7434e

Please sign in to comment.