买卖股票的自动化 [英] Automation of buying and selling shares

查看:50
本文介绍了买卖股票的自动化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


您好,¥b $ b


我的要求如下。我试图想出一个解决方案,并在这里提供了我的C#代码。如果它看起来不错或者我有什么东西在这里请你告诉我吗?

谢谢你的支持提前帮助。


*********************************** ****************需求********************************* ************需要需要编写一个自动购买股票的交易代理商。当该
股票的价格低于某些股票时,该代理商将购买给定数量的特定股票阈值。


代理必须实现ITradeAgent接口。它应该在没有更多工作要做的时候发出Finished事件的信号,并在出现错误时发出错误事件的信号由于交易框架是多线程的,因此在触发完成事件后代理不会立即被移除,并且在被处理之前它可能仍然会收到一些价格滴答。\\ n \\ n周期.b $ b垃圾收集。


代理商通过实施收到价格滴答IPriceListener接口。


代理必须通过我们的传统后台主机系统进行交易。这里有一个IBackOffice接口。它的方法不会返回返回码。


成功拨打  "买入"表示该消息将被发送到后台系统,并且将进行交易


。如果无法发送消息,BackOffice会抛出BackOfficeException。

解决方案

我不知道在美国股票市场看起来像什么,但是我以前的工作是在香港的一家主要股票交易软件供应商。根据我的学习,"购买"/"卖出"操作永远不会那么简单。


您需要编写至少支持以下场景的代码(正常交易)。


1)进行交易当您的代码接受令牌时(一个交易只有一个交易,一个交易系统的交易系统),可以支付令牌生成的频率。

2) 来自股票交易系统的成功通知。 假设股票交易系统会在您的交易订单有匹配交易时通知您。如果系统报价与您说明的价格不同(即:卖出时价格较高,购买时价格低于b $ b),则需要调整交易价格。

3 ) 清理。当市场关闭时,所有从未提交的指示自动被视为已取消。


此外,请注意,您需要保留日终流程的交易日志。 (向清算公司生成银行转账指令所需的金额)


当代码从异常中消失时,如何在不弄乱所有内容的情况下恢复交易过程(我们确实遇到了线程池饱和或当香港交易所决定提高收费率时,旧服务器上的内存不足问题)或电源中断
也很重要。




如果我是你,我将首先尝试实施股票交易系统列出的所有基本基础设施,然后将ITradingAgent和IPriceListener变形以适应。



Hello,

I've the requirement as below. I've attempted to come up with a solution and have provided my C# code here.Could you please let me know if it looks ok or is there something I'm missing here please?
Thanks for your help in advance.

***************************************************Requirement*********************************************Need Need to write a trading agent that will automatically buy stocks.This Agent will buy a given quantity of a given stock when of the price of that stock falls below some threshold.

The agent must implement ITradeAgent interface.It should signal the Finished event when it has no more work to do and signal the Error event whenever some error occus.

Because the trading framework is multithreaded, the agent will not be removed immediately after firing the Finished event and it might still receive some price ticks before being garbage collected.

The agent receives price ticks by implementing the IPriceListener interface.

The agent must trade through our legacy back office mainframe system. There's a IBackOffice interface for the same. Its methods don't return a return code.

A successful call to the  "Buy" means that message will be delivered to the back office system and
the trade will be made. BackOffice throws a BackOfficeException if the message cannot be sent.

解决方案

I don't know what looks like in American stock market, but one of my previous employment was at a major stock trading software vendor in Hong Kong. From what I learn, "buy"/"sell" operation is never that simple.

You need to write code that at least supports the following scenario (normal trading).

1) Place your trading instruction on queue of stock trading system (AMS of HKEX in my case) when your code accepts token (One token for one trade only. The frequency of token generation is something you can pay to increase from the stock trading system).
2) Success notification from the stock trading system. Say the stock trading system will inform you when there is matching deal for your trading order. If the price quoted by the system differs from your stated price (i.e.: higher when you sell, or lower when you buy), you'll need to adjust the trading price.
3) Clean-up. All instructions submitted by never complete is automatically considered cancelled when the market closes.

Also, be reminded you'll need to keep the trading log for your day-end process. (The amount you need to generate the bank transfer instruction to clearing company)

How to resume the trading process without messing up everything when your code dies from exceptions (we did experience thread pool saturation or even out of memory problem on older server when HKEX decided to increase the tick rate) or power interruption is also important.


If I were you, I'll try to implement all the essential infrastructures listed by the stock trading system first, then morph the ITradingAgent and IPriceListener to fit in.


这篇关于买卖股票的自动化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆