我有以下毫/秒精度字符串来解析某种提升日期时间.
std::string cell ="20091201 00:00:04.437";
Run Code Online (Sandbox Code Playgroud)
我看过关于方面的文档.像这样的东西
date_input_facet* f = new date_input_facet();
f->format("%Y%m%d %F *");
Run Code Online (Sandbox Code Playgroud)
但我不知道如何使用它们.
我尝试使用从StackOverflow中清除的代码来编写这个程序,但我无法让millis显示:
#include <string>
#include <iostream>
#include <sstream>
#include <fstream>
#include <map>
#include <boost/algorithm/string.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/date_time.hpp>
namespace bt = boost::posix_time;
const std::locale formats[] =
{
std::locale(std::locale::classic(),new bt::time_input_facet("%Y%m%d %H:%M:%S.f")),
std::locale(std::locale::classic(),new bt::time_input_facet("%Y-%m-%d %H:%M:%S")),
std::locale(std::locale::classic(),new bt::time_input_facet("%Y/%m/%d %H:%M:%S")),
std::locale(std::locale::classic(),new bt::time_input_facet("%d.%m.%Y %H:%M:%S")),
std::locale(std::locale::classic(),new bt::time_input_facet("%Y-%m-%d"))
};
const size_t formats_n = sizeof(formats) / sizeof(formats[0]);
std::time_t pt_to_time_t(const bt::ptime& pt)
{
bt::ptime timet_start(boost::gregorian::date(1970,1,1));
bt::time_duration diff = pt - timet_start;
return diff.ticks()/bt::time_duration::rep_type::ticks_per_second;
}
void …Run Code Online (Sandbox Code Playgroud) 我有看起来像这样的scrapy代码
for row in response.css("div#flexBox_flex_calendar_mainCal table tr.calendar_row"):
print "================"
print row.xpath(".//td[@class='time']/text()").extract()
print row.xpath(".//td[@class='currency']/text()").extract()
print row.xpath(".//td[@class='impact']/span/@title").extract()
print row.xpath(".//td[@class='event']/span/text()").extract()
print row.xpath(".//td[@class='actual']/text()").extract()
print row.xpath(".//td[@class='forecast']/text()").extract()
print row.xpath(".//td[@class='previous']/text()").extract()
print "================"
Run Code Online (Sandbox Code Playgroud)
我可以像这样使用纯 python 获得相同的东西,
from lxml import html
import requests
page = requests.get('http://www.forexfactory.com/calendar.php?day=dec1.2011')
tree = html.fromstring(page.text)
print tree.xpath(".//td[@class='time']/text()")
print tree.xpath(".//td[@class='currency']/text()")
print tree.xpath(".//td[@class='impact']/span/@title")
print tree.xpath(".//td[@class='event']/span/text()")
print tree.xpath(".//td[@class='actual']/text()")
print tree.xpath(".//td[@class='forecast']/text()")
print tree.xpath(".//td[@class='previous']/text()")
Run Code Online (Sandbox Code Playgroud)
但是我需要逐行执行此操作。我第一次尝试移植到 lxml 不起作用:
from lxml import html
import requests
page = requests.get('http://www.forexfactory.com/calendar.php?day=dec1.2011')
tree = html.fromstring(page.text)
for row in tree.css("div#flexBox_flex_calendar_mainCal table tr.calendar_row"):
print row.xpath(".//td[@class='time']/text()")
print row.xpath(".//td[@class='currency']/text()")
print …Run Code Online (Sandbox Code Playgroud) 如果我说
plt.title(r'$\tau$')
Run Code Online (Sandbox Code Playgroud)
或者
plt.xlabel(r'$\tau$')
Run Code Online (Sandbox Code Playgroud)
在jupyter笔记本中,我得到希腊字母 tau。
我如何对文本执行同样的操作?
这不起作用:
print(r'$\tau$', tau)
Run Code Online (Sandbox Code Playgroud) 我有一个apiClient.OrderSend必须在"GUI"线程内调用的函数,所以我创建了这个函数
private void RunOnUIThread(Action action)
{
this.BeginInvoke(action);
}
Run Code Online (Sandbox Code Playgroud)
然后,我有一个需要的功能return的int这样的
int AlgoSendOrder(MT4Order order)
{
int retVal = -1;
RunOnUIThread(() =>
{
retVal = apiClient.OrderSend(order.Symbol, (TradeOperation)order.OrderSide, order.Volume,
order.Price, order.AllowedSlippage ?? default(int),
order.PriceToStopLoss ?? default(double),
order.PriceToTakeProfit ?? default(double));
});
return retVal;
}
Run Code Online (Sandbox Code Playgroud)
问题是AlgoSendOrder返回之前apiClient.OrderSend返回,因此retVal对于此函数的客户端始终为-1.
看来这个合理的改变就是await-async在GUI线程中使用pair执行函数,并具有等待返回值的预期效果.但是我似乎无法让它发挥作用.
好像我应该可以返工RunOnUIThread使用async-await
public async Task RunOnUIThreadAsync()
{
if (InvokeRequired)
{
// what do I put here?
}
{
… // like before (but …Run Code Online (Sandbox Code Playgroud) 我通过socket.io一个对象发送到这样的react应用程序:
function getApiAndEmit(socket, quote)
{
try
{
var { ticker, type, price, size, timestamp } = quote;
socket.emit("FromAPI", quote);
//console.log(ticker, type, price, size, timestamp)
}
catch (error)
{
console.error(`Error: ${error.code}`);
}
};
Run Code Online (Sandbox Code Playgroud)
当我尝试在客户端呈现它时,我收到错误:
If you meant to render a collection of children, use an array instead or wrap the object using createFragment(object) from the React add-ons.
Run Code Online (Sandbox Code Playgroud)
使用Web浏览器呈现字段的正确方法是什么react?
代码
import React, { Component } from "react";
import socketIOClient from "socket.io-client";
class App extends Component { …Run Code Online (Sandbox Code Playgroud) 在usingnon-clustered index上创建时,我收到此消息。我尝试更改设置,但没有帮助:tableSSMStimeoutdatabase
USE Options ;
GO
EXEC sp_configure 'remote query timeout', 0 ;
GO
RECONFIGURE ;
GO
Run Code Online (Sandbox Code Playgroud)
sql服务器错误:
===================================
Create failed for Index 'NonClusteredIndex-20200121-151256'. (Microsoft.SqlServer.Smo)
------------------------------
For help, click: https://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=15.0.18142.0+((SSMS_Rel).190722-0816)&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Create+Index&LinkId=20476
------------------------------
Program Location:
at Microsoft.SqlServer.Management.Smo.SqlSmoObject.CreateImpl()
at Microsoft.SqlServer.Management.Smo.Index.Create()
at Microsoft.SqlServer.Management.Smo.IndexExtender.IndexExtenderHelper.Execute(IndexAction action)
at Microsoft.SqlServer.Management.RelationalEngineTasks.IndexTaskFormComponent.PerformTask(ITaskExecutionContext context)
at Microsoft.SqlServer.Management.RelationalEngineTasks.IndexTaskFormComponent.Microsoft.SqlServer.Management.ITask.Perform(ITaskExecutionContext )
at Microsoft.SqlServer.Management.TaskForms.TaskExecutionManager.ExecuteTaskSequence(ISfcScriptCollector collector)
===================================
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
------------------------------
Program Location:
at Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery(String sqlCommand, ExecutionTypes executionType, Boolean retry)
at Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery(StringCollection sqlCommands, …Run Code Online (Sandbox Code Playgroud) 我有一个这样的听众:
receiver r(io_service,
boost::asio::ip::address::from_string(argv[1]),
boost::asio::ip::address::from_string(argv[2]));
Run Code Online (Sandbox Code Playgroud)
如果我使用参数运行代码
./BoostAsioMCReceiver 0.0.0.0 239.255.0.1
Run Code Online (Sandbox Code Playgroud)
侦听器从发送者(在另一台计算机上)获取所有多播数据包。但是,如果我实际上输入机器的以太网IP地址,例如
./BoostAsioMCReceiver 172.22.1.5 239.255.0.1
Run Code Online (Sandbox Code Playgroud)
接收方似乎没有收到任何数据包。我需要这样做是因为计算机有多个以太网卡,并且我需要确保数据包从给定的 NIC 发出,并通过扩展到达正确的交换机。
接收器看起来像这样:
receiver(boost::asio::io_service& io_service,
const boost::asio::ip::address& listen_address,
const boost::asio::ip::address& multicast_address)
: socket_(io_service)
{
boost::asio::ip::udp::endpoint listen_endpoint(
listen_address, multicast_port);
socket_.open(listen_endpoint.protocol());
socket_.set_option(boost::asio::ip::udp::socket::reuse_address(true));
socket_.bind(listen_endpoint);
socket_.set_option(
boost::asio::ip::multicast::join_group(multicast_address));
socket_.async_receive_from(
boost::asio::buffer(data, max_length), sender_endpoint,
boost::bind(&receiver::handle_receive_from, this,
boost::asio::placeholders::error,
boost::asio::placeholders::bytes_transferred));
}
private:
boost::asio::ip::udp::socket socket;
boost::asio::ip::udp::endpoint sender_endpoint;
Run Code Online (Sandbox Code Playgroud)
为什么会发生这种情况?建议的修复方法是什么?
谢谢。
我有一个F#类库:
namespace FsharpTestSystem
open System
open System.IO
open TCLoggerEntity
open TCIQuoteEntity
type TestCallback() =
member this.LoggerOutput() = Logger.Info("F#")
member this.OnQuote(q : TCQuote) = Console.WriteLine(q.ToString())
Run Code Online (Sandbox Code Playgroud)
将这个F#程序集的引用添加到C#项目中,我测试过我可以从C#中调用LoggerOutput.但是,如果我尝试在F#中执行C#事件回调,则会在下面的行中出现错误:
来自C#:
using FsharpTestSystem;
public delegate void QuoteChangeEvent(TCQuote q);
event QuoteChangeEvent OnQuoteChange;
TestCallback fsts = new TestCallback();
api.MAPI.OnQuoteChange += fsts.OnQuote(); // this doesn't work
fsts.LoggerOutput(); // This works fine
Run Code Online (Sandbox Code Playgroud) 我有一个function这样的:
private void DropIncompleteQuarters(//what goes in here? This? IEnumerable<dynamic> gb)
{
foreach(var groupInGb in gb)
{
// What goes in here to get each element?
}
}
Run Code Online (Sandbox Code Playgroud)
我正在生成Grouping这样的:
histData = new List<OHLC>();
var gb = histData.GroupBy(o => new
{
Year = o.Date.Year,
Quarter = ((o.Date.Month - 1) / 3) + 1
})
.ToDictionary(g => g.Key, g => g.ToList());
Run Code Online (Sandbox Code Playgroud)
我想传递gb给DropIncompleteQuarters,但我不确定type应该是什么。
然后在里面DropIncompleteQuarters,我想迭代一下items?
限价具有小数值.市场价格没有.
如何在F#中对此进行建模?
module TradingDomain
let NoPrice = None
type PriceActionType =
| Limit of decimal
| Market of NoPrice
Run Code Online (Sandbox Code Playgroud) c# ×3
c++ ×2
f# ×2
async-await ×1
begininvoke ×1
boost ×1
boost-asio ×1
dynamic ×1
grouping ×1
lxml ×1
python ×1
reactjs ×1
scrapy ×1
sql-server ×1
ssms ×1
winforms ×1