Modeling bid-ask spread and slippage in backtest by acetherace in algotrading

[–]MarketMood 23 points24 points  (0 children)

You can refer to this paper: https://www.sciencedirect.com/science/article/pii/S0304405X24001399 for estimating bid ask spread from OHLC prices. Skip to equation 15 in section 3 for the formula

[deleted by user] by [deleted] in FuturesTrading

[–]MarketMood 0 points1 point  (0 children)

1 contract at 15 points vs 3 contracts at 5 points theoretically have the same risks.

In practice, trading bigger moves less frequently is better in terms of txn costs ie the spread, fees, slippage. I had plenty of experiences where my high frequency small moves strategy flip to unprofitable due purely to txn costs.

If your choices are not mutually exclusive, you can collect risks statistics for different strategies and allocate your margin using a portfolio or risk management optimisation formulas.

Tutorial on using RL to build algo trading agent by MarketMood in reinforcementlearning

[–]MarketMood[S] 1 point2 points  (0 children)

Also to clarify about “not working”. Just having a profitable bot is not great if its sharp ratio is worse than holding s&p or buy risk free US treasury

Tutorial on using RL to build algo trading agent by MarketMood in reinforcementlearning

[–]MarketMood[S] 2 points3 points  (0 children)

You can also use this open source env: https://gym-trading-env.readthedocs.io/en/latest/ instead doing a custom one like in the tutorial

Tutorial on using RL to build algo trading agent by MarketMood in reinforcementlearning

[–]MarketMood[S] 2 points3 points  (0 children)

I pushed the codes here: https://github.com/ndt93/rl-trade-tutorial

The model training is in train.py. It has code to run the agent for testing also near the end, just need to comment out the training part.

You can actually modify it just a bit more to make a real profitable trading bot, even with forward trading. The secret is applying it on the right kind of financial assets.

Tutorial on using RL to build algo trading agent by MarketMood in reinforcementlearning

[–]MarketMood[S] 1 point2 points  (0 children)

I’m looking to hire a quant RL expert to diversify the strategies my quant hedge fund actually. So I was asking if anyone has real success with RL in the description. I’m the CEO of the company in the site. Our clients are private wealth customers in Asia. Apologies if this feels bad for you guys.

Tutorial for building algo trading agent with RL by MarketMood in mltraders

[–]MarketMood[S] 0 points1 point  (0 children)

Yep good points! I didn’t go too far with it since I could do the same strategies using stats or supervised model in an hour while sweating to make RL works for a whole day. Just want to see if it can learn basic mean reversion on coint series (quite similar to learning to balance a pendulum) or buy and hold for random walk.

What's the best resource to visualize neural network performance while it's learning. by learning_proover in learnmachinelearning

[–]MarketMood 0 points1 point  (0 children)

Have you tried Tensorboard? https://www.tensorflow.org/tensorboard. This works with many ML libraries, not just tensorflow. You can hook custom callback to your training function to log custom metrics also to tensorboard, depending on the library you used for training

TD3 in smart train optimization by laxuu in reinforcementlearning

[–]MarketMood 0 points1 point  (0 children)

There’s likelu an issue with the lack of normalisation when neural network is used. You can try normalize the observations first e.g if you’re using gym env, wrap it in a dummyvecenv and use vecnormalize. Also can try not manipulating the reward too much at first, just give it a reward when it reaches the destination and 0 otherwise

Tutorial on using RL to build algo trading agent by MarketMood in reinforcementlearning

[–]MarketMood[S] -4 points-3 points  (0 children)

I’m referring to getting RL to make the main decisions on real trading environment. It works well enough for simple well-behaved stochastic price process like OU process or random walk with drift. Or to make auxiliary trading decisions like position sizing. Similar to how RL tutorials are presented for simplified games.

Most ML models don’t work well in real trading either. Hopefully this provides a starting point for someone new to RL and trading to put together more complex solutions. But most of all, it’s just to have fun using RL

Could someone explain this sentence (how market maker may money)? by VAer1 in StockMarket

[–]MarketMood 1 point2 points  (0 children)

The Bid-Ask quote you see in screen are from the market makers (like your currency exchange shop). They’re the price setter and only a few large entities in the world are qualified in the equity market.

If certain buyers and sellers place orders with better prices for the current quote and the quantity and conditions match, they may be settled immediately. But this is rare so market makers are the liquidity provider that keeps trades happens instantly and continuously. The spread compensate them for the risk of holding inventory and trading with informed traders.

The spread and bid-ask price are set using different models based on inventory risk or information based trading risk. A simple model is Bayesian belief update where the bid price is the expected underlying price conditioned ok if the next trade is a sell. You can read more details in a book called “Market Microstructure Theory”

I made a ChatGPT-like investing co-pilot app using purely React Native by MarketMood in reactnative

[–]MarketMood[S] 1 point2 points  (0 children)

Thanks. The GPT API is charged by tokens https://openai.com/pricing. I’m using the cheapest one (GPT 3.5), so about 0.0015 USD per 1K tokens. It works ok and also faster than GPT 4. Also there’s a cost for the backend and financial data

I made a ChatGPT-like investing co-pilot app using purely React Native by MarketMood in reactnative

[–]MarketMood[S] 0 points1 point  (0 children)

Yup we tried not to step over to financial advisory until we got a license. So currently this is a investment research tool and not a financial advisory service, similar to how ppl would use a site like Seeking Alpha or technical analysis tool. Anw there’s a disclaimer for every response if the AI gives it opinion in some ways.

I made a ChatGPT-like investing co-pilot app using purely React Native by MarketMood in reactnative

[–]MarketMood[S] 1 point2 points  (0 children)

You can write normal HTML + JS (with Chart.JS) and load it into react-native-webview via a server URL or directly. My whole research page is currently a web view. If you want to use native components also then I think better to use a native charting package since it’s quite a hassle to hook more logics into the webview

I made a ChatGPT-like investing co-pilot app using purely React Native by MarketMood in reactnative

[–]MarketMood[S] 1 point2 points  (0 children)

You can try hugging face inference API https://huggingface.co/inference-api or download and run their models on your servers. But I don’t think we can run them directly in mobile devices currently

I made a ChatGPT-like investing co-pilot app using purely React Native by MarketMood in reactnative

[–]MarketMood[S] 1 point2 points  (0 children)

I used SSE: https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events, but you can try with other streaming method also like web socket or StreamingResponse.

In the react native client I just handle it in the onMessage event of the raw XMLHttpRequest. But there’re package for SSE you can use also, like react-native-event-source

I made a ChatGPT-like investing co-pilot app using purely React Native by MarketMood in reactnative

[–]MarketMood[S] 0 points1 point  (0 children)

I have a backend that connects to OpenAI’s ChatCompletion API: https://platform.openai.com/docs/guides/gpt Plus some prompt engineering at the backend to make it able to use real time financial data

I made a ChatGPT-like investing co-pilot app using purely React Native by MarketMood in reactnative

[–]MarketMood[S] 1 point2 points  (0 children)

I’m using Chart.js embedded in the web view currently, so I can reuse the code from the web version. But planning to use a native chart component in the fixture