forked from Yvictor/TradingGym
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkoshish.py
33 lines (29 loc) · 1.25 KB
/
koshish.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import random
import numpy as np
import pandas as pd
import trading_env
df = pd.read_hdf('dataset/SGXTWsample.h5', 'STW')
env = trading_env.make(env_id='training_v1', obs_data_len=256, step_len=128,
df=df, fee=0.1, max_position=5, deal_col_name='Price',
feature_names=['Price', 'Volume',
'Ask_price','Bid_price',
'Ask_deal_vol','Bid_deal_vol',
'Bid/Ask_deal', 'Updown'])
env = trading_env.make(env_id='backtest_v1', obs_data_len=4096, step_len=5,
df=df, fee=0.1, max_position=50, deal_col_name='Price',
feature_names=['Price', 'Volume',
'Ask_price','Bid_price',
'Ask_deal_vol','Bid_deal_vol',
'Bid/Ask_deal', 'Updown'])
env.reset()
env.render()
state, reward, done, info = env.step(random.randrange(3))
### randow choice action and show the transaction detail
for i in range(500):
print(i)
state, reward, done, info = env.step(random.randrange(3))
print(state, reward)
env.render()
if done:
break
env.transaction_details